mirror of
https://github.com/ZuneDev/ZuneUIXTools.git
synced 2026-07-27 13:11:59 -07:00
Fix assembly:// imports that don't specify a namespace
This commit is contained in:
@@ -102,13 +102,19 @@ public class Disassembler
|
|||||||
if (scheme == "assembly")
|
if (scheme == "assembly")
|
||||||
{
|
{
|
||||||
// Assume 'host' is an assembly name and path represents a C# namespace
|
// Assume 'host' is an assembly name and path represents a C# namespace
|
||||||
var assemblyUriParts = uri.Split('/');
|
var path = uri[(schemeLength + 3)..];
|
||||||
|
var nsIndex = path.IndexOf('/');
|
||||||
var importedNamespace = assemblyUriParts[^1];
|
if (nsIndex >= 0)
|
||||||
namespacePrefix = importedNamespace.Split('.', '/', '\\', '!')[^1];
|
{
|
||||||
|
var importedNamespace = path[(nsIndex + 1)..];
|
||||||
System.Reflection.AssemblyName assemblyName = new(assemblyUriParts[^2]);
|
namespacePrefix = importedNamespace.Split('.', '/', '\\', '!')[^1];
|
||||||
uri = $"{scheme}://{assemblyName.Name}/{importedNamespace}";
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// No namespace was specified, assume we're importing the whole assembly
|
||||||
|
System.Reflection.AssemblyName assemblyName = new(path);
|
||||||
|
namespacePrefix = assemblyName.Name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -202,7 +208,9 @@ public class Disassembler
|
|||||||
}
|
}
|
||||||
|
|
||||||
var runtimeType = constantValue.GetType();
|
var runtimeType = constantValue.GetType();
|
||||||
var typeSchema = _loadResult.ImportTables.TypeImports.FirstOrDefault(t => t.RuntimeType == runtimeType);
|
var typeSchema = _loadResult.ImportTables.TypeImports.FirstOrDefault(t => t.RuntimeType == runtimeType)
|
||||||
|
?? _loadResult.ImportTables.TypeImports.FirstOrDefault(t => t.RuntimeType == runtimeType.BaseType)
|
||||||
|
?? throw new Exception($"Failed to find type schema for '{runtimeType.Name}' in {_loadResult.Uri}");
|
||||||
|
|
||||||
constants.Add((c, typeSchema, constantValue));
|
constants.Add((c, typeSchema, constantValue));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user