diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1649UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1649UnitTests.cs
index aac0f6167..ae3405ecb 100644
--- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1649UnitTests.cs
+++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1649UnitTests.cs
@@ -116,6 +116,38 @@ public async Task VerifyWrongFileNameMultipleExtensionsAsync(string typeKeyword)
await this.VerifyRenameAsync(testCode, "WrongFileName.svc.cs", "TestType.svc.cs", CancellationToken.None).ConfigureAwait(false);
}
+ ///
+ /// Verifies that a wrong file name with no extension is correctly reported and fixed. This is a regression test
+ /// for DotNetAnalyzers/StyleCopAnalyzers#1829.
+ ///
+ /// The type keyword to use during the test.
+ /// A representing the asynchronous unit test.
+ [Theory]
+ [MemberData(nameof(TypeKeywords))]
+ public async Task VerifyWrongFileNameNoExtensionAsync(string typeKeyword)
+ {
+ var testCode = $@"namespace TestNameSpace
+{{
+ public {typeKeyword} TestType
+ {{
+ }}
+}}
+";
+
+ var fixedCode = $@"namespace TestNamespace
+{{
+ public {typeKeyword} TestType
+ {{
+ }}
+}}
+";
+
+ var expectedDiagnostic = this.CSharpDiagnostic().WithLocation("WrongFileName", 3, 13 + typeKeyword.Length);
+ await this.VerifyCSharpDiagnosticAsync(testCode, expectedDiagnostic, CancellationToken.None, "WrongFileName").ConfigureAwait(false);
+ await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None, "TestType").ConfigureAwait(false);
+ await this.VerifyRenameAsync(testCode, "WrongFileName", "TestType", CancellationToken.None).ConfigureAwait(false);
+ }
+
///
/// Verifies that the file name is not case sensitive.
///
@@ -234,6 +266,40 @@ public async Task VerifyMetadataNamingConventionForGenericTypeAsync(string typeK
await this.VerifyRenameAsync(testCode, "TestType.cs", "TestType`3.cs", CancellationToken.None).ConfigureAwait(false);
}
+ ///
+ /// Verifies that a wrong metadata file name with multiple extensions is correctly reported and fixed. This is a
+ /// regression test for DotNetAnalyzers/StyleCopAnalyzers#1829.
+ ///
+ /// The type keyword to use during the test.
+ /// A representing the asynchronous unit test.
+ [Theory]
+ [MemberData(nameof(TypeKeywords))]
+ public async Task VerifyMetadataNamingConventionForGenericTypeMultipleExtensionsAsync(string typeKeyword)
+ {
+ this.useMetadataSettings = true;
+
+ var testCode = $@"namespace TestNameSpace
+{{
+ public {typeKeyword} TestType
+ {{
+ }}
+}}
+";
+
+ var fixedCode = $@"namespace TestNamespace
+{{
+ public {typeKeyword} TestType
+ {{
+ }}
+}}
+";
+
+ var expectedDiagnostic = this.CSharpDiagnostic().WithLocation("TestType.svc.cs", 3, 13 + typeKeyword.Length);
+ await this.VerifyCSharpDiagnosticAsync(testCode, expectedDiagnostic, CancellationToken.None, "TestType.svc.cs").ConfigureAwait(false);
+ await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None, "TestType`1.svc.cs").ConfigureAwait(false);
+ await this.VerifyRenameAsync(testCode, "TestType.svc.cs", "TestType`1.svc.cs", CancellationToken.None).ConfigureAwait(false);
+ }
+
///
/// Verifies that no diagnostic is generated if there is no first type.
///