Skip to content

Commit

Permalink
fix: issue with readers and writers from other assemblies
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpach committed Sep 30, 2020
1 parent a55f88c commit 18f3eba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
12 changes: 3 additions & 9 deletions Assets/Mirror/Editor/Weaver/Processors/ReaderWriterProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,22 @@ public static class ReaderWriterProcessor

public static void Process(AssemblyDefinition CurrentAssembly, Assembly unityAssembly)
{
// darn global state causing bugs
Weaver.WeaveLists.generateContainerClass = null;
Readers.Init();
Writers.Init();
foreach (Assembly unityAsm in unityAssembly.assemblyReferences)
{
// cute optimization, None of the unity libraries have readers and writers
// saves about .3 seconds in every weaver test
if (Path.GetFileName(unityAsm.outputPath).StartsWith("Unity"))
continue;

try
if (unityAsm.name == "Mirror")
{
using (var asmResolver = new DefaultAssemblyResolver())
using (var assembly = AssemblyDefinition.ReadAssembly(unityAsm.outputPath, new ReaderParameters { ReadWrite = false, ReadSymbols = false, AssemblyResolver = asmResolver }))
{
ProcessAssemblyClasses(CurrentAssembly, assembly);
}
}
catch (FileNotFoundException)
{
// During first import, this gets called before some assemblies
// are built, just skip them
}
}

ProcessAssemblyClasses(CurrentAssembly, CurrentAssembly);
Expand Down
2 changes: 1 addition & 1 deletion Assets/Mirror/Editor/Weaver/Weaver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void ConfirmGeneratedCodeClass()
if (generateContainerClass == null)
{
generateContainerClass = new TypeDefinition("Mirror", "GeneratedNetworkCode",
TypeAttributes.BeforeFieldInit | TypeAttributes.Class | TypeAttributes.AnsiClass | TypeAttributes.Public | TypeAttributes.AutoClass | TypeAttributes.Abstract | TypeAttributes.Sealed,
TypeAttributes.BeforeFieldInit | TypeAttributes.Class | TypeAttributes.AnsiClass | TypeAttributes.Public | TypeAttributes.AutoClass,
WeaverTypes.Import<object>());
}
}
Expand Down

0 comments on commit 18f3eba

Please sign in to comment.