Skip to content

Commit

Permalink
fix: generate writer for types in other assemblies
Browse files Browse the repository at this point in the history
writer generator now always import the type reference in the current module
  • Loading branch information
paulpach committed Nov 14, 2020
1 parent b685226 commit 8385c29
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ private static void GenerateReadersWriters(ModuleDefinition module, TypeReferenc
return;
}

parameterType = module.ImportReference(parameterType);
module.GetWriteFunc(parameterType);
module.GetReadFunc(parameterType);
}
Expand Down
7 changes: 3 additions & 4 deletions Assets/Mirror/Editor/Weaver/Writers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public static MethodReference GetWriteFunc(this ModuleDefinition module, TypeRef
{
// this try/catch will be removed in future PR and make `GetWriteFunc` throw instead
try
{
return GenerateWriter(module, typeReference);
{
return GenerateWriter(module, module.ImportReference(typeReference));
}
catch (GenerateWriterException e)
{
Expand Down Expand Up @@ -226,8 +226,7 @@ static bool WriteAllFields(TypeReference variable, ILProcessor worker)

foreach (FieldDefinition field in variable.FindAllPublicFields())
{
TypeReference fieldTypeRef = module.ImportReference(field.FieldType);
MethodReference writeFunc = module.GetWriteFunc(fieldTypeRef);
MethodReference writeFunc = module.GetWriteFunc(field.FieldType);
// need this null check till later PR when GetWriteFunc throws exception instead
if (writeFunc == null) { return false; }

Expand Down

0 comments on commit 8385c29

Please sign in to comment.