mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
fix: using mathematics in commands and rpcs (#2425)
Generating readers and writers for structs in other assemblies could sometimes cause a ``` System.ArgumentException: Member 'xxx' is declared in another module and needs to be imported ``` This in particular affected unity mathematics. fixes #2406
This commit is contained in:
parent
59ed64f9d0
commit
037ac55937
@ -269,8 +269,8 @@ static void ReadAllFields(TypeReference variable, ILProcessor worker)
|
||||
// mismatched ldloca/ldloc for struct/class combinations is invalid IL, which causes crash at runtime
|
||||
OpCode opcode = variable.IsValueType ? OpCodes.Ldloca : OpCodes.Ldloc;
|
||||
worker.Append(worker.Create(opcode, 0));
|
||||
|
||||
MethodReference readFunc = GetReadFunc(field.FieldType);
|
||||
TypeReference fieldTypeRef = Weaver.CurrentAssembly.MainModule.ImportReference(field.FieldType);
|
||||
MethodReference readFunc = GetReadFunc(fieldTypeRef);
|
||||
if (readFunc != null)
|
||||
{
|
||||
worker.Append(worker.Create(OpCodes.Ldarg_0));
|
||||
|
@ -218,7 +218,8 @@ static bool WriteAllFields(TypeReference variable, ILProcessor worker)
|
||||
uint fields = 0;
|
||||
foreach (FieldDefinition field in variable.FindAllPublicFields())
|
||||
{
|
||||
MethodReference writeFunc = GetWriteFunc(field.FieldType);
|
||||
TypeReference fieldTypeRef = Weaver.CurrentAssembly.MainModule.ImportReference(field.FieldType);
|
||||
MethodReference writeFunc = GetWriteFunc(fieldTypeRef);
|
||||
// need this null check till later PR when GetWriteFunc throws exception instead
|
||||
if (writeFunc == null) { return false; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user