CompiledAssemblyFromFile simplified

This commit is contained in:
vis2k 2021-08-28 20:51:07 +08:00
parent 523fcdec88
commit e481a3fba5

View File

@ -13,30 +13,19 @@ namespace Mirror.Weaver
public class CompiledAssemblyFromFile : ICompiledAssembly
{
readonly string assemblyPath;
InMemoryAssembly inMemoryAssembly;
public string Name => Path.GetFileNameWithoutExtension(assemblyPath);
public string[] References { get; set; }
public string[] Defines { get; set; }
public InMemoryAssembly InMemoryAssembly { get; }
public CompiledAssemblyFromFile(string assemblyPath)
{
this.assemblyPath = assemblyPath;
}
public InMemoryAssembly InMemoryAssembly
{
get
{
if (inMemoryAssembly == null)
{
byte[] peData = File.ReadAllBytes(assemblyPath);
string pdbFileName = Path.GetFileNameWithoutExtension(assemblyPath) + ".pdb";
byte[] pdbData = File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(assemblyPath), pdbFileName));
inMemoryAssembly = new InMemoryAssembly(peData, pdbData);
}
return inMemoryAssembly;
}
InMemoryAssembly = new InMemoryAssembly(peData, pdbData);
}
}
}