Revert "8.2版本上传"

This reverts commit 6a881f2e8a.
This commit is contained in:
2025-06-18 17:37:53 +08:00
parent 7fe716baab
commit e9af7221de
261 changed files with 1340 additions and 9065 deletions

View File

@@ -1,56 +0,0 @@
using dnlib.DotNet;
using dnlib.DotNet.Writer;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HybridCLR.Editor.AOT
{
public class AOTAssemblyMetadataStripper
{
public static byte[] Strip(byte[] assemblyBytes)
{
var context = ModuleDef.CreateModuleContext();
var readerOption = new ModuleCreationOptions(context)
{
Runtime = CLRRuntimeReaderKind.Mono
};
var mod = ModuleDefMD.Load(assemblyBytes, readerOption);
// remove all resources
mod.Resources.Clear();
foreach (var type in mod.GetTypes())
{
if (type.HasGenericParameters)
{
continue;
}
foreach (var method in type.Methods)
{
if (!method.HasBody || method.HasGenericParameters)
{
continue;
}
method.Body = null;
}
}
var writer = new System.IO.MemoryStream();
var options = new ModuleWriterOptions(mod);
options.MetadataOptions.Flags |= MetadataFlags.PreserveRids;
mod.Write(writer, options);
writer.Flush();
return writer.ToArray();
}
public static void Strip(string originalAssemblyPath, string strippedAssemblyPath)
{
byte[] originDllBytes = System.IO.File.ReadAllBytes(originalAssemblyPath);
byte[] strippedDllBytes = Strip(originDllBytes);
UnityEngine.Debug.Log($"aot dll:{originalAssemblyPath}, length: {originDllBytes.Length} -> {strippedDllBytes.Length}, stripping rate:{(originDllBytes.Length - strippedDllBytes.Length)/(double)originDllBytes.Length} ");
Directory.CreateDirectory(System.IO.Path.GetDirectoryName(strippedAssemblyPath));
System.IO.File.WriteAllBytes(strippedAssemblyPath, strippedDllBytes);
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 7e9e6a048682dcb4fab806251411f29f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -17,16 +17,12 @@ namespace HybridCLR.Editor.AOT
public AssemblyReferenceDeepCollector Collector { get; set; }
public int MaxIterationCount { get; set; }
public bool ComputeAotAssembly { get; set; }
}
private readonly int _maxInterationCount;
private readonly AssemblyReferenceDeepCollector _assemblyCollector;
private readonly bool _computeAotAssembly;
private readonly HashSet<GenericClass> _genericTypes = new HashSet<GenericClass>();
private readonly HashSet<GenericMethod> _genericMethods = new HashSet<GenericMethod>();
@@ -51,7 +47,6 @@ namespace HybridCLR.Editor.AOT
{
_assemblyCollector = options.Collector;
_maxInterationCount = options.MaxIterationCount;
_computeAotAssembly = options.ComputeAotAssembly;
_methodReferenceAnalyzer = new MethodReferenceAnalyzer(this.OnNewMethod);
_hotUpdateAssemblyFiles = new HashSet<string>(options.Collector.GetRootAssemblyNames().Select(assName => assName + ".dll"));
}
@@ -76,7 +71,7 @@ namespace HybridCLR.Editor.AOT
private bool IsAotType(TypeDef type)
{
return _computeAotAssembly || !_hotUpdateAssemblyFiles.Contains(type.Module.Name);
return !_hotUpdateAssemblyFiles.Contains(type.Module.Name);
}
private bool IsAotGenericMethod(MethodDef method)
@@ -196,29 +191,11 @@ namespace HybridCLR.Editor.AOT
}
}
private bool IsNotShareableAOTGenericType(TypeDef typeDef)
{
if (!IsAotType(typeDef))
{
return false;
}
return typeDef.GenericParameters.Any(c => !c.HasReferenceTypeConstraint);
}
private bool IsNotShareableAOTGenericMethod(MethodDef method)
{
if (!IsAotGenericMethod(method))
{
return false;
}
return method.GenericParameters.Concat(method.DeclaringType.GenericParameters).Any(c => !c.HasReferenceTypeConstraint);
}
private void FilterAOTGenericTypeAndMethods()
{
ConstraintContext cc = this.ConstraintContext;
AotGenericTypes.AddRange(_genericTypes.Where(type => IsNotShareableAOTGenericType(type.Type)).Select(gc => cc.ApplyConstraints(gc)));
AotGenericMethods.AddRange(_genericMethods.Where(method => IsNotShareableAOTGenericMethod(method.Method)).Select(gm => cc.ApplyConstraints(gm)));
AotGenericTypes.AddRange(_genericTypes.Where(type => IsAotType(type.Type)).Select(gc => cc.ApplyConstraints(gc)));
AotGenericMethods.AddRange(_genericMethods.Where(method => IsAotGenericMethod(method.Method)).Select(gm => cc.ApplyConstraints(gm)));
}
public void Run()

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 30bbf4a80a6cf3a43b3f489747d9dd6a
guid: 5eb77177ef7793a44af2666b647e9605
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 812d81a75b690394bbe16ef5f0bcbc46
guid: b6b6f4ac6086fbc46b43cb1610dba4fb
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -39,7 +39,7 @@ namespace HybridCLR.Editor.AOT
{
_typeSimpleNameMapping.Add(e.Key.FullName, e.Value);
}
_systemTypePattern = new Regex(string.Join("|", _typeSimpleNameMapping.Keys.Select (k => $@"\b{Regex.Escape(k)}\b")));
_systemTypePattern = new Regex(string.Join("|", _typeSimpleNameMapping.Keys.Select (k => $@"\b{k}\b")));
}
public string PrettifyTypeSig(string typeSig)

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: d1243cf04685361478972f93b5ca868a
guid: cc730a906269a78429589f950b5a92f3
MonoImporter:
externalObjects: {}
serializedVersion: 2