Skip to content

Commit

Permalink
Disable SA1126 (PrefixCallsCorrectly)
Browse files Browse the repository at this point in the history
  • Loading branch information
sharwell committed Jul 18, 2015
1 parent 60d01af commit 44554d1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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;

/// <summary>
/// This class contains unit tests for <see cref="SA1126PrefixCallsCorrectly"/>.
/// </summary>
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);
}

/// <inheritdoc/>
protected override IEnumerable<DiagnosticAnalyzer> GetCSharpDiagnosticAnalyzers()
{
yield return new SA1126PrefixCallsCorrectly();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@
<Compile Include="ReadabilityRules\SA1123UnitTests.cs" />
<Compile Include="ReadabilityRules\SA1124UnitTests.cs" />
<Compile Include="ReadabilityRules\SA1125UnitTests.cs" />
<Compile Include="ReadabilityRules\SA1126UnitTests.cs" />
<Compile Include="SpacingRules\NumberSignSpacingTestBase.cs" />
<Compile Include="SpacingRules\SA1000UnitTests.cs" />
<Compile Include="SpacingRules\SA1001UnitTests.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
/// prefix to indicate the intended method call, within a C# code file.
/// </summary>
/// <remarks>
/// <para>This diagnostic is not implemented in StyleCopAnalyzers.</para>
///
/// <para>A violation of this rule occurs whenever the code contains a call to a member which is not prefixed
/// correctly.</para>
///
Expand All @@ -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<DiagnosticDescriptor> SupportedDiagnosticsValue =
ImmutableArray.Create(Descriptor);
Expand All @@ -45,7 +47,7 @@ public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
/// <inheritdoc/>
public override void Initialize(AnalysisContext context)
{
// TODO: Implement analysis
// This diagnostic is not implemented (by design) in StyleCopAnalyzers.
}
}
}

0 comments on commit 44554d1

Please sign in to comment.