-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Simplifier options #60174
Simplifier options #60174
Conversation
2047746
to
a930435
Compare
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.
src/Workspaces/VisualBasicTest/CodeGeneration/AddImportsTests.vb
Outdated
Show resolved
Hide resolved
Integration tests showing gold bar
|
579ac53
to
5a8b5e2
Compare
003608b
to
21d8d35
Compare
src/EditorFeatures/CSharp/Simplification/CSharpGlobalIdeOptionsProvider.cs
Outdated
Show resolved
Hide resolved
Dim simplifiedDocument As Document | ||
If Not explicitSpansToSimplifyWithin.IsDefaultOrEmpty Then | ||
simplifiedDocument = Await Simplifier.ReduceAsync(document, explicitSpansToSimplifyWithin, optionSet) | ||
Else | ||
simplifiedDocument = Await Simplifier.ReduceAsync(document, Simplifier.Annotation, optionSet) | ||
End If | ||
#Enable Warning RS0030 |
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.
could just update this to use the new apis right?
src/EditorFeatures/VisualBasic/Simplification/VisualBasicSimplifierOptionsStorage.vb
Outdated
Show resolved
Hide resolved
...ixes/Suppression/AbstractSuppressionCodeFixProvider.GlobalSuppressMessageFixAllCodeAction.cs
Show resolved
Hide resolved
bool NavigateToDecompiledSources = true, | ||
bool AlwaysUseDefaultSymbolServers = true) | ||
{ | ||
public static readonly MetadataAsSourceOptions Default = new(); | ||
|
||
public MetadataAsSourceOptions() | ||
: this(NavigateToDecompiledSources: true) | ||
: this(SimplifierOptions: null) |
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.
aside: i'm not really a fan of using structs here primarily because i find having to reason about no-param constructors (vs, all optional constructors) so painful. Consider moving these to classes.
src/Features/Core/Portable/Options/IGlobalIdeOptionsProvider.cs
Outdated
Show resolved
Hide resolved
...s/CSharp/Portable/Simplification/Reducers/AbstractCSharpReducer.AbstractReductionRewriter.cs
Show resolved
Hide resolved
...s/CSharp/Portable/Simplification/Reducers/AbstractCSharpReducer.AbstractReductionRewriter.cs
Show resolved
Hide resolved
{ | ||
Contract.ThrowIfNull(ParseOptions); | ||
Debug.Assert(Options != null); | ||
Debug.Assert(SemanticModel != null); |
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.
just use Contract.ThrowIfNull for all of htem :)
src/Workspaces/CSharp/Portable/Simplification/Reducers/AbstractCSharpReducer.cs
Show resolved
Hide resolved
src/Workspaces/CSharp/Portable/Simplification/Reducers/AbstractCSharpReducer.cs
Outdated
Show resolved
Hide resolved
...haredUtilitiesAndExtensions/Workspace/Core/LanguageServices/AddImports/IAddImportsService.cs
Show resolved
Hide resolved
…res/required-members * upstream/main: (66 commits) Fix #55183: Add SymbolVisitor<TArgument, TResult> (#56530) Simplifier options (#60174) Remove duplicated asset Do not try to refcount solution syncing when communicating with OOP Delay symbol-search index updating until solution is fully loaded. add more miscellaneous tests for checked operators (#60727) Support checked operators in explicit interface implementation (#60715) Avoid formatting diagnostics with raw strings (#60655) Make heading levels for warning waves documentation consistent (#60721) Clean up IDiagnosticService extension methods Remove #nullable enable Add integration test to flag MEF composition breaks Generate static abstract interface members correctly (#60618) Merge release/dev17.2 to main (#60682) Fix FAR on checked operators (#60698) Add implement interface support for checked operators and cast operators (#60719) Update csc.dll path in launch.json (#60663) Grab bag of UTF8 string support in IDE features (#60599) Allow code actions to retrieve options for any language (#60697) Fix flaky VSTypeScriptHandlerTests (#60706) ...
…o setsrequiredmembers * upstream/features/required-members: (66 commits) Fix dotnet#55183: Add SymbolVisitor<TArgument, TResult> (dotnet#56530) Simplifier options (dotnet#60174) Remove duplicated asset Do not try to refcount solution syncing when communicating with OOP Delay symbol-search index updating until solution is fully loaded. add more miscellaneous tests for checked operators (dotnet#60727) Support checked operators in explicit interface implementation (dotnet#60715) Avoid formatting diagnostics with raw strings (dotnet#60655) Make heading levels for warning waves documentation consistent (dotnet#60721) Clean up IDiagnosticService extension methods Remove #nullable enable Add integration test to flag MEF composition breaks Generate static abstract interface members correctly (dotnet#60618) Merge release/dev17.2 to main (dotnet#60682) Fix FAR on checked operators (dotnet#60698) Add implement interface support for checked operators and cast operators (dotnet#60719) Update csc.dll path in launch.json (dotnet#60663) Grab bag of UTF8 string support in IDE features (dotnet#60599) Allow code actions to retrieve options for any language (dotnet#60697) Fix flaky VSTypeScriptHandlerTests (dotnet#60706) ...
Add
(CSharp|VisualBasic)SimplifierOptions
containing all code style options used by simplifiers.The first commit introduces SimplifierOptions and threads them through.
Since these options are editorconfig options we also need to pass around "fallback options" that are used when a simplifier option is not specified in the editorconfig files applicable to the given document. The fallback options are only available in the IDE - they are stored in the registry and accessed via
IGlobalOptionService
. In this PR fallback options are not required since we still fall back from DocumentOptions to the solution options. To limit the size of the PR some call sites that create options passnull
fallback options -- these will be updated in a follow up PR.Since the set of available simplifier options is language specific, we can't use a single
SimplifierOptionsStorage
extension method defined forIGlobalOptionService
as it does not know how to construct the derived option types. We introduceISimplifierOptionStorage
language service for that purpose.Recommended to review commit by commit. The first commit already reviewed by @ryzngard.