Add publicized assemblies to metadata references
This commit is contained in:
+29
-7
@@ -72,10 +72,10 @@ public class PluginManagementService : IAssemblyManagementService
|
|||||||
private static readonly SyntaxTree BaseAssemblyImports = CSharpSyntaxTree.ParseText(
|
private static readonly SyntaxTree BaseAssemblyImports = CSharpSyntaxTree.ParseText(
|
||||||
new StringBuilder()
|
new StringBuilder()
|
||||||
.AppendLine("global using LuaCsHook = Barotrauma.LuaCs.Compatibility.ILuaCsHook;")
|
.AppendLine("global using LuaCsHook = Barotrauma.LuaCs.Compatibility.ILuaCsHook;")
|
||||||
.AppendLine("using System.Reflection;")
|
.AppendLine("global using System.Reflection;")
|
||||||
.AppendLine("using Barotrauma;")
|
.AppendLine("global using Barotrauma;")
|
||||||
.AppendLine("using Barotrauma.LuaCs;")
|
.AppendLine("global using Barotrauma.LuaCs;")
|
||||||
.AppendLine("using Barotrauma.LuaCs.Compatibility;")
|
.AppendLine("global using Barotrauma.LuaCs.Compatibility;")
|
||||||
.AppendLine("using System.Runtime.CompilerServices;")
|
.AppendLine("using System.Runtime.CompilerServices;")
|
||||||
.AppendLine("[assembly: IgnoresAccessChecksTo(\"BarotraumaCore\")]")
|
.AppendLine("[assembly: IgnoresAccessChecksTo(\"BarotraumaCore\")]")
|
||||||
#if CLIENT
|
#if CLIENT
|
||||||
@@ -559,10 +559,32 @@ public class PluginManagementService : IAssemblyManagementService
|
|||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
throw new NotImplementedException($"Needs to use publicized barotrauma assemblies and cache metadata.");
|
throw new NotImplementedException($"Needs to use publicized barotrauma assemblies and cache metadata.");
|
||||||
#endif
|
#endif
|
||||||
|
var publicizedDir = Path.Combine(Directory.GetCurrentDirectory(), "Publicized");
|
||||||
|
|
||||||
|
string[] publicizedAssemblies =
|
||||||
|
{
|
||||||
|
#if CLIENT
|
||||||
|
"Barotrauma",
|
||||||
|
#elif SERVER
|
||||||
|
"DedicatedServer",
|
||||||
|
#endif
|
||||||
|
"BarotraumaCore"
|
||||||
|
};
|
||||||
|
|
||||||
|
var publicizedRefs = publicizedAssemblies
|
||||||
|
.Select(name => Path.Combine(publicizedDir, $"{name}.dll"))
|
||||||
|
.Where(File.Exists)
|
||||||
|
.Select(path => MetadataReference.CreateFromFile(path));
|
||||||
|
|
||||||
|
var runtimeRefs = AppDomain.CurrentDomain.GetAssemblies()
|
||||||
|
.Where(ass =>
|
||||||
|
!string.IsNullOrWhiteSpace(ass.Location) &&
|
||||||
|
!publicizedAssemblies.Contains(ass.GetName().Name))
|
||||||
|
.Select(ass => MetadataReference.CreateFromFile(ass.Location));
|
||||||
|
|
||||||
return Basic.Reference.Assemblies.Net80.References.All
|
return Basic.Reference.Assemblies.Net80.References.All
|
||||||
.Union(AppDomain.CurrentDomain.GetAssemblies()
|
.Union(runtimeRefs)
|
||||||
.Where(ass => !ass.Location.IsNullOrWhiteSpace())
|
.Union(publicizedRefs);
|
||||||
.Select(ass => MetadataReference.CreateFromFile(ass.Location)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user