diff --git a/src/vm/clsload.cpp b/src/vm/clsload.cpp index ff4d0a07248e..1aef6b4dfeb6 100644 --- a/src/vm/clsload.cpp +++ b/src/vm/clsload.cpp @@ -3339,8 +3339,7 @@ TypeHandle ClassLoader::CreateTypeHandleForTypeKey(TypeKey* pKey, AllocMemTracke else { // no parameterized type allowed on a reference - if (paramType.GetInternalCorElementType() == ELEMENT_TYPE_BYREF || - paramType.GetInternalCorElementType() == ELEMENT_TYPE_TYPEDBYREF) + if (paramType.GetInternalCorElementType() == ELEMENT_TYPE_BYREF) { ThrowTypeLoadException(pKey, IDS_CLASSLOAD_GENERAL); } diff --git a/tests/src/reflection/regression/github_25697/25697.cs b/tests/src/reflection/regression/github_25697/25697.cs new file mode 100644 index 000000000000..362846084997 --- /dev/null +++ b/tests/src/reflection/regression/github_25697/25697.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Reflection; + +unsafe class Program +{ + public static void AsTypedReference(ref T value, TypedReference* output) + { + *output = __makeref(value); + value = (T)(object)"Hello"; + } + + static int Main() + { + // In this test, we try to reflect on a signature of a method that takes a TypedReference*. + // This is not useful for much else than Reflection.Emit or Delegate.CreateDelegate. + // (Do not Reflection.Invoke this - the TypedReference is likely going to point to a dead + // temporary when the method returns.) + var method = typeof(Program).GetMethod(nameof(Program.AsTypedReference)); + var s = method.ToString(); + Console.WriteLine(s); + if (s != "Void AsTypedReference[T](T ByRef, TypedReference*)") + return 1; + + return 100; + } +} diff --git a/tests/src/reflection/regression/github_25697/25697.csproj b/tests/src/reflection/regression/github_25697/25697.csproj new file mode 100644 index 000000000000..a2ded7e88df3 --- /dev/null +++ b/tests/src/reflection/regression/github_25697/25697.csproj @@ -0,0 +1,36 @@ + + + + + Debug + AnyCPU + 2.0 + {CE893CE4-177E-47D3-A5DA-DF4D64E76812} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + BuildAndRun + 1 + + + + + + + + + False + + + + + + + + + + + + + \ No newline at end of file