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 icsharpcode#2932
  • Loading branch information
workgroupengineering committed Jun 17, 2023
1 parent 4514e33 commit b6f606e
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion ILSpy/TreeNodes/AssemblyReferenceTreeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,11 @@ public AssemblyReferenceTreeNode(AssemblyReference r, AssemblyTreeNode parentAss
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 +84,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 +111,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 b6f606e

Please sign in to comment.