-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Xmldoc with <see cref="Foo{T}(T?)"/> or similar fails to compile #33782
Comments
It appears the addition of the nullable ref types feature may have introduced a regression here. |
Confirmed this is a regression (15.9 accepts this xml doc). Investigating.... |
Fixed for dev16 (rc4) |
Thanks @cyanite for reporting this! |
Not fixed in Visual Studio 2019 Professional RTM (version 16.0.0). |
My bad. It does repro on 16.0 preview 5. I forgot to enable XML documentation in the project. |
I can't repro this in 16.3 preview 3. |
@RikkiGibson great. Can we change the test @jcouv originally added so that it forces XML doc creation? That should close the gap. |
Sorry for nagging but... I'm still seeing the issue in Visual Studio Professional 2019 16.3.1. |
This does not repro with latest |
@jaredpar I can reproduce this in a .NET Framework 4.7.2 project with C# 7.3 in Visual Studio 2019 16.7.2. Code and screenshot below. The difference seems to be my use of a nullable generic enum type parameter. Should I file a new bug or will you reopen this issue? Relevant code:
Screenshot: |
It would be really helpful to have a more minimal reproducer. I wasn't able to come up with one in a few minutes of trying. I defer to @jaredpar on whether this issue should be reopened or a new issue should be opened. |
I agree we'd need more info in order to make progress here. The code samples we have no longer reproduce this behavior hence there really isn't a way to make progress without a new one that demonstrates the negative behavior. |
I found a minimal reproducer. It seems that having a LangVersion < 8 is key. Project.csproj <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>library</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>7.3</LangVersion>
<DocumentationFile>ConsoleApp11.xml</DocumentationFile>
</PropertyGroup>
</Project> Program.cs /// <summary>
/// Something about C
/// </summary>
public class C
{
// warning CS1580: Invalid type for parameter T? in XML comment cref attribute: 'M{T}(T?)'
/// <summary>Something about <see cref="M{T}(T?)" /></summary>
public static void M<T>(T? t) where T : struct
{
}
} |
BTW, there exists a workaround: manually change So if you have:
Change it to this:
and the warning is solved. No need for suppression. Phew! |
It's good to hear you were able to work around the issue. Apparently I found a reproducer that works with old LangVersion, but I neglected to reopen the issue. Sorry about that--it does feel like we should address this problem. |
Visual Studio 2019 RC (csc.exe version 3.0.19.12206 (ec36668)):
Steps to Reproduce:
Write this code. Note that Visual Studio helps you complete the
<see cref...>
. Enable XML documentation file and enable all warnings as errors.Expected Behavior:
It works.
Actual Behavior:
It fails with CS1580 Invalid type for parameter T? in XML comment cref attribute: 'Foo{T}(T?)'
If you change it to
<see cref="Foo{T}(Nullable{T})"/>
it works, but Visual Studio will now nag you to change it back to the version that doesn't :p.This is a regression; both syntaxes worked in Visual Studio 2017. The old compiler produced the following in the document file:
The new one produces:
(and warns/fails if warnings as errors is enabled.)
The text was updated successfully, but these errors were encountered: