diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/InterceptorsTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/InterceptorsTests.cs index 4a30bc0e1c9f6..01413cca0f5a0 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/InterceptorsTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/InterceptorsTests.cs @@ -1663,7 +1663,7 @@ partial class C [Fact] public void ArgumentLabels() { - var source = """ + var source = (""" using System; class C @@ -1680,9 +1680,9 @@ public static void Main() c.InterceptableMethod(s2: "World", s1: "Hello "); } } - """; + """, "Program.cs"); var locations = GetInterceptableLocations(source); - var interceptors = $$""" + var interceptors = ($$""" using System.Runtime.CompilerServices; using System; @@ -1691,7 +1691,7 @@ static class D [InterceptsLocation({{GetAttributeArgs(locations[1]!)}})] public static void Interceptor1(this C c, string s1, string s2) { Console.Write("interceptor " + s1 + s2); } } - """; + """, "Interceptors.cs"); var verifier = CompileAndVerify([source, interceptors, s_attributesSource], parseOptions: RegularWithInterceptors, expectedOutput: "interceptor Hello World"); verifier.VerifyDiagnostics(); } @@ -3965,7 +3965,7 @@ static class D public void SignatureMismatch_08() { // nint/IntPtr difference - var source = """ + var source = (""" using System; class C @@ -3987,9 +3987,9 @@ public static void Main() c.Method1(default!); } } - """; + """, "Program.cs"); var locations = GetInterceptableLocations(source); - var interceptors = $$""" + var interceptors = ($$""" using System.Runtime.CompilerServices; using System; @@ -4003,25 +4003,7 @@ static class D [InterceptsLocation({{GetAttributeArgs(locations[3]!)}})] public static void Interceptor2(this C s, nint param2) => Console.Write(2); } - """; - - // TODO2: 'InterceptableLocation' is not finding the correct call with this specific set of inputs. change ANYTHING about the content of 'source' and expected errors will be reported. - // It doesn't appear to be a hash collision issue, unsure yet what it really is. - - var comp = CreateCompilation([source, interceptors, s_attributesSource], parseOptions: RegularWithInterceptors); - comp.VerifyEmitDiagnostics( - // (6,6): warning CS9154: Intercepting a call to 'C.Method1(nint)' with interceptor 'D.Interceptor1(C, IntPtr)', but the signatures do not match. - // [InterceptsLocation(1, "7SN+G7Nd46k5We+z0k74ffUAAAA=")] // 1 - Diagnostic(ErrorCode.WRN_InterceptorSignatureMismatch, "InterceptsLocation").WithArguments("C.Method1(nint)", "D.Interceptor1(C, System.IntPtr)").WithLocation(6, 6), - // (7,6): error CS9144: Cannot intercept method 'Console.Write(int)' with interceptor 'D.Interceptor1(C, IntPtr)' because the signatures do not match. - // [InterceptsLocation(1, "7SN+G7Nd46k5We+z0k74fRMBAAA=")] - Diagnostic(ErrorCode.ERR_InterceptorSignatureMismatch, "InterceptsLocation").WithArguments("System.Console.Write(int)", "D.Interceptor1(C, System.IntPtr)").WithLocation(7, 6), - // (10,6): warning CS9154: Intercepting a call to 'C.Method2(IntPtr)' with interceptor 'D.Interceptor2(C, nint)', but the signatures do not match. - // [InterceptsLocation(1, "7SN+G7Nd46k5We+z0k74fTMBAAA=")] // 2 - Diagnostic(ErrorCode.WRN_InterceptorSignatureMismatch, "InterceptsLocation").WithArguments("C.Method2(System.IntPtr)", "D.Interceptor2(C, nint)").WithLocation(10, 6)); - - // TODO2: re-enable -#if false + """, "Interceptors.cs"); var verifier = CompileAndVerify([source, interceptors, s_attributesSource], parseOptions: RegularWithInterceptors, expectedOutput: "1122"); verifier.VerifyDiagnostics( // (6,6): warning CS9154: Intercepting a call to 'C.Method1(nint)' with interceptor 'D.Interceptor1(C, IntPtr)', but the signatures do not match. @@ -4030,7 +4012,6 @@ static class D // (10,6): warning CS9154: Intercepting a call to 'C.Method2(IntPtr)' with interceptor 'D.Interceptor2(C, nint)', but the signatures do not match. // [InterceptsLocation(1, "3ONc0QK7vNwCujpTORn5YjUBAAA=")] // 2 Diagnostic(ErrorCode.WRN_InterceptorSignatureMismatch, "InterceptsLocation").WithArguments("C.Method2(System.IntPtr)", "D.Interceptor2(C, nint)").WithLocation(10, 6)); -#endif } [Fact]