Skip to content

Commit e182acd

Browse files
committed
Move all the shared layer analyzers to use the new options and code style types - this cleans up the #if CODE_STYLE mess from our shared layer analyzers.
1 parent e96fd8f commit e182acd

File tree

4 files changed

+10
-24
lines changed

4 files changed

+10
-24
lines changed

src/Analyzers/CSharp/Analyzers/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionDiagnosticAnalyzer.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,11 @@
66
using System.Globalization;
77
using System.Linq;
88
using Microsoft.CodeAnalysis.CodeStyle;
9+
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
910
using Microsoft.CodeAnalysis.CSharp.Syntax;
1011
using Microsoft.CodeAnalysis.Diagnostics;
1112
using Microsoft.CodeAnalysis.PooledObjects;
1213

13-
#if CODE_STYLE
14-
using Microsoft.CodeAnalysis.CSharp.Internal.CodeStyle;
15-
#else
16-
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
17-
#endif
18-
1914
namespace Microsoft.CodeAnalysis.CSharp.ConvertSwitchStatementToExpression
2015
{
2116
using Constants = ConvertSwitchStatementToExpressionConstants;

src/Analyzers/CSharp/Analyzers/UseImplicitOrExplicitType/CSharpTypeStyleDiagnosticAnalyzerBase.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@
44

55
using System.Collections.Immutable;
66
using Microsoft.CodeAnalysis.CodeStyle;
7+
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
78
using Microsoft.CodeAnalysis.CSharp.Extensions;
89
using Microsoft.CodeAnalysis.CSharp.Utilities;
910
using Microsoft.CodeAnalysis.Diagnostics;
11+
using Microsoft.CodeAnalysis.Options;
1012
using Microsoft.CodeAnalysis.Text;
1113

1214
#if CODE_STYLE
1315
using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions;
14-
using Microsoft.CodeAnalysis.CSharp.Internal.CodeStyle;
15-
using Microsoft.CodeAnalysis.Internal.Options;
1616
#else
17-
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
18-
using Microsoft.CodeAnalysis.Options;
17+
using OptionSet = Microsoft.CodeAnalysis.Options.OptionSet;
1918
#endif
2019

2120
namespace Microsoft.CodeAnalysis.CSharp.Diagnostics.TypeStyle
@@ -42,9 +41,9 @@ public override bool OpenFileOnly(OptionSet options)
4241
var whereApparentOption = options.GetOption(CSharpCodeStyleOptions.VarWhenTypeIsApparent).Notification;
4342
var wherePossibleOption = options.GetOption(CSharpCodeStyleOptions.VarElsewhere).Notification;
4443

45-
return !(forIntrinsicTypesOption == NotificationOption.Warning || forIntrinsicTypesOption == NotificationOption.Error ||
46-
whereApparentOption == NotificationOption.Warning || whereApparentOption == NotificationOption.Error ||
47-
wherePossibleOption == NotificationOption.Warning || wherePossibleOption == NotificationOption.Error);
44+
return !(forIntrinsicTypesOption == NotificationOption2.Warning || forIntrinsicTypesOption == NotificationOption2.Error ||
45+
whereApparentOption == NotificationOption2.Warning || whereApparentOption == NotificationOption2.Error ||
46+
wherePossibleOption == NotificationOption2.Warning || wherePossibleOption == NotificationOption2.Error);
4847
}
4948

5049
protected override void InitializeWorker(AnalysisContext context)

src/Analyzers/Core/Analyzers/FileHeaders/AbstractFileHeaderDiagnosticAnalyzer.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,14 @@
99
using Microsoft.CodeAnalysis.Diagnostics;
1010
using Roslyn.Utilities;
1111

12-
#if CODE_STYLE
13-
using Microsoft.CodeAnalysis.Internal.Options;
14-
#endif
15-
1612
namespace Microsoft.CodeAnalysis.FileHeaders
1713
{
1814
internal abstract class AbstractFileHeaderDiagnosticAnalyzer : AbstractBuiltInCodeStyleDiagnosticAnalyzer
1915
{
2016
protected AbstractFileHeaderDiagnosticAnalyzer(string language)
2117
: base(
2218
IDEDiagnosticIds.FileHeaderMismatch,
23-
CodeStyleOptions.FileHeaderTemplate,
19+
CodeStyleOptions2.FileHeaderTemplate,
2420
language,
2521
new LocalizableResourceString(nameof(AnalyzersResources.The_file_header_is_missing_or_not_located_at_the_top_of_the_file), AnalyzersResources.ResourceManager, typeof(AnalyzersResources)),
2622
new LocalizableResourceString(nameof(AnalyzersResources.A_source_file_is_missing_a_required_header), AnalyzersResources.ResourceManager, typeof(AnalyzersResources)))
@@ -55,7 +51,7 @@ private void HandleSyntaxTree(SyntaxTreeAnalysisContext context)
5551
return;
5652
}
5753

58-
if (!context.Options.TryGetEditorConfigOption(CodeStyleOptions.FileHeaderTemplate, tree, out string fileHeaderTemplate)
54+
if (!context.Options.TryGetEditorConfigOption(CodeStyleOptions2.FileHeaderTemplate, tree, out string fileHeaderTemplate)
5955
|| string.IsNullOrEmpty(fileHeaderTemplate))
6056
{
6157
return;

src/Analyzers/Core/CodeFixes/FileHeaders/AbstractFileHeaderCodeFixProvider.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
using Microsoft.CodeAnalysis.Shared.Extensions;
2121
using Roslyn.Utilities;
2222

23-
#if CODE_STYLE
24-
using CodeStyleOptions = Microsoft.CodeAnalysis.Internal.Options.CodeStyleOptions;
25-
#endif
26-
2723
namespace Microsoft.CodeAnalysis.FileHeaders
2824
{
2925
internal abstract class AbstractFileHeaderCodeFixProvider : CodeFixProvider
@@ -62,7 +58,7 @@ private async Task<SyntaxNode> GetTransformedSyntaxRootAsync(Document document,
6258
var tree = await document.GetRequiredSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
6359
var root = await tree.GetRootAsync(cancellationToken).ConfigureAwait(false);
6460

65-
if (!document.Project.AnalyzerOptions.TryGetEditorConfigOption(CodeStyleOptions.FileHeaderTemplate, tree, out string fileHeaderTemplate)
61+
if (!document.Project.AnalyzerOptions.TryGetEditorConfigOption(CodeStyleOptions2.FileHeaderTemplate, tree, out string fileHeaderTemplate)
6662
|| string.IsNullOrEmpty(fileHeaderTemplate))
6763
{
6864
// This exception would show up as a gold bar, but as indicated we do not believe this is reachable.

0 commit comments

Comments
 (0)