Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tmat committed Jul 10, 2024
1 parent 81f28d7 commit 5ec779f
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.ImplementInterface;
Expand Down Expand Up @@ -8006,7 +8007,7 @@ void M() { }
public int Prop => throw new System.NotImplementedException();
}
""",
CodeActionOptions = (CSharpCodeActionOptions.Default with
CodeActionOptions = (CodeActionOptions.Default with
{
ImplementTypeOptions = new() { InsertionBehavior = ImplementTypeInsertionBehavior.AtTheEnd }
}).CreateProvider()
Expand Down Expand Up @@ -8188,7 +8189,7 @@ class Class : IInterface
public int WriteOnlyProp { set => throw new System.NotImplementedException(); }
}
""",
CodeActionOptions = (CSharpCodeActionOptions.Default with
CodeActionOptions = (CodeActionOptions.Default with
{
ImplementTypeOptions = new() { PropertyGenerationBehavior = ImplementTypePropertyGenerationBehavior.PreferAutoProperties }
}).CreateProvider()
Expand Down
2 changes: 1 addition & 1 deletion src/EditorFeatures/Test/Options/GlobalOptionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public void ReadingOptionsFromGlobalOptions(string language)
var languageServices = workspace.Services.SolutionServices.GetLanguageServices(language);

VerifyDataMembersHaveNonDefaultValues(globalOptions.GetIdeAnalyzerOptions(languageServices), IdeAnalyzerOptions.GetDefault(languageServices), language);
VerifyDataMembersHaveNonDefaultValues(globalOptions.GetCodeActionOptions(languageServices), CodeActionOptions.GetDefault(languageServices), language);
VerifyDataMembersHaveNonDefaultValues(globalOptions.GetCodeActionOptions(languageServices), CodeActionOptions.Default, language);
VerifyDataMembersHaveNonDefaultValues(globalOptions.GetBraceMatchingOptions(language), BraceMatchingOptions.Default, language);
VerifyDataMembersHaveNonDefaultValues(globalOptions.GetFindUsagesOptions(language), FindUsagesOptions.Default, language);
VerifyDataMembersHaveNonDefaultValues(globalOptions.GetInlineHintsOptions(language), InlineHintsOptions.Default, language);
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,12 @@ internal readonly record struct OmniSharpCodeActionOptions(
OmniSharpImplementTypeOptions ImplementTypeOptions,
OmniSharpLineFormattingOptions LineFormattingOptions)
{
#pragma warning disable IDE0060 // Remove unused parameter
internal CodeActionOptions GetCodeActionOptions(LanguageServices languageServices)
#pragma warning restore IDE0060 // Remove unused parameter
{
var defaultOptions = CodeActionOptions.GetDefault(languageServices);
return defaultOptions with
return CodeActionOptions.Default with
{
CleanupOptions = defaultOptions.CleanupOptions with
{
FormattingOptions = defaultOptions.CleanupOptions.FormattingOptions with
{
LineFormatting = new()
{
IndentationSize = LineFormattingOptions.IndentationSize,
TabSize = LineFormattingOptions.TabSize,
UseTabs = LineFormattingOptions.UseTabs,
NewLine = LineFormattingOptions.NewLine,
}
}
},
ImplementTypeOptions = new()
{
InsertionBehavior = (ImplementTypeInsertionBehavior)ImplementTypeOptions.InsertionBehavior,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ internal static class CodeActionOptionsStorage
public static CodeActionOptions GetCodeActionOptions(this IGlobalOptionService globalOptions, LanguageServices languageServices)
=> new()
{
CleanupOptions = globalOptions.GetCodeCleanupOptions(languageServices),
CodeGenerationOptions = globalOptions.GetCodeGenerationOptions(languageServices),
SearchOptions = globalOptions.GetSymbolSearchOptions(languageServices.Language),
ImplementTypeOptions = globalOptions.GetImplementTypeOptions(languageServices.Language),
HideAdvancedMembers = globalOptions.GetOption(CompletionOptionsStorage.HideAdvancedMembers, languageServices.Language),
Expand Down
2 changes: 1 addition & 1 deletion src/Workspaces/CoreTest/Remote/ServiceDescriptorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public void OptionsAreMessagePackSerializable(string language)
SyntaxFormattingOptions.GetDefault(languageServices),
CodeCleanupOptions.GetDefault(languageServices),
CodeGenerationOptions.GetDefault(languageServices),
CodeActionOptions.GetDefault(languageServices),
CodeActionOptions.Default,
IndentationOptions.GetDefault(languageServices),
ExtractMethodGenerationOptions.GetDefault(languageServices),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,13 @@ namespace Microsoft.CodeAnalysis.CodeActions;
[DataContract]
internal sealed record class CodeActionOptions
{
#if CODE_STYLE
public static readonly CodeActionOptionsProvider DefaultProvider = new DelegatingCodeActionOptionsProvider(GetDefault);
#else
public static readonly CodeActionOptionsProvider DefaultProvider = new DelegatingCodeActionOptionsProvider(static ls => GetDefault(ls));
#endif
public static readonly CodeActionOptions Default = new();
public static readonly CodeActionOptionsProvider DefaultProvider = Default.CreateProvider();

#if !CODE_STYLE
[DataMember] public required CodeCleanupOptions CleanupOptions { get; init; }
[DataMember] public required CodeGenerationOptions CodeGenerationOptions { get; init; }
[DataMember] public SymbolSearchOptions SearchOptions { get; init; } = SymbolSearchOptions.Default;
[DataMember] public ImplementTypeOptions ImplementTypeOptions { get; init; } = ImplementTypeOptions.Default;
[DataMember] public bool HideAdvancedMembers { get; init; } = false;

public static CodeActionOptions GetDefault(LanguageServices languageServices)
=> new()
{
CleanupOptions = CodeCleanupOptions.GetDefault(languageServices),
CodeGenerationOptions = CodeGenerationOptions.GetDefault(languageServices),
};
#else
public static CodeActionOptions GetDefault(LanguageServices languageServices)
=> new();
#endif
public CodeActionOptionsProvider CreateProvider()
=> new DelegatingCodeActionOptionsProvider(_ => this);
Expand Down

0 comments on commit 5ec779f

Please sign in to comment.