Browse Source

#1214: Assertion Failed in DecodeSignature() - Fix type system metadata; parameter metadata was assigned to parameter types in the wrong order.

pull/1420/head
Siegfried Pammer 8 years ago
parent
commit
bfdff894bc
  1. 17
      ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataMethod.cs

17
ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataMethod.cs

@ -157,6 +157,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
CustomAttributeHandleCollection? returnTypeAttributes = null; CustomAttributeHandleCollection? returnTypeAttributes = null;
IParameter[] parameters = new IParameter[signature.RequiredParameterCount IParameter[] parameters = new IParameter[signature.RequiredParameterCount
+ (signature.Header.CallingConvention == SignatureCallingConvention.VarArgs ? 1 : 0)]; + (signature.Header.CallingConvention == SignatureCallingConvention.VarArgs ? 1 : 0)];
IType parameterType;
if (parameterHandles != null) { if (parameterHandles != null) {
foreach (var parameterHandle in parameterHandles) { foreach (var parameterHandle in parameterHandles) {
var par = metadata.GetParameter(parameterHandle); var par = metadata.GetParameter(parameterHandle);
@ -164,8 +165,18 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
// "parameter" holds return type attributes // "parameter" holds return type attributes
returnTypeAttributes = par.GetCustomAttributes(); returnTypeAttributes = par.GetCustomAttributes();
} else if (par.SequenceNumber > 0 && i < signature.RequiredParameterCount) { } else if (par.SequenceNumber > 0 && i < signature.RequiredParameterCount) {
Debug.Assert(par.SequenceNumber - 1 == i); // "Successive rows of the Param table that are owned by the same method shall be
var parameterType = ApplyAttributeTypeVisitor.ApplyAttributesToType( // ordered by increasing Sequence value - although gaps in the sequence are allowed"
Debug.Assert(i < par.SequenceNumber);
// Fill gaps in the sequence with non-metadata parameters:
while (i < par.SequenceNumber - 1) {
parameterType = ApplyAttributeTypeVisitor.ApplyAttributesToType(
signature.ParameterTypes[i], module.Compilation, null, metadata, module.TypeSystemOptions);
parameters[i] = new DefaultParameter(parameterType, name: string.Empty, owner,
isRef: parameterType.Kind == TypeKind.ByReference);
i++;
}
parameterType = ApplyAttributeTypeVisitor.ApplyAttributesToType(
signature.ParameterTypes[i], module.Compilation, signature.ParameterTypes[i], module.Compilation,
par.GetCustomAttributes(), metadata, module.TypeSystemOptions); par.GetCustomAttributes(), metadata, module.TypeSystemOptions);
parameters[i] = new MetadataParameter(module, owner, parameterType, parameterHandle); parameters[i] = new MetadataParameter(module, owner, parameterType, parameterHandle);
@ -174,7 +185,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
} }
} }
while (i < signature.RequiredParameterCount) { while (i < signature.RequiredParameterCount) {
var parameterType = ApplyAttributeTypeVisitor.ApplyAttributesToType( parameterType = ApplyAttributeTypeVisitor.ApplyAttributesToType(
signature.ParameterTypes[i], module.Compilation, null, metadata, module.TypeSystemOptions); signature.ParameterTypes[i], module.Compilation, null, metadata, module.TypeSystemOptions);
parameters[i] = new DefaultParameter(parameterType, name: string.Empty, owner, parameters[i] = new DefaultParameter(parameterType, name: string.Empty, owner,
isRef: parameterType.Kind == TypeKind.ByReference); isRef: parameterType.Kind == TypeKind.ByReference);

Loading…
Cancel
Save