Skip to content

Commit

Permalink
Properly disable SA1646 (IncludedDocumentationXPathDoesNotExist)
Browse files Browse the repository at this point in the history
  • Loading branch information
sharwell committed Aug 15, 2015
1 parent 6cd5381 commit e71f7b9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace StyleCop.Analyzers.Test.DocumentationRules
{
using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using StyleCop.Analyzers.DocumentationRules;
using TestHelper;
using Xunit;

/// <summary>
/// This class contains unit tests for <see cref="SA1646IncludedDocumentationXPathDoesNotExist"/>.
/// </summary>
public class SA1646UnitTests : DiagnosticVerifier
{
[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 SA1646IncludedDocumentationXPathDoesNotExist();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
<Compile Include="DocumentationRules\SA1642UnitTests.cs" />
<Compile Include="DocumentationRules\SA1643UnitTests.cs" />
<Compile Include="DocumentationRules\SA1645UnitTests.cs" />
<Compile Include="DocumentationRules\SA1646UnitTests.cs" />
<Compile Include="DocumentationRules\SA1648UnitTests.cs" />
<Compile Include="DocumentationRules\SA1650UnitTests.cs" />
<Compile Include="DocumentationRules\SA1651UnitTests.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
/// documentation file.</para>
/// </remarks>
[DiagnosticAnalyzer(LanguageNames.CSharp)]
[NoDiagnostic("This is already handled by the compiler with warning CS1589.")]
[NoCodeFix("Cannot generate documentation")]
public class SA1646IncludedDocumentationXPathDoesNotExist : DiagnosticAnalyzer
{
Expand All @@ -43,7 +44,7 @@ public class SA1646IncludedDocumentationXPathDoesNotExist : DiagnosticAnalyzer
private const string HelpLink = "http://www.stylecop.com/docs/SA1646.html";

private static readonly DiagnosticDescriptor Descriptor =
new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledNoTests, Description, HelpLink);
new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.NotConfigurable);

private static readonly ImmutableArray<DiagnosticDescriptor> SupportedDiagnosticsValue =
ImmutableArray.Create(Descriptor);
Expand All @@ -60,7 +61,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 e71f7b9

Please sign in to comment.