diff --git a/Mono.Cecil/AssemblyWriter.cs b/Mono.Cecil/AssemblyWriter.cs index 836aa2172..2cdd7f4b8 100644 --- a/Mono.Cecil/AssemblyWriter.cs +++ b/Mono.Cecil/AssemblyWriter.cs @@ -1769,6 +1769,10 @@ void AddParameter (ushort sequence, ParameterDefinition parameter, ParamTable ta sequence, GetStringIndex (parameter.Name))); + // fixbug: update custom attributes and others before update token + _ = parameter.CustomAttributes; + var hasMarshalInfo = parameter.HasMarshalInfo; + parameter.token = new MetadataToken (TokenType.Param, param_rid++); if (parameter.HasCustomAttributes) @@ -1777,7 +1781,7 @@ void AddParameter (ushort sequence, ParameterDefinition parameter, ParamTable ta if (parameter.HasConstant) AddConstant (parameter, parameter.ParameterType); - if (parameter.HasMarshalInfo) + if (hasMarshalInfo) AddMarshalInfo (parameter); }