mirror of https://github.com/icsharpcode/ILSpy.git
22 changed files with 1010 additions and 48 deletions
@ -0,0 +1,103 @@
@@ -0,0 +1,103 @@
|
||||
// Copyright (c) 2023 James May
|
||||
//
|
||||
// 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
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#nullable enable |
||||
|
||||
using System; |
||||
using System.Collections.Immutable; |
||||
using System.Linq; |
||||
using System.Reflection; |
||||
using System.Reflection.Metadata; |
||||
|
||||
namespace ICSharpCode.Decompiler.Metadata |
||||
{ |
||||
#if !VSADDIN
|
||||
/// <summary>
|
||||
/// Convenience wrapper for <see cref="ExportedType"/> and <see cref="ExportedTypeHandle"/>.
|
||||
/// </summary>
|
||||
public sealed class ExportedTypeMetadata |
||||
{ |
||||
readonly ExportedType entry; |
||||
|
||||
public MetadataReader Metadata { get; } |
||||
public ExportedTypeHandle Handle { get; } |
||||
|
||||
string? name; |
||||
public string Name { |
||||
get { |
||||
try |
||||
{ |
||||
return name ??= Metadata.GetString(entry.Name); |
||||
} |
||||
catch (BadImageFormatException) |
||||
{ |
||||
return name = $"ET:{Handle}"; |
||||
} |
||||
} |
||||
} |
||||
|
||||
string? @namespace; |
||||
public string Namespace { |
||||
get { |
||||
try |
||||
{ |
||||
return @namespace ??= Metadata.GetString(entry.Namespace); |
||||
} |
||||
catch (BadImageFormatException) |
||||
{ |
||||
return @namespace = $"namespace(ET:{Handle})"; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public EntityHandle Implementation => entry.Implementation; |
||||
public TypeAttributes Attributes => entry.Attributes; |
||||
public bool IsForwarder => entry.IsForwarder; |
||||
public NamespaceDefinition NamespaceDefinition => Metadata.GetNamespaceDefinition(entry.NamespaceDefinition); |
||||
|
||||
ImmutableArray<ExportedTypeMetadata> exportedTypes; |
||||
public ImmutableArray<ExportedTypeMetadata> ExportedTypes { |
||||
get { |
||||
var value = exportedTypes; |
||||
if (value.IsDefault) |
||||
{ |
||||
value = Metadata.ExportedTypes |
||||
.Select(r => new ExportedTypeMetadata(Metadata, r)) |
||||
.Where(r => r.Implementation == Handle) |
||||
.OrderBy(r => r.Namespace) |
||||
.ThenBy(r => r.Name) |
||||
.ToImmutableArray(); |
||||
exportedTypes = value; |
||||
} |
||||
return value; |
||||
} |
||||
} |
||||
|
||||
public ExportedTypeMetadata(MetadataReader metadata, ExportedTypeHandle handle) |
||||
{ |
||||
Metadata = metadata ?? throw new ArgumentNullException(nameof(metadata)); |
||||
if (handle.IsNil) |
||||
throw new ArgumentNullException(nameof(handle)); |
||||
Handle = handle; |
||||
entry = metadata.GetExportedType(handle); |
||||
} |
||||
|
||||
public override string ToString() => $"{Namespace}::{Name}"; |
||||
} |
||||
#endif
|
||||
} |
@ -0,0 +1,69 @@
@@ -0,0 +1,69 @@
|
||||
// Copyright (c) 2023 James May
|
||||
//
|
||||
// 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
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#nullable enable |
||||
|
||||
using System; |
||||
using System.Reflection.Metadata; |
||||
|
||||
namespace ICSharpCode.Decompiler.Metadata |
||||
{ |
||||
#if !VSADDIN
|
||||
/// <summary>
|
||||
/// Convenience wrapper for <see cref="MemberReference"/> and <see cref="MemberReferenceHandle"/>.
|
||||
/// </summary>
|
||||
public sealed class MemberReferenceMetadata |
||||
{ |
||||
readonly MemberReference entry; |
||||
|
||||
public MetadataReader Metadata { get; } |
||||
public MemberReferenceHandle Handle { get; } |
||||
|
||||
string? name; |
||||
|
||||
public string Name { |
||||
get { |
||||
try |
||||
{ |
||||
return name ??= Metadata.GetString(entry.Name); |
||||
} |
||||
catch (BadImageFormatException) |
||||
{ |
||||
return name = $"MR:{Handle}"; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public EntityHandle Parent => entry.Parent; |
||||
|
||||
public MemberReferenceKind MemberReferenceKind => entry.GetKind(); |
||||
|
||||
public MemberReferenceMetadata(MetadataReader metadata, MemberReferenceHandle handle) |
||||
{ |
||||
Metadata = metadata ?? throw new ArgumentNullException(nameof(metadata)); |
||||
if (handle.IsNil) |
||||
throw new ArgumentNullException(nameof(handle)); |
||||
Handle = handle; |
||||
entry = metadata.GetMemberReference(handle); |
||||
} |
||||
|
||||
public override string ToString() |
||||
=> Name; |
||||
} |
||||
#endif
|
||||
} |
@ -0,0 +1,132 @@
@@ -0,0 +1,132 @@
|
||||
// Copyright (c) 2023 James May
|
||||
//
|
||||
// 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
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#nullable enable |
||||
|
||||
using System; |
||||
using System.Collections.Immutable; |
||||
using System.Linq; |
||||
using System.Reflection; |
||||
using System.Reflection.Metadata; |
||||
|
||||
namespace ICSharpCode.Decompiler.Metadata |
||||
{ |
||||
#if !VSADDIN
|
||||
public class ModuleReferenceMetadata /* : IModuleReference*/ |
||||
{ |
||||
readonly ModuleReference entry; |
||||
|
||||
public MetadataReader Metadata { get; } |
||||
public ModuleReferenceHandle Handle { get; } |
||||
|
||||
string? name; |
||||
public string Name { |
||||
get { |
||||
if (name == null) |
||||
{ |
||||
try |
||||
{ |
||||
name = Metadata.GetString(entry.Name); |
||||
} |
||||
catch (BadImageFormatException) |
||||
{ |
||||
name = $"AR:{Handle}"; |
||||
} |
||||
} |
||||
return name; |
||||
} |
||||
} |
||||
|
||||
ImmutableArray<CustomAttribute> attributes; |
||||
public ImmutableArray<CustomAttribute> Attributes { |
||||
get { |
||||
var value = attributes; |
||||
if (value.IsDefault) |
||||
{ |
||||
value = entry.GetCustomAttributes().Select(Metadata.GetCustomAttribute).ToImmutableArray(); |
||||
attributes = value; |
||||
} |
||||
return value; |
||||
} |
||||
} |
||||
|
||||
ImmutableArray<TypeReferenceMetadata> typeReferences; |
||||
public ImmutableArray<TypeReferenceMetadata> TypeReferences { |
||||
get { |
||||
var value = typeReferences; |
||||
if (value.IsDefault) |
||||
{ |
||||
value = Metadata.TypeReferences |
||||
.Select(r => new TypeReferenceMetadata(Metadata, r)) |
||||
.Where(r => r.ResolutionScope == Handle) |
||||
.OrderBy(r => r.Namespace) |
||||
.ThenBy(r => r.Name) |
||||
.ToImmutableArray(); |
||||
typeReferences = value; |
||||
} |
||||
return value; |
||||
} |
||||
} |
||||
|
||||
ImmutableArray<ExportedTypeMetadata> exportedTypes; |
||||
public ImmutableArray<ExportedTypeMetadata> ExportedTypes { |
||||
get { |
||||
var value = exportedTypes; |
||||
if (value.IsDefault) |
||||
{ |
||||
value = Metadata.ExportedTypes |
||||
.Select(r => new ExportedTypeMetadata(Metadata, r)) |
||||
.Where(r => r.Implementation == Handle) |
||||
.OrderBy(r => r.Namespace) |
||||
.ThenBy(r => r.Name) |
||||
.ToImmutableArray(); |
||||
exportedTypes = value; |
||||
} |
||||
return value; |
||||
} |
||||
} |
||||
|
||||
public ModuleReferenceMetadata(MetadataReader metadata, ModuleReferenceHandle handle) |
||||
{ |
||||
if (metadata == null) |
||||
throw new ArgumentNullException(nameof(metadata)); |
||||
if (handle.IsNil) |
||||
throw new ArgumentNullException(nameof(handle)); |
||||
Metadata = metadata; |
||||
Handle = handle; |
||||
entry = metadata.GetModuleReference(handle); |
||||
} |
||||
|
||||
public ModuleReferenceMetadata(PEFile module, ModuleReferenceHandle handle) |
||||
{ |
||||
if (module == null) |
||||
throw new ArgumentNullException(nameof(module)); |
||||
if (handle.IsNil) |
||||
throw new ArgumentNullException(nameof(handle)); |
||||
Metadata = module.Metadata; |
||||
Handle = handle; |
||||
entry = Metadata.GetModuleReference(handle); |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return Name; |
||||
} |
||||
} |
||||
#endif
|
||||
} |
@ -0,0 +1,112 @@
@@ -0,0 +1,112 @@
|
||||
// Copyright (c) 2023 James May
|
||||
//
|
||||
// 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
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#nullable enable |
||||
|
||||
using System; |
||||
using System.Collections.Immutable; |
||||
using System.Linq; |
||||
using System.Reflection.Metadata; |
||||
|
||||
namespace ICSharpCode.Decompiler.Metadata |
||||
{ |
||||
#if !VSADDIN
|
||||
public sealed class TypeReferenceMetadata |
||||
{ |
||||
readonly TypeReference entry; |
||||
|
||||
public MetadataReader Metadata { get; } |
||||
public TypeReferenceHandle Handle { get; } |
||||
|
||||
string? name; |
||||
public string Name { |
||||
get { |
||||
try |
||||
{ |
||||
return name ??= Metadata.GetString(entry.Name); |
||||
} |
||||
catch (BadImageFormatException) |
||||
{ |
||||
return name = $"TR:{Handle}"; |
||||
} |
||||
} |
||||
} |
||||
|
||||
string? @namespace; |
||||
public string Namespace { |
||||
get { |
||||
try |
||||
{ |
||||
return @namespace ??= Metadata.GetString(entry.Namespace); |
||||
} |
||||
catch (BadImageFormatException) |
||||
{ |
||||
return @namespace = $"namespace(TR:{Handle})"; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public EntityHandle ResolutionScope => entry.ResolutionScope; |
||||
|
||||
ImmutableArray<MemberReferenceMetadata> memberReferences; |
||||
public ImmutableArray<MemberReferenceMetadata> MemberReferences { |
||||
get { |
||||
var value = memberReferences; |
||||
if (value.IsDefault) |
||||
{ |
||||
value = Metadata.MemberReferences |
||||
.Select(r => new MemberReferenceMetadata(Metadata, r)) |
||||
.Where(r => r.Parent == Handle) |
||||
.OrderBy(r => r.Name) |
||||
.ToImmutableArray(); |
||||
memberReferences = value; |
||||
} |
||||
return value; |
||||
} |
||||
} |
||||
|
||||
ImmutableArray<TypeReferenceMetadata> typeReferences; |
||||
public ImmutableArray<TypeReferenceMetadata> TypeReferences { |
||||
get { |
||||
var value = typeReferences; |
||||
if (value.IsDefault) |
||||
{ |
||||
value = Metadata.TypeReferences |
||||
.Select(r => new TypeReferenceMetadata(Metadata, r)) |
||||
.Where(r => r.ResolutionScope == Handle) |
||||
.OrderBy(r => r.Name) |
||||
.ToImmutableArray(); |
||||
typeReferences = value; |
||||
} |
||||
return value; |
||||
} |
||||
} |
||||
|
||||
public TypeReferenceMetadata(MetadataReader metadata, TypeReferenceHandle handle) |
||||
{ |
||||
Metadata = metadata ?? throw new ArgumentNullException(nameof(metadata)); |
||||
if (handle.IsNil) |
||||
throw new ArgumentNullException(nameof(handle)); |
||||
Handle = handle; |
||||
entry = metadata.GetTypeReference(handle); |
||||
} |
||||
|
||||
public override string ToString() => $"{Namespace}::{Name}"; |
||||
} |
||||
#endif
|
||||
} |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
<DrawingGroup xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" ClipGeometry="M0,0 V16 H16 V0 H0 Z"> |
||||
<DrawingGroup.Transform> |
||||
<TranslateTransform X="12.444443702697754" Y="12.444443702697754" /> |
||||
</DrawingGroup.Transform> |
||||
<DrawingGroup Opacity="1" Transform="0.5625,0,0,1,7,12.444445"> |
||||
<GeometryDrawing Geometry="F1 M16,16z M0,0z M16,-12.444444L16,3.5555556 -12.444444,3.5555556 -12.444444,-12.444444z"> |
||||
<GeometryDrawing.Brush> |
||||
<SolidColorBrush Color="#FFF6F6F6" Opacity="0" /> |
||||
</GeometryDrawing.Brush> |
||||
</GeometryDrawing> |
||||
</DrawingGroup> |
||||
<DrawingGroup Opacity="1" Transform="0.5625,0,0,0.5625,7,7"> |
||||
<GeometryDrawing Brush="#FFF6F6F6" Geometry="F1 M16,16z M0,0z M5.793,0.879L8.621,3.707 7.328,5 10.5,5C13.533,5 16,7.467 16,10.5 16,13.532 13.533,16 10.5,16L9.5,16 9.5,12 10.5,12C11.327,12 12,11.327 12,10.5 12,9.673 11.327,9 10.5,9L7.328,9 8.621,10.293 5.793,13.121 0,7.328 0,6.672z" /> |
||||
</DrawingGroup> |
||||
<DrawingGroup Opacity="1" Transform="0.5625,0,0,0.5625,7,7"> |
||||
<GeometryDrawing Brush="#FF00539C" Geometry="F1 M16,16z M0,0z M5.793,2.293L7.207,3.707 4.914,6 10.5,6C12.981,6 15,8.019 15,10.5 15,12.981 12.981,15 10.5,15L10.5,13C11.878,13 13,11.879 13,10.5 13,9.121 11.878,8 10.5,8L4.914,8 7.207,10.293 5.793,11.707 1.086,7z" /> |
||||
</DrawingGroup> |
||||
</DrawingGroup> |
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
<DrawingGroup xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" ClipGeometry="M0,0 V16 H16 V0 H0 Z"> |
||||
<DrawingGroup Opacity="1"> |
||||
<GeometryDrawing Geometry="F1 M16,16z M0,0z M0,0L16,0 16,16 0,16z"> |
||||
<GeometryDrawing.Brush> |
||||
<SolidColorBrush Color="#FFF6F6F6" Opacity="0" /> |
||||
</GeometryDrawing.Brush> |
||||
</GeometryDrawing> |
||||
<GeometryDrawing Brush="#FFF6F6F6" Geometry="F1 M16,16z M0,0z M9,9L9,16 16,16 16,9z" /> |
||||
</DrawingGroup> |
||||
<GeometryDrawing Brush="#FF424242" Geometry="F1 M16,16z M0,0z M10,10L10,15 15,15 15,10 10,10z M14,13L13,14 13,12.5 11.5,14 11,13.5 12.5,12 11,12 12,11 14,11 14,13z" /> |
||||
<GeometryDrawing Brush="#FFF0EFF1" Geometry="F1 M16,16z M0,0z M14,11L14,13 13,14 13,12.5 11.5,14 11,13.5 12.5,12 11,12 12,11z" /> |
||||
</DrawingGroup> |
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
// Copyright (c) 2023 James May
|
||||
//
|
||||
// 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
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
|
||||
using ICSharpCode.Decompiler; |
||||
using ICSharpCode.Decompiler.Metadata; |
||||
using ICSharpCode.Decompiler.TypeSystem; |
||||
|
||||
namespace ICSharpCode.ILSpy.TreeNodes |
||||
{ |
||||
/// <summary>
|
||||
/// Referenced Types node in assembly reference list
|
||||
/// </summary>
|
||||
public sealed class AssemblyReferenceReferencedTypesTreeNode : ILSpyTreeNode |
||||
{ |
||||
readonly MetadataModule module; |
||||
readonly AssemblyReference r; |
||||
|
||||
public AssemblyReferenceReferencedTypesTreeNode(MetadataModule module, AssemblyReference r) |
||||
{ |
||||
this.module = module ?? throw new ArgumentNullException(nameof(module)); |
||||
this.r = r ?? throw new ArgumentNullException(nameof(r)); |
||||
|
||||
this.LazyLoading = true; |
||||
} |
||||
|
||||
public override object Text => $"Referenced Types ({r.TypeReferences.Length + r.ExportedTypes.Length})"; |
||||
public override object Icon => Images.MetadataTable; |
||||
|
||||
protected override void LoadChildren() |
||||
{ |
||||
foreach (var typeRef in r.TypeReferences) |
||||
this.Children.Add(new TypeReferenceTreeNode(module, typeRef)); |
||||
|
||||
foreach (var exportedType in r.ExportedTypes) |
||||
this.Children.Add(new ExportedTypeTreeNode(module, exportedType)); |
||||
} |
||||
|
||||
public override bool ShowExpander => !r.TypeReferences.IsEmpty || !r.ExportedTypes.IsEmpty; |
||||
|
||||
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options) |
||||
{ |
||||
EnsureLazyChildren(); |
||||
foreach (ILSpyTreeNode child in Children) |
||||
child.Decompile(language, output, options); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,63 @@
@@ -0,0 +1,63 @@
|
||||
// Copyright (c) 2023 James May
|
||||
//
|
||||
// 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
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
|
||||
using ICSharpCode.Decompiler; |
||||
using ICSharpCode.Decompiler.Metadata; |
||||
using ICSharpCode.Decompiler.TypeSystem; |
||||
|
||||
namespace ICSharpCode.ILSpy.TreeNodes |
||||
{ |
||||
/// <summary>
|
||||
/// exported type within assembly reference list.
|
||||
/// </summary>
|
||||
public sealed class ExportedTypeTreeNode : ILSpyTreeNode |
||||
{ |
||||
readonly MetadataModule module; |
||||
readonly ExportedTypeMetadata r; |
||||
readonly IType resolvedType; |
||||
|
||||
public ExportedTypeTreeNode(MetadataModule module, ExportedTypeMetadata r) |
||||
{ |
||||
this.module = module ?? throw new ArgumentNullException(nameof(module)); |
||||
this.r = r ?? throw new ArgumentNullException(nameof(r)); |
||||
this.resolvedType = module.ResolveType(r.Handle, default); |
||||
|
||||
this.LazyLoading = true; |
||||
} |
||||
|
||||
public override object Text |
||||
=> Language.TypeToString(resolvedType, includeNamespace: true) + GetSuffixString(r.Handle); |
||||
|
||||
public override object Icon => Images.ExportedType; |
||||
|
||||
protected override void LoadChildren() |
||||
{ |
||||
foreach (var exportedType in r.ExportedTypes) |
||||
this.Children.Add(new ExportedTypeTreeNode(module, exportedType)); |
||||
} |
||||
|
||||
public override bool ShowExpander => !r.ExportedTypes.IsEmpty; |
||||
|
||||
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options) |
||||
{ |
||||
language.WriteCommentLine(output, $"{Language.TypeToString(resolvedType, includeNamespace: true)} (Exported, IsForwarder: {r.IsForwarder}, Attributes: {(int)r.Attributes:X8})"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,67 @@
@@ -0,0 +1,67 @@
|
||||
// Copyright (c) 2023 James May
|
||||
//
|
||||
// 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
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#nullable enable |
||||
|
||||
using System; |
||||
using System.Reflection.Metadata; |
||||
|
||||
using ICSharpCode.Decompiler; |
||||
using ICSharpCode.Decompiler.Metadata; |
||||
using ICSharpCode.Decompiler.TypeSystem; |
||||
|
||||
namespace ICSharpCode.ILSpy.TreeNodes |
||||
{ |
||||
/// <summary>
|
||||
/// Reference to member from assembly reference list.
|
||||
/// </summary>
|
||||
public sealed class MemberReferenceTreeNode : ILSpyTreeNode |
||||
{ |
||||
readonly MetadataModule module; |
||||
readonly MemberReferenceMetadata r; |
||||
readonly IMember resolvedMember; |
||||
|
||||
public MemberReferenceTreeNode(MetadataModule module, MemberReferenceMetadata r) |
||||
{ |
||||
this.module = module ?? throw new ArgumentNullException(nameof(module)); |
||||
this.r = r; |
||||
this.resolvedMember = r.MemberReferenceKind switch { |
||||
MemberReferenceKind.Method => module.ResolveMethod(r.Handle, default), |
||||
MemberReferenceKind.Field => (IMember)module.ResolveEntity(r.Handle), |
||||
_ => throw new NotSupportedException(), |
||||
}; |
||||
} |
||||
|
||||
public override object Text => Signature + GetSuffixString(r.Handle); |
||||
|
||||
public override object Icon => r.MemberReferenceKind switch { |
||||
MemberReferenceKind.Method => Images.MethodReference, |
||||
MemberReferenceKind.Field => Images.FieldReference, |
||||
_ => throw new NotSupportedException(), |
||||
}; |
||||
|
||||
public string Signature => resolvedMember is IMethod m ? Language.MethodToString(m, false, false, false) : Language.FieldToString((IField)resolvedMember, false, false, false); |
||||
|
||||
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options) |
||||
{ |
||||
language.WriteCommentLine(output, Signature); |
||||
} |
||||
|
||||
public override object ToolTip => Language.GetRichTextTooltip(resolvedMember); |
||||
} |
||||
} |
@ -0,0 +1,73 @@
@@ -0,0 +1,73 @@
|
||||
// Copyright (c) 2023 James May
|
||||
//
|
||||
// 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
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
|
||||
using ICSharpCode.Decompiler; |
||||
using ICSharpCode.Decompiler.Metadata; |
||||
using ICSharpCode.Decompiler.TypeSystem; |
||||
|
||||
namespace ICSharpCode.ILSpy.TreeNodes |
||||
{ |
||||
/// <summary>
|
||||
/// referenced type within assembly reference list.
|
||||
/// </summary>
|
||||
public sealed class TypeReferenceTreeNode : ILSpyTreeNode |
||||
{ |
||||
readonly MetadataModule module; |
||||
readonly TypeReferenceMetadata r; |
||||
readonly IType resolvedType; |
||||
|
||||
public TypeReferenceTreeNode(MetadataModule module, TypeReferenceMetadata r) |
||||
{ |
||||
this.module = module ?? throw new ArgumentNullException(nameof(module)); |
||||
this.r = r ?? throw new ArgumentNullException(nameof(r)); |
||||
this.resolvedType = module.ResolveType(r.Handle, default); |
||||
|
||||
this.LazyLoading = true; |
||||
} |
||||
|
||||
public override object Text |
||||
=> Language.TypeToString(resolvedType, includeNamespace: false) + GetSuffixString(r.Handle); |
||||
|
||||
public override object Icon => Images.TypeReference; |
||||
|
||||
protected override void LoadChildren() |
||||
{ |
||||
foreach (var typeRef in r.TypeReferences) |
||||
this.Children.Add(new TypeReferenceTreeNode(module, typeRef)); |
||||
|
||||
foreach (var memberRef in r.MemberReferences) |
||||
this.Children.Add(new MemberReferenceTreeNode(module, memberRef)); |
||||
} |
||||
|
||||
public override bool ShowExpander => !r.TypeReferences.IsEmpty || !r.MemberReferences.IsEmpty; |
||||
|
||||
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options) |
||||
{ |
||||
language.WriteCommentLine(output, Language.TypeToString(resolvedType, includeNamespace: true)); |
||||
EnsureLazyChildren(); |
||||
foreach (ILSpyTreeNode child in Children) |
||||
{ |
||||
output.Indent(); |
||||
child.Decompile(language, output, options); |
||||
output.Unindent(); |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue