Fix #29390, add space after tuple type and identifier#29405
Fix #29390, add space after tuple type and identifier#29405jcouv merged 2 commits intodotnet:masterfrom
Conversation
I agree. it should have a space. When there's a type, it's |
There was a problem hiding this comment.
- i don't understand what the IsWord check is for.
- you don't need
?.after token.Parent. All tokens you could reach in SyntaxNormalizer have parents. - I'd much rather we enumerate the cases where a tuple type would want a space after it (or where it woudl not want a space after it). Looking specifically for
iswordjust seems busted.
There was a problem hiding this comment.
In cases like:
(string a, (string b, string c))I don't want to add space after c) so I want to have space only after )<identifier,word> the same expression exist above but for braket: https://github.com/dotnet/roslyn/blob/ec99ff789c32a34fe444f8631e5a5166d2ebc11d/src/Compilers/CSharp/Portable/Syntax/SyntaxNormalizer.cs#L400
There was a problem hiding this comment.
So I think we want space after tuple only when next token is word.
ec99ff7 to
014820a
Compare
|
Add space after new and before tuple: var a = new(string a, int b)[10];Will be normalized to: var a = new (string a, int b)[10]; |
|
@jcouv Can we point it to v15.9 (or earlier) milestone? |
|
I'm not sure this would meet any 15.9 bar... |
|
From my point of view, it is too small changes to postpone it. But I'm ok with it. |
It's not postponed. It's just going into the next appropriate release. Right now 16.0 is where all current work is done unless it is critical for 15.9. A tiny formatting fix is not critical under any sort of assessment, and would thus be innapropriate IMO to take for 15.9. |
|
@CyrusNajmabadi got it, thank you, I thought that 15.9 will be next release, not 16. |
|
P.S. By the way I can't understand your branching strategy: dev15.9.x, dev15.9.x-vs-deps |
'dev15.9.x' is the branch going into VS15.9. It contains all the changes roslyn wants to go in that release, and should only be taking PRs that have been specifically approved for that release based on a high 'bar' check that warrants it. 'master' is where pretty much all other work goes. At some point master will branch off onto whatever come after 'dev15.9.x'. That may be 'dev15.10.x', 'dev16.x', or something else entirely. At that point, that branch will again only be for approved changes for that specific release, and 'master' will again be for the release after that. And so on and so forth. Effectively: we do work in master. And, from time to time, branches are made to capture the point in time containing all the work we want to go in a specific VS release. |
|
@ivanbasov for second review. Thanks |
|
Closed/re-opened to kick CI. |
|
Merged. Thanks @werwolfby ! |
Since updating Microsoft.CodeAnalysis to 3.3.1, the automatic formatting for tuples in C# has been fixed, so update tests accordingly. dotnet/roslyn#29405
* Update to Microsoft.CodeAnalysis 3.3.1 This updates to the latest Microsoft.CodeAnalysis packages for C#8 support. Fixes the following error on a project that uses nullable reference types: Microsoft.DocAsCode.Exceptions.DocfxException: Unable to generate spec reference for !: ---> System.IO.InvalidDataException: Fail to parse id for symbol in namespace . at Microsoft.DocAsCode.Metadata.ManagedReference.YamlModelGenerator.AddSpecReference (Microsoft.CodeAnalysis.ISymbol symbol, System.Collections.Generic.IReadOnlyList`1[T] typeGenericParameters, System.Collections.Generic.IReadOnlyList`1[T] methodGenericParameters, System.Collections.Generic.Dictionary`2[TKey,TValue] references, Microsoft.DocAsCode.Metadata.ManagedReference.SymbolVisitorAdapter adapter) [0x0005e] in <27b606b838ab45b788854d5e45efa610>:0 at Microsoft.DocAsCode.Metadata.ManagedReference.SymbolVisitorAdapter.AddSpecReference (Microsoft.CodeAnalysis.ISymbol symbol, System.Collections.Generic.IReadOnlyList`1[T] typeGenericParameters, System.Collections.Generic.IReadOnlyList`1[T] methodGenericParameters) [0x00000] in <27b606b838ab45b788854d5e45efa610>:0 * Fix TODO for space after tuple Since updating Microsoft.CodeAnalysis to 3.3.1, the automatic formatting for tuples in C# has been fixed, so update tests accordingly. dotnet/roslyn#29405 * Fix TestCSharpFeature_Default_7_1Class Since updating to Microsoft.CodeAnalysis 3.3.1, the default keyword is resolved to a vaule instead of the a default expression. Probably comes from dotnet/roslyn#37596
Fix for #29390
But I don't know what to do with this:
From my point of view it should have space:
Completely similar to:
We don't have spaces only in 2 cases:
In both cases we don't specify any type here, so skip space looks natural.
But for tuple from my point of view it is unnatural, because tuple - is just a type, and for types we have extract space.
I've found a few discussions:
from @jcouv: dotnet/csharplang#100 (comment)
and @sharwell : #23686 (comment)
But I can't find final decision
Right now I'll leave test code commented. And will not add whitespace before tuple in
newexpression. I need your input on this.