dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.01k stars 4.03k forks source link

Compiler should not produce warning for nullable type parameter in XML doc cref #67737

Open ElStefan opened 1 year ago

ElStefan commented 1 year ago

Version Used: VS 17.5.3, C#11

Steps to Reproduce:

See SharpLab

using System;

#nullable enable

public interface ITest
{
    /// <summary>
    /// Some text.
    /// </summary>
    public void TestMethod<T>(T? obj);
}

public class Test : ITest
{
    /// <inheritdoc cref="ITest.TestMethod{T}(T?)" />
    public void TestMethod<T>(T? obj)
    {
    }
}

Expected Behavior: No warnings Actual Behavior: A compiler warning CS1574 appears, stating that the given reference method in cref cannot be found. But navigating to the interface works and hovering with the mouse even shows a tooltip with the correct summary.

vbreuss commented 1 year ago
jcouv commented 1 year ago

I'll have to check what are the rules for nullable annotations in xml docs, but from quick experimentation I noticed that removing the ? annotation in the xml doc solves the problem (sharplab).