提交 0295b3cc 编写于 作者: D David Poeschl

Reanalyze on CodeStyleOptions changed

When a code style option is changed, it can change the set of
diagnostics or the severity of existing diagnostics. We now trigger
reanalysis when one of these options is changed.
上级 d710efa2
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Internal.Log; using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.Options; using Microsoft.CodeAnalysis.Shared.Options;
...@@ -128,6 +129,7 @@ public override void RemoveProject(ProjectId projectId) ...@@ -128,6 +129,7 @@ public override void RemoveProject(ProjectId projectId)
public override bool NeedsReanalysisOnOptionChanged(object sender, OptionChangedEventArgs e) public override bool NeedsReanalysisOnOptionChanged(object sender, OptionChangedEventArgs e)
{ {
return e.Option.Feature == nameof(SimplificationOptions) || return e.Option.Feature == nameof(SimplificationOptions) ||
e.Option.Feature == nameof(CodeStyleOptions) ||
e.Option == ServiceFeatureOnOffOptions.ClosedFileDiagnostic || e.Option == ServiceFeatureOnOffOptions.ClosedFileDiagnostic ||
e.Option == RuntimeOptions.FullSolutionAnalysis || e.Option == RuntimeOptions.FullSolutionAnalysis ||
e.Option == InternalDiagnosticsOptions.UseDiagnosticEngineV2 || e.Option == InternalDiagnosticsOptions.UseDiagnosticEngineV2 ||
......
...@@ -8,19 +8,19 @@ namespace Microsoft.CodeAnalysis.CSharp.CodeStyle ...@@ -8,19 +8,19 @@ namespace Microsoft.CodeAnalysis.CSharp.CodeStyle
internal static class CSharpCodeStyleOptions internal static class CSharpCodeStyleOptions
{ {
// TODO: get sign off on public api changes. // TODO: get sign off on public api changes.
public static readonly Option<bool> UseVarWhenDeclaringLocals = new Option<bool>(nameof(CSharpCodeStyleOptions), nameof(UseVarWhenDeclaringLocals), defaultValue: true, public static readonly Option<bool> UseVarWhenDeclaringLocals = new Option<bool>(nameof(CodeStyleOptions), nameof(UseVarWhenDeclaringLocals), defaultValue: true,
storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.UseVarWhenDeclaringLocals")); storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.UseVarWhenDeclaringLocals"));
public static readonly Option<CodeStyleOption<bool>> UseImplicitTypeForIntrinsicTypes = new Option<CodeStyleOption<bool>>(nameof(CSharpCodeStyleOptions), nameof(UseImplicitTypeForIntrinsicTypes), defaultValue: CodeStyleOption<bool>.Default, public static readonly Option<CodeStyleOption<bool>> UseImplicitTypeForIntrinsicTypes = new Option<CodeStyleOption<bool>>(nameof(CodeStyleOptions), nameof(UseImplicitTypeForIntrinsicTypes), defaultValue: CodeStyleOption<bool>.Default,
storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.UseImplicitTypeForIntrinsicTypes")); storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.UseImplicitTypeForIntrinsicTypes"));
public static readonly Option<CodeStyleOption<bool>> UseImplicitTypeWhereApparent = new Option<CodeStyleOption<bool>>(nameof(CSharpCodeStyleOptions), nameof(UseImplicitTypeWhereApparent), defaultValue: CodeStyleOption<bool>.Default, public static readonly Option<CodeStyleOption<bool>> UseImplicitTypeWhereApparent = new Option<CodeStyleOption<bool>>(nameof(CodeStyleOptions), nameof(UseImplicitTypeWhereApparent), defaultValue: CodeStyleOption<bool>.Default,
storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.UseImplicitTypeWhereApparent")); storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.UseImplicitTypeWhereApparent"));
public static readonly Option<CodeStyleOption<bool>> UseImplicitTypeWherePossible = new Option<CodeStyleOption<bool>>(nameof(CSharpCodeStyleOptions), nameof(UseImplicitTypeWherePossible), defaultValue: CodeStyleOption<bool>.Default, public static readonly Option<CodeStyleOption<bool>> UseImplicitTypeWherePossible = new Option<CodeStyleOption<bool>>(nameof(CodeStyleOptions), nameof(UseImplicitTypeWherePossible), defaultValue: CodeStyleOption<bool>.Default,
storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.UseImplicitTypeWherePossible")); storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.UseImplicitTypeWherePossible"));
public static readonly Option<CodeStyleOption<bool>> PreferConditionalDelegateCall = new Option<CodeStyleOption<bool>>(nameof(CSharpCodeStyleOptions), nameof(PreferConditionalDelegateCall), defaultValue: CodeStyleOptions.trueWithSuggestionEnforcement, public static readonly Option<CodeStyleOption<bool>> PreferConditionalDelegateCall = new Option<CodeStyleOption<bool>>(nameof(CodeStyleOptions), nameof(PreferConditionalDelegateCall), defaultValue: CodeStyleOptions.trueWithSuggestionEnforcement,
storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.PreferConditionalDelegateCall")); storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.PreferConditionalDelegateCall"));
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册