Skip to content

Commit ad2d9d6

Browse files
feat(UI): Use AssemblyWarning when AssemblyReference load faulted
Allow you to easily and quickly see the reference libraries not found fixes #2932
1 parent 2aad681 commit ad2d9d6

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

ILSpy/TreeNodes/AssemblyReferenceTreeNode.cs

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
2-
//
2+
//
33
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
44
// software and associated documentation files (the "Software"), to deal in the Software
55
// without restriction, including without limitation the rights to use, copy, modify, merge,
66
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
77
// to whom the Software is furnished to do so, subject to the following conditions:
8-
//
8+
//
99
// The above copyright notice and this permission notice shall be included in all copies or
1010
// substantial portions of the Software.
11-
//
11+
//
1212
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
1313
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
1414
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
@@ -31,6 +31,7 @@ public sealed class AssemblyReferenceTreeNode : ILSpyTreeNode
3131
{
3232
readonly AssemblyReference r;
3333
readonly AssemblyTreeNode parentAssembly;
34+
private bool? loadFualt;
3435

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

48-
public override object Icon => Images.Assembly;
49+
public override object Icon => loadFualt switch {
50+
true => Images.AssemblyWarning,
51+
_ => Images.Assembly
52+
};
4953

5054
public override bool ShowExpander {
5155
get {
@@ -79,9 +83,15 @@ protected override void LoadChildren()
7983
var module = resolver.Resolve(r);
8084
if (module != null)
8185
{
86+
loadFualt = false;
8287
foreach (var childRef in module.AssemblyReferences)
8388
this.Children.Add(new AssemblyReferenceTreeNode(childRef, parentAssembly));
8489
}
90+
else
91+
{
92+
loadFualt = true;
93+
}
94+
RaisePropertyChanged(nameof(Icon));
8595
}
8696

8797
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
@@ -100,14 +110,22 @@ public override void Decompile(Language language, ITextOutput output, Decompilat
100110
output.Indent();
101111
language.WriteCommentLine(output, "Assembly reference loading information:");
102112
if (info.HasErrors)
113+
{
103114
language.WriteCommentLine(output, "There were some problems during assembly reference load, see below for more information!");
115+
loadFualt = true;
116+
}
117+
else
118+
{
119+
loadFualt = false;
120+
}
104121
foreach (var item in info.Messages)
105122
{
106123
language.WriteCommentLine(output, $"{item.Item1}: {item.Item2}");
107124
}
108125
output.Unindent();
109126
output.WriteLine();
110127
}
128+
RaisePropertyChanged(nameof(Icon));
111129
}
112130
}
113131
}

0 commit comments

Comments
 (0)