Closed AArnott closed 3 years ago
This appears to be correct: the UnaryPattern only allows NotKeyword: https://github.com/dotnet/roslyn/blob/badcd003f616de451aa1ce04191f27c0be835c4d/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Main.Generated.cs#L3720
If you check Keep redundant API calls
it will show the NotKeyword:
Quoter has detected that setting it explicitly is redundant and has eliminated it.
P.S. I'm not quite sure why the syntax tree shown by SharpLab looks like this though:
Maybe @ashmind knows?
When I parse myself and look at the syntax tree, it looks just like what Quoter does:
When I use the code the quoter gives me, no not
keyword appears in the generated C# code.
This is what I had to use to actually get not
to show up: https://github.com/AArnott/CSharpIsNull/blob/09d8a209b3e150cc79ba4eeaf2dedd69a6a76999/src/CSharpIsNullAnalyzer.CodeFixes/CSIsNull002Fixer.cs#L36
Ok, never mind. It works. I guess I had some other bug at the time when it appeared to not work.
Parse
o is not null
as an expression, and you get:Note that the
not
in the expression is nowhere represented.