Support closed and union syntax via preview Roslyn#1881
Draft
wuzzeb wants to merge 1 commit into
Draft
Conversation
Add closed to modifier ordering and route Roslyn's preview UnionDeclaration syntax kind through the existing base type declaration printer. Add formatting coverage for closed record classes and union declarations. This draft intentionally references the .NET 11 Preview 5 SDK Roslyn assemblies for net10.0 builds because matching Microsoft.CodeAnalysis.CSharp NuGet packages are not yet published. Replace RoslynPreviewSdkReferences.props with a normal NuGet package update before merging.
Author
|
Also, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add closed to modifier ordering and route Roslyn's preview UnionDeclaration syntax kind through the existing base type declaration printer. Add formatting coverage for closed record classes and union declarations.
For modifier ordering, the current IDE0036 default-order documentation does not yet list the new closed modifier, so this PR makes a local ordering choice rather than copying an official one. I placed closed with the inheritance/type-shape modifiers, directly after abstract and before sealed, because the C# preview docs describe closed as a class modifier for closed hierarchies, and it is related to inheritance constraints. That keeps it near the modifiers it semantically overlaps with while leaving the existing documented order otherwise unchanged.
Microsoft.CodeAnalysis.CSharp
Unfortunately, the published nuget for Microsoft.CodeAnalysis.CSharp does not yet support either closed or union. To implement it temporarily, I reference the packages from the .NET 11 preview 5 SDK. Thus, we should not merge this PR as-is. The idea is to just have something ready.
When Microsoft.CodeAnalysis.CSharp is updated on nuget, we can take out the
RoslynPreviewSdkReferences.propsfile and all the overrides and just use the nuget package, and then the PR will be ready to merge.This draft intentionally references the .NET 11 Preview 5 SDK Roslyn assemblies for net10.0 builds because matching Microsoft.CodeAnalysis.CSharp NuGet packages are not yet published. Replace RoslynPreviewSdkReferences.props with a normal NuGet package update before merging.
Related Issue
Fixes #1880
Checklist
varthis.