Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/cecil.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Boemer <sbomer@gmail.com>2022-09-30 00:03:25 +0300
committerGitHub <noreply@github.com>2022-09-30 00:03:25 +0300
commit42b9ef143d3f02403d19f7c3bbe1af0c59fe2031 (patch)
treeb5704eaf024101dae811a1956d4358055af9ba82 /Mono.Cecil
parent49b1c52df5e8d2bf03768dc35ba6575e88277bc7 (diff)
Add support for generic attributes (#871)
* Add support for generic attributes * Compile test assembly against mscorlib To satisfy PEVerify
Diffstat (limited to 'Mono.Cecil')
-rw-r--r--Mono.Cecil/AssemblyReader.cs7
-rw-r--r--Mono.Cecil/AssemblyWriter.cs7
2 files changed, 10 insertions, 4 deletions
diff --git a/Mono.Cecil/AssemblyReader.cs b/Mono.Cecil/AssemblyReader.cs
index ee2c229..4180d78 100644
--- a/Mono.Cecil/AssemblyReader.cs
+++ b/Mono.Cecil/AssemblyReader.cs
@@ -3513,9 +3513,12 @@ namespace Mono.Cecil {
attribute.arguments = new Collection<CustomAttributeArgument> (count);
- for (int i = 0; i < count; i++)
+ for (int i = 0; i < count; i++) {
+ var parameterType = GenericParameterResolver.ResolveParameterTypeIfNeeded (
+ attribute.Constructor, parameters [i]);
attribute.arguments.Add (
- ReadCustomAttributeFixedArgument (parameters [i].ParameterType));
+ ReadCustomAttributeFixedArgument (parameterType));
+ }
}
CustomAttributeArgument ReadCustomAttributeFixedArgument (TypeReference type)
diff --git a/Mono.Cecil/AssemblyWriter.cs b/Mono.Cecil/AssemblyWriter.cs
index 3cba95e..9972c12 100644
--- a/Mono.Cecil/AssemblyWriter.cs
+++ b/Mono.Cecil/AssemblyWriter.cs
@@ -2922,8 +2922,11 @@ namespace Mono.Cecil {
if (parameters.Count != arguments.Count)
throw new InvalidOperationException ();
- for (int i = 0; i < arguments.Count; i++)
- WriteCustomAttributeFixedArgument (parameters [i].ParameterType, arguments [i]);
+ for (int i = 0; i < arguments.Count; i++) {
+ var parameterType = GenericParameterResolver.ResolveParameterTypeIfNeeded (
+ attribute.Constructor, parameters [i]);
+ WriteCustomAttributeFixedArgument (parameterType, arguments [i]);
+ }
}
void WriteCustomAttributeFixedArgument (TypeReference type, CustomAttributeArgument argument)