未验证 提交 1b87ff9e 编写于 作者: M Michal Strehovský 提交者: GitHub

Fix failure building two libraries tests (#70881)

Microsoft.CSharp was hitting an issue due to a vararg constructor. We don't support varargs. They shouldn't make it into the dependency graph. We are already checking in many places. We were erroneously thinking a vararg constructor with no mandatory arguments is a default constructor.

Runtime.InteropServices were crashing because we got a MulticastDelegate type into a codepath that expects a MulticastDelegate descendant.
上级 3fdee968
...@@ -374,7 +374,12 @@ public override MethodDesc GetDefaultConstructor() ...@@ -374,7 +374,12 @@ public override MethodDesc GetDefaultConstructor()
&& stringComparer.Equals(methodDefinition.Name, ".ctor")) && stringComparer.Equals(methodDefinition.Name, ".ctor"))
{ {
var method = (EcmaMethod)_module.GetObject(handle); var method = (EcmaMethod)_module.GetObject(handle);
if (method.Signature.Length != 0) MethodSignature sig = method.Signature;
if (sig.Length != 0)
continue;
if ((sig.Flags & MethodSignatureFlags.UnmanagedCallingConventionMask) == MethodSignatureFlags.CallingConventionVarargs)
continue; continue;
return method; return method;
......
...@@ -625,7 +625,7 @@ public override bool HandleCall(MethodIL callingMethodBody, MethodDesc calledMet ...@@ -625,7 +625,7 @@ public override bool HandleCall(MethodIL callingMethodBody, MethodDesc calledMet
&& !systemTypeValue.RepresentedType.Type.IsGenericDefinition && !systemTypeValue.RepresentedType.Type.IsGenericDefinition
&& !systemTypeValue.RepresentedType.Type.ContainsSignatureVariables(treatGenericParameterLikeSignatureVariable: true)) && !systemTypeValue.RepresentedType.Type.ContainsSignatureVariables(treatGenericParameterLikeSignatureVariable: true))
{ {
if (systemTypeValue.RepresentedType.Type.IsDefType) if (systemTypeValue.RepresentedType.Type.IsDelegate)
{ {
_reflectionMarker.Dependencies.Add(_factory.DelegateMarshallingData((DefType)systemTypeValue.RepresentedType.Type), "Marshal API"); _reflectionMarker.Dependencies.Add(_factory.DelegateMarshallingData((DefType)systemTypeValue.RepresentedType.Type), "Marshal API");
} }
......
...@@ -264,6 +264,8 @@ private void ImportCall(ILOpcode opcode, int token) ...@@ -264,6 +264,8 @@ private void ImportCall(ILOpcode opcode, int token)
var method = (MethodDesc)_canonMethodIL.GetObject(token); var method = (MethodDesc)_canonMethodIL.GetObject(token);
_compilation.TypeSystemContext.EnsureLoadableMethod(method); _compilation.TypeSystemContext.EnsureLoadableMethod(method);
if ((method.Signature.Flags & MethodSignatureFlags.UnmanagedCallingConventionMask) == MethodSignatureFlags.CallingConventionVarargs)
ThrowHelper.ThrowBadImageFormatException();
_compilation.NodeFactory.MetadataManager.GetDependenciesDueToAccess(ref _dependencies, _compilation.NodeFactory, _canonMethodIL, method); _compilation.NodeFactory.MetadataManager.GetDependenciesDueToAccess(ref _dependencies, _compilation.NodeFactory, _canonMethodIL, method);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册