@@ -116,6 +116,38 @@ public async Task VerifyWrongFileNameMultipleExtensionsAsync(string typeKeyword)
116116 await this . VerifyRenameAsync ( testCode , "WrongFileName.svc.cs" , "TestType.svc.cs" , CancellationToken . None ) . ConfigureAwait ( false ) ;
117117 }
118118
119+ /// <summary>
120+ /// Verifies that a wrong file name with no extension is correctly reported and fixed. This is a regression test
121+ /// for DotNetAnalyzers/StyleCopAnalyzers#1829.
122+ /// </summary>
123+ /// <param name="typeKeyword">The type keyword to use during the test.</param>
124+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
125+ [ Theory ]
126+ [ MemberData ( nameof ( TypeKeywords ) ) ]
127+ public async Task VerifyWrongFileNameNoExtensionAsync ( string typeKeyword )
128+ {
129+ var testCode = $@ "namespace TestNameSpace
130+ {{
131+ public { typeKeyword } TestType
132+ {{
133+ }}
134+ }}
135+ " ;
136+
137+ var fixedCode = $@ "namespace TestNamespace
138+ {{
139+ public { typeKeyword } TestType
140+ {{
141+ }}
142+ }}
143+ " ;
144+
145+ var expectedDiagnostic = this . CSharpDiagnostic ( ) . WithLocation ( "WrongFileName" , 3 , 13 + typeKeyword . Length ) ;
146+ await this . VerifyCSharpDiagnosticAsync ( testCode , expectedDiagnostic , CancellationToken . None , "WrongFileName" ) . ConfigureAwait ( false ) ;
147+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None , "TestType" ) . ConfigureAwait ( false ) ;
148+ await this . VerifyRenameAsync ( testCode , "WrongFileName" , "TestType" , CancellationToken . None ) . ConfigureAwait ( false ) ;
149+ }
150+
119151 /// <summary>
120152 /// Verifies that the file name is not case sensitive.
121153 /// </summary>
@@ -234,6 +266,40 @@ public async Task VerifyMetadataNamingConventionForGenericTypeAsync(string typeK
234266 await this . VerifyRenameAsync ( testCode , "TestType.cs" , "TestType`3.cs" , CancellationToken . None ) . ConfigureAwait ( false ) ;
235267 }
236268
269+ /// <summary>
270+ /// Verifies that a wrong metadata file name with multiple extensions is correctly reported and fixed. This is a
271+ /// regression test for DotNetAnalyzers/StyleCopAnalyzers#1829.
272+ /// </summary>
273+ /// <param name="typeKeyword">The type keyword to use during the test.</param>
274+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
275+ [ Theory ]
276+ [ MemberData ( nameof ( TypeKeywords ) ) ]
277+ public async Task VerifyMetadataNamingConventionForGenericTypeMultipleExtensionsAsync ( string typeKeyword )
278+ {
279+ this . useMetadataSettings = true ;
280+
281+ var testCode = $@ "namespace TestNameSpace
282+ {{
283+ public { typeKeyword } TestType<T>
284+ {{
285+ }}
286+ }}
287+ " ;
288+
289+ var fixedCode = $@ "namespace TestNamespace
290+ {{
291+ public { typeKeyword } TestType<T>
292+ {{
293+ }}
294+ }}
295+ " ;
296+
297+ var expectedDiagnostic = this . CSharpDiagnostic ( ) . WithLocation ( "TestType.svc.cs" , 3 , 13 + typeKeyword . Length ) ;
298+ await this . VerifyCSharpDiagnosticAsync ( testCode , expectedDiagnostic , CancellationToken . None , "TestType.svc.cs" ) . ConfigureAwait ( false ) ;
299+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None , "TestType`1.svc.cs" ) . ConfigureAwait ( false ) ;
300+ await this . VerifyRenameAsync ( testCode , "TestType.svc.cs" , "TestType`1.svc.cs" , CancellationToken . None ) . ConfigureAwait ( false ) ;
301+ }
302+
237303 /// <summary>
238304 /// Verifies that no diagnostic is generated if there is no first type.
239305 /// </summary>
0 commit comments