From e01cd645c5f5558106ea890a3d236cf2fe7c1358 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sat, 18 Jul 2015 14:09:30 -0500 Subject: [PATCH] Disable SA1126 (PrefixCallsCorrectly) Fixes #59 --- .../ReadabilityRules/SA1126UnitTests.cs | 40 +++++++++++++++++++ .../SA1126PrefixCallsCorrectly.cs | 6 ++- 2 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1126UnitTests.cs diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1126UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1126UnitTests.cs new file mode 100644 index 000000000..3c8e57a02 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1126UnitTests.cs @@ -0,0 +1,40 @@ +namespace StyleCop.Analyzers.Test.ReadabilityRules +{ + using System.Collections.Generic; + using System.Linq; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.Diagnostics; + using StyleCop.Analyzers.ReadabilityRules; + using TestHelper; + using Xunit; + + /// + /// This class contains unit tests for . + /// + public class SA1126UnitTests : DiagnosticVerifier + { + [Fact] + public async Task TestEmptySourceAsync() + { + var testCode = string.Empty; + await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public void TestDisabledByDefaultAndNotConfigurable() + { + var analyzer = this.GetCSharpDiagnosticAnalyzers().Single(); + Assert.Equal(1, analyzer.SupportedDiagnostics.Length); + Assert.False(analyzer.SupportedDiagnostics[0].IsEnabledByDefault); + Assert.Contains(WellKnownDiagnosticTags.NotConfigurable, analyzer.SupportedDiagnostics[0].CustomTags); + } + + /// + protected override IEnumerable GetCSharpDiagnosticAnalyzers() + { + yield return new SA1126PrefixCallsCorrectly(); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1126PrefixCallsCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1126PrefixCallsCorrectly.cs index 3674a3afd..dc5d22b2f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1126PrefixCallsCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1126PrefixCallsCorrectly.cs @@ -9,6 +9,8 @@ /// prefix to indicate the intended method call, within a C# code file. /// /// + /// This diagnostic is not implemented in StyleCopAnalyzers. + /// /// A violation of this rule occurs whenever the code contains a call to a member which is not prefixed /// correctly. /// @@ -28,7 +30,7 @@ public class SA1126PrefixCallsCorrectly : DiagnosticAnalyzer private static readonly string HelpLink = "http://www.stylecop.com/docs/SA1126.html"; private static readonly DiagnosticDescriptor Descriptor = - new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledNoTests, Description, HelpLink); + new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.NotConfigurable); private static readonly ImmutableArray SupportedDiagnosticsValue = ImmutableArray.Create(Descriptor); @@ -45,7 +47,7 @@ public override ImmutableArray SupportedDiagnostics /// public override void Initialize(AnalysisContext context) { - // TODO: Implement analysis + // This diagnostic is not implemented (by design) in StyleCopAnalyzers. } } }