mirror of
https://github.com/ZuneDev/ZuneUIXTools.git
synced 2026-07-27 13:11:59 -07:00
Deduplicate disassembly imports
This commit is contained in:
@@ -19,16 +19,14 @@ public class Disassembler
|
|||||||
|
|
||||||
public IEnumerable<IImport> GetImports()
|
public IEnumerable<IImport> GetImports()
|
||||||
{
|
{
|
||||||
|
// Keep track of which namespaces have already been imported,
|
||||||
|
// and skip self and default UIX namespace
|
||||||
|
HashSet<string> importedUris = [_loadResult.Uri, "http://schemas.microsoft.com/2007/uix"];
|
||||||
|
|
||||||
foreach (var typeImport in _loadResult.ImportTables.TypeImports)
|
foreach (var typeImport in _loadResult.ImportTables.TypeImports)
|
||||||
{
|
{
|
||||||
var uri = typeImport.Owner.Uri;
|
var uri = typeImport.Owner.Uri;
|
||||||
|
if (importedUris.Contains(uri))
|
||||||
// Skip default UIX namespace
|
|
||||||
if (uri == "http://schemas.microsoft.com/2007/uix")
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Skip self
|
|
||||||
if (uri == _loadResult.Uri)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
string name = uri;
|
string name = uri;
|
||||||
@@ -61,7 +59,6 @@ public class Disassembler
|
|||||||
var reader = _loadResult.ObjectSection;
|
var reader = _loadResult.ObjectSection;
|
||||||
|
|
||||||
// Insert a label to mark the start of the object section.
|
// Insert a label to mark the start of the object section.
|
||||||
// In the future, this might use a special directive like `.section object`
|
|
||||||
yield return new SectionDirective("object");
|
yield return new SectionDirective("object");
|
||||||
|
|
||||||
while (reader.CurrentOffset < reader.Size)
|
while (reader.CurrentOffset < reader.Size)
|
||||||
|
|||||||
Reference in New Issue
Block a user