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
18.91k stars 4.01k forks source link

Missing CS8908 #58878

Open TheLeftExit opened 2 years ago

TheLeftExit commented 2 years ago

Version Used: Microsoft Visual Studio Community 2022 (64-bit) Version 17.0.5 C# Tools 4.0.1-1.21568.1+6ab6601178d9fba8c680b56934cd1742e0816bff .NET 6,

Steps to Reproduce:

  1. Create a project using the .NET 6 Console App template
  2. Add the following line at the end of Program.cs:
    public unsafe record MyStruct(void* Value1, nuint Value2);
  3. Enable unsafe code in the project using the Quick Actions and Refactorings... context menu

Expected Behavior: CS8908 is shown in Error List, the line is marked.

Actual Behavior: No errors are shown in the editor before and after attempted build. CS8908 is only shown in the Output window:

CS8908: The type 'void*' may not be used for a field of a record.
jcouv commented 2 years ago

I suspect it's because this error (ERR_BadFieldTypeInRecord) is generated during the emit phase of the compilation. The IDE and Error List don't report those well.