diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs index caaadc4583465..78b54a2b7481e 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs @@ -3133,12 +3133,12 @@ public void RefAssignment_Foreach() void verify(string variableType, string itemType, params DiagnosticDescription[] expected) { - var source = @" + var source = $$""" class C { void M(RefEnumerable collection) { - foreach (ref VARTYPE item in collection) + foreach (ref {{variableType}} item in collection) { item.ToString(); } @@ -3149,13 +3149,14 @@ class RefEnumerable public StructEnum GetEnumerator() => throw null!; public struct StructEnum { - public ref ITEMTYPE Current => throw null!; + public ref {{itemType}} Current => throw null!; public bool MoveNext() => throw null!; } } -}"; +} +"""; - var comp = CreateCompilation(source.Replace("VARTYPE", variableType).Replace("ITEMTYPE", itemType), options: WithNullableEnable()); + var comp = CreateCompilation(source, options: WithNullableEnable()); comp.VerifyDiagnostics(expected); } }