Skip to content

Commit

Permalink
feat(UI): Use AssemblyWarning when AssemblyReference load faulted
Browse files Browse the repository at this point in the history
Allow you to easily and quickly see the reference libraries not found fixes #2932
  • Loading branch information
workgroupengineering authored and spaccabit committed Jun 21, 2023
1 parent d57b08c commit d800e1e
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions ILSpy/TreeNodes/AssemblyReferenceTreeNode.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
Expand All @@ -31,6 +31,7 @@ public sealed class AssemblyReferenceTreeNode : ILSpyTreeNode
{
readonly AssemblyReference r;
readonly AssemblyTreeNode parentAssembly;
private bool? loadFualt;

public AssemblyReferenceTreeNode(AssemblyReference r, AssemblyTreeNode parentAssembly)
{
Expand All @@ -45,7 +46,10 @@ public override object Text {
get { return Language.EscapeName(r.Name) + GetSuffixString(r.Handle); }
}

public override object Icon => Images.Assembly;
public override object Icon => loadFualt switch {
true => Images.AssemblyWarning,
_ => Images.Assembly
};

public override bool ShowExpander {
get {
Expand Down Expand Up @@ -79,9 +83,15 @@ protected override void LoadChildren()
var module = resolver.Resolve(r);
if (module != null)
{
loadFualt = false;
foreach (var childRef in module.AssemblyReferences)
this.Children.Add(new AssemblyReferenceTreeNode(childRef, parentAssembly));
}
else
{
loadFualt = true;
}
RaisePropertyChanged(nameof(Icon));
}

public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
Expand All @@ -100,14 +110,22 @@ public override void Decompile(Language language, ITextOutput output, Decompilat
output.Indent();
language.WriteCommentLine(output, "Assembly reference loading information:");
if (info.HasErrors)
{
language.WriteCommentLine(output, "There were some problems during assembly reference load, see below for more information!");
loadFualt = true;
}
else
{
loadFualt = false;
}
foreach (var item in info.Messages)
{
language.WriteCommentLine(output, $"{item.Item1}: {item.Item2}");
}
output.Unindent();
output.WriteLine();
}
RaisePropertyChanged(nameof(Icon));
}
}
}

0 comments on commit d800e1e

Please sign in to comment.