Skip to content

Commit

Permalink
fix: using mathematics in commands and rpcs (#492)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
paulpach committed Nov 14, 2020
1 parent c9fa47f commit ee27841
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Assets/Mirror/Editor/Weaver/Readers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ static void ReadAllFields(TypeReference variable, ILProcessor worker)
OpCode opcode = variable.IsValueType ? OpCodes.Ldloca : OpCodes.Ldloc;
worker.Append(worker.Create(opcode, 0));

MethodReference readFunc = GetReadFunc(field.FieldType);
TypeReference fieldTypeRef = worker.Body.Method.Module.ImportReference(field.FieldType);
MethodReference readFunc = GetReadFunc(fieldTypeRef);
if (readFunc != null)
{
worker.Append(worker.Create(OpCodes.Ldarg_0));
Expand Down
3 changes: 2 additions & 1 deletion Assets/Mirror/Editor/Weaver/Writers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ static bool WriteAllFields(TypeReference variable, ILProcessor worker)
uint fields = 0;
foreach (FieldDefinition field in variable.FindAllPublicFields())
{
MethodReference writeFunc = GetWriteFunc(field.FieldType);
TypeReference fieldTypeRef = worker.Body.Method.Module.ImportReference(field.FieldType);
MethodReference writeFunc = GetWriteFunc(fieldTypeRef);
// need this null check till later PR when GetWriteFunc throws exception instead
if (writeFunc == null) { return false; }

Expand Down

0 comments on commit ee27841

Please sign in to comment.