-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Remove usages of #if CODE_STYLE
where possible.
#74958
Conversation
using Microsoft.CodeAnalysis.Editing; | ||
using Microsoft.CodeAnalysis.Formatting; | ||
using Microsoft.CodeAnalysis.Options; | ||
|
||
namespace Microsoft.CodeAnalysis.OrganizeImports; | ||
|
||
[DataContract] | ||
internal readonly record struct OrganizeImportsOptions |
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.
options type moved to tis own file in the CodeStyle layer. The 'Providers' types move to the CodeFixes layer. This removes the need for CODE_STYLE checks, and properly layers things.
@@ -26,20 +18,11 @@ internal sealed record class CodeCleanupOptions | |||
[DataMember] public AddImportPlacementOptions AddImportOptions { get; init; } = AddImportPlacementOptions.Default; | |||
[DataMember] public DocumentFormattingOptions DocumentFormattingOptions { get; init; } = DocumentFormattingOptions.Default; | |||
|
|||
#if !CODE_STYLE | |||
public static CodeCleanupOptions GetDefault(LanguageServices languageServices) |
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.
thios moved to the CodeFixes layer.
namespace Microsoft.CodeAnalysis.CodeGeneration; | ||
|
||
[DataContract] | ||
internal readonly record struct CodeAndImportGenerationOptions |
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.
extracted out type into its own file.
} | ||
|
||
[DataContract] | ||
internal readonly record struct CodeAndImportGenerationOptions |
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.
moved to its own file.
@@ -38,28 +30,4 @@ private protected CodeGenerationOptions(IOptionsReader options, string language) | |||
{ | |||
NamingStyle = options.GetOption(NamingStyleOptions.NamingPreferences, language); | |||
} | |||
|
|||
#if !CODE_STYLE |
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.
moved to codefixes layer.
[DataMember] | ||
public required AddImportPlacementOptions AddImportOptions { get; init; } | ||
|
||
#if !CODE_STYLE |
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.
moved to codefixes layer.
#if !CODE_STYLE | ||
public static SyntaxFormattingOptions GetDefault(Host.LanguageServices languageServices) | ||
=> languageServices.GetRequiredService<ISyntaxFormattingService>().DefaultOptions; | ||
#endif |
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.
moved to codefixes layer
@@ -19,9 +15,4 @@ internal readonly record struct IndentationOptions( | |||
[DataMember(Order = 2)] public FormattingOptions2.IndentStyle IndentStyle { get; init; } = DefaultIndentStyle; | |||
|
|||
public const FormattingOptions2.IndentStyle DefaultIndentStyle = FormattingOptions2.IndentStyle.Smart; | |||
|
|||
#if !CODE_STYLE |
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.
moved to codefixes layer
namespace Microsoft.CodeAnalysis.OrganizeImports; | ||
|
||
[DataContract] | ||
internal readonly record struct OrganizeImportsOptions |
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.
moved this type to codestyle layer.
@@ -52,9 +52,4 @@ public bool TryGetQualifyMemberAccessOption(SymbolKind symbolKind, [NotNullWhen( | |||
|
|||
return option != null; | |||
} | |||
|
|||
#if !CODE_STYLE |
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.
moved to codefixes layer
...paces/SharedUtilitiesAndExtensions/Workspace/Core/CodeCleanup/CodeCleanupOptionsProviders.cs
Outdated
Show resolved
Hide resolved
@@ -23,31 +19,27 @@ internal readonly record struct CleanCodeGenerationOptions | |||
[DataMember] | |||
public required CodeCleanupOptions CleanupOptions { get; init; } | |||
|
|||
#if !CODE_STYLE |
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.
moved to codefixes layer.
return _document.Project.Solution.Services.GetRequiredLanguageService<TLanguageService>(language); | ||
#endif | ||
} | ||
=> _document.Project.Solution.Workspace.Services.GetExtendedLanguageServices(language).GetRequiredService<TLanguageService>(); |
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.
the call to GetExtendedLanguageServices already defers to GetRequiredLanguageService if not in the code-style layer. so we can simplify all of this.
#if CODE_STYLE
where possible.
src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems
Outdated
Show resolved
Hide resolved
…kspaceExtensions.projitems
Trying to unify the behavior (and especially teh code) for analyzers/fixers shipped in the features layer and code-style SDK layers.