diff --git a/MirrorWeaver/ImprovedExtensions.cs b/MirrorWeaver/ImprovedExtensions.cs
index 69c91d2a..c034ebe8 100644
--- a/MirrorWeaver/ImprovedExtensions.cs
+++ b/MirrorWeaver/ImprovedExtensions.cs
@@ -1,4 +1,6 @@
-using Mono.Cecil;
+using Mirror.Weaver;
+using Mono.Cecil;
+using System;
using System.Collections.Generic;
namespace MirrorWeaver;
@@ -9,8 +11,9 @@ public static class ImprovedExtensions
/// filters ONLY public fields instead of all non-private
/// replaces generic parameter fields with their corresponding argument
///
- public static IEnumerable FindAllPublicFields_Improved(this TypeReference tr)
+ public static IEnumerable FindAllPublicFields_Improved(this TypeReference tr)
{
+ Console.WriteLine($"FindAllPublicFields_Improved {tr}");
while (tr != null)
{
var td = tr.Resolve();
@@ -26,15 +29,24 @@ public static class ImprovedExtensions
continue;
}
- if (fd.FieldType is GenericParameter gp && gp.Owner == td)
+ FieldReference fr;
+ if (tr is GenericInstanceType git &&
+ fd.FieldType is GenericParameter gp &&
+ gp.Owner == td)
{
- fd.FieldType = ((GenericInstanceType)tr).GenericArguments[gp.Position];
+ fr = fd.SpecializeField(fd.Module, git);
+ Console.WriteLine($"\t\t{fd.FieldType} -> {fr.FieldType}");
+ }
+ else
+ {
+ fr = fd.Module.ImportReference(fd);
}
- yield return fd;
+ Console.WriteLine($"\t\t{fd}");
+ yield return fr;
}
- tr = td.BaseType;
+ tr = td.BaseType?.ApplyGenericParameters(tr);
}
}
-}
\ No newline at end of file
+}