From 4bdee381502bb8c0a0f9842ee0d2b8934c0ec301 Mon Sep 17 00:00:00 2001 From: windy Date: Fri, 15 Mar 2024 18:30:09 +0800 Subject: [PATCH] fixbug: fix exception that failed to resolve TupleElementNamesAttribute:.ctor sometime --- Mono.Cecil/AssemblyWriter.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); }