Handle function pointer and xml normalization#51981
Conversation
| } | ||
|
|
||
| // No space after asterisk in function pointer. | ||
| if (token.IsKind(SyntaxKind.AsteriskToken) && token.Parent.IsKind(SyntaxKind.FunctionPointerType)) |
There was a problem hiding this comment.
It's a bit more complicated than this. The IDE rules I implemented are:
- If there is no calling convention, no spaces.
- If there is a calling convention, put a space between the asterisk and the calling convention. So, for example,
delegate* unmanaged<void>. See the IDE spacing rules here: https://github.com/dotnet/roslyn/blob/main/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/Rules/SpacingFormattingRule.cs#L321-L413. #Closed
There was a problem hiding this comment.
Thanks @333fred. This makes it much easier. #Closed
|
Done review pass (commit 2) |
| // No space after the < in function pointer parameter lists | ||
| // delegate*<void | ||
| if (token.IsKind(SyntaxKind.LessThanToken) && token.Parent.IsKind(SyntaxKind.FunctionPointerParameterList)) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| // No space before the > in function pointer parameter lists | ||
| // delegate*<void> | ||
| if (next.IsKind(SyntaxKind.GreaterThanToken) && next.Parent.IsKind(SyntaxKind.FunctionPointerParameterList)) | ||
| { | ||
| return false; |
There was a problem hiding this comment.
The IDE spacing is using an IDE option, which I don't think is available to use here. I defaulted to the more common convention, which is no space before > and no space after <. #Resolved
There was a problem hiding this comment.
Yeah, the normalizer isn't customized. There's one normalization.
In reply to: 598105046 [](ancestors = 598105046)
| TestNormalizeDeclaration("public (string prefix,string uri)Foo()", "public (string prefix, string uri) Foo()"); | ||
| } | ||
|
|
||
| [Fact] |
There was a problem hiding this comment.
Tests are copy from IDE tests, except 2 tests that produce an invalid tree and have different behavior (which I think is acceptable):
333fred
left a comment
There was a problem hiding this comment.
LGTM (commit 7). Thanks for the ping, this had slipped off my radar. @dotnet/roslyn-compiler for a second review.
|
Merged/squashed. Thanks @Youssef1313 |
Fixes #50664 (commit 1)
Fixes #49732 (commit 2)