diff --git a/Editor/Meta/GenericArgumentContext.cs b/Editor/Meta/GenericArgumentContext.cs index 577fc97..47883f5 100644 --- a/Editor/Meta/GenericArgumentContext.cs +++ b/Editor/Meta/GenericArgumentContext.cs @@ -37,6 +37,7 @@ namespace HybridCLR.Editor.Meta { return typeSig; } + typeSig = typeSig.RemovePinnedAndModifiers(); switch (typeSig.ElementType) { case ElementType.Ptr: return new PtrSig(Resolve(typeSig.Next)); @@ -64,7 +65,7 @@ namespace HybridCLR.Editor.Meta { GenericMVar genericVar = (GenericMVar)typeSig; var newSig = Resolve(methodArgsStack, genericVar.Number, true); - if (newSig is null) + if (newSig == null) { throw new Exception(); } diff --git a/Editor/Meta/GenericMethod.cs b/Editor/Meta/GenericMethod.cs index a725db7..c3cb419 100644 --- a/Editor/Meta/GenericMethod.cs +++ b/Editor/Meta/GenericMethod.cs @@ -42,6 +42,11 @@ namespace HybridCLR.Editor.Meta return _hashCode; } + public override string ToString() + { + return $"{Method}|{string.Join(",", (IEnumerable)KlassInst ?? Array.Empty())}|{string.Join(",", (IEnumerable)MethodInst ?? Array.Empty())}"; + } + private int ComputHashCode() { int hash = MethodEqualityComparer.CompareDeclaringTypes.GetHashCode(Method); diff --git a/Editor/Meta/UnityAOTAssemblyResolver.cs b/Editor/Meta/UnityAOTAssemblyResolver.cs new file mode 100644 index 0000000..fcd0319 --- /dev/null +++ b/Editor/Meta/UnityAOTAssemblyResolver.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +namespace HybridCLR.Editor.Meta +{ + public class UnityAOTAssemblyResolver : IAssemblyResolver + { + public string ResolveAssembly(string assemblyName, bool throwExIfNotFind) + { + // + var assemblyFile = $"{UnityEditor.EditorApplication.applicationContentsPath}/MonoBleedingEdge/lib/mono/unityaot/{assemblyName}.dll"; + if (File.Exists(assemblyFile)) + { + Debug.Log($"UnityAOTAssemblyResolver.ResolveAssembly:{assemblyFile}"); + return assemblyFile; + } + if (throwExIfNotFind) + { + throw new Exception($"resolve assembly:{assemblyName} fail"); + } + return null; + } + } +} diff --git a/Editor/Meta/UnityAOTAssemblyResolver.cs.meta b/Editor/Meta/UnityAOTAssemblyResolver.cs.meta new file mode 100644 index 0000000..8fb10f3 --- /dev/null +++ b/Editor/Meta/UnityAOTAssemblyResolver.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 029bc0368e1ada342aa29a18d4fae879 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/Meta/UnityPluginAssemblyResolver.cs b/Editor/Meta/UnityPluginAssemblyResolver.cs index 2e747c7..35af9f2 100644 --- a/Editor/Meta/UnityPluginAssemblyResolver.cs +++ b/Editor/Meta/UnityPluginAssemblyResolver.cs @@ -30,7 +30,7 @@ namespace HybridCLR.Editor.Meta { if (Path.GetFileNameWithoutExtension(dll) == assemblyName && IsPluginDll(dll)) { - Debug.Log($"plugin:{dll}"); + Debug.Log($"UnityPluginAssemblyResolver.ResolveAssembly:{dll}"); return dll; } } diff --git a/Editor/MetaUtil.cs b/Editor/MetaUtil.cs index 24fd7fa..b1ed9b6 100644 --- a/Editor/MetaUtil.cs +++ b/Editor/MetaUtil.cs @@ -29,7 +29,7 @@ namespace HybridCLR.Editor return typeSig; } var a = typeSig.RemovePinnedAndModifiers(); - switch (typeSig.ElementType) + switch (a.ElementType) { case ElementType.Void: return corTypes.Void; case ElementType.Boolean: return corTypes.Byte; @@ -87,6 +87,7 @@ namespace HybridCLR.Editor return new CombinedAssemblyResolver(new PathAssemblyResolver( SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target)), new UnityPluginAssemblyResolver(), + new UnityAOTAssemblyResolver(), new UnityEditorAssemblyResolver()); } } diff --git a/Editor/MethodBridge/Analyzer.cs b/Editor/MethodBridge/Analyzer.cs index 29cbae9..5cdd9e8 100644 --- a/Editor/MethodBridge/Analyzer.cs +++ b/Editor/MethodBridge/Analyzer.cs @@ -118,7 +118,7 @@ namespace HybridCLR.Editor.MethodBridge } foreach (var method in typeDef.Methods) { - // 对于带泛型的参数,统率泛型共享为object + // 对于带泛型的参数,统一泛型共享为object _notGenericMethods.Add(method); } } @@ -182,10 +182,10 @@ namespace HybridCLR.Editor.MethodBridge _newMethods = temp; _newMethods.Clear(); - Task.WhenAll(_processingMethods.Select(method => Task.Run(() => + Task.WaitAll(_processingMethods.Select(method => Task.Run(() => { _methodReferenceAnalyzer.WalkMethod(method.Method, method.KlassInst, method.MethodInst); - }))); + })).ToArray()); Debug.Log($"iteration:[{i}] allMethods:{_notGenericMethods.Count} genericClass:{_genericTypes.Count} genericMethods:{_genericMethods.Count} newMethods:{_newMethods.Count}"); } } diff --git a/package.json b/package.json index 3f00ce1..cadce58 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.focus-creative-games.hybridclr_unity", - "version": "0.4.0", + "version": "0.4.1", "displayName": "HybridCLR", "description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR", "category": "Runtime",