File tree Expand file tree Collapse file tree
StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -149,6 +149,25 @@ public async Task VerifyThatAFieldStartingWithAnUnderscoreAndADigitIsNotAffected
149149 await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
150150 }
151151
152+ [ Fact ]
153+ public async Task VerifyThatAFieldStartingWithUnderscoreAndFollowedByKeywordTriggersDiagnosticAndIsCorrectedByCodefixAsync ( )
154+ {
155+ var testCode = @"public class Foo
156+ {
157+ private string _int = ""baz"";
158+ }" ;
159+
160+ var fixedCode = @"public class Foo
161+ {
162+ private string @int = ""baz"";
163+ }" ;
164+
165+ DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithArguments ( "_int" ) . WithLocation ( 3 , 20 ) ;
166+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
167+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
168+ await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
169+ }
170+
152171 protected override IEnumerable < DiagnosticAnalyzer > GetCSharpDiagnosticAnalyzers ( )
153172 {
154173 yield return new SA1309FieldNamesMustNotBeginWithUnderscore ( ) ;
You can’t perform that action at this time.
0 commit comments