@@ -162,6 +162,42 @@ public partial class Foo
162162 await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
163163 }
164164
165+ /// <summary>
166+ /// Verifies that all 5 access modifiers are accepted for nested types.
167+ /// This is a regression test for issue #2040.
168+ /// </summary>
169+ /// <param name="accessModifier">The access modifier to use for the nested type.</param>
170+ /// <param name="typeKeyword">The type keyword to use.</param>
171+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
172+ [ Theory ]
173+ [ InlineData ( "public" , "class" ) ]
174+ [ InlineData ( "protected" , "class" ) ]
175+ [ InlineData ( "internal" , "class" ) ]
176+ [ InlineData ( "protected internal" , "class" ) ]
177+ [ InlineData ( "private" , "class" ) ]
178+ [ InlineData ( "public" , "struct" ) ]
179+ [ InlineData ( "protected" , "struct" ) ]
180+ [ InlineData ( "internal" , "struct" ) ]
181+ [ InlineData ( "protected internal" , "struct" ) ]
182+ [ InlineData ( "private" , "struct" ) ]
183+ public async Task TestNestedTypeAccessModifiersAsync ( string accessModifier , string typeKeyword )
184+ {
185+ var testCode = $@ "
186+ internal static partial class TestPartial
187+ {{
188+ { accessModifier } partial { typeKeyword } PartialInner
189+ {{
190+ public int Do()
191+ {{
192+ return 2;
193+ }}
194+ }}
195+ }}
196+ " ;
197+
198+ await this . VerifyCSharpDiagnosticAsync ( testCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
199+ }
200+
165201 /// <inheritdoc/>
166202 protected override IEnumerable < DiagnosticAnalyzer > GetCSharpDiagnosticAnalyzers ( )
167203 {
0 commit comments