[new] Generate支持 netstandard

main
walon 2023-11-01 20:33:42 +08:00
parent f51c2803c1
commit d9ed27abfb
6 changed files with 36 additions and 3 deletions

Binary file not shown.

Binary file not shown.

View File

@ -15,6 +15,7 @@ namespace HybridCLR.Editor.Meta
private readonly ModuleContext _modCtx;
private readonly AssemblyResolver _asmResolver;
private bool disposedValue;
private bool _loadedNetstandard;
public Dictionary<string, ModuleDefMD> LoadedModules { get; } = new Dictionary<string, ModuleDefMD>();
@ -34,6 +35,15 @@ namespace HybridCLR.Editor.Meta
{
return mod;
}
if (moduleName == "netstandard")
{
if (!_loadedNetstandard)
{
LoadNetStandard();
_loadedNetstandard = true;
}
return null;
}
mod = DoLoadModule(_assemblyPathResolver.ResolveAssembly(moduleName, true));
LoadedModules.Add(moduleName, mod);
@ -48,6 +58,12 @@ namespace HybridCLR.Editor.Meta
return mod;
}
private void LoadNetStandard()
{
LoadModule("netstandard2.0", false);
LoadModule("netstandard2.1", false);
}
private ModuleDefMD DoLoadModule(string dllPath)
{
//Debug.Log($"do load module:{dllPath}");

View File

@ -17,6 +17,7 @@ namespace HybridCLR.Editor.Meta
private readonly ModuleContext _modCtx;
private readonly AssemblyResolver _asmResolver;
private bool disposedValue;
private bool _loadedNetstandard;
public Dictionary<string, ModuleDefMD> LoadedModules { get; } = new Dictionary<string, ModuleDefMD>();
@ -66,6 +67,15 @@ namespace HybridCLR.Editor.Meta
{
return mod;
}
if (moduleName == "netstandard")
{
if (!_loadedNetstandard)
{
LoadNetStandard();
_loadedNetstandard = true;
}
return null;
}
mod = DoLoadModule(_assemblyPathResolver.ResolveAssembly(moduleName, true));
LoadedModules.Add(moduleName, mod);
@ -84,6 +94,12 @@ namespace HybridCLR.Editor.Meta
return mod;
}
private void LoadNetStandard()
{
DoLoadModule(_assemblyPathResolver.ResolveAssembly("netstandard2.0", true));
DoLoadModule(_assemblyPathResolver.ResolveAssembly("netstandard2.1", true));
}
protected virtual void Dispose(bool disposing)
{
if (!disposedValue)

View File

@ -170,7 +170,8 @@ namespace HybridCLR.Editor.Meta
{
return new CombinedAssemblyResolver(
CreateHotUpdateAssemblyResolver(target, hotUpdateDlls),
CreateAOTAssemblyResolver(target)
CreateAOTAssemblyResolver(target),
new PathAssemblyResolver($"{SettingsUtil.HybridCLRDataPathInPackage}/NetStandard")
);
}

View File

@ -33,9 +33,9 @@ namespace HybridCLR.Editor.ReversePInvokeWrap
public Analyzer(AssemblyCache cache, List<string> assemblyNames)
{
foreach(var assemblyName in assemblyNames)
foreach (var assemblyName in assemblyNames)
{
_rootModules.Add(cache.LoadModule(assemblyName, false));
_rootModules.Add(cache.LoadModule(assemblyName));
}
}