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

Refinement on the message for CS0103, or a new rule. #70891

Open otac0n opened 11 months ago

otac0n commented 11 months ago

Analyzer

Diagnostic ID: CS0103

Describe the improvement

Describe suggestions on how to achieve the rule

As above, replace the syntax tree. If the parse is better (according to constrained analysis), update the existing diagnostic.

Additional context

.Select(x => x.word)

vs

.Select(x = x.word)

image
otac0n commented 11 months ago
image

These are all bad suggestions.

huoyaoyuan commented 11 months ago

x = x.word is a perfectly valid expression to be passed as an argument if x is an identifier.

otac0n commented 11 months ago

Yes, I'm aware. But in the case that this is a raised semantic error, I would prefer the message to be improved.