提交 4985a18e 编写于 作者: M Manish Vasani

Address feedback

上级 50287dea
...@@ -659,7 +659,7 @@ static void Main() ...@@ -659,7 +659,7 @@ static void Main()
/// <summary> /// <summary>
/// Verifies that the use of braces in a construct nested within the true portion of an <c>if</c> statement does /// Verifies that the use of braces in a construct nested within the true portion of an <c>if</c> statement does
/// not trigger the multiline behavior the <c>else</c> clause of a containing stetemnet for /// not trigger the multiline behavior the <c>else</c> clause of a containing stetemnet for
/// "PreferBracesPreference.WhenMultiline". The <c>else</c> clause would only need braces if the true /// <see cref="PreferBracesPreference.WhenMultiline"/>. The <c>else</c> clause would only need braces if the true
/// portion also used braces (which would be required if the true portion was considered multiline. /// portion also used braces (which would be required if the true portion was considered multiline.
/// </summary> /// </summary>
[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsAddBraces)] [Theory, Trait(Traits.Feature, Traits.Features.CodeActionsAddBraces)]
...@@ -668,6 +668,8 @@ static void Main() ...@@ -668,6 +668,8 @@ static void Main()
[InlineData((int)PreferBracesPreference.Always, true)] [InlineData((int)PreferBracesPreference.Always, true)]
public async Task FireForIfNestedInElseWithoutBracesWithMultilineContext5(int bracesPreference, bool expectDiagnostic) public async Task FireForIfNestedInElseWithoutBracesWithMultilineContext5(int bracesPreference, bool expectDiagnostic)
{ {
var x = PreferBracesPreference.WhenMultiline;
await TestAsync( await TestAsync(
@" @"
class Program class Program
......
...@@ -100,19 +100,19 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.AddAccessibilityModifiers ...@@ -100,19 +100,19 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.AddAccessibilityModifiers
If member.IsParentKind(SyntaxKind.CompilationUnit) OrElse If member.IsParentKind(SyntaxKind.CompilationUnit) OrElse
member.IsParentKind(SyntaxKind.NamespaceBlock) Then member.IsParentKind(SyntaxKind.NamespaceBlock) Then
' default is Friend ' default is Friend
Return accessibility = accessibility.Friend Return accessibility = Accessibility.Friend
End If End If
' default for const and field in a class is private ' default for const and field in a class is private
If member.IsParentKind(SyntaxKind.ClassBlock) OrElse If member.IsParentKind(SyntaxKind.ClassBlock) OrElse
member.IsParentKind(SyntaxKind.ModuleBlock) Then member.IsParentKind(SyntaxKind.ModuleBlock) Then
If member.IsKind(SyntaxKind.FieldDeclaration) Then If member.IsKind(SyntaxKind.FieldDeclaration) Then
Return accessibility = accessibility.Private Return accessibility = Accessibility.Private
End If End If
End If End If
' Everything else has a default of public ' Everything else has a default of public
Return accessibility = accessibility.Public Return accessibility = Accessibility.Public
End Function End Function
End Class End Class
End Namespace End Namespace
<Project> <Project>
<Import Project="..\..\Directory.Build.targets"/> <Import Project="..\..\Directory.Build.targets"/>
<ItemGroup Condition="'$(IsShipping)' == 'true'"> <ItemGroup>
<AdditionalFiles Include="$(MSBuildThisFileDirectory)\BannedSymbols.txt" /> <AdditionalFiles Include="$(MSBuildThisFileDirectory)\BannedSymbols.txt" />
</ItemGroup> </ItemGroup>
</Project> </Project>
\ No newline at end of file
...@@ -19,45 +19,44 @@ public abstract class AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest : ...@@ -19,45 +19,44 @@ public abstract class AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest :
protected override TestWorkspace CreateWorkspaceFromFile(string initialMarkup, TestParameters parameters) protected override TestWorkspace CreateWorkspaceFromFile(string initialMarkup, TestParameters parameters)
=> TestWorkspace.CreateCSharp(initialMarkup, parameters.parseOptions, parameters.compilationOptions); => TestWorkspace.CreateCSharp(initialMarkup, parameters.parseOptions, parameters.compilationOptions);
#pragma warning disable CS0108 // Member hides inherited member; missing new keyword
#if CODE_STYLE #if CODE_STYLE
internal (OptionKey2, object) SingleOption<T>(Option2<T> option, T enabled) internal (OptionKey2, object) SingleOption<T>(Option2<T> option, T enabled)
=> (new OptionKey2(option), enabled); => (new OptionKey2(option), enabled);
private protected (OptionKey2, object) SingleOption<T>(PerLanguageOption2<T> option, T value) internal (OptionKey2, object) SingleOption<T>(PerLanguageOption2<T> option, T value)
=> (new OptionKey2(option, this.GetLanguage()), value); => (new OptionKey2(option, this.GetLanguage()), value);
private protected (OptionKey2, object) SingleOption<T>(Option2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification) internal (OptionKey2, object) SingleOption<T>(Option2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification)
=> SingleOption(option, new CodeStyleOption2<T>(enabled, notification)); => SingleOption(option, new CodeStyleOption2<T>(enabled, notification));
private protected (OptionKey2, object) SingleOption<T>(Option2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle) internal (OptionKey2, object) SingleOption<T>(Option2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle)
=> (new OptionKey2(option), codeStyle); => (new OptionKey2(option), codeStyle);
private protected (OptionKey2, object) SingleOption<T>(PerLanguageOption2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification) internal (OptionKey2, object) SingleOption<T>(PerLanguageOption2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification)
=> SingleOption(option, new CodeStyleOption2<T>(enabled, notification)); => SingleOption(option, new CodeStyleOption2<T>(enabled, notification));
private protected (OptionKey2, object) SingleOption<T>(PerLanguageOption2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle) internal (OptionKey2, object) SingleOption<T>(PerLanguageOption2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle)
=> SingleOption(option, codeStyle, language: GetLanguage()); => SingleOption(option, codeStyle, language: GetLanguage());
private protected static (OptionKey2, object) SingleOption<T>(PerLanguageOption2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle, string language) internal static (OptionKey2, object) SingleOption<T>(PerLanguageOption2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle, string language)
=> (new OptionKey2(option, language), codeStyle); => (new OptionKey2(option, language), codeStyle);
private protected IOptionsCollection Option<T>(Option2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification) internal IOptionsCollection Option<T>(Option2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification)
=> OptionsSet(SingleOption(option, enabled, notification)); => OptionsSet(SingleOption(option, enabled, notification));
private protected IOptionsCollection Option<T>(Option2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle) internal IOptionsCollection Option<T>(Option2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle)
=> OptionsSet(SingleOption(option, codeStyle)); => OptionsSet(SingleOption(option, codeStyle));
private protected IOptionsCollection Option<T>(PerLanguageOption2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification) internal IOptionsCollection Option<T>(PerLanguageOption2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification)
=> OptionsSet(SingleOption(option, enabled, notification)); => OptionsSet(SingleOption(option, enabled, notification));
private protected IOptionsCollection Option<T>(PerLanguageOption2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle) internal IOptionsCollection Option<T>(PerLanguageOption2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle)
=> OptionsSet(SingleOption(option, codeStyle)); => OptionsSet(SingleOption(option, codeStyle));
private protected IOptionsCollection Option<T>(Option2<T> option, T value) internal IOptionsCollection Option<T>(Option2<T> option, T value)
=> OptionsSet(SingleOption(option, value)); => OptionsSet(SingleOption(option, value));
private protected IOptionsCollection Option<T>(PerLanguageOption2<T> option, T value) internal IOptionsCollection Option<T>(PerLanguageOption2<T> option, T value)
=> OptionsSet(SingleOption(option, value)); => OptionsSet(SingleOption(option, value));
internal static IOptionsCollection OptionsSet(params (OptionKey2 key, object value)[] options) internal static IOptionsCollection OptionsSet(params (OptionKey2 key, object value)[] options)
......
...@@ -688,82 +688,43 @@ protected static ImmutableArray<CodeAction> GetNestedActions(ImmutableArray<Code ...@@ -688,82 +688,43 @@ protected static ImmutableArray<CodeAction> GetNestedActions(ImmutableArray<Code
internal (OptionKey2, object) SingleOption<T>(Option2<T> option, T enabled) internal (OptionKey2, object) SingleOption<T>(Option2<T> option, T enabled)
=> (new OptionKey2(option), enabled); => (new OptionKey2(option), enabled);
internal (OptionKey2, object) SingleOption<T>(Option<T> option, T enabled)
=> (new OptionKey2(option), enabled);
internal (OptionKey2, object) SingleOption<T>(PerLanguageOption2<T> option, T value) internal (OptionKey2, object) SingleOption<T>(PerLanguageOption2<T> option, T value)
=> (new OptionKey2(option, this.GetLanguage()), value); => (new OptionKey2(option, this.GetLanguage()), value);
internal (OptionKey2, object) SingleOption<T>(PerLanguageOption<T> option, T value) internal (OptionKey2, object) SingleOption<T>(Option2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification)
=> (new OptionKey2(option, this.GetLanguage()), value);
private protected (OptionKey2, object) SingleOption<T>(Option2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification)
=> (new OptionKey2(option), new CodeStyleOption2<T>(enabled, notification)); => (new OptionKey2(option), new CodeStyleOption2<T>(enabled, notification));
private protected (OptionKey2, object) SingleOption<T>(Option<CodeStyleOption<T>> option, T enabled, NotificationOption notification) internal (OptionKey2, object) SingleOption<T>(Option2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle)
=> (new OptionKey2(option), new CodeStyleOption2<T>(enabled, (NotificationOption2)notification));
private protected (OptionKey2, object) SingleOption<T>(Option2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle)
=> (new OptionKey2(option), codeStyle);
private protected (OptionKey2, object) SingleOption<T>(Option<CodeStyleOption<T>> option, CodeStyleOption<T> codeStyle)
=> (new OptionKey2(option), codeStyle); => (new OptionKey2(option), codeStyle);
private protected (OptionKey2, object) SingleOption<T>(PerLanguageOption2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification) internal (OptionKey2, object) SingleOption<T>(PerLanguageOption2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification)
=> (new OptionKey2(option, this.GetLanguage()), new CodeStyleOption2<T>(enabled, notification)); => (new OptionKey2(option, this.GetLanguage()), new CodeStyleOption2<T>(enabled, notification));
private protected (OptionKey2, object) SingleOption<T>(PerLanguageOption<CodeStyleOption<T>> option, T enabled, NotificationOption notification) internal (OptionKey2, object) SingleOption<T>(PerLanguageOption2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle)
=> (new OptionKey2(option, this.GetLanguage()), new CodeStyleOption2<T>(enabled, (NotificationOption2)notification));
private protected (OptionKey2, object) SingleOption<T>(PerLanguageOption2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle)
=> (new OptionKey2(option, this.GetLanguage()), codeStyle);
private protected (OptionKey2, object) SingleOption<T>(PerLanguageOption<CodeStyleOption<T>> option, CodeStyleOption<T> codeStyle)
=> (new OptionKey2(option, this.GetLanguage()), codeStyle); => (new OptionKey2(option, this.GetLanguage()), codeStyle);
private protected static (OptionKey2, object) SingleOption<T>(PerLanguageOption2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle, string language) internal static (OptionKey2, object) SingleOption<T>(PerLanguageOption2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle, string language)
=> (new OptionKey2(option, language), codeStyle);
private protected static (OptionKey2, object) SingleOption<T>(PerLanguageOption<CodeStyleOption<T>> option, CodeStyleOption<T> codeStyle, string language)
=> (new OptionKey2(option, language), codeStyle); => (new OptionKey2(option, language), codeStyle);
private protected IOptionsCollection Option<T>(Option2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification) internal IOptionsCollection Option<T>(Option2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification)
=> OptionsSet(SingleOption(option, enabled, notification)); => OptionsSet(SingleOption(option, enabled, notification));
private protected IOptionsCollection Option<T>(Option<CodeStyleOption<T>> option, T enabled, NotificationOption notification) internal IOptionsCollection Option<T>(Option2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle)
=> OptionsSet(SingleOption(option, enabled, notification));
private protected IOptionsCollection Option<T>(Option2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle)
=> OptionsSet(SingleOption(option, codeStyle));
private protected IOptionsCollection Option<T>(Option<CodeStyleOption<T>> option, CodeStyleOption<T> codeStyle)
=> OptionsSet(SingleOption(option, codeStyle)); => OptionsSet(SingleOption(option, codeStyle));
private protected IOptionsCollection Option<T>(PerLanguageOption2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification) internal IOptionsCollection Option<T>(PerLanguageOption2<CodeStyleOption2<T>> option, T enabled, NotificationOption2 notification)
=> OptionsSet(SingleOption(option, enabled, notification));
private protected IOptionsCollection Option<T>(PerLanguageOption<CodeStyleOption<T>> option, T enabled, NotificationOption notification)
=> OptionsSet(SingleOption(option, enabled, notification)); => OptionsSet(SingleOption(option, enabled, notification));
private protected IOptionsCollection Option<T>(Option2<T> option, T value) internal IOptionsCollection Option<T>(Option2<T> option, T value)
=> OptionsSet(SingleOption(option, value)); => OptionsSet(SingleOption(option, value));
private protected IOptionsCollection Option<T>(Option<T> option, T value) internal IOptionsCollection Option<T>(PerLanguageOption2<T> option, T value)
=> OptionsSet(SingleOption(option, value)); => OptionsSet(SingleOption(option, value));
private protected IOptionsCollection Option<T>(PerLanguageOption2<T> option, T value) internal IOptionsCollection Option<T>(PerLanguageOption2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle)
=> OptionsSet(SingleOption(option, value));
private protected IOptionsCollection Option<T>(PerLanguageOption<T> option, T value)
=> OptionsSet(SingleOption(option, value));
private protected IOptionsCollection Option<T>(PerLanguageOption2<CodeStyleOption2<T>> option, CodeStyleOption2<T> codeStyle)
=> OptionsSet(SingleOption(option, codeStyle));
private protected IOptionsCollection Option<T>(PerLanguageOption<CodeStyleOption<T>> option, CodeStyleOption<T> codeStyle)
=> OptionsSet(SingleOption(option, codeStyle)); => OptionsSet(SingleOption(option, codeStyle));
private protected IOptionsCollection OptionsSet(OptionKey2 option, object value) internal IOptionsCollection OptionsSet(OptionKey2 option, object value)
=> OptionsSet((option, value)); => OptionsSet((option, value));
#if CODE_STYLE #if CODE_STYLE
......
...@@ -37,10 +37,10 @@ public Test() ...@@ -37,10 +37,10 @@ public Test()
SolutionTransforms.Add((solution, projectId) => SolutionTransforms.Add((solution, projectId) =>
{ {
var parseOptions = (CSharpParseOptions)solution.GetProject(projectId)?.ParseOptions!; var parseOptions = (CSharpParseOptions)solution.GetProject(projectId)!.ParseOptions!;
solution = solution.WithProjectParseOptions(projectId, parseOptions.WithLanguageVersion(LanguageVersion)); solution = solution.WithProjectParseOptions(projectId, parseOptions.WithLanguageVersion(LanguageVersion));
var compilationOptions = solution.GetProject(projectId)?.CompilationOptions!; var compilationOptions = solution.GetProject(projectId)!.CompilationOptions!;
compilationOptions = compilationOptions.WithSpecificDiagnosticOptions(compilationOptions.SpecificDiagnosticOptions.SetItems(s_nullableWarnings)); compilationOptions = compilationOptions.WithSpecificDiagnosticOptions(compilationOptions.SpecificDiagnosticOptions.SetItems(s_nullableWarnings));
solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); solution = solution.WithProjectCompilationOptions(projectId, compilationOptions);
......
...@@ -27,7 +27,7 @@ public Test() ...@@ -27,7 +27,7 @@ public Test()
SolutionTransforms.Add((solution, projectId) => SolutionTransforms.Add((solution, projectId) =>
{ {
var parseOptions = (VisualBasicParseOptions)solution.GetProject(projectId)?.ParseOptions!; var parseOptions = (VisualBasicParseOptions)solution.GetProject(projectId)!.ParseOptions!;
solution = solution.WithProjectParseOptions(projectId, parseOptions.WithLanguageVersion(LanguageVersion)); solution = solution.WithProjectParseOptions(projectId, parseOptions.WithLanguageVersion(LanguageVersion));
var (analyzerConfigSource, remainingOptions) = CodeFixVerifierHelper.ConvertOptionsToAnalyzerConfig(DefaultFileExt, EditorConfig, Options); var (analyzerConfigSource, remainingOptions) = CodeFixVerifierHelper.ConvertOptionsToAnalyzerConfig(DefaultFileExt, EditorConfig, Options);
......
...@@ -50,61 +50,60 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics ...@@ -50,61 +50,60 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics
Return LanguageNames.VisualBasic Return LanguageNames.VisualBasic
End Function End Function
#Disable Warning BC40003 ' Member shadows an overloadable member declared in the base type
#If CODE_STYLE Then #If CODE_STYLE Then
Friend Function SingleOption(Of T)(optionParam As Option2(Of T), enabled As T) As (OptionKey2, Object) Friend Shadows Function SingleOption(Of T)(optionParam As Option2(Of T), enabled As T) As (OptionKey2, Object)
Return (New OptionKey2(optionParam), enabled) Return (New OptionKey2(optionParam), enabled)
End Function End Function
Private Protected Function SingleOption(Of T)(optionParam As PerLanguageOption2(Of T), value As T) As (OptionKey2, Object) Friend Shadows Function SingleOption(Of T)(optionParam As PerLanguageOption2(Of T), value As T) As (OptionKey2, Object)
Return (New OptionKey2(optionParam, Me.GetLanguage()), value) Return (New OptionKey2(optionParam, Me.GetLanguage()), value)
End Function End Function
Private Protected Function SingleOption(Of T)(optionParam As Option2(Of CodeStyleOption2(Of T)), enabled As T, notification As NotificationOption2) As (OptionKey2, Object) Friend Shadows Function SingleOption(Of T)(optionParam As Option2(Of CodeStyleOption2(Of T)), enabled As T, notification As NotificationOption2) As (OptionKey2, Object)
Return SingleOption(optionParam, New CodeStyleOption2(Of T)(enabled, notification)) Return SingleOption(optionParam, New CodeStyleOption2(Of T)(enabled, notification))
End Function End Function
Private Protected Function SingleOption(Of T)(optionParam As Option2(Of CodeStyleOption2(Of T)), codeStyle As CodeStyleOption2(Of T)) As (OptionKey2, Object) Friend Shadows Function SingleOption(Of T)(optionParam As Option2(Of CodeStyleOption2(Of T)), codeStyle As CodeStyleOption2(Of T)) As (OptionKey2, Object)
Return (New OptionKey2(optionParam), codeStyle) Return (New OptionKey2(optionParam), codeStyle)
End Function End Function
Private Protected Function SingleOption(Of T)(optionParam As PerLanguageOption2(Of CodeStyleOption2(Of T)), enabled As T, notification As NotificationOption2) As (OptionKey2, Object) Friend Shadows Function SingleOption(Of T)(optionParam As PerLanguageOption2(Of CodeStyleOption2(Of T)), enabled As T, notification As NotificationOption2) As (OptionKey2, Object)
Return SingleOption(optionParam, New CodeStyleOption2(Of T)(enabled, notification)) Return SingleOption(optionParam, New CodeStyleOption2(Of T)(enabled, notification))
End Function End Function
Private Protected Function SingleOption(Of T)(optionParam As PerLanguageOption2(Of CodeStyleOption2(Of T)), codeStyle As CodeStyleOption2(Of T)) As (OptionKey2, Object) Friend Shadows Function SingleOption(Of T)(optionParam As PerLanguageOption2(Of CodeStyleOption2(Of T)), codeStyle As CodeStyleOption2(Of T)) As (OptionKey2, Object)
Return SingleOption(optionParam, codeStyle, language:=GetLanguage()) Return SingleOption(optionParam, codeStyle, language:=GetLanguage())
End Function End Function
Private Protected Shared Function SingleOption(Of T)(optionParam As PerLanguageOption2(Of CodeStyleOption2(Of T)), codeStyle As CodeStyleOption2(Of T), language As String) As (OptionKey2, Object) Friend Shadows Function SingleOption(Of T)(optionParam As PerLanguageOption2(Of CodeStyleOption2(Of T)), codeStyle As CodeStyleOption2(Of T), language As String) As (OptionKey2, Object)
Return (New OptionKey2(optionParam, language), codeStyle) Return (New OptionKey2(optionParam, language), codeStyle)
End Function End Function
Private Protected Function [Option](Of T)(optionParam As Option2(Of CodeStyleOption2(Of T)), enabled As T, notification As NotificationOption2) As IOptionsCollection Friend Shadows Function [Option](Of T)(optionParam As Option2(Of CodeStyleOption2(Of T)), enabled As T, notification As NotificationOption2) As IOptionsCollection
Return OptionsSet(SingleOption(optionParam, enabled, notification)) Return OptionsSet(SingleOption(optionParam, enabled, notification))
End Function End Function
Private Protected Function [Option](Of T)(optionParam As Option2(Of CodeStyleOption2(Of T)), codeStyle As CodeStyleOption2(Of T)) As IOptionsCollection Friend Shadows Function [Option](Of T)(optionParam As Option2(Of CodeStyleOption2(Of T)), codeStyle As CodeStyleOption2(Of T)) As IOptionsCollection
Return OptionsSet(SingleOption(optionParam, codeStyle)) Return OptionsSet(SingleOption(optionParam, codeStyle))
End Function End Function
Private Protected Function [Option](Of T)(optionParam As PerLanguageOption2(Of CodeStyleOption2(Of T)), enabled As T, notification As NotificationOption2) As IOptionsCollection Friend Shadows Function [Option](Of T)(optionParam As PerLanguageOption2(Of CodeStyleOption2(Of T)), enabled As T, notification As NotificationOption2) As IOptionsCollection
Return OptionsSet(SingleOption(optionParam, enabled, notification)) Return OptionsSet(SingleOption(optionParam, enabled, notification))
End Function End Function
Private Protected Function [Option](Of T)(optionParam As PerLanguageOption2(Of CodeStyleOption2(Of T)), codeStyle As CodeStyleOption2(Of T)) As IOptionsCollection Friend Shadows Function [Option](Of T)(optionParam As PerLanguageOption2(Of CodeStyleOption2(Of T)), codeStyle As CodeStyleOption2(Of T)) As IOptionsCollection
Return OptionsSet(SingleOption(optionParam, codeStyle)) Return OptionsSet(SingleOption(optionParam, codeStyle))
End Function End Function
Private Protected Function [Option](Of T)(optionParam As Option2(Of T), value As T) As IOptionsCollection Friend Shadows Function [Option](Of T)(optionParam As Option2(Of T), value As T) As IOptionsCollection
Return OptionsSet(SingleOption(optionParam, value)) Return OptionsSet(SingleOption(optionParam, value))
End Function End Function
Private Protected Function [Option](Of T)(optionParam As PerLanguageOption2(Of T), value As T) As IOptionsCollection Friend Shadows Function [Option](Of T)(optionParam As PerLanguageOption2(Of T), value As T) As IOptionsCollection
Return OptionsSet(SingleOption(optionParam, value)) Return OptionsSet(SingleOption(optionParam, value))
End Function End Function
Friend Shared Function OptionsSet(ParamArray options As (OptionKey2, Object)()) As IOptionsCollection Friend Shared Shadows Function OptionsSet(ParamArray options As (OptionKey2, Object)()) As IOptionsCollection
Return New OptionsCollection(LanguageNames.VisualBasic, options) Return New OptionsCollection(LanguageNames.VisualBasic, options)
End Function End Function
#End If #End If
......
...@@ -21,10 +21,6 @@ ...@@ -21,10 +21,6 @@
using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities; using Roslyn.Utilities;
#if !CODE_STYLE
using OptionSet = Microsoft.CodeAnalysis.Options.OptionSet;
#endif
namespace Microsoft.CodeAnalysis.Diagnostics namespace Microsoft.CodeAnalysis.Diagnostics
{ {
internal static partial class AnalyzerHelper internal static partial class AnalyzerHelper
......
...@@ -95,7 +95,6 @@ public bool NeedsReanalysisOnOptionChanged(object sender, OptionChangedEventArgs ...@@ -95,7 +95,6 @@ public bool NeedsReanalysisOnOptionChanged(object sender, OptionChangedEventArgs
{ {
return e.Option.Feature == nameof(SimplificationOptions) || return e.Option.Feature == nameof(SimplificationOptions) ||
e.Option.Feature == nameof(CodeStyleOptions) || e.Option.Feature == nameof(CodeStyleOptions) ||
e.Option.Feature == nameof(CodeStyleOptions2) ||
e.Option == SolutionCrawlerOptions.BackgroundAnalysisScopeOption || e.Option == SolutionCrawlerOptions.BackgroundAnalysisScopeOption ||
#pragma warning disable CS0618 // Type or member is obsolete - TypeScript and F# are still on the older ClosedFileDiagnostic option. #pragma warning disable CS0618 // Type or member is obsolete - TypeScript and F# are still on the older ClosedFileDiagnostic option.
e.Option == ServiceFeatureOnOffOptions.ClosedFileDiagnostic; e.Option == ServiceFeatureOnOffOptions.ClosedFileDiagnostic;
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
using Microsoft.CodeAnalysis.CodeStyle; using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Options;
using OptionSet = Microsoft.CodeAnalysis.Options.OptionSet;
namespace Microsoft.CodeAnalysis.PreferFrameworkType namespace Microsoft.CodeAnalysis.PreferFrameworkType
{ {
......
<Project> <Project>
<Import Project="..\..\Directory.Build.targets"/> <Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />
<ItemGroup Condition="'$(IsShipping)' == 'true'"> <ItemGroup>
<AdditionalFiles Include="$(MSBuildThisFileDirectory)\BannedSymbols.txt" /> <AdditionalFiles Include="$(MSBuildThisFileDirectory)\BannedSymbols.txt" />
</ItemGroup> </ItemGroup>
</Project> </Project>
\ No newline at end of file
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
namespace Microsoft.CodeAnalysis.CSharp.Formatting namespace Microsoft.CodeAnalysis.CSharp.Formatting
{ {
/// <inheritdoc cref="CSharpFormattingOptions"/> /// <inheritdoc cref="CSharpFormattingOptions"/>
public static partial class CSharpFormattingOptions public static class CSharpFormattingOptions
{ {
/// <inheritdoc cref="CSharpFormattingOptions2.SpacingAfterMethodDeclarationName"/> /// <inheritdoc cref="CSharpFormattingOptions2.SpacingAfterMethodDeclarationName"/>
public static Option<bool> SpacingAfterMethodDeclarationName { get; } = (Option<bool>)CSharpFormattingOptions2.SpacingAfterMethodDeclarationName; public static Option<bool> SpacingAfterMethodDeclarationName { get; } = (Option<bool>)CSharpFormattingOptions2.SpacingAfterMethodDeclarationName;
......
...@@ -19,8 +19,7 @@ internal CodeStyleOption(CodeStyleOption2<T> codeStyleOptionImpl) ...@@ -19,8 +19,7 @@ internal CodeStyleOption(CodeStyleOption2<T> codeStyleOptionImpl)
} }
public CodeStyleOption(T value, NotificationOption notification) public CodeStyleOption(T value, NotificationOption notification)
: this(new CodeStyleOption2<T>(value, : this(new CodeStyleOption2<T>(value, (NotificationOption2)notification))
(NotificationOption2)(notification ?? throw new ArgumentNullException(nameof(notification)))))
{ {
} }
......
...@@ -4,11 +4,12 @@ ...@@ -4,11 +4,12 @@
#nullable enable #nullable enable
using System;
using Roslyn.Utilities; using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CodeStyle namespace Microsoft.CodeAnalysis.CodeStyle
{ {
internal partial class NotificationOption2 internal sealed partial class NotificationOption2 : IEquatable<NotificationOption2?>
{ {
public static explicit operator NotificationOption2?(NotificationOption? notificationOption) public static explicit operator NotificationOption2?(NotificationOption? notificationOption)
{ {
...@@ -48,12 +49,7 @@ internal partial class NotificationOption2 ...@@ -48,12 +49,7 @@ internal partial class NotificationOption2
public override bool Equals(object? obj) public override bool Equals(object? obj)
{ {
if (obj is NotificationOption2 notificationOption2) return ReferenceEquals(this, obj);
{
return this.Equals(notificationOption2);
}
return false;
} }
public bool Equals(NotificationOption2? notificationOption2) public bool Equals(NotificationOption2? notificationOption2)
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
namespace Microsoft.CodeAnalysis.CodeStyle namespace Microsoft.CodeAnalysis.CodeStyle
{ {
internal class CodeStyleOptions2 internal static class CodeStyleOptions2
{ {
private static readonly ImmutableArray<IOption2>.Builder s_allOptionsBuilder = ImmutableArray.CreateBuilder<IOption2>(); private static readonly ImmutableArray<IOption2>.Builder s_allOptionsBuilder = ImmutableArray.CreateBuilder<IOption2>();
...@@ -20,7 +20,7 @@ internal class CodeStyleOptions2 ...@@ -20,7 +20,7 @@ internal class CodeStyleOptions2
private static PerLanguageOption2<T> CreateOption<T>(OptionGroup group, string name, T defaultValue, params OptionStorageLocation2[] storageLocations) private static PerLanguageOption2<T> CreateOption<T>(OptionGroup group, string name, T defaultValue, params OptionStorageLocation2[] storageLocations)
{ {
var option = new PerLanguageOption2<T>("CodeStyleOption", group, name, defaultValue, storageLocations); var option = new PerLanguageOption2<T>("CodeStyleOptions", group, name, defaultValue, storageLocations);
s_allOptionsBuilder.Add(option); s_allOptionsBuilder.Add(option);
return option; return option;
} }
......
...@@ -18,7 +18,7 @@ namespace Microsoft.CodeAnalysis.CodeStyle ...@@ -18,7 +18,7 @@ namespace Microsoft.CodeAnalysis.CodeStyle
/// This also supports various properties for databinding. /// This also supports various properties for databinding.
/// </remarks> /// </remarks>
/// <completionlist cref="NotificationOption2"/> /// <completionlist cref="NotificationOption2"/>
internal partial class NotificationOption2 internal sealed partial class NotificationOption2
{ {
/// <summary> /// <summary>
/// Name for the notification option. /// Name for the notification option.
......
...@@ -26,19 +26,19 @@ public static T GetOption<T>(this AnalyzerConfigOptions analyzerConfigOptions, P ...@@ -26,19 +26,19 @@ public static T GetOption<T>(this AnalyzerConfigOptions analyzerConfigOptions, P
} }
#else #else
public static T GetOption<T>(this AnalyzerConfigOptions analyzerConfigOptions, Options.Option<T> option) public static T GetOption<T>(this AnalyzerConfigOptions analyzerConfigOptions, Options.Option<T> option)
=> analyzerConfigOptions.GetOptionWithAssertOnFailure<T>(option); => GetOptionWithAssertOnFailure<T>(analyzerConfigOptions, option);
public static T GetOption<T>(this AnalyzerConfigOptions analyzerConfigOptions, Options.PerLanguageOption<T> option) public static T GetOption<T>(this AnalyzerConfigOptions analyzerConfigOptions, Options.PerLanguageOption<T> option)
=> analyzerConfigOptions.GetOptionWithAssertOnFailure<T>(option); => GetOptionWithAssertOnFailure<T>(analyzerConfigOptions, option);
#endif #endif
public static T GetOption<T>(this AnalyzerConfigOptions analyzerConfigOptions, Option2<T> option) public static T GetOption<T>(this AnalyzerConfigOptions analyzerConfigOptions, Option2<T> option)
=> analyzerConfigOptions.GetOptionWithAssertOnFailure<T>(option); => GetOptionWithAssertOnFailure<T>(analyzerConfigOptions, option);
public static T GetOption<T>(this AnalyzerConfigOptions analyzerConfigOptions, PerLanguageOption2<T> option) public static T GetOption<T>(this AnalyzerConfigOptions analyzerConfigOptions, PerLanguageOption2<T> option)
=> analyzerConfigOptions.GetOptionWithAssertOnFailure<T>(option); => GetOptionWithAssertOnFailure<T>(analyzerConfigOptions, option);
private static T GetOptionWithAssertOnFailure<T>(this AnalyzerConfigOptions analyzerConfigOptions, TOption option) private static T GetOptionWithAssertOnFailure<T>(AnalyzerConfigOptions analyzerConfigOptions, TOption option)
{ {
if (!TryGetEditorConfigOptionOrDefault(analyzerConfigOptions, option, out T value)) if (!TryGetEditorConfigOptionOrDefault(analyzerConfigOptions, option, out T value))
{ {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
namespace Microsoft.CodeAnalysis.Formatting namespace Microsoft.CodeAnalysis.Formatting
{ {
internal static partial class FormattingOptions2 internal static class FormattingOptions2
{ {
private static readonly ImmutableArray<IOption2>.Builder s_allOptionsBuilder = ImmutableArray.CreateBuilder<IOption2>(); private static readonly ImmutableArray<IOption2>.Builder s_allOptionsBuilder = ImmutableArray.CreateBuilder<IOption2>();
......
...@@ -13,8 +13,6 @@ ...@@ -13,8 +13,6 @@
#if CODE_STYLE #if CODE_STYLE
using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions;
#else
using OptionSet = Microsoft.CodeAnalysis.Options.OptionSet;
#endif #endif
namespace Microsoft.CodeAnalysis.Options namespace Microsoft.CodeAnalysis.Options
......
...@@ -51,13 +51,6 @@ internal partial class Option2<T> : ILanguageSpecificOption<T> ...@@ -51,13 +51,6 @@ internal partial class Option2<T> : ILanguageSpecificOption<T>
/// </summary> /// </summary>
public ImmutableArray<OptionStorageLocation2> StorageLocations { get; } public ImmutableArray<OptionStorageLocation2> StorageLocations { get; }
[Obsolete("Use a constructor that specifies an explicit default value.")]
public Option2(string feature, string name)
: this(feature, name, default!)
{
// This constructor forwards to the next one; it exists to maintain source-level compatibility with older callers.
}
public Option2(string feature, string name, T defaultValue) public Option2(string feature, string name, T defaultValue)
: this(feature, name, defaultValue, storageLocations: Array.Empty<OptionStorageLocation2>()) : this(feature, name, defaultValue, storageLocations: Array.Empty<OptionStorageLocation2>())
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册