-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Fix layering of C# formatting options #79083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
CyrusNajmabadi
merged 26 commits into
dotnet:main
from
CyrusNajmabadi:csharpFOrmattingOptionLayering
Jun 21, 2025
Merged
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
b82d180
Fix layering of C# formatting options
CyrusNajmabadi e62026e
Fix EA
CyrusNajmabadi 6e54804
Downstream fallout
CyrusNajmabadi 5aeae54
Actually wrap
CyrusNajmabadi f826c99
Docs
CyrusNajmabadi 809bf21
Remove
CyrusNajmabadi 91950fc
Rename for clarity
CyrusNajmabadi f60ba09
Remove unsafe
CyrusNajmabadi 2bb20b2
Remove unsafe
CyrusNajmabadi 6083288
Make option definition more strongly typed
CyrusNajmabadi c8ec941
Merge branch 'strongTyping' into csharpFOrmattingOptionLayering
CyrusNajmabadi 3477b93
Make more safe
CyrusNajmabadi d3bec4f
Remove int dependency
CyrusNajmabadi 69d90ed
Simplify
CyrusNajmabadi da4763a
move to utility location
CyrusNajmabadi 5f79ae3
Rename
CyrusNajmabadi 80330bc
Extract class
CyrusNajmabadi f2ae58f
Remove unused using
CyrusNajmabadi 5a82752
Convert to extension method
CyrusNajmabadi f87109b
Simplify
CyrusNajmabadi 0ffb308
Move to common utilities
CyrusNajmabadi 996803a
Move to common utilities
CyrusNajmabadi a1b4dce
Apply suggestions from code review
CyrusNajmabadi 1cf12da
Simplify
CyrusNajmabadi b975ccb
Simplify
CyrusNajmabadi f104982
Fix
CyrusNajmabadi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| #pragma warning disable RS0030 // Do not used banned APIs: Option<T> | ||
|
|
||
| using System; | ||
| using Microsoft.CodeAnalysis.Shared.Utilities; | ||
|
|
||
| namespace Microsoft.CodeAnalysis.Options; | ||
|
|
||
| internal static class OptionExtensions | ||
| { | ||
| /// <summary> | ||
| /// Allows an option of one enum type to be converted to another enum type, provided that both enums share the same underlying type. | ||
| /// Useful for some cases in Roslyn where we have an existing shipped public option in the Workspace layer, and an internal option | ||
| /// in the CodeStyle layer, and we want to map between them. | ||
| /// </summary> | ||
| public static Option<TToEnum> ConvertEnumOption<TFromEnum, TToEnum>(this Option<TFromEnum> option) | ||
| where TFromEnum : struct, Enum | ||
| where TToEnum : struct, Enum | ||
| { | ||
| var definition = option.OptionDefinition; | ||
| var newDefaultValue = EnumValueUtilities.ConvertEnum<TFromEnum, TToEnum>(definition.DefaultValue); | ||
| var newSerializer = EditorConfigValueSerializer.ConvertEnumSerializer<TFromEnum, TToEnum>(definition.Serializer); | ||
|
|
||
| var newDefinition = new OptionDefinition<TToEnum>( | ||
| defaultValue: newDefaultValue, newSerializer, definition.Group, definition.ConfigName, definition.StorageMapping, definition.IsEditorConfigOption); | ||
|
|
||
| return new(newDefinition, option.Feature, option.Name, option.StorageLocations); | ||
| } | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thse are not new apis. they just moved from the shared location her.e we don't want it in teh shared location as that adds public types to multiple assemblies, which is bad (esp. for code that then references both assemblies.