Browse Source

feat(UI): Use AssemblyWarning when AssemblyReference load faulted

Allow you to easily and quickly see the reference libraries not found fixes #2932
pull/3013/head
Giuseppe Lippolis 2 years ago
parent
commit
935cf67a4f
  1. 49
      ILSpy/Images/AssemblyLoading.svg
  2. 28
      ILSpy/Images/AssemblyLoading.xaml
  3. 1
      ILSpy/Images/Images.cs
  4. 41
      ILSpy/TreeNodes/AssemblyReferenceTreeNode.cs

49
ILSpy/Images/AssemblyLoading.svg

@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
viewBox="0 0 16 16"
version="1.1"
id="svg3"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs3" />
<style
id="style1">.st0{opacity:0}.st0,.st1{fill:#f6f6f6}.st2{fill:#424242}</style>
<g
id="outline">
<path
class="st0"
d="M0 0h16v16H0z"
id="path1" />
<path
class="st1"
d="M16 3v9H8V9H6v2H0V4h6v2h2V3h8z"
id="path2" />
</g>
<g
id="icon_x5F_bg">
<path
class="st2"
d="M1 5h4v5H1zM9 4h6v7H9zM6 7h2v1H6z"
id="path3" />
</g>
<path
class="icon-canvas-transparent"
d="M 16,8.000001 V 16 H 8.000001 V 8.000001 Z"
id="canvas"
style="opacity:0;fill:#f6f6f6;stroke-width:0.5" />
<path
class="icon-vs-out"
d="m 16,12 c 0,2.2055 -1.7945,4 -4,4 C 9.7945007,16 8.000001,14.2055 8.000001,12 A 3.9949993,3.9949993 0 0 1 8.5440009,10.000001 H 8.000001 v -2 H 12 V 12 h -1.999999 c 0,1.103 0.896999,2 1.999999,2 1.103,0 2,-0.897 2,-2 0,-0.672 -0.3345,-1.294999 -0.895,-1.666999 l -0.4165,-0.277 1.1075,-1.6660001 0.4165,0.2765 A 3.9959993,3.9959993 0 0 1 16,12 Z"
id="outline-9"
style="fill:#f6f6f6;stroke-width:0.5" />
<g
id="iconBg"
transform="matrix(0.49999992,0,0,0.49999992,8.000001,8.000001)">
<path
class="icon-vs-action-blue"
d="m 15,8 c 0,3.859 -3.141,7 -7,7 C 4.14,15 1,11.859 1,8 A 7,7 0 0 1 3.12,3 H 1 V 1 H 7 V 7 H 5 V 4.002 A 5.01,5.01 0 0 0 3,8 c 0,2.757 2.243,5 5,5 2.757,0 5,-2.243 5,-5 A 4.993,4.993 0 0 0 10.764,3.833 L 11.871,2.167 A 6.989,6.989 0 0 1 15,8 Z"
id="path1-1"
style="fill:#00539c" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

28
ILSpy/Images/AssemblyLoading.xaml

@ -0,0 +1,28 @@ @@ -0,0 +1,28 @@
<?xml version="1.0" ?>
<DrawingGroup xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<DrawingGroup.ClipGeometry>
<RectangleGeometry Rect="0.0,0.0,16.0,16.0"/>
</DrawingGroup.ClipGeometry>
<GeometryDrawing Brush="#fff6f6f6">
<GeometryDrawing.Geometry>
<PathGeometry Figures="M 16 3 v 9 H 8 V 9 H 6 v 2 H 0 V 4 h 6 v 2 h 2 V 3 h 8 z" FillRule="Nonzero"/>
</GeometryDrawing.Geometry>
</GeometryDrawing>
<GeometryDrawing Brush="#ff424242">
<GeometryDrawing.Geometry>
<PathGeometry Figures="M 1 5 h 4 v 5 H 1 z M 9 4 h 6 v 7 H 9 z M 6 7 h 2 v 1 H 6 z" FillRule="Nonzero"/>
</GeometryDrawing.Geometry>
</GeometryDrawing>
<GeometryDrawing Brush="#fff6f6f6">
<GeometryDrawing.Geometry>
<PathGeometry Figures="m 16 12 c 0 2.2055 -1.7945 4 -4 4 C 9.7945 16 8 14.2055 8 12 A 3.995 3.995 0 0 1 8.544 10 H 8 v -2 H 12 V 12 h -2 c 0 1.103 0.896999 2 2 2 c 1.103 0 2 -0.897 2 -2 c 0 -0.672 -0.3345 -1.295 -0.895 -1.667 l -0.4165 -0.277 l 1.1075 -1.666 l 0.4165 0.2765 A 3.996 3.996 0 0 1 16 12 Z" FillRule="Nonzero"/>
</GeometryDrawing.Geometry>
</GeometryDrawing>
<DrawingGroup Transform="0.49999992,0.0,0.0,0.49999992,8.000001,8.000001">
<GeometryDrawing Brush="#ff00539c">
<GeometryDrawing.Geometry>
<PathGeometry Figures="m 15 8 c 0 3.859 -3.141 7 -7 7 C 4.14 15 1 11.859 1 8 A 7 7 0 0 1 3.12 3 H 1 V 1 H 7 V 7 H 5 V 4.002 A 5.01 5.01 0 0 0 3 8 c 0 2.757 2.243 5 5 5 c 2.757 0 5 -2.243 5 -5 A 4.993 4.993 0 0 0 10.764 3.833 L 11.871 2.167 A 6.989 6.989 0 0 1 15 8 Z" FillRule="Nonzero"/>
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingGroup>
</DrawingGroup>

1
ILSpy/Images/Images.cs

@ -51,6 +51,7 @@ namespace ICSharpCode.ILSpy @@ -51,6 +51,7 @@ namespace ICSharpCode.ILSpy
public static readonly ImageSource Assembly = Load("Assembly");
public static readonly ImageSource AssemblyWarning = Load("AssemblyWarning");
public static readonly ImageSource AssemblyLoading = Load(nameof(AssemblyLoading));
public static readonly ImageSource FindAssembly = Load("FindAssembly");
public static readonly ImageSource Library = Load("Library");

41
ILSpy/TreeNodes/AssemblyReferenceTreeNode.cs

@ -30,9 +30,18 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -30,9 +30,18 @@ namespace ICSharpCode.ILSpy.TreeNodes
/// </summary>
public sealed class AssemblyReferenceTreeNode : ILSpyTreeNode
{
private enum LoadState
{
Unloaded,
Loading,
Loadded,
Failed
}
readonly MetadataModule module;
readonly AssemblyReference r;
readonly AssemblyTreeNode parentAssembly;
MetadataFile referencedModule;
private LoadState state;
public AssemblyReferenceTreeNode(MetadataModule module, AssemblyReference r, AssemblyTreeNode parentAssembly)
{
@ -48,7 +57,27 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -48,7 +57,27 @@ namespace ICSharpCode.ILSpy.TreeNodes
get { return Language.EscapeName(r.Name) + GetSuffixString(r.Handle); }
}
public override object Icon => Images.Assembly;
public override object Icon {
get {
if (state == LoadState.Unloaded)
{
state = LoadState.Loading;
Dispatcher.CurrentDispatcher.BeginInvoke(() => {
var resolver = parentAssembly.LoadedAssembly.GetAssemblyResolver(MainWindow.Instance.CurrentDecompilerSettings.AutoLoadAssemblyReferences);
referencedModule = resolver.Resolve(r);
state = referencedModule is null
? LoadState.Failed
: LoadState.Loadded;
RaisePropertyChanged(nameof(Icon));
}, DispatcherPriority.Background);
}
return state switch {
LoadState.Loadded => Images.Assembly,
LoadState.Failed => Images.AssemblyWarning,
_ => Images.AssemblyLoading,
};
}
}
public override bool ShowExpander {
get {
@ -60,7 +89,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -60,7 +89,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
// while the list of references is updated causes problems with WPF's ListView rendering.
// Moving the assembly resolving out of the "add assembly reference"-loop by using the
// dispatcher fixes the issue.
Dispatcher.CurrentDispatcher.BeginInvoke((Action)EnsureLazyChildren, DispatcherPriority.Normal);
Dispatcher.CurrentDispatcher.BeginInvoke(EnsureLazyChildren, DispatcherPriority.Normal);
}
return base.ShowExpander;
}
@ -79,10 +108,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -79,10 +108,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
protected override void LoadChildren()
{
this.Children.Add(new AssemblyReferenceReferencedTypesTreeNode(module, r));
var resolver = parentAssembly.LoadedAssembly.GetAssemblyResolver(MainWindow.Instance.CurrentDecompilerSettings.AutoLoadAssemblyReferences);
var referencedModule = resolver.Resolve(r);
if (referencedModule != null)
if (referencedModule is not null)
{
var module = (MetadataModule)referencedModule.GetTypeSystemWithCurrentOptionsOrNull().MainModule;
foreach (var childRef in referencedModule.AssemblyReferences)
@ -106,7 +132,10 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -106,7 +132,10 @@ namespace ICSharpCode.ILSpy.TreeNodes
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!");
state = LoadState.Failed;
}
foreach (var item in info.Messages)
{
language.WriteCommentLine(output, $"{item.Item1}: {item.Item2}");

Loading…
Cancel
Save