提交 923fffcd 编写于 作者: B Brett V. Forsgren

rename `SimpleCodeStyleOption` to `CodeStyleOption<bool>` and serialize C# preferences

上级 330ecc80
...@@ -20,7 +20,7 @@ protected override object CreateCodeRefactoringProvider(Workspace workspace) ...@@ -20,7 +20,7 @@ protected override object CreateCodeRefactoringProvider(Workspace workspace)
return new IntroduceVariableCodeRefactoringProvider(); return new IntroduceVariableCodeRefactoringProvider();
} }
private readonly SimpleCodeStyleOption onWithInfo = new SimpleCodeStyleOption(true, NotificationOption.Info); private readonly CodeStyleOption<bool> onWithInfo = new CodeStyleOption<bool>(true, NotificationOption.Info);
// specify all options explicitly to override defaults. // specify all options explicitly to override defaults.
private IDictionary<OptionKey, object> ImplicitTypingEverywhere() => private IDictionary<OptionKey, object> ImplicitTypingEverywhere() =>
......
...@@ -24,7 +24,7 @@ public class GenerateVariableTests : AbstractCSharpDiagnosticProviderBasedUserDi ...@@ -24,7 +24,7 @@ public class GenerateVariableTests : AbstractCSharpDiagnosticProviderBasedUserDi
null, new GenerateVariableCodeFixProvider()); null, new GenerateVariableCodeFixProvider());
} }
private readonly SimpleCodeStyleOption onWithInfo = new SimpleCodeStyleOption(true, NotificationOption.Info); private readonly CodeStyleOption<bool> onWithInfo = new CodeStyleOption<bool>(true, NotificationOption.Info);
// specify all options explicitly to override defaults. // specify all options explicitly to override defaults.
private IDictionary<OptionKey, object> ImplicitTypingEverywhere() => private IDictionary<OptionKey, object> ImplicitTypingEverywhere() =>
......
...@@ -20,12 +20,12 @@ public class QualifyMemberAccessTests : AbstractCSharpDiagnosticProviderBasedUse ...@@ -20,12 +20,12 @@ public class QualifyMemberAccessTests : AbstractCSharpDiagnosticProviderBasedUse
return Tuple.Create<DiagnosticAnalyzer, CodeFixProvider>(new CSharpQualifyMemberAccessDiagnosticAnalyzer(), new CSharpQualifyMemberAccessCodeFixProvider()); return Tuple.Create<DiagnosticAnalyzer, CodeFixProvider>(new CSharpQualifyMemberAccessDiagnosticAnalyzer(), new CSharpQualifyMemberAccessCodeFixProvider());
} }
private Task TestAsyncWithOption(string code, string expected, PerLanguageOption<SimpleCodeStyleOption> option) private Task TestAsyncWithOption(string code, string expected, PerLanguageOption<CodeStyleOption<bool>> option)
{ {
return TestAsync(code, expected, options: Option(option, true, NotificationOption.Error)); return TestAsync(code, expected, options: Option(option, true, NotificationOption.Error));
} }
private Task TestMissingAsyncWithOption(string code, PerLanguageOption<SimpleCodeStyleOption> option) private Task TestMissingAsyncWithOption(string code, PerLanguageOption<CodeStyleOption<bool>> option)
{ {
return TestMissingAsync(code, options: Option(option, true, NotificationOption.Error)); return TestMissingAsync(code, options: Option(option, true, NotificationOption.Error));
} }
......
...@@ -22,14 +22,14 @@ public partial class UseExplicitTypeTests : AbstractCSharpDiagnosticProviderBase ...@@ -22,14 +22,14 @@ public partial class UseExplicitTypeTests : AbstractCSharpDiagnosticProviderBase
new Tuple<DiagnosticAnalyzer, CodeFixProvider>( new Tuple<DiagnosticAnalyzer, CodeFixProvider>(
new CSharpUseExplicitTypeDiagnosticAnalyzer(), new UseExplicitTypeCodeFixProvider()); new CSharpUseExplicitTypeDiagnosticAnalyzer(), new UseExplicitTypeCodeFixProvider());
private readonly SimpleCodeStyleOption onWithNone = new SimpleCodeStyleOption(true, NotificationOption.None); private readonly CodeStyleOption<bool> onWithNone = new CodeStyleOption<bool>(true, NotificationOption.None);
private readonly SimpleCodeStyleOption offWithNone = new SimpleCodeStyleOption(false, NotificationOption.None); private readonly CodeStyleOption<bool> offWithNone = new CodeStyleOption<bool>(false, NotificationOption.None);
private readonly SimpleCodeStyleOption onWithInfo = new SimpleCodeStyleOption(true, NotificationOption.Info); private readonly CodeStyleOption<bool> onWithInfo = new CodeStyleOption<bool>(true, NotificationOption.Info);
private readonly SimpleCodeStyleOption offWithInfo = new SimpleCodeStyleOption(false, NotificationOption.Info); private readonly CodeStyleOption<bool> offWithInfo = new CodeStyleOption<bool>(false, NotificationOption.Info);
private readonly SimpleCodeStyleOption onWithWarning = new SimpleCodeStyleOption(true, NotificationOption.Warning); private readonly CodeStyleOption<bool> onWithWarning = new CodeStyleOption<bool>(true, NotificationOption.Warning);
private readonly SimpleCodeStyleOption offWithWarning = new SimpleCodeStyleOption(false, NotificationOption.Warning); private readonly CodeStyleOption<bool> offWithWarning = new CodeStyleOption<bool>(false, NotificationOption.Warning);
private readonly SimpleCodeStyleOption onWithError = new SimpleCodeStyleOption(true, NotificationOption.Error); private readonly CodeStyleOption<bool> onWithError = new CodeStyleOption<bool>(true, NotificationOption.Error);
private readonly SimpleCodeStyleOption offWithError = new SimpleCodeStyleOption(false, NotificationOption.Error); private readonly CodeStyleOption<bool> offWithError = new CodeStyleOption<bool>(false, NotificationOption.Error);
// specify all options explicitly to override defaults. // specify all options explicitly to override defaults.
private IDictionary<OptionKey, object> ExplicitTypeEverywhere() => private IDictionary<OptionKey, object> ExplicitTypeEverywhere() =>
......
...@@ -23,14 +23,14 @@ public partial class UseImplicitTypeTests : AbstractCSharpDiagnosticProviderBase ...@@ -23,14 +23,14 @@ public partial class UseImplicitTypeTests : AbstractCSharpDiagnosticProviderBase
new Tuple<DiagnosticAnalyzer, CodeFixProvider>( new Tuple<DiagnosticAnalyzer, CodeFixProvider>(
new CSharpUseImplicitTypeDiagnosticAnalyzer(), new UseImplicitTypeCodeFixProvider()); new CSharpUseImplicitTypeDiagnosticAnalyzer(), new UseImplicitTypeCodeFixProvider());
private readonly SimpleCodeStyleOption onWithNone = new SimpleCodeStyleOption(true, NotificationOption.None); private readonly CodeStyleOption<bool> onWithNone = new CodeStyleOption<bool>(true, NotificationOption.None);
private readonly SimpleCodeStyleOption offWithNone = new SimpleCodeStyleOption(false, NotificationOption.None); private readonly CodeStyleOption<bool> offWithNone = new CodeStyleOption<bool>(false, NotificationOption.None);
private readonly SimpleCodeStyleOption onWithInfo = new SimpleCodeStyleOption(true, NotificationOption.Info); private readonly CodeStyleOption<bool> onWithInfo = new CodeStyleOption<bool>(true, NotificationOption.Info);
private readonly SimpleCodeStyleOption offWithInfo = new SimpleCodeStyleOption(false, NotificationOption.Info); private readonly CodeStyleOption<bool> offWithInfo = new CodeStyleOption<bool>(false, NotificationOption.Info);
private readonly SimpleCodeStyleOption onWithWarning = new SimpleCodeStyleOption(true, NotificationOption.Warning); private readonly CodeStyleOption<bool> onWithWarning = new CodeStyleOption<bool>(true, NotificationOption.Warning);
private readonly SimpleCodeStyleOption offWithWarning = new SimpleCodeStyleOption(false, NotificationOption.Warning); private readonly CodeStyleOption<bool> offWithWarning = new CodeStyleOption<bool>(false, NotificationOption.Warning);
private readonly SimpleCodeStyleOption onWithError = new SimpleCodeStyleOption(true, NotificationOption.Error); private readonly CodeStyleOption<bool> onWithError = new CodeStyleOption<bool>(true, NotificationOption.Error);
private readonly SimpleCodeStyleOption offWithError = new SimpleCodeStyleOption(false, NotificationOption.Error); private readonly CodeStyleOption<bool> offWithError = new CodeStyleOption<bool>(false, NotificationOption.Error);
// specify all options explicitly to override defaults. // specify all options explicitly to override defaults.
private IDictionary<OptionKey, object> ImplicitTypeEverywhere() => private IDictionary<OptionKey, object> ImplicitTypeEverywhere() =>
......
...@@ -962,6 +962,6 @@ private void C_MyEvent() ...@@ -962,6 +962,6 @@ private void C_MyEvent()
} }
} }
private IDictionary<OptionKey, object> QualifyMethodAccess => new Dictionary<OptionKey, object>() { { new OptionKey(CodeStyleOptions.QualifyMethodAccess, LanguageNames.CSharp), new SimpleCodeStyleOption(true, NotificationOption.Error) } }; private IDictionary<OptionKey, object> QualifyMethodAccess => new Dictionary<OptionKey, object>() { { new OptionKey(CodeStyleOptions.QualifyMethodAccess, LanguageNames.CSharp), new CodeStyleOption<bool>(true, NotificationOption.Error) } };
} }
} }
...@@ -367,9 +367,9 @@ protected static IList<CodeAction> FlattenActions(IEnumerable<CodeAction> codeAc ...@@ -367,9 +367,9 @@ protected static IList<CodeAction> FlattenActions(IEnumerable<CodeAction> codeAc
return codeActions?.SelectMany(a => a.HasCodeActions ? a.GetCodeActions().ToArray() : new[] { a }).ToList(); return codeActions?.SelectMany(a => a.HasCodeActions ? a.GetCodeActions().ToArray() : new[] { a }).ToList();
} }
protected IDictionary<OptionKey, object> Option(PerLanguageOption<CodeStyle.SimpleCodeStyleOption> option, bool value, CodeStyle.NotificationOption notification) protected IDictionary<OptionKey, object> Option(PerLanguageOption<CodeStyle.CodeStyleOption<bool>> option, bool value, CodeStyle.NotificationOption notification)
{ {
return new Dictionary<OptionKey, object>() { { new OptionKey(option, GetLanguage()), new CodeStyle.SimpleCodeStyleOption(value, notification) } }; return new Dictionary<OptionKey, object>() { { new OptionKey(option, GetLanguage()), new CodeStyle.CodeStyleOption<bool>(value, notification) } };
} }
} }
} }
...@@ -2437,7 +2437,7 @@ class C ...@@ -2437,7 +2437,7 @@ class C
} }
]]> ]]>
</text> </text>
Dim simplificationOptionSet = New Dictionary(Of OptionKey, Object) From {{New OptionKey(CodeStyleOptions.QualifyFieldAccess, LanguageNames.CSharp), New SimpleCodeStyleOption(True, NotificationOption.Error)}} Dim simplificationOptionSet = New Dictionary(Of OptionKey, Object) From {{New OptionKey(CodeStyleOptions.QualifyFieldAccess, LanguageNames.CSharp), New CodeStyleOption(Of Boolean)(True, NotificationOption.Error)}}
Await TestAsync(input, expected, simplificationOptionSet) Await TestAsync(input, expected, simplificationOptionSet)
End Function End Function
...@@ -5555,19 +5555,19 @@ End Class ...@@ -5555,19 +5555,19 @@ End Class
#Region "Helpers" #Region "Helpers"
Protected Function QualifyFieldAccessOption(languageName As String) As Dictionary(Of OptionKey, Object) Protected Function QualifyFieldAccessOption(languageName As String) As Dictionary(Of OptionKey, Object)
Return New Dictionary(Of OptionKey, Object) From {{New OptionKey(CodeStyleOptions.QualifyFieldAccess, languageName), New SimpleCodeStyleOption(True, NotificationOption.Error)}} Return New Dictionary(Of OptionKey, Object) From {{New OptionKey(CodeStyleOptions.QualifyFieldAccess, languageName), New CodeStyleOption(Of Boolean)(True, NotificationOption.Error)}}
End Function End Function
Protected Function QualifyPropertyAccessOption(languageName As String) As Dictionary(Of OptionKey, Object) Protected Function QualifyPropertyAccessOption(languageName As String) As Dictionary(Of OptionKey, Object)
Return New Dictionary(Of OptionKey, Object) From {{New OptionKey(CodeStyleOptions.QualifyPropertyAccess, languageName), New SimpleCodeStyleOption(True, NotificationOption.Error)}} Return New Dictionary(Of OptionKey, Object) From {{New OptionKey(CodeStyleOptions.QualifyPropertyAccess, languageName), New CodeStyleOption(Of Boolean)(True, NotificationOption.Error)}}
End Function End Function
Protected Function QualifyMethodAccessOption(languageName As String) As Dictionary(Of OptionKey, Object) Protected Function QualifyMethodAccessOption(languageName As String) As Dictionary(Of OptionKey, Object)
Return New Dictionary(Of OptionKey, Object) From {{New OptionKey(CodeStyleOptions.QualifyMethodAccess, languageName), New SimpleCodeStyleOption(True, NotificationOption.Error)}} Return New Dictionary(Of OptionKey, Object) From {{New OptionKey(CodeStyleOptions.QualifyMethodAccess, languageName), New CodeStyleOption(Of Boolean)(True, NotificationOption.Error)}}
End Function End Function
Protected Function QualifyEventAccessOption(languageName As String) As Dictionary(Of OptionKey, Object) Protected Function QualifyEventAccessOption(languageName As String) As Dictionary(Of OptionKey, Object)
Return New Dictionary(Of OptionKey, Object) From {{New OptionKey(CodeStyleOptions.QualifyEventAccess, languageName), New SimpleCodeStyleOption(True, NotificationOption.Error)}} Return New Dictionary(Of OptionKey, Object) From {{New OptionKey(CodeStyleOptions.QualifyEventAccess, languageName), New CodeStyleOption(Of Boolean)(True, NotificationOption.Error)}}
End Function End Function
Shared DontPreferIntrinsicPredefinedTypeKeywordInDeclaration As Dictionary(Of OptionKey, Object) = New Dictionary(Of OptionKey, Object) From {{New OptionKey(SimplificationOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, LanguageNames.VisualBasic), False}} Shared DontPreferIntrinsicPredefinedTypeKeywordInDeclaration As Dictionary(Of OptionKey, Object) = New Dictionary(Of OptionKey, Object) From {{New OptionKey(SimplificationOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, LanguageNames.VisualBasic), False}}
......
...@@ -15,11 +15,11 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics.Qualif ...@@ -15,11 +15,11 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics.Qualif
Return Tuple.Create(Of DiagnosticAnalyzer, CodeFixProvider)(New VisualBasicQualifyMemberAccessDiagnosticAnalyzer(), New VisualBasicQualifyMemberAccessCodeFixProvider()) Return Tuple.Create(Of DiagnosticAnalyzer, CodeFixProvider)(New VisualBasicQualifyMemberAccessDiagnosticAnalyzer(), New VisualBasicQualifyMemberAccessCodeFixProvider())
End Function End Function
Private Function TestAsyncWithOption(code As String, expected As String, opt As PerLanguageOption(Of SimpleCodeStyleOption)) As Task Private Function TestAsyncWithOption(code As String, expected As String, opt As PerLanguageOption(Of CodeStyleOption(Of Boolean))) As Task
Return TestAsync(code, expected, options:=[Option](opt, True, NotificationOption.Error)) Return TestAsync(code, expected, options:=[Option](opt, True, NotificationOption.Error))
End Function End Function
Private Function TestMissingAsyncWithOption(code As String, opt As PerLanguageOption(Of SimpleCodeStyleOption)) As Task Private Function TestMissingAsyncWithOption(code As String, opt As PerLanguageOption(Of CodeStyleOption(Of Boolean))) As Task
Return TestMissingAsync(code, options:=[Option](opt, True, NotificationOption.Error)) Return TestMissingAsync(code, options:=[Option](opt, True, NotificationOption.Error))
End Function End Function
......
...@@ -136,17 +136,17 @@ private TypeStylePreference GetCurrentTypeStylePreferences(OptionSet optionSet) ...@@ -136,17 +136,17 @@ private TypeStylePreference GetCurrentTypeStylePreferences(OptionSet optionSet)
_styleToSeverityMap.Add(TypeStylePreference.ImplicitTypeWhereApparent, styleForApparent.Notification.Value); _styleToSeverityMap.Add(TypeStylePreference.ImplicitTypeWhereApparent, styleForApparent.Notification.Value);
_styleToSeverityMap.Add(TypeStylePreference.ImplicitTypeWherePossible, styleForElsewhere.Notification.Value); _styleToSeverityMap.Add(TypeStylePreference.ImplicitTypeWherePossible, styleForElsewhere.Notification.Value);
if (styleForIntrinsicTypes.IsChecked) if (styleForIntrinsicTypes.Value)
{ {
stylePreferences |= TypeStylePreference.ImplicitTypeForIntrinsicTypes; stylePreferences |= TypeStylePreference.ImplicitTypeForIntrinsicTypes;
} }
if (styleForApparent.IsChecked) if (styleForApparent.Value)
{ {
stylePreferences |= TypeStylePreference.ImplicitTypeWhereApparent; stylePreferences |= TypeStylePreference.ImplicitTypeWhereApparent;
} }
if (styleForElsewhere.IsChecked) if (styleForElsewhere.Value)
{ {
stylePreferences |= TypeStylePreference.ImplicitTypeWherePossible; stylePreferences |= TypeStylePreference.ImplicitTypeWherePossible;
} }
......
...@@ -487,28 +487,28 @@ public string Style_NamingPreferences ...@@ -487,28 +487,28 @@ public string Style_NamingPreferences
} }
} }
public int Style_QualifyFieldAccess public string Style_QualifyFieldAccess
{ {
get { return GetBooleanOption(CodeStyleOptions.QualifyFieldAccess); } get { return GetXmlOption(CodeStyleOptions.QualifyFieldAccess); }
set { SetBooleanOption(CodeStyleOptions.QualifyFieldAccess, value); } set { SetXmlOption(CodeStyleOptions.QualifyFieldAccess, value); }
} }
public int Style_QualifyPropertyAccess public string Style_QualifyPropertyAccess
{ {
get { return GetBooleanOption(CodeStyleOptions.QualifyPropertyAccess); } get { return GetXmlOption(CodeStyleOptions.QualifyPropertyAccess); }
set { SetBooleanOption(CodeStyleOptions.QualifyPropertyAccess, value); } set { SetXmlOption(CodeStyleOptions.QualifyPropertyAccess, value); }
} }
public int Style_QualifyMethodAccess public string Style_QualifyMethodAccess
{ {
get { return GetBooleanOption(CodeStyleOptions.QualifyMethodAccess); } get { return GetXmlOption(CodeStyleOptions.QualifyMethodAccess); }
set { SetBooleanOption(CodeStyleOptions.QualifyMethodAccess, value); } set { SetXmlOption(CodeStyleOptions.QualifyMethodAccess, value); }
} }
public int Style_QualifyEventAccess public string Style_QualifyEventAccess
{ {
get { return GetBooleanOption(CodeStyleOptions.QualifyEventAccess); } get { return GetXmlOption(CodeStyleOptions.QualifyEventAccess); }
set { SetBooleanOption(CodeStyleOptions.QualifyEventAccess, value); } set { SetXmlOption(CodeStyleOptions.QualifyEventAccess, value); }
} }
public int Style_UseVarWhenDeclaringLocals public int Style_UseVarWhenDeclaringLocals
...@@ -519,38 +519,20 @@ public int Style_UseVarWhenDeclaringLocals ...@@ -519,38 +519,20 @@ public int Style_UseVarWhenDeclaringLocals
public string Style_UseImplicitTypeWherePossible public string Style_UseImplicitTypeWherePossible
{ {
get get { return GetXmlOption(CSharpCodeStyleOptions.UseImplicitTypeWherePossible); }
{ set { SetXmlOption(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, value); }
return GetUseVarOption(CSharpCodeStyleOptions.UseImplicitTypeWherePossible);
}
set
{
SetUseVarOption(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, value);
}
} }
public string Style_UseImplicitTypeWhereApparent public string Style_UseImplicitTypeWhereApparent
{ {
get get { return GetXmlOption(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent); }
{ set { SetXmlOption(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, value); }
return GetUseVarOption(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent);
}
set
{
SetUseVarOption(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, value);
}
} }
public string Style_UseImplicitTypeForIntrinsicTypes public string Style_UseImplicitTypeForIntrinsicTypes
{ {
get get { return GetXmlOption(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes); }
{ set { SetXmlOption(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, value); }
return GetUseVarOption(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes);
}
set
{
SetUseVarOption(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, value);
}
} }
public int Wrapping_IgnoreSpacesAroundBinaryOperators public int Wrapping_IgnoreSpacesAroundBinaryOperators
...@@ -594,11 +576,6 @@ private int GetBooleanOption(PerLanguageOption<bool> key) ...@@ -594,11 +576,6 @@ private int GetBooleanOption(PerLanguageOption<bool> key)
return _workspace.Options.GetOption(key, LanguageNames.CSharp) ? 1 : 0; return _workspace.Options.GetOption(key, LanguageNames.CSharp) ? 1 : 0;
} }
private int GetBooleanOption(PerLanguageOption<SimpleCodeStyleOption> key)
{
return _workspace.Options.GetOption(key, LanguageNames.CSharp).IsChecked ? 1 : 0;
}
private void SetBooleanOption(Option<bool> key, int value) private void SetBooleanOption(Option<bool> key, int value)
{ {
_workspace.Options = _workspace.Options.WithChangedOption(key, value != 0); _workspace.Options = _workspace.Options.WithChangedOption(key, value != 0);
...@@ -620,11 +597,9 @@ private int GetBooleanOption(PerLanguageOption<bool?> key) ...@@ -620,11 +597,9 @@ private int GetBooleanOption(PerLanguageOption<bool?> key)
return option.Value ? 1 : 0; return option.Value ? 1 : 0;
} }
private void SetBooleanOption(PerLanguageOption<SimpleCodeStyleOption> key, int value) private string GetXmlOption(Option<CodeStyleOption<bool>> option)
{ {
var opt = _workspace.Options.GetOption(key, LanguageNames.CSharp); return _workspace.Options.GetOption(option).ToXElement().ToString();
opt.IsChecked = value != 0;
_workspace.Options = _workspace.Options.WithChangedOption(key, LanguageNames.CSharp, opt);
} }
private void SetBooleanOption(PerLanguageOption<bool?> key, int value) private void SetBooleanOption(PerLanguageOption<bool?> key, int value)
...@@ -633,15 +608,21 @@ private void SetBooleanOption(PerLanguageOption<bool?> key, int value) ...@@ -633,15 +608,21 @@ private void SetBooleanOption(PerLanguageOption<bool?> key, int value)
_workspace.Options = _workspace.Options.WithChangedOption(key, LanguageNames.CSharp, boolValue); _workspace.Options = _workspace.Options.WithChangedOption(key, LanguageNames.CSharp, boolValue);
} }
private string GetUseVarOption(Option<SimpleCodeStyleOption> option) private string GetXmlOption(PerLanguageOption<CodeStyleOption<bool>> option)
{ {
return _workspace.Options.GetOption(option).ToXElement().ToString(); return _workspace.Options.GetOption(option, LanguageNames.CSharp).ToXElement().ToString();
} }
private void SetUseVarOption(Option<SimpleCodeStyleOption> option, string value) private void SetXmlOption(Option<CodeStyleOption<bool>> option, string value)
{ {
var convertedValue = SimpleCodeStyleOption.FromXElement(XElement.Parse(value)); var convertedValue = CodeStyleOption<bool>.FromXElement(XElement.Parse(value));
_workspace.Options = _workspace.Options.WithChangedOption(option, convertedValue); _workspace.Options = _workspace.Options.WithChangedOption(option, convertedValue);
} }
private void SetXmlOption(PerLanguageOption<CodeStyleOption<bool>> option, string value)
{
var convertedValue = CodeStyleOption<bool>.FromXElement(XElement.Parse(value));
_workspace.Options = _workspace.Options.WithChangedOption(option, LanguageNames.CSharp, convertedValue);
}
} }
} }
...@@ -33,6 +33,7 @@ namespace Microsoft.VisualStudio.LanguageServices.CSharp.Options ...@@ -33,6 +33,7 @@ namespace Microsoft.VisualStudio.LanguageServices.CSharp.Options
CompletionOptions.FeatureName, CompletionOptions.FeatureName,
CSharpCompletionOptions.FeatureName, CSharpCompletionOptions.FeatureName,
CSharpCodeStyleOptions.FeatureName, CSharpCodeStyleOptions.FeatureName,
CodeStyleOptions.PerLanguageCodeStyleOption,
SimplificationOptions.PerLanguageFeatureName, SimplificationOptions.PerLanguageFeatureName,
ExtractMethodOptions.FeatureName, ExtractMethodOptions.FeatureName,
CSharpFormattingOptions.IndentFeatureName, CSharpFormattingOptions.IndentFeatureName,
...@@ -54,6 +55,10 @@ public CSharpSettingsManagerOptionSerializer(SVsServiceProvider serviceProvider, ...@@ -54,6 +55,10 @@ public CSharpSettingsManagerOptionSerializer(SVsServiceProvider serviceProvider,
private const string SpaceAroundBinaryOperator = nameof(AutomationObject.Space_AroundBinaryOperator); private const string SpaceAroundBinaryOperator = nameof(AutomationObject.Space_AroundBinaryOperator);
private const string UnindentLabels = nameof(AutomationObject.Indent_UnindentLabels); private const string UnindentLabels = nameof(AutomationObject.Indent_UnindentLabels);
private const string FlushLabelsLeft = nameof(AutomationObject.Indent_FlushLabelsLeft); private const string FlushLabelsLeft = nameof(AutomationObject.Indent_FlushLabelsLeft);
private const string Style_QualifyFieldAccess = nameof(AutomationObject.Style_QualifyFieldAccess);
private const string Style_QualifyPropertyAccess = nameof(AutomationObject.Style_QualifyPropertyAccess);
private const string Style_QualifyMethodAccess = nameof(AutomationObject.Style_QualifyMethodAccess);
private const string Style_QualifyEventAccess = nameof(AutomationObject.Style_QualifyEventAccess);
private const string Style_UseImplicitTypeForIntrinsicTypes = nameof(AutomationObject.Style_UseImplicitTypeForIntrinsicTypes); private const string Style_UseImplicitTypeForIntrinsicTypes = nameof(AutomationObject.Style_UseImplicitTypeForIntrinsicTypes);
private const string Style_UseImplicitTypeWhereApparent = nameof(AutomationObject.Style_UseImplicitTypeWhereApparent); private const string Style_UseImplicitTypeWhereApparent = nameof(AutomationObject.Style_UseImplicitTypeWhereApparent);
private const string Style_UseImplicitTypeWherePossible = nameof(AutomationObject.Style_UseImplicitTypeWherePossible); private const string Style_UseImplicitTypeWherePossible = nameof(AutomationObject.Style_UseImplicitTypeWherePossible);
...@@ -89,7 +94,8 @@ private bool ShouldIncludeOnOffOption(FieldInfo fieldInfo) ...@@ -89,7 +94,8 @@ private bool ShouldIncludeOnOffOption(FieldInfo fieldInfo)
typeof(CSharpCodeStyleOptions), typeof(CSharpCodeStyleOptions),
typeof(ExtractMethodOptions), typeof(ExtractMethodOptions),
typeof(ServiceFeatureOnOffOptions), typeof(ServiceFeatureOnOffOptions),
typeof(CSharpFormattingOptions) typeof(CSharpFormattingOptions),
typeof(CodeStyleOptions)
}; };
var bindingFlags = BindingFlags.Public | BindingFlags.Static; var bindingFlags = BindingFlags.Public | BindingFlags.Static;
...@@ -126,6 +132,7 @@ protected override bool SupportsOption(IOption option, string languageName) ...@@ -126,6 +132,7 @@ protected override bool SupportsOption(IOption option, string languageName)
option == AddImportOptions.SuggestForTypesInNuGetPackages || option == AddImportOptions.SuggestForTypesInNuGetPackages ||
option == CSharpCompletionOptions.AddNewLineOnEnterAfterFullyTypedWord || option == CSharpCompletionOptions.AddNewLineOnEnterAfterFullyTypedWord ||
option == CSharpCompletionOptions.IncludeSnippets || option == CSharpCompletionOptions.IncludeSnippets ||
option.Feature == CodeStyleOptions.PerLanguageCodeStyleOption ||
option.Feature == CSharpCodeStyleOptions.FeatureName || option.Feature == CSharpCodeStyleOptions.FeatureName ||
option.Feature == CSharpFormattingOptions.WrappingFeatureName || option.Feature == CSharpFormattingOptions.WrappingFeatureName ||
option.Feature == CSharpFormattingOptions.IndentFeatureName || option.Feature == CSharpFormattingOptions.IndentFeatureName ||
...@@ -224,26 +231,46 @@ public override bool TryFetch(OptionKey optionKey, out object value) ...@@ -224,26 +231,46 @@ public override bool TryFetch(OptionKey optionKey, out object value)
return true; return true;
} }
// code style: use this.
if (optionKey.Option == CodeStyleOptions.QualifyFieldAccess)
{
return FetchStyleBool(Style_QualifyFieldAccess, out value);
}
else if (optionKey.Option == CodeStyleOptions.QualifyPropertyAccess)
{
return FetchStyleBool(Style_QualifyPropertyAccess, out value);
}
else if (optionKey.Option == CodeStyleOptions.QualifyMethodAccess)
{
return FetchStyleBool(Style_QualifyMethodAccess, out value);
}
else if (optionKey.Option == CodeStyleOptions.QualifyEventAccess)
{
return FetchStyleBool(Style_QualifyEventAccess, out value);
}
// code style: use var options. // code style: use var options.
if (optionKey.Option == CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes) if (optionKey.Option == CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes)
{ {
var typeStyleValue = this.Manager.GetValueOrDefault<string>(Style_UseImplicitTypeForIntrinsicTypes); return FetchStyleBool(Style_UseImplicitTypeForIntrinsicTypes, out value);
return FetchTypeStyleOption(typeStyleValue, out value);
} }
else if (optionKey.Option == CSharpCodeStyleOptions.UseImplicitTypeWhereApparent) else if (optionKey.Option == CSharpCodeStyleOptions.UseImplicitTypeWhereApparent)
{ {
var typeStyleValue = this.Manager.GetValueOrDefault<string>(Style_UseImplicitTypeWhereApparent); return FetchStyleBool(Style_UseImplicitTypeWhereApparent, out value);
return FetchTypeStyleOption(typeStyleValue, out value);
} }
else if (optionKey.Option == CSharpCodeStyleOptions.UseImplicitTypeWherePossible) else if (optionKey.Option == CSharpCodeStyleOptions.UseImplicitTypeWherePossible)
{ {
var typeStyleValue = this.Manager.GetValueOrDefault<string>(Style_UseImplicitTypeWherePossible); return FetchStyleBool(Style_UseImplicitTypeWherePossible, out value);
return FetchTypeStyleOption(typeStyleValue, out value);
} }
return base.TryFetch(optionKey, out value); return base.TryFetch(optionKey, out value);
} }
private bool FetchStyleBool(string settingName, out object value)
{
var typeStyleValue = Manager.GetValueOrDefault<string>(settingName);
return FetchStyleOption<bool>(typeStyleValue, out value);
}
public override bool TryPersist(OptionKey optionKey, object value) public override bool TryPersist(OptionKey optionKey, object value)
{ {
...@@ -310,39 +337,57 @@ public override bool TryPersist(OptionKey optionKey, object value) ...@@ -310,39 +337,57 @@ public override bool TryPersist(OptionKey optionKey, object value)
} }
} }
// code style: use this.
if (optionKey.Option == CodeStyleOptions.QualifyFieldAccess)
{
return PersistStyleOption<bool>(Style_QualifyFieldAccess, value);
}
else if (optionKey.Option == CodeStyleOptions.QualifyPropertyAccess)
{
return PersistStyleOption<bool>(Style_QualifyPropertyAccess, value);
}
else if (optionKey.Option == CodeStyleOptions.QualifyMethodAccess)
{
return PersistStyleOption<bool>(Style_QualifyMethodAccess, value);
}
else if (optionKey.Option == CodeStyleOptions.QualifyEventAccess)
{
return PersistStyleOption<bool>(Style_QualifyEventAccess, value);
}
// code style: use var options. // code style: use var options.
if (optionKey.Option == CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes) if (optionKey.Option == CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes)
{ {
return PersistTypeStyleOption(Style_UseImplicitTypeForIntrinsicTypes, value); return PersistStyleOption<bool>(Style_UseImplicitTypeForIntrinsicTypes, value);
} }
else if (optionKey.Option == CSharpCodeStyleOptions.UseImplicitTypeWhereApparent) else if (optionKey.Option == CSharpCodeStyleOptions.UseImplicitTypeWhereApparent)
{ {
return PersistTypeStyleOption(Style_UseImplicitTypeWhereApparent, value); return PersistStyleOption<bool>(Style_UseImplicitTypeWhereApparent, value);
} }
else if (optionKey.Option == CSharpCodeStyleOptions.UseImplicitTypeWherePossible) else if (optionKey.Option == CSharpCodeStyleOptions.UseImplicitTypeWherePossible)
{ {
return PersistTypeStyleOption(Style_UseImplicitTypeWherePossible, value); return PersistStyleOption<bool>(Style_UseImplicitTypeWherePossible, value);
} }
return base.TryPersist(optionKey, value); return base.TryPersist(optionKey, value);
} }
private bool PersistTypeStyleOption(string option, object value) private bool PersistStyleOption<T>(string option, object value)
{ {
var serializedValue = ((SimpleCodeStyleOption)value).ToXElement().ToString(); var serializedValue = ((CodeStyleOption<T>)value).ToXElement().ToString();
this.Manager.SetValueAsync(option, value: serializedValue, isMachineLocal: false); this.Manager.SetValueAsync(option, value: serializedValue, isMachineLocal: false);
return true; return true;
} }
private static bool FetchTypeStyleOption(string typeStyleOptionValue, out object value) private static bool FetchStyleOption<T>(string typeStyleOptionValue, out object value)
{ {
if (string.IsNullOrEmpty(typeStyleOptionValue)) if (string.IsNullOrEmpty(typeStyleOptionValue))
{ {
value = SimpleCodeStyleOption.Default; value = CodeStyleOption<T>.Default;
} }
else else
{ {
value = SimpleCodeStyleOption.FromXElement(XElement.Parse(typeStyleOptionValue)); value = CodeStyleOption<T>.FromXElement(XElement.Parse(typeStyleOptionValue));
} }
return true; return true;
......
...@@ -22,7 +22,9 @@ internal class StyleViewModel : AbstractOptionPreviewViewModel ...@@ -22,7 +22,9 @@ internal class StyleViewModel : AbstractOptionPreviewViewModel
{ {
internal override bool ShouldPersistOption(OptionKey key) internal override bool ShouldPersistOption(OptionKey key)
{ {
return key.Option.Feature == CSharpCodeStyleOptions.FeatureName || key.Option.Feature == SimplificationOptions.PerLanguageFeatureName; return key.Option.Feature == CSharpCodeStyleOptions.FeatureName ||
key.Option.Feature == CodeStyleOptions.PerLanguageCodeStyleOption ||
key.Option.Feature == SimplificationOptions.PerLanguageFeatureName;
} }
#region "Preview Text" #region "Preview Text"
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
using System.Threading; using System.Threading;
using System.Windows.Data; using System.Windows.Data;
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Editor; using Microsoft.CodeAnalysis.Editor;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions; using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Editor.Shared.Preview; using Microsoft.CodeAnalysis.Editor.Shared.Preview;
...@@ -79,13 +80,29 @@ internal OptionSet ApplyChangedOptions(OptionSet optionSet) ...@@ -79,13 +80,29 @@ internal OptionSet ApplyChangedOptions(OptionSet optionSet)
public void SetOptionAndUpdatePreview<T>(T value, IOption option, string preview) public void SetOptionAndUpdatePreview<T>(T value, IOption option, string preview)
{ {
if (option is PerLanguageOption<T>) if (option is Option<CodeStyleOption<T>>)
{
var opt = Options.GetOption((Option<CodeStyleOption<T>>)option);
opt.Value = value;
Options = Options.WithChangedOption((Option<CodeStyleOption<T>>)option, opt);
}
else if (option is PerLanguageOption<CodeStyleOption<T>>)
{
var opt = Options.GetOption((PerLanguageOption<CodeStyleOption<T>>)option, Language);
opt.Value = value;
Options = Options.WithChangedOption((PerLanguageOption<CodeStyleOption<T>>)option, Language, opt);
}
else if (option is Option<T>)
{
Options = Options.WithChangedOption((Option<T>)option, value);
}
else if (option is PerLanguageOption<T>)
{ {
Options = Options.WithChangedOption((PerLanguageOption<T>)option, Language, value); Options = Options.WithChangedOption((PerLanguageOption<T>)option, Language, value);
} }
else else
{ {
Options = Options.WithChangedOption((Option<T>)option, value); throw new InvalidOperationException("Unexpected option type");
} }
UpdateDocument(preview); UpdateDocument(preview);
......
...@@ -15,7 +15,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.Options ...@@ -15,7 +15,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.Options
/// <remarks> /// <remarks>
/// This exists to support options that are implemented as boolean /// This exists to support options that are implemented as boolean
/// options in the non UI layers, <see cref="Option{Boolean}"/>. /// options in the non UI layers, <see cref="Option{Boolean}"/>.
/// In future, if such options are moved to use <see cref="SimpleCodeStyleOption"/>, /// In future, if such options are moved to use <see cref="CodeStyleOption{T}"/>,
/// this class can be completely deleted. /// this class can be completely deleted.
/// </remarks> /// </remarks>
internal class BooleanCodeStyleOptionViewModel : AbstractCodeStyleOptionViewModel internal class BooleanCodeStyleOptionViewModel : AbstractCodeStyleOptionViewModel
......
...@@ -12,7 +12,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.Options ...@@ -12,7 +12,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.Options
/// has a checkbox for selection and a combobox for notification levels. /// has a checkbox for selection and a combobox for notification levels.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// At the features level, this maps to <see cref="SimpleCodeStyleOption"/> /// At the features level, this maps to <see cref="CodeStyleOption{T}"/>
/// </remarks> /// </remarks>
internal class CheckBoxWithComboOptionViewModel : AbstractCheckBoxViewModel internal class CheckBoxWithComboOptionViewModel : AbstractCheckBoxViewModel
{ {
...@@ -30,8 +30,8 @@ public CheckBoxWithComboOptionViewModel(IOption option, string description, stri ...@@ -30,8 +30,8 @@ public CheckBoxWithComboOptionViewModel(IOption option, string description, stri
{ {
NotificationOptions = items; NotificationOptions = items;
var codeStyleOption = ((SimpleCodeStyleOption)options.GetOption(new OptionKey(option, option.IsPerLanguage ? info.Language : null))); var codeStyleOption = ((CodeStyleOption<bool>)options.GetOption(new OptionKey(option, option.IsPerLanguage ? info.Language : null)));
SetProperty(ref _isChecked, codeStyleOption.IsChecked); SetProperty(ref _isChecked, codeStyleOption.Value);
var notificationViewModel = items.Where(i => i.Notification.Value == codeStyleOption.Notification.Value).Single(); var notificationViewModel = items.Where(i => i.Notification.Value == codeStyleOption.Notification.Value).Single();
SetProperty(ref _selectedNotificationOption, notificationViewModel); SetProperty(ref _selectedNotificationOption, notificationViewModel);
...@@ -47,7 +47,7 @@ public override bool IsChecked ...@@ -47,7 +47,7 @@ public override bool IsChecked
set set
{ {
SetProperty(ref _isChecked, value); SetProperty(ref _isChecked, value);
Info.SetOptionAndUpdatePreview(new SimpleCodeStyleOption(_isChecked, _selectedNotificationOption.Notification), Option, GetPreview()); Info.SetOptionAndUpdatePreview(new CodeStyleOption<bool>(_isChecked, _selectedNotificationOption.Notification), Option, GetPreview());
} }
} }
...@@ -60,7 +60,7 @@ public NotificationOptionViewModel SelectedNotificationOption ...@@ -60,7 +60,7 @@ public NotificationOptionViewModel SelectedNotificationOption
set set
{ {
SetProperty(ref _selectedNotificationOption, value); SetProperty(ref _selectedNotificationOption, value);
Info.SetOptionAndUpdatePreview(new SimpleCodeStyleOption(_isChecked, _selectedNotificationOption.Notification), Option, GetPreview()); Info.SetOptionAndUpdatePreview(new CodeStyleOption<bool>(_isChecked, _selectedNotificationOption.Notification), Option, GetPreview());
} }
} }
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
namespace Microsoft.VisualStudio.LanguageServices.Implementation.Options namespace Microsoft.VisualStudio.LanguageServices.Implementation.Options
{ {
/// <summary> /// <summary>
/// This class represents the view model for a <see cref="SimpleCodeStyleOption"/> /// This class represents the view model for a <see cref="CodeStyleOption{T}"/>
/// that binds to the codestyle options UI. /// that binds to the codestyle options UI.
/// </summary> /// </summary>
internal class SimpleCodeStyleOptionViewModel : AbstractCodeStyleOptionViewModel internal class SimpleCodeStyleOptionViewModel : AbstractCodeStyleOptionViewModel
...@@ -24,7 +24,7 @@ public override CodeStylePreference SelectedPreference ...@@ -24,7 +24,7 @@ public override CodeStylePreference SelectedPreference
{ {
if (SetProperty(ref _selectedPreference, value)) if (SetProperty(ref _selectedPreference, value))
{ {
Info.SetOptionAndUpdatePreview(new SimpleCodeStyleOption(_selectedPreference.IsChecked, _selectedNotificationPreference.Notification), Option, GetPreview()); Info.SetOptionAndUpdatePreview(new CodeStyleOption<bool>(_selectedPreference.IsChecked, _selectedNotificationPreference.Notification), Option, GetPreview());
} }
} }
} }
...@@ -41,7 +41,7 @@ public override NotificationOptionViewModel SelectedNotificationPreference ...@@ -41,7 +41,7 @@ public override NotificationOptionViewModel SelectedNotificationPreference
{ {
if (SetProperty(ref _selectedNotificationPreference, value)) if (SetProperty(ref _selectedNotificationPreference, value))
{ {
Info.SetOptionAndUpdatePreview(new SimpleCodeStyleOption(_selectedPreference.IsChecked, _selectedNotificationPreference.Notification), Option, GetPreview()); Info.SetOptionAndUpdatePreview(new CodeStyleOption<bool>(_selectedPreference.IsChecked, _selectedNotificationPreference.Notification), Option, GetPreview());
} }
} }
} }
...@@ -60,8 +60,8 @@ public override NotificationOptionViewModel SelectedNotificationPreference ...@@ -60,8 +60,8 @@ public override NotificationOptionViewModel SelectedNotificationPreference
List<NotificationOptionViewModel> notificationPreferences = null) List<NotificationOptionViewModel> notificationPreferences = null)
: base(option, description, truePreview, falsePreview, info, options, groupName, preferences, notificationPreferences) : base(option, description, truePreview, falsePreview, info, options, groupName, preferences, notificationPreferences)
{ {
var codeStyleOption = ((SimpleCodeStyleOption)options.GetOption(new OptionKey(option, option.IsPerLanguage ? info.Language : null))); var codeStyleOption = ((CodeStyleOption<bool>)options.GetOption(new OptionKey(option, option.IsPerLanguage ? info.Language : null)));
_selectedPreference = Preferences.Single(c => c.IsChecked == codeStyleOption.IsChecked); _selectedPreference = Preferences.Single(c => c.IsChecked == codeStyleOption.Value);
var notificationViewModel = NotificationPreferences.Single(i => i.Notification.Value == codeStyleOption.Notification.Value); var notificationViewModel = NotificationPreferences.Single(i => i.Notification.Value == codeStyleOption.Notification.Value);
_selectedNotificationPreference = NotificationPreferences.Single(p => p.Notification.Value == notificationViewModel.Notification.Value); _selectedNotificationPreference = NotificationPreferences.Single(p => p.Notification.Value == notificationViewModel.Notification.Value);
......
...@@ -243,13 +243,13 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options ...@@ -243,13 +243,13 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
_workspace.Options = _workspace.Options.WithChangedOption(key, LanguageNames.VisualBasic, boolValue) _workspace.Options = _workspace.Options.WithChangedOption(key, LanguageNames.VisualBasic, boolValue)
End Sub End Sub
Private Function GetBooleanOption(key As [PerLanguageOption](Of SimpleCodeStyleOption)) As Boolean Private Function GetBooleanOption(key As [PerLanguageOption](Of CodeStyleOption(Of Boolean))) As Boolean
Return _workspace.Options.GetOption(key, LanguageNames.VisualBasic).IsChecked Return _workspace.Options.GetOption(key, LanguageNames.VisualBasic).Value
End Function End Function
Private Sub SetBooleanOption(key As [PerLanguageOption](Of SimpleCodeStyleOption), value As Boolean) Private Sub SetBooleanOption(key As [PerLanguageOption](Of CodeStyleOption(Of Boolean)), value As Boolean)
Dim opt = _workspace.Options.GetOption(key, LanguageNames.VisualBasic) Dim opt = _workspace.Options.GetOption(key, LanguageNames.VisualBasic)
opt.IsChecked = value opt.Value = value
_workspace.Options = _workspace.Options.WithChangedOption(key, LanguageNames.VisualBasic, opt) _workspace.Options = _workspace.Options.WithChangedOption(key, LanguageNames.VisualBasic, opt)
End Sub End Sub
End Class End Class
......
...@@ -12,8 +12,8 @@ internal static class CSharpCodeStyleOptions ...@@ -12,8 +12,8 @@ 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>(FeatureName, "UseVarWhenDeclaringLocals", defaultValue: true); public static readonly Option<bool> UseVarWhenDeclaringLocals = new Option<bool>(FeatureName, "UseVarWhenDeclaringLocals", defaultValue: true);
public static readonly Option<SimpleCodeStyleOption> UseImplicitTypeForIntrinsicTypes = new Option<SimpleCodeStyleOption>(FeatureName, nameof(UseImplicitTypeForIntrinsicTypes), defaultValue: SimpleCodeStyleOption.Default); public static readonly Option<CodeStyleOption<bool>> UseImplicitTypeForIntrinsicTypes = new Option<CodeStyleOption<bool>>(FeatureName, nameof(UseImplicitTypeForIntrinsicTypes), defaultValue: CodeStyleOption<bool>.Default);
public static readonly Option<SimpleCodeStyleOption> UseImplicitTypeWhereApparent = new Option<SimpleCodeStyleOption>(FeatureName, nameof(UseImplicitTypeWhereApparent), defaultValue: SimpleCodeStyleOption.Default); public static readonly Option<CodeStyleOption<bool>> UseImplicitTypeWhereApparent = new Option<CodeStyleOption<bool>>(FeatureName, nameof(UseImplicitTypeWhereApparent), defaultValue: CodeStyleOption<bool>.Default);
public static readonly Option<SimpleCodeStyleOption> UseImplicitTypeWherePossible = new Option<SimpleCodeStyleOption>(FeatureName, nameof(UseImplicitTypeWherePossible), defaultValue: SimpleCodeStyleOption.Default); public static readonly Option<CodeStyleOption<bool>> UseImplicitTypeWherePossible = new Option<CodeStyleOption<bool>>(FeatureName, nameof(UseImplicitTypeWherePossible), defaultValue: CodeStyleOption<bool>.Default);
} }
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Composition; using System.Composition;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Options.Providers; using Microsoft.CodeAnalysis.Options.Providers;
...@@ -13,6 +14,10 @@ internal class CSharpCodeStyleOptionsProvider : IOptionProvider ...@@ -13,6 +14,10 @@ internal class CSharpCodeStyleOptionsProvider : IOptionProvider
{ {
private readonly IEnumerable<IOption> _options = new List<IOption> private readonly IEnumerable<IOption> _options = new List<IOption>
{ {
CodeStyleOptions.QualifyFieldAccess,
CodeStyleOptions.QualifyPropertyAccess,
CodeStyleOptions.QualifyMethodAccess,
CodeStyleOptions.QualifyEventAccess,
CSharpCodeStyleOptions.UseVarWhenDeclaringLocals, CSharpCodeStyleOptions.UseVarWhenDeclaringLocals,
CSharpCodeStyleOptions.UseImplicitTypeWherePossible, CSharpCodeStyleOptions.UseImplicitTypeWherePossible,
CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, CSharpCodeStyleOptions.UseImplicitTypeWhereApparent,
......
...@@ -234,17 +234,17 @@ private static TypeStylePreference GetCurrentTypeStylePreferences(OptionSet opti ...@@ -234,17 +234,17 @@ private static TypeStylePreference GetCurrentTypeStylePreferences(OptionSet opti
var styleForApparent = optionSet.GetOption(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent); var styleForApparent = optionSet.GetOption(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent);
var styleForElsewhere = optionSet.GetOption(CSharpCodeStyleOptions.UseImplicitTypeWherePossible); var styleForElsewhere = optionSet.GetOption(CSharpCodeStyleOptions.UseImplicitTypeWherePossible);
if (styleForIntrinsicTypes.IsChecked) if (styleForIntrinsicTypes.Value)
{ {
stylePreferences |= TypeStylePreference.ImplicitTypeForIntrinsicTypes; stylePreferences |= TypeStylePreference.ImplicitTypeForIntrinsicTypes;
} }
if (styleForApparent.IsChecked) if (styleForApparent.Value)
{ {
stylePreferences |= TypeStylePreference.ImplicitTypeWhereApparent; stylePreferences |= TypeStylePreference.ImplicitTypeWhereApparent;
} }
if (styleForElsewhere.IsChecked) if (styleForElsewhere.Value)
{ {
stylePreferences |= TypeStylePreference.ImplicitTypeWherePossible; stylePreferences |= TypeStylePreference.ImplicitTypeWherePossible;
} }
......
...@@ -6,44 +6,45 @@ ...@@ -6,44 +6,45 @@
namespace Microsoft.CodeAnalysis.CodeStyle namespace Microsoft.CodeAnalysis.CodeStyle
{ {
/// <summary> /// <summary>
/// Represents a code style option that typically /// Represents a code style option and an associated notification option.
/// offers two choices as preferences and a set of
/// notification styles. the preference is then
/// simply recorded as a boolean.
/// </summary> /// </summary>
public class SimpleCodeStyleOption public class CodeStyleOption<T>
{ {
public static CodeStyleOption<T> Default => new CodeStyleOption<T>(default(T), NotificationOption.None);
private const int SerializationVersion = 1; private const int SerializationVersion = 1;
public static readonly SimpleCodeStyleOption Default = new SimpleCodeStyleOption(false, NotificationOption.None);
public SimpleCodeStyleOption(bool isChecked, NotificationOption notification) public CodeStyleOption(T value, NotificationOption notification)
{ {
IsChecked = isChecked; Value = value;
Notification = notification; Notification = notification;
} }
public bool IsChecked { get; set; } public T Value { get; set; }
public NotificationOption Notification { get; set; } public NotificationOption Notification { get; set; }
public XElement ToXElement() => public XElement ToXElement() =>
new XElement(nameof(SimpleCodeStyleOption), new XElement(nameof(CodeStyleOption<T>), // `nameof()` returns just "CodeStyleOption"
new XAttribute(nameof(SerializationVersion), SerializationVersion), new XAttribute(nameof(SerializationVersion), SerializationVersion),
new XAttribute(nameof(IsChecked), IsChecked), new XAttribute("Type", typeof(T).Name),
new XAttribute(nameof(Value), Value),
new XAttribute(nameof(DiagnosticSeverity), Notification.Value)); new XAttribute(nameof(DiagnosticSeverity), Notification.Value));
public static SimpleCodeStyleOption FromXElement(XElement element) public static CodeStyleOption<T> FromXElement(XElement element)
{ {
var isCheckedAttribute = element.Attribute(nameof(IsChecked)); var typeAttribute = element.Attribute("Type");
var valueAttribute = element.Attribute(nameof(Value));
var severityAttribute = element.Attribute(nameof(DiagnosticSeverity)); var severityAttribute = element.Attribute(nameof(DiagnosticSeverity));
if (isCheckedAttribute == null || severityAttribute == null) if (typeAttribute == null || valueAttribute == null || severityAttribute == null)
{ {
// data from storage is corrupt, or nothing has been stored yet. // data from storage is corrupt, or nothing has been stored yet.
return Default; return Default;
} }
var isChecked = bool.Parse(isCheckedAttribute.Value); var parser = GetParser(typeAttribute.Value);
var value = (T)parser(valueAttribute.Value);
var severity = (DiagnosticSeverity)Enum.Parse(typeof(DiagnosticSeverity), severityAttribute.Value); var severity = (DiagnosticSeverity)Enum.Parse(typeof(DiagnosticSeverity), severityAttribute.Value);
NotificationOption notificationOption; NotificationOption notificationOption;
...@@ -65,7 +66,18 @@ public static SimpleCodeStyleOption FromXElement(XElement element) ...@@ -65,7 +66,18 @@ public static SimpleCodeStyleOption FromXElement(XElement element)
throw new ArgumentException(nameof(element)); throw new ArgumentException(nameof(element));
} }
return new SimpleCodeStyleOption(isChecked, notificationOption); return new CodeStyleOption<T>(value, notificationOption);
}
private static Func<string, object> GetParser(string type)
{
switch (type)
{
case nameof(Boolean):
return v => bool.Parse(v);
default:
throw new ArgumentException(nameof(type));
}
} }
} }
} }
...@@ -11,21 +11,21 @@ public class CodeStyleOptions ...@@ -11,21 +11,21 @@ public class CodeStyleOptions
/// <summary> /// <summary>
/// This option says if we should simplify away the <see langword="this"/>. or <see langword="Me"/>. in field access expressions. /// This option says if we should simplify away the <see langword="this"/>. or <see langword="Me"/>. in field access expressions.
/// </summary> /// </summary>
public static readonly PerLanguageOption<SimpleCodeStyleOption> QualifyFieldAccess = new PerLanguageOption<SimpleCodeStyleOption>(PerLanguageCodeStyleOption, nameof(QualifyFieldAccess), defaultValue: SimpleCodeStyleOption.Default); public static readonly PerLanguageOption<CodeStyleOption<bool>> QualifyFieldAccess = new PerLanguageOption<CodeStyleOption<bool>>(PerLanguageCodeStyleOption, nameof(QualifyFieldAccess), defaultValue: CodeStyleOption<bool>.Default);
/// <summary> /// <summary>
/// This option says if we should simplify away the <see langword="this"/>. or <see langword="Me"/>. in property access expressions. /// This option says if we should simplify away the <see langword="this"/>. or <see langword="Me"/>. in property access expressions.
/// </summary> /// </summary>
public static readonly PerLanguageOption<SimpleCodeStyleOption> QualifyPropertyAccess = new PerLanguageOption<SimpleCodeStyleOption>(PerLanguageCodeStyleOption, nameof(QualifyPropertyAccess), defaultValue: SimpleCodeStyleOption.Default); public static readonly PerLanguageOption<CodeStyleOption<bool>> QualifyPropertyAccess = new PerLanguageOption<CodeStyleOption<bool>>(PerLanguageCodeStyleOption, nameof(QualifyPropertyAccess), defaultValue: CodeStyleOption<bool>.Default);
/// <summary> /// <summary>
/// This option says if we should simplify away the <see langword="this"/>. or <see langword="Me"/>. in method access expressions. /// This option says if we should simplify away the <see langword="this"/>. or <see langword="Me"/>. in method access expressions.
/// </summary> /// </summary>
public static readonly PerLanguageOption<SimpleCodeStyleOption> QualifyMethodAccess = new PerLanguageOption<SimpleCodeStyleOption>(PerLanguageCodeStyleOption, nameof(QualifyMethodAccess), defaultValue: SimpleCodeStyleOption.Default); public static readonly PerLanguageOption<CodeStyleOption<bool>> QualifyMethodAccess = new PerLanguageOption<CodeStyleOption<bool>>(PerLanguageCodeStyleOption, nameof(QualifyMethodAccess), defaultValue: CodeStyleOption<bool>.Default);
/// <summary> /// <summary>
/// This option says if we should simplify away the <see langword="this"/>. or <see langword="Me"/>. in event access expressions. /// This option says if we should simplify away the <see langword="this"/>. or <see langword="Me"/>. in event access expressions.
/// </summary> /// </summary>
public static readonly PerLanguageOption<SimpleCodeStyleOption> QualifyEventAccess = new PerLanguageOption<SimpleCodeStyleOption>(PerLanguageCodeStyleOption, nameof(QualifyEventAccess), defaultValue: SimpleCodeStyleOption.Default); public static readonly PerLanguageOption<CodeStyleOption<bool>> QualifyEventAccess = new PerLanguageOption<CodeStyleOption<bool>>(PerLanguageCodeStyleOption, nameof(QualifyEventAccess), defaultValue: CodeStyleOption<bool>.Default);
} }
} }
Microsoft.CodeAnalysis.CodeStyle.CodeStyleOption<T>
Microsoft.CodeAnalysis.CodeStyle.CodeStyleOption<T>.CodeStyleOption(T value, Microsoft.CodeAnalysis.CodeStyle.NotificationOption notification) -> void
Microsoft.CodeAnalysis.CodeStyle.CodeStyleOption<T>.Notification.get -> Microsoft.CodeAnalysis.CodeStyle.NotificationOption
Microsoft.CodeAnalysis.CodeStyle.CodeStyleOption<T>.Notification.set -> void
Microsoft.CodeAnalysis.CodeStyle.CodeStyleOption<T>.ToXElement() -> System.Xml.Linq.XElement
Microsoft.CodeAnalysis.CodeStyle.CodeStyleOption<T>.Value.get -> T
Microsoft.CodeAnalysis.CodeStyle.CodeStyleOption<T>.Value.set -> void
Microsoft.CodeAnalysis.CodeStyle.CodeStyleOptions Microsoft.CodeAnalysis.CodeStyle.CodeStyleOptions
Microsoft.CodeAnalysis.CodeStyle.CodeStyleOptions.CodeStyleOptions() -> void Microsoft.CodeAnalysis.CodeStyle.CodeStyleOptions.CodeStyleOptions() -> void
Microsoft.CodeAnalysis.CodeStyle.NotificationOption Microsoft.CodeAnalysis.CodeStyle.NotificationOption
...@@ -5,13 +12,6 @@ Microsoft.CodeAnalysis.CodeStyle.NotificationOption.Name.get -> string ...@@ -5,13 +12,6 @@ Microsoft.CodeAnalysis.CodeStyle.NotificationOption.Name.get -> string
Microsoft.CodeAnalysis.CodeStyle.NotificationOption.Name.set -> void Microsoft.CodeAnalysis.CodeStyle.NotificationOption.Name.set -> void
Microsoft.CodeAnalysis.CodeStyle.NotificationOption.Value.get -> Microsoft.CodeAnalysis.DiagnosticSeverity Microsoft.CodeAnalysis.CodeStyle.NotificationOption.Value.get -> Microsoft.CodeAnalysis.DiagnosticSeverity
Microsoft.CodeAnalysis.CodeStyle.NotificationOption.Value.set -> void Microsoft.CodeAnalysis.CodeStyle.NotificationOption.Value.set -> void
Microsoft.CodeAnalysis.CodeStyle.SimpleCodeStyleOption
Microsoft.CodeAnalysis.CodeStyle.SimpleCodeStyleOption.IsChecked.get -> bool
Microsoft.CodeAnalysis.CodeStyle.SimpleCodeStyleOption.IsChecked.set -> void
Microsoft.CodeAnalysis.CodeStyle.SimpleCodeStyleOption.Notification.get -> Microsoft.CodeAnalysis.CodeStyle.NotificationOption
Microsoft.CodeAnalysis.CodeStyle.SimpleCodeStyleOption.Notification.set -> void
Microsoft.CodeAnalysis.CodeStyle.SimpleCodeStyleOption.SimpleCodeStyleOption(bool isChecked, Microsoft.CodeAnalysis.CodeStyle.NotificationOption notification) -> void
Microsoft.CodeAnalysis.CodeStyle.SimpleCodeStyleOption.ToXElement() -> System.Xml.Linq.XElement
Microsoft.CodeAnalysis.Document.Options.get -> Microsoft.CodeAnalysis.Options.DocumentOptionSet Microsoft.CodeAnalysis.Document.Options.get -> Microsoft.CodeAnalysis.Options.DocumentOptionSet
Microsoft.CodeAnalysis.Editing.SyntaxGenerator.AddSwitchSections(Microsoft.CodeAnalysis.SyntaxNode switchStatement, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.SyntaxNode> switchSections) -> Microsoft.CodeAnalysis.SyntaxNode Microsoft.CodeAnalysis.Editing.SyntaxGenerator.AddSwitchSections(Microsoft.CodeAnalysis.SyntaxNode switchStatement, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.SyntaxNode> switchSections) -> Microsoft.CodeAnalysis.SyntaxNode
Microsoft.CodeAnalysis.Options.DocumentOptionSet Microsoft.CodeAnalysis.Options.DocumentOptionSet
...@@ -29,20 +29,20 @@ override Microsoft.CodeAnalysis.Options.DocumentOptionSet.GetOption<T>(Microsoft ...@@ -29,20 +29,20 @@ override Microsoft.CodeAnalysis.Options.DocumentOptionSet.GetOption<T>(Microsoft
override Microsoft.CodeAnalysis.Options.DocumentOptionSet.WithChangedOption(Microsoft.CodeAnalysis.Options.OptionKey optionAndLanguage, object value) -> Microsoft.CodeAnalysis.Options.OptionSet override Microsoft.CodeAnalysis.Options.DocumentOptionSet.WithChangedOption(Microsoft.CodeAnalysis.Options.OptionKey optionAndLanguage, object value) -> Microsoft.CodeAnalysis.Options.OptionSet
override Microsoft.CodeAnalysis.Options.DocumentOptionSet.WithChangedOption<T>(Microsoft.CodeAnalysis.Options.Option<T> option, T value) -> Microsoft.CodeAnalysis.Options.OptionSet override Microsoft.CodeAnalysis.Options.DocumentOptionSet.WithChangedOption<T>(Microsoft.CodeAnalysis.Options.Option<T> option, T value) -> Microsoft.CodeAnalysis.Options.OptionSet
override Microsoft.CodeAnalysis.Options.DocumentOptionSet.WithChangedOption<T>(Microsoft.CodeAnalysis.Options.PerLanguageOption<T> option, string language, T value) -> Microsoft.CodeAnalysis.Options.OptionSet override Microsoft.CodeAnalysis.Options.DocumentOptionSet.WithChangedOption<T>(Microsoft.CodeAnalysis.Options.PerLanguageOption<T> option, string language, T value) -> Microsoft.CodeAnalysis.Options.OptionSet
static Microsoft.CodeAnalysis.CodeStyle.SimpleCodeStyleOption.FromXElement(System.Xml.Linq.XElement element) -> Microsoft.CodeAnalysis.CodeStyle.SimpleCodeStyleOption
static Microsoft.CodeAnalysis.Editing.DeclarationModifiers.TryParse(string value, out Microsoft.CodeAnalysis.Editing.DeclarationModifiers modifiers) -> bool static Microsoft.CodeAnalysis.Editing.DeclarationModifiers.TryParse(string value, out Microsoft.CodeAnalysis.Editing.DeclarationModifiers modifiers) -> bool
static Microsoft.CodeAnalysis.CodeStyle.CodeStyleOption<T>.Default.get -> Microsoft.CodeAnalysis.CodeStyle.CodeStyleOption<T>
static Microsoft.CodeAnalysis.CodeStyle.CodeStyleOption<T>.FromXElement(System.Xml.Linq.XElement element) -> Microsoft.CodeAnalysis.CodeStyle.CodeStyleOption<T>
static Microsoft.CodeAnalysis.Simplification.SimplificationOptions.NamingPreferences.get -> Microsoft.CodeAnalysis.Options.PerLanguageOption<string> static Microsoft.CodeAnalysis.Simplification.SimplificationOptions.NamingPreferences.get -> Microsoft.CodeAnalysis.Options.PerLanguageOption<string>
static Microsoft.CodeAnalysis.Simplification.SimplificationOptions.QualifyEventAccess.get -> Microsoft.CodeAnalysis.Options.PerLanguageOption<bool> static Microsoft.CodeAnalysis.Simplification.SimplificationOptions.QualifyEventAccess.get -> Microsoft.CodeAnalysis.Options.PerLanguageOption<bool>
static Microsoft.CodeAnalysis.Simplification.SimplificationOptions.QualifyFieldAccess.get -> Microsoft.CodeAnalysis.Options.PerLanguageOption<bool> static Microsoft.CodeAnalysis.Simplification.SimplificationOptions.QualifyFieldAccess.get -> Microsoft.CodeAnalysis.Options.PerLanguageOption<bool>
static Microsoft.CodeAnalysis.Simplification.SimplificationOptions.QualifyMethodAccess.get -> Microsoft.CodeAnalysis.Options.PerLanguageOption<bool> static Microsoft.CodeAnalysis.Simplification.SimplificationOptions.QualifyMethodAccess.get -> Microsoft.CodeAnalysis.Options.PerLanguageOption<bool>
static Microsoft.CodeAnalysis.Simplification.SimplificationOptions.QualifyPropertyAccess.get -> Microsoft.CodeAnalysis.Options.PerLanguageOption<bool> static Microsoft.CodeAnalysis.Simplification.SimplificationOptions.QualifyPropertyAccess.get -> Microsoft.CodeAnalysis.Options.PerLanguageOption<bool>
static readonly Microsoft.CodeAnalysis.CodeStyle.CodeStyleOptions.QualifyEventAccess -> Microsoft.CodeAnalysis.Options.PerLanguageOption<Microsoft.CodeAnalysis.CodeStyle.SimpleCodeStyleOption> static readonly Microsoft.CodeAnalysis.CodeStyle.CodeStyleOptions.QualifyEventAccess -> Microsoft.CodeAnalysis.Options.PerLanguageOption<Microsoft.CodeAnalysis.CodeStyle.CodeStyleOption<bool>>
static readonly Microsoft.CodeAnalysis.CodeStyle.CodeStyleOptions.QualifyFieldAccess -> Microsoft.CodeAnalysis.Options.PerLanguageOption<Microsoft.CodeAnalysis.CodeStyle.SimpleCodeStyleOption> static readonly Microsoft.CodeAnalysis.CodeStyle.CodeStyleOptions.QualifyFieldAccess -> Microsoft.CodeAnalysis.Options.PerLanguageOption<Microsoft.CodeAnalysis.CodeStyle.CodeStyleOption<bool>>
static readonly Microsoft.CodeAnalysis.CodeStyle.CodeStyleOptions.QualifyMethodAccess -> Microsoft.CodeAnalysis.Options.PerLanguageOption<Microsoft.CodeAnalysis.CodeStyle.SimpleCodeStyleOption> static readonly Microsoft.CodeAnalysis.CodeStyle.CodeStyleOptions.QualifyMethodAccess -> Microsoft.CodeAnalysis.Options.PerLanguageOption<Microsoft.CodeAnalysis.CodeStyle.CodeStyleOption<bool>>
static readonly Microsoft.CodeAnalysis.CodeStyle.CodeStyleOptions.QualifyPropertyAccess -> Microsoft.CodeAnalysis.Options.PerLanguageOption<Microsoft.CodeAnalysis.CodeStyle.SimpleCodeStyleOption> static readonly Microsoft.CodeAnalysis.CodeStyle.CodeStyleOptions.QualifyPropertyAccess -> Microsoft.CodeAnalysis.Options.PerLanguageOption<Microsoft.CodeAnalysis.CodeStyle.CodeStyleOption<bool>>
static readonly Microsoft.CodeAnalysis.CodeStyle.NotificationOption.Error -> Microsoft.CodeAnalysis.CodeStyle.NotificationOption static readonly Microsoft.CodeAnalysis.CodeStyle.NotificationOption.Error -> Microsoft.CodeAnalysis.CodeStyle.NotificationOption
static readonly Microsoft.CodeAnalysis.CodeStyle.NotificationOption.Info -> Microsoft.CodeAnalysis.CodeStyle.NotificationOption static readonly Microsoft.CodeAnalysis.CodeStyle.NotificationOption.Info -> Microsoft.CodeAnalysis.CodeStyle.NotificationOption
static readonly Microsoft.CodeAnalysis.CodeStyle.NotificationOption.None -> Microsoft.CodeAnalysis.CodeStyle.NotificationOption static readonly Microsoft.CodeAnalysis.CodeStyle.NotificationOption.None -> Microsoft.CodeAnalysis.CodeStyle.NotificationOption
static readonly Microsoft.CodeAnalysis.CodeStyle.NotificationOption.Warning -> Microsoft.CodeAnalysis.CodeStyle.NotificationOption static readonly Microsoft.CodeAnalysis.CodeStyle.NotificationOption.Warning -> Microsoft.CodeAnalysis.CodeStyle.NotificationOption
static readonly Microsoft.CodeAnalysis.CodeStyle.SimpleCodeStyleOption.Default -> Microsoft.CodeAnalysis.CodeStyle.SimpleCodeStyleOption virtual Microsoft.CodeAnalysis.Workspace.UpdateGeneratedDocuments(Microsoft.CodeAnalysis.ProjectId projectId, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.DocumentInfo> documentsRemoved, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.DocumentInfo> documentsAdded) -> void
virtual Microsoft.CodeAnalysis.Workspace.UpdateGeneratedDocuments(Microsoft.CodeAnalysis.ProjectId projectId, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.DocumentInfo> documentsRemoved, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.DocumentInfo> documentsAdded) -> void
\ No newline at end of file
...@@ -110,10 +110,10 @@ internal static bool ShouldSimplifyMemberAccessExpression(SemanticModel semantic ...@@ -110,10 +110,10 @@ internal static bool ShouldSimplifyMemberAccessExpression(SemanticModel semantic
internal static bool ShouldSimplifyMemberAccessExpression(ISymbol symbol, string languageName, OptionSet optionSet) internal static bool ShouldSimplifyMemberAccessExpression(ISymbol symbol, string languageName, OptionSet optionSet)
{ {
if (!symbol.IsStatic && if (!symbol.IsStatic &&
(symbol.IsKind(SymbolKind.Field) && optionSet.GetOption(CodeStyleOptions.QualifyFieldAccess, languageName).IsChecked || (symbol.IsKind(SymbolKind.Field) && optionSet.GetOption(CodeStyleOptions.QualifyFieldAccess, languageName).Value ||
(symbol.IsKind(SymbolKind.Property) && optionSet.GetOption(CodeStyleOptions.QualifyPropertyAccess, languageName).IsChecked) || (symbol.IsKind(SymbolKind.Property) && optionSet.GetOption(CodeStyleOptions.QualifyPropertyAccess, languageName).Value) ||
(symbol.IsKind(SymbolKind.Method) && optionSet.GetOption(CodeStyleOptions.QualifyMethodAccess, languageName).IsChecked) || (symbol.IsKind(SymbolKind.Method) && optionSet.GetOption(CodeStyleOptions.QualifyMethodAccess, languageName).Value) ||
(symbol.IsKind(SymbolKind.Event) && optionSet.GetOption(CodeStyleOptions.QualifyEventAccess, languageName).IsChecked))) (symbol.IsKind(SymbolKind.Event) && optionSet.GetOption(CodeStyleOptions.QualifyEventAccess, languageName).Value)))
{ {
return false; return false;
} }
......
...@@ -346,7 +346,7 @@ ...@@ -346,7 +346,7 @@
<Compile Include="CodeGeneration\CodeGenerator.cs" /> <Compile Include="CodeGeneration\CodeGenerator.cs" />
<Compile Include="CodeStyle\CodeStyleOptions.cs" /> <Compile Include="CodeStyle\CodeStyleOptions.cs" />
<Compile Include="CodeStyle\NotificationOption.cs" /> <Compile Include="CodeStyle\NotificationOption.cs" />
<Compile Include="CodeStyle\SimpleCodeStyleOption.cs" /> <Compile Include="CodeStyle\CodeStyleOption.cs" />
<Compile Include="Diagnostics\DiagnosticData.cs" /> <Compile Include="Diagnostics\DiagnosticData.cs" />
<Compile Include="Diagnostics\DiagnosticProvider.cs" /> <Compile Include="Diagnostics\DiagnosticProvider.cs" />
<Compile Include="Diagnostics\Extensions.cs" /> <Compile Include="Diagnostics\Extensions.cs" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册