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.02k stars 4.03k forks source link

Balanced Source Generator mode does not work on saving #75586

Open Dreamescaper opened 3 hours ago

Dreamescaper commented 3 hours ago

Based on the description, source generators should be invoked on document Save. However, this doesn't happen.

Version Used: Visual Studio 2022 v17.12 Preview 4

Steps to Reproduce: Paste the snippet to Visual Studio:

using System.Text.RegularExpressions;

var regex = MyTestRegex();
regex.Match("1234");

partial class Program
{
    [GeneratedRegex(@"\w+")]
    private static partial Regex MyTestRegex();
}

Click Save / Press Ctrl+S.

Expected Behavior: Method implemenation is generated, and the error is not displayed.

Actual Behavior: Method implementation is not generated until build.

CS8795 Partial method 'Program.MyTestRegex()' must have an implementation part because it has accessibility modifiers.

Error disappears after build.

Dreamescaper commented 3 hours ago

Image