[change] 解决AOTGenericReference生成不稳定的问题
parent
4492449b73
commit
768512bcfa
|
@ -91,10 +91,11 @@ namespace HybridCLR.Editor.AOT
|
||||||
codes.Add("");
|
codes.Add("");
|
||||||
codes.Add("\t// {{ AOT generic types");
|
codes.Add("\t// {{ AOT generic types");
|
||||||
|
|
||||||
types.Sort((a, b) => a.Type.FullName.CompareTo(b.Type.FullName));
|
List<string> typeNames = types.Select(t => PrettifyTypeSig(t.ToTypeSig().ToString())).ToList();
|
||||||
foreach(var type in types)
|
typeNames.Sort(string.CompareOrdinal);
|
||||||
|
foreach(var typeName in typeNames)
|
||||||
{
|
{
|
||||||
codes.Add($"\t// {PrettifyTypeSig(type.ToTypeSig().ToString())}");
|
codes.Add($"\t// {typeName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
codes.Add("\t// }}");
|
codes.Add("\t// }}");
|
||||||
|
@ -102,27 +103,36 @@ namespace HybridCLR.Editor.AOT
|
||||||
codes.Add("");
|
codes.Add("");
|
||||||
codes.Add("\tpublic void RefMethods()");
|
codes.Add("\tpublic void RefMethods()");
|
||||||
codes.Add("\t{");
|
codes.Add("\t{");
|
||||||
methods.Sort((a, b) =>
|
|
||||||
|
List<(string, string, string)> methodTypeAndNames = methods.Select(m =>
|
||||||
|
(PrettifyTypeSig(m.Method.DeclaringType.ToString()), PrettifyMethodSig(m.Method.Name), PrettifyMethodSig(m.ToMethodSpec().ToString())))
|
||||||
|
.ToList();
|
||||||
|
methodTypeAndNames.Sort((a, b) =>
|
||||||
{
|
{
|
||||||
int c = a.Method.DeclaringType.FullName.CompareTo(b.Method.DeclaringType.FullName);
|
int c = String.Compare(a.Item1, b.Item1, StringComparison.Ordinal);
|
||||||
if (c != 0)
|
if (c != 0)
|
||||||
{
|
{
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
c = a.Method.Name.CompareTo(b.Method.Name);
|
|
||||||
return c;
|
c = String.Compare(a.Item2, b.Item2, StringComparison.Ordinal);
|
||||||
});
|
if (c != 0)
|
||||||
foreach(var method in methods)
|
|
||||||
{
|
{
|
||||||
codes.Add($"\t\t// {PrettifyMethodSig(method.ToMethodSpec().ToString())}");
|
return c;
|
||||||
|
}
|
||||||
|
return String.Compare(a.Item3, b.Item3, StringComparison.Ordinal);
|
||||||
|
});
|
||||||
|
foreach(var method in methodTypeAndNames)
|
||||||
|
{
|
||||||
|
codes.Add($"\t\t// {PrettifyMethodSig(method.Item3)}");
|
||||||
}
|
}
|
||||||
codes.Add("\t}");
|
codes.Add("\t}");
|
||||||
|
|
||||||
codes.Add("}");
|
codes.Add("}");
|
||||||
|
|
||||||
|
|
||||||
var utf8WithoutBOM = new System.Text.UTF8Encoding(false);
|
var utf8WithoutBom = new System.Text.UTF8Encoding(false);
|
||||||
File.WriteAllText(outputFile, string.Join("\n", codes), utf8WithoutBOM);
|
File.WriteAllText(outputFile, string.Join("\n", codes), utf8WithoutBom);
|
||||||
Debug.Log($"[GenericReferenceWriter] write {outputFile}");
|
Debug.Log($"[GenericReferenceWriter] write {outputFile}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue