Browse Source

Move search functionality to ILSpyX

pull/2697/head
Siegfried Pammer 3 years ago
parent
commit
e8a480d43f
  1. 36
      ICSharpCode.ILSpyX/Abstractions/ILanguage.cs
  2. 44
      ICSharpCode.ILSpyX/Abstractions/ITreeNode.cs
  3. 27
      ICSharpCode.ILSpyX/ApiVisibility.cs
  4. 6
      ICSharpCode.ILSpyX/LoadedAssemblyExtensions.cs
  5. 96
      ICSharpCode.ILSpyX/Search/AbstractEntitySearchStrategy.cs
  6. 25
      ICSharpCode.ILSpyX/Search/AbstractSearchStrategy.cs
  7. 12
      ICSharpCode.ILSpyX/Search/AssemblySearchStrategy.cs
  8. 5
      ICSharpCode.ILSpyX/Search/CSharpLexer.cs
  9. 9
      ICSharpCode.ILSpyX/Search/LiteralSearchStrategy.cs
  10. 7
      ICSharpCode.ILSpyX/Search/MemberSearchStrategy.cs
  11. 7
      ICSharpCode.ILSpyX/Search/MetadataTokenSearchStrategy.cs
  12. 14
      ICSharpCode.ILSpyX/Search/NamespaceSearchStrategy.cs
  13. 33
      ICSharpCode.ILSpyX/Search/ResourceSearchStrategy.cs
  14. 62
      ICSharpCode.ILSpyX/Search/SearchResult.cs
  15. 3
      ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs
  16. 1
      ILSpy/ContextMenuEntry.cs
  17. 9
      ILSpy/FilterSettings.cs
  18. 3
      ILSpy/Languages/Language.cs
  19. 3
      ILSpy/MainWindow.xaml
  20. 1
      ILSpy/MainWindow.xaml.cs
  21. 23
      ILSpy/Search/SearchPane.cs
  22. 2
      ILSpy/Search/SearchPane.xaml
  23. 166
      ILSpy/Search/SearchResultFactory.cs
  24. 1
      ILSpy/SessionSettings.cs
  25. 1
      ILSpy/TreeNodes/EventTreeNode.cs
  26. 1
      ILSpy/TreeNodes/FieldTreeNode.cs
  27. 6
      ILSpy/TreeNodes/ILSpyTreeNode.cs
  28. 1
      ILSpy/TreeNodes/MethodTreeNode.cs
  29. 1
      ILSpy/TreeNodes/PropertyTreeNode.cs
  30. 1
      ILSpy/TreeNodes/ResourceListTreeNode.cs
  31. 3
      ILSpy/TreeNodes/ResourceNodes/CursorResourceEntryNode.cs
  32. 3
      ILSpy/TreeNodes/ResourceNodes/IResourceNodeFactory.cs
  33. 3
      ILSpy/TreeNodes/ResourceNodes/IconResourceEntryNode.cs
  34. 3
      ILSpy/TreeNodes/ResourceNodes/ImageListResourceEntryNode.cs
  35. 3
      ILSpy/TreeNodes/ResourceNodes/ImageResourceEntryNode.cs
  36. 3
      ILSpy/TreeNodes/ResourceNodes/ResourceEntryNode.cs
  37. 4
      ILSpy/TreeNodes/ResourceNodes/ResourceTreeNode.cs
  38. 5
      ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs
  39. 3
      ILSpy/TreeNodes/ResourceNodes/XamlResourceNode.cs
  40. 3
      ILSpy/TreeNodes/ResourceNodes/XmlResourceNode.cs
  41. 1
      ILSpy/TreeNodes/TypeTreeNode.cs

36
ICSharpCode.ILSpyX/Abstractions/ILanguage.cs

@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
// Copyright (c) 2022 Siegfried Pammer
//
// 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 ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.ILSpyX.Abstractions
{
public interface ILanguage
{
bool ShowMember(IEntity member);
string GetEntityName(PEFile module, System.Reflection.Metadata.EntityHandle handle, bool fullName, bool omitGenerics);
string GetTooltip(IEntity entity);
string TypeToString(IType type, bool includeNamespace);
string MethodToString(IMethod method, bool includeDeclaringTypeName, bool includeNamespace, bool includeNamespaceOfDeclaringTypeName);
string FieldToString(IField field, bool includeDeclaringTypeName, bool includeNamespace, bool includeNamespaceOfDeclaringTypeName);
string PropertyToString(IProperty property, bool includeDeclaringTypeName, bool includeNamespace, bool includeNamespaceOfDeclaringTypeName);
string EventToString(IEvent @event, bool includeDeclaringTypeName, bool includeNamespace, bool includeNamespaceOfDeclaringTypeName);
}
}

44
ICSharpCode.ILSpyX/Abstractions/ITreeNode.cs

@ -0,0 +1,44 @@ @@ -0,0 +1,44 @@
// Copyright (c) 2022 Siegfried Pammer
//
// 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.Collections.Generic;
using ICSharpCode.Decompiler.Metadata;
namespace ICSharpCode.ILSpyX.Abstractions
{
public interface ITreeNode
{
object Text { get; }
object Icon { get; }
IEnumerable<ITreeNode> Children { get; }
void EnsureLazyChildren();
}
public interface IResourcesFileTreeNode : ITreeNode
{
Resource Resource { get; }
}
public interface ITreeNodeFactory
{
ITreeNode CreateResourcesList(PEFile module);
ITreeNode Create(Resource resource);
}
}

27
ICSharpCode.ILSpyX/ApiVisibility.cs

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
// 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
// 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.
namespace ICSharpCode.ILSpyX
{
public enum ApiVisibility
{
PublicOnly,
PublicAndInternal,
All
}
}

6
ICSharpCode.ILSpyX/LoadedAssemblyExtensions.cs

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
using System;
using System.IO;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.DebugInfo;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
@ -46,6 +47,11 @@ namespace ICSharpCode.ILSpyX @@ -46,6 +47,11 @@ namespace ICSharpCode.ILSpyX
return GetLoadedAssembly(file).GetTypeSystemOrNull();
}
public static ICompilation? GetTypeSystemWithDecompilerSettingsOrNull(this PEFile file, DecompilerSettings settings)
{
return GetLoadedAssembly(file).GetTypeSystemOrNull(DecompilerTypeSystem.GetOptions(settings));
}
public static LoadedAssembly GetLoadedAssembly(this PEFile file)
{
if (file == null)

96
ICSharpCode.ILSpyX/Search/AbstractEntitySearchStrategy.cs

@ -0,0 +1,96 @@ @@ -0,0 +1,96 @@
// 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
// 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 System.Collections.Concurrent;
namespace ICSharpCode.ILSpyX.Search
{
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpyX.Abstractions;
abstract class AbstractEntitySearchStrategy : AbstractSearchStrategy
{
protected readonly ILanguage language;
protected readonly ApiVisibility apiVisibility;
protected AbstractEntitySearchStrategy(ILanguage language, ApiVisibility apiVisibility,
SearchRequest searchRequest, IProducerConsumerCollection<SearchResult> resultQueue)
: base(searchRequest, resultQueue)
{
this.language = language;
this.apiVisibility = apiVisibility;
}
protected bool CheckVisibility(IEntity entity)
{
if (apiVisibility == ApiVisibility.All)
return true;
do
{
if (apiVisibility == ApiVisibility.PublicOnly)
{
if (!(entity.Accessibility == Accessibility.Public ||
entity.Accessibility == Accessibility.Protected ||
entity.Accessibility == Accessibility.ProtectedOrInternal))
return false;
}
else if (apiVisibility == ApiVisibility.PublicAndInternal)
{
if (!language.ShowMember(entity))
return false;
}
entity = entity.DeclaringTypeDefinition;
}
while (entity != null);
return true;
}
protected bool IsInNamespaceOrAssembly(IEntity entity)
{
if (searchRequest.InAssembly != null)
{
if (!entity.ParentModule.FullAssemblyName.Contains(searchRequest.InAssembly))
{
return false;
}
}
if (searchRequest.InNamespace != null)
{
if (searchRequest.InNamespace.Length == 0)
{
return entity.Namespace.Length == 0;
}
else if (!entity.Namespace.Contains(searchRequest.InNamespace))
{
return false;
}
}
return true;
}
protected void OnFoundResult(IEntity entity)
{
OnFoundResult(searchRequest.SearchResultFactory.Create(entity));
}
}
}

25
ILSpy/Search/AbstractSearchStrategy.cs → ICSharpCode.ILSpyX/Search/AbstractSearchStrategy.cs

@ -21,12 +21,33 @@ using System.Collections.Concurrent; @@ -21,12 +21,33 @@ using System.Collections.Concurrent;
using System.Text.RegularExpressions;
using System.Threading;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpyX.Abstractions;
namespace ICSharpCode.ILSpyX.Search
{
public enum SearchMode
{
TypeAndMember,
Type,
Member,
Method,
Field,
Property,
Event,
Literal,
Token,
Resource,
Assembly,
Namespace
}
namespace ICSharpCode.ILSpy.Search
{
struct SearchRequest
{
public DecompilerSettings DecompilerSettings;
public ITreeNodeFactory TreeNodeFactory;
public ISearchResultFactory SearchResultFactory;
public SearchMode Mode;
public AssemblySearchKind AssemblySearchKind;
public MemberSearchKind MemberSearchKind;

12
ILSpy/Search/AssemblySearchStrategy.cs → ICSharpCode.ILSpyX/Search/AssemblySearchStrategy.cs

@ -22,7 +22,7 @@ using System.Threading; @@ -22,7 +22,7 @@ using System.Threading;
using ICSharpCode.Decompiler.Metadata;
namespace ICSharpCode.ILSpy.Search
namespace ICSharpCode.ILSpyX.Search
{
class AssemblySearchStrategy : AbstractSearchStrategy
{
@ -92,15 +92,7 @@ namespace ICSharpCode.ILSpy.Search @@ -92,15 +92,7 @@ namespace ICSharpCode.ILSpy.Search
void OnFoundResult(PEFile module)
{
var result = new AssemblySearchResult {
Module = module,
Fitness = 1.0f / module.Name.Length,
Name = module.Name,
Location = module.FileName,
Assembly = module.FullName,
ToolTip = module.FileName,
};
OnFoundResult(result);
OnFoundResult(searchRequest.SearchResultFactory.Create(module));
}
}

5
ILSpy/Languages/CSharpLexer.cs → ICSharpCode.ILSpyX/Search/CSharpLexer.cs

@ -22,7 +22,7 @@ using System.Globalization; @@ -22,7 +22,7 @@ using System.Globalization;
using System.IO;
using System.Text;
namespace ICSharpCode.ILSpy
namespace ICSharpCode.ILSpyX.Search
{
class LATextReader : TextReader
{
@ -76,8 +76,7 @@ namespace ICSharpCode.ILSpy @@ -76,8 +76,7 @@ namespace ICSharpCode.ILSpy
OctalNumber,
StringLiteral,
VerbatimStringLiteral,
CharLiteral,
DateTimeLiteral
CharLiteral
}
class Literal

9
ILSpy/Search/LiteralSearchStrategy.cs → ICSharpCode.ILSpyX/Search/LiteralSearchStrategy.cs

@ -25,19 +25,20 @@ using ICSharpCode.Decompiler.Disassembler; @@ -25,19 +25,20 @@ using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.Decompiler.Util;
using ICSharpCode.ILSpyX.Abstractions;
using static System.Reflection.Metadata.PEReaderExtensions;
using ILOpCode = System.Reflection.Metadata.ILOpCode;
namespace ICSharpCode.ILSpy.Search
namespace ICSharpCode.ILSpyX.Search
{
class LiteralSearchStrategy : AbstractEntitySearchStrategy
{
readonly TypeCode searchTermLiteralType;
readonly object searchTermLiteralValue;
public LiteralSearchStrategy(Language language, ApiVisibility apiVisibility, SearchRequest request,
public LiteralSearchStrategy(ILanguage language, ApiVisibility apiVisibility, SearchRequest request,
IProducerConsumerCollection<SearchResult> resultQueue)
: base(language, apiVisibility, request, resultQueue)
{
@ -78,7 +79,7 @@ namespace ICSharpCode.ILSpy.Search @@ -78,7 +79,7 @@ namespace ICSharpCode.ILSpy.Search
{
cancellationToken.ThrowIfCancellationRequested();
var metadata = module.Metadata;
var typeSystem = module.GetTypeSystemWithCurrentOptionsOrNull();
var typeSystem = module.GetTypeSystemWithDecompilerSettingsOrNull(searchRequest.DecompilerSettings);
if (typeSystem == null)
return;
@ -114,7 +115,7 @@ namespace ICSharpCode.ILSpy.Search @@ -114,7 +115,7 @@ namespace ICSharpCode.ILSpy.Search
}
}
bool IsLiteralMatch(MetadataReader metadata, object val)
bool IsLiteralMatch(MetadataReader metadata, object? val)
{
if (val == null)
return false;

7
ILSpy/Search/MemberSearchStrategy.cs → ICSharpCode.ILSpyX/Search/MemberSearchStrategy.cs

@ -21,14 +21,15 @@ using System.Threading; @@ -21,14 +21,15 @@ using System.Threading;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpyX.Abstractions;
namespace ICSharpCode.ILSpy.Search
namespace ICSharpCode.ILSpyX.Search
{
class MemberSearchStrategy : AbstractEntitySearchStrategy
{
readonly MemberSearchKind searchKind;
public MemberSearchStrategy(Language language, ApiVisibility apiVisibility, SearchRequest searchRequest,
public MemberSearchStrategy(ILanguage language, ApiVisibility apiVisibility, SearchRequest searchRequest,
IProducerConsumerCollection<SearchResult> resultQueue, MemberSearchKind searchKind = MemberSearchKind.All)
: base(language, apiVisibility, searchRequest, resultQueue)
{
@ -39,7 +40,7 @@ namespace ICSharpCode.ILSpy.Search @@ -39,7 +40,7 @@ namespace ICSharpCode.ILSpy.Search
{
cancellationToken.ThrowIfCancellationRequested();
var metadata = module.Metadata;
var typeSystem = module.GetTypeSystemWithCurrentOptionsOrNull();
var typeSystem = module.GetTypeSystemWithDecompilerSettingsOrNull(searchRequest.DecompilerSettings);
if (typeSystem == null)
return;

7
ILSpy/Search/MetadataTokenSearchStrategy.cs → ICSharpCode.ILSpyX/Search/MetadataTokenSearchStrategy.cs

@ -24,14 +24,15 @@ using System.Threading; @@ -24,14 +24,15 @@ using System.Threading;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpyX.Abstractions;
namespace ICSharpCode.ILSpy.Search
namespace ICSharpCode.ILSpyX.Search
{
class MetadataTokenSearchStrategy : AbstractEntitySearchStrategy
{
readonly EntityHandle searchTermToken;
public MetadataTokenSearchStrategy(Language language, ApiVisibility apiVisibility, SearchRequest request,
public MetadataTokenSearchStrategy(ILanguage language, ApiVisibility apiVisibility, SearchRequest request,
IProducerConsumerCollection<SearchResult> resultQueue)
: base(language, apiVisibility, request, resultQueue)
{
@ -48,7 +49,7 @@ namespace ICSharpCode.ILSpy.Search @@ -48,7 +49,7 @@ namespace ICSharpCode.ILSpy.Search
cancellationToken.ThrowIfCancellationRequested();
if (searchTermToken.IsNil)
return;
var typeSystem = module.GetTypeSystemWithCurrentOptionsOrNull();
var typeSystem = module.GetTypeSystemWithDecompilerSettingsOrNull(searchRequest.DecompilerSettings);
if (typeSystem == null)
return;
var metadataModule = (MetadataModule)typeSystem.MainModule;

14
ILSpy/Search/NamespaceSearchStrategy.cs → ICSharpCode.ILSpyX/Search/NamespaceSearchStrategy.cs

@ -24,7 +24,7 @@ using ICSharpCode.Decompiler.Metadata; @@ -24,7 +24,7 @@ using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.Decompiler.Util;
namespace ICSharpCode.ILSpy.Search
namespace ICSharpCode.ILSpyX.Search
{
class NamespaceSearchStrategy : AbstractSearchStrategy
{
@ -36,7 +36,7 @@ namespace ICSharpCode.ILSpy.Search @@ -36,7 +36,7 @@ namespace ICSharpCode.ILSpy.Search
public override void Search(PEFile module, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
var typeSystem = module.GetTypeSystemWithCurrentOptionsOrNull();
var typeSystem = module.GetTypeSystemWithDecompilerSettingsOrNull(searchRequest.DecompilerSettings);
if (typeSystem == null)
return;
@ -58,15 +58,7 @@ namespace ICSharpCode.ILSpy.Search @@ -58,15 +58,7 @@ namespace ICSharpCode.ILSpy.Search
void OnFoundResult(PEFile module, INamespace ns)
{
var name = ns.FullName.Length == 0 ? "-" : ns.FullName;
var result = new NamespaceSearchResult {
Namespace = ns,
Name = name,
Fitness = 1.0f / name.Length,
Location = module.Name,
Assembly = module.FullName,
};
OnFoundResult(result);
OnFoundResult(searchRequest.SearchResultFactory.Create(module, ns));
}
}
}

33
ILSpy/Search/ResourceSearchStrategy.cs → ICSharpCode.ILSpyX/Search/ResourceSearchStrategy.cs

@ -19,22 +19,22 @@ using System; @@ -19,22 +19,22 @@ using System;
using System.Collections.Concurrent;
using System.Reflection;
using System.Threading;
using System.Windows.Media;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.TreeView;
using ICSharpCode.ILSpyX.Abstractions;
namespace ICSharpCode.ILSpy.Search
namespace ICSharpCode.ILSpyX.Search
{
class ResourceSearchStrategy : AbstractSearchStrategy
{
protected readonly bool searchInside;
protected readonly ApiVisibility apiVisibility;
protected readonly ITreeNodeFactory treeNodeFactory;
public ResourceSearchStrategy(ApiVisibility apiVisibility, SearchRequest request, IProducerConsumerCollection<SearchResult> resultQueue)
: base(request, resultQueue)
{
this.treeNodeFactory = request.TreeNodeFactory;
this.apiVisibility = apiVisibility;
this.searchInside = true;
}
@ -53,24 +53,24 @@ namespace ICSharpCode.ILSpy.Search @@ -53,24 +53,24 @@ namespace ICSharpCode.ILSpy.Search
public override void Search(PEFile module, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
var resourcesNode = new ResourceListTreeNode(module);
var resourcesNode = treeNodeFactory.CreateResourcesList(module);
foreach (Resource resource in module.Resources)
Search(module, resource, resourcesNode, ResourceTreeNode.Create(resource), cancellationToken);
Search(module, resource, resourcesNode, treeNodeFactory.Create(resource), cancellationToken);
}
void Search(PEFile module, Resource resource, SharpTreeNode parent, SharpTreeNode node, CancellationToken cancellationToken)
void Search(PEFile module, Resource resource, ITreeNode parent, ITreeNode node, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
if (node is ResourceTreeNode treeNode)
if (node is IResourcesFileTreeNode treeNode)
{
if (!CheckVisibility(treeNode.Resource))
return;
resource = treeNode.Resource;
}
if (node.Text != null && IsMatch((string)node.Text))
if (node.Text is string s && IsMatch(s))
OnFoundResult(module, resource, node, parent);
if (!searchInside)
@ -81,20 +81,9 @@ namespace ICSharpCode.ILSpy.Search @@ -81,20 +81,9 @@ namespace ICSharpCode.ILSpy.Search
Search(module, resource, node, child, cancellationToken);
}
void OnFoundResult(PEFile module, Resource resource, SharpTreeNode node, SharpTreeNode parent)
void OnFoundResult(PEFile module, Resource resource, ITreeNode node, ITreeNode parent)
{
var name = (string)node.Text;
var result = new ResourceSearchResult {
Resource = resource,
Fitness = 1.0f / name.Length,
Image = (ImageSource)node.Icon,
Name = name,
LocationImage = (ImageSource)parent.Icon,
Location = (string)parent.Text,
Assembly = module.FullName,
ToolTip = module.FileName,
};
OnFoundResult(result);
OnFoundResult(searchRequest.SearchResultFactory.Create(module, resource, node, parent));
}
}
}

62
ILSpy/Search/SearchResult.cs → ICSharpCode.ILSpyX/Search/SearchResult.cs

@ -18,40 +18,38 @@ @@ -18,40 +18,38 @@
using System;
using System.Collections.Generic;
using System.Windows.Media;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.Search;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.ILSpyX.Abstractions;
namespace ICSharpCode.ILSpy
namespace ICSharpCode.ILSpyX.Search
{
public interface ISearchResultFactory
{
MemberSearchResult Create(IEntity entity);
ResourceSearchResult Create(PEFile module, Resource resource, ITreeNode node, ITreeNode parent);
AssemblySearchResult Create(PEFile module);
NamespaceSearchResult Create(PEFile module, INamespace @namespace);
}
public class SearchResult
{
public static readonly IComparer<SearchResult> ComparerByName = new SearchResultNameComparer();
public static readonly IComparer<SearchResult> ComparerByFitness = new SearchResultFitnessComparer();
public virtual object Reference {
get {
return null;
}
}
public virtual object? Reference => null;
public float Fitness { get; set; }
public string Name { get; set; }
public string Location { get; set; }
public string Assembly { get; set; }
public object ToolTip { get; set; }
public virtual ImageSource Image { get; set; }
public virtual ImageSource LocationImage { get; set; }
public object? ToolTip { get; set; }
public object Image { get; set; }
public object LocationImage { get; set; }
public ImageSource AssemblyImage {
get {
return Images.Assembly;
}
}
public object AssemblyImage { get; set; }
public override string ToString()
{
@ -60,7 +58,7 @@ namespace ICSharpCode.ILSpy @@ -60,7 +58,7 @@ namespace ICSharpCode.ILSpy
class SearchResultNameComparer : IComparer<SearchResult>
{
public int Compare(SearchResult x, SearchResult y)
public int Compare(SearchResult? x, SearchResult? y)
{
return StringComparer.Ordinal.Compare(x?.Name ?? "", y?.Name ?? "");
}
@ -68,7 +66,7 @@ namespace ICSharpCode.ILSpy @@ -68,7 +66,7 @@ namespace ICSharpCode.ILSpy
class SearchResultFitnessComparer : IComparer<SearchResult>
{
public int Compare(SearchResult x, SearchResult y)
public int Compare(SearchResult? x, SearchResult? y)
{
//elements with higher Fitness come first
return Comparer<float>.Default.Compare(y?.Fitness ?? 0, x?.Fitness ?? 0);
@ -80,26 +78,6 @@ namespace ICSharpCode.ILSpy @@ -80,26 +78,6 @@ namespace ICSharpCode.ILSpy
{
public IEntity Member { get; set; }
public override object Reference => Member;
public override ImageSource Image {
get {
if (base.Image == null)
{
base.Image = AbstractEntitySearchStrategy.GetIcon(Member);
}
return base.Image;
}
}
public override ImageSource LocationImage {
get {
if (base.LocationImage == null)
{
base.LocationImage = Member.DeclaringTypeDefinition != null ? TypeTreeNode.GetIcon(Member.DeclaringTypeDefinition) : Images.Namespace;
}
return base.LocationImage;
}
}
}
public class ResourceSearchResult : SearchResult
@ -112,17 +90,11 @@ namespace ICSharpCode.ILSpy @@ -112,17 +90,11 @@ namespace ICSharpCode.ILSpy
{
public PEFile Module { get; set; }
public override object Reference => Module;
public override ImageSource Image => Images.Assembly;
public override ImageSource LocationImage => Images.Library;
}
public class NamespaceSearchResult : SearchResult
{
public INamespace Namespace { get; set; }
public override object Reference => Namespace;
public override ImageSource Image => Images.Namespace;
public override ImageSource LocationImage => Images.Assembly;
}
}

3
ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs

@ -24,13 +24,14 @@ using ICSharpCode.Decompiler.Metadata; @@ -24,13 +24,14 @@ using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.ILSpyX;
using ICSharpCode.ILSpyX.Abstractions;
namespace ILSpy.BamlDecompiler
{
[Export(typeof(IResourceNodeFactory))]
public sealed class BamlResourceNodeFactory : IResourceNodeFactory
{
public ILSpyTreeNode CreateNode(Resource resource)
public ITreeNode CreateNode(Resource resource)
{
if (resource.Name.EndsWith(".baml", StringComparison.OrdinalIgnoreCase))
return new BamlResourceEntryNode(resource.Name, resource.TryOpenStream);

1
ILSpy/ContextMenuEntry.cs

@ -27,6 +27,7 @@ using System.Windows.Media; @@ -27,6 +27,7 @@ using System.Windows.Media;
using ICSharpCode.AvalonEdit;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpyX.Search;
using ICSharpCode.TreeView;
namespace ICSharpCode.ILSpy

9
ILSpy/FilterSettings.cs

@ -23,6 +23,8 @@ using System.Linq; @@ -23,6 +23,8 @@ using System.Linq;
using System.Runtime.CompilerServices;
using System.Xml.Linq;
using ICSharpCode.ILSpyX;
namespace ICSharpCode.ILSpy
{
/// <summary>
@ -220,11 +222,4 @@ namespace ICSharpCode.ILSpy @@ -220,11 +222,4 @@ namespace ICSharpCode.ILSpy
return f;
}
}
public enum ApiVisibility
{
PublicOnly,
PublicAndInternal,
All
}
}

3
ILSpy/Languages/Language.cs

@ -30,6 +30,7 @@ using ICSharpCode.Decompiler.TypeSystem; @@ -30,6 +30,7 @@ using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.Decompiler.TypeSystem.Implementation;
using ICSharpCode.Decompiler.Util;
using ICSharpCode.ILSpyX;
using ICSharpCode.ILSpyX.Abstractions;
using SRM = System.Reflection.Metadata;
@ -58,7 +59,7 @@ namespace ICSharpCode.ILSpy @@ -58,7 +59,7 @@ namespace ICSharpCode.ILSpy
/// <remarks>
/// Implementations of this class must be thread-safe.
/// </remarks>
public abstract class Language
public abstract class Language : ILanguage
{
/// <summary>
/// Gets the name of the language (as shown in the UI)

3
ILSpy/MainWindow.xaml

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
x:ClassModifier="public"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:tv="clr-namespace:ICSharpCode.TreeView;assembly=ICSharpCode.TreeView"
xmlns:local="clr-namespace:ICSharpCode.ILSpy"
xmlns:search="clr-namespace:ICSharpCode.ILSpy.Search"
xmlns:avalondock="https://github.com/Dirkster99/AvalonDock"
xmlns:controls="clr-namespace:ICSharpCode.ILSpy.Controls"
xmlns:docking="clr-namespace:ICSharpCode.ILSpy.Docking"
@ -75,7 +76,7 @@ @@ -75,7 +76,7 @@
<ContentControl Content="{StaticResource DebugSteps}" />
</DataTemplate>
<local:SearchPane x:Key="SearchPane" />
<search:SearchPane x:Key="SearchPane" />
<DataTemplate x:Key="SearchPaneTemplate">
<ContentControl Content="{StaticResource SearchPane}" />

1
ILSpy/MainWindow.xaml.cs

@ -45,6 +45,7 @@ using ICSharpCode.Decompiler.TypeSystem.Implementation; @@ -45,6 +45,7 @@ using ICSharpCode.Decompiler.TypeSystem.Implementation;
using ICSharpCode.ILSpy.Analyzers;
using ICSharpCode.ILSpy.Commands;
using ICSharpCode.ILSpy.Docking;
using ICSharpCode.ILSpy.Search;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.Themes;
using ICSharpCode.ILSpy.TreeNodes;

23
ILSpy/Search/SearchPane.cs

@ -35,12 +35,12 @@ using System.Windows.Threading; @@ -35,12 +35,12 @@ using System.Windows.Threading;
using ICSharpCode.ILSpy.Docking;
using ICSharpCode.ILSpy.Options;
using ICSharpCode.ILSpy.Search;
using ICSharpCode.ILSpy.ViewModels;
using ICSharpCode.ILSpyX;
using ICSharpCode.ILSpyX.Extensions;
using ICSharpCode.ILSpyX.Search;
namespace ICSharpCode.ILSpy
namespace ICSharpCode.ILSpy.Search
{
/// <summary>
/// Search pane
@ -447,6 +447,9 @@ namespace ICSharpCode.ILSpy @@ -447,6 +447,9 @@ namespace ICSharpCode.ILSpy
request.Keywords = keywords.ToArray();
request.RegEx = regex;
request.SearchResultFactory = new SearchResultFactory(language);
request.TreeNodeFactory = new TreeNodeFactory();
request.DecompilerSettings = new DecompilationOptions().DecompilerSettings;
return request;
}
@ -536,20 +539,4 @@ namespace ICSharpCode.ILSpy @@ -536,20 +539,4 @@ namespace ICSharpCode.ILSpy
NavigationCommands.Search.InputGestures.Add(new KeyGesture(Key.E, ModifierKeys.Control));
}
}
public enum SearchMode
{
TypeAndMember,
Type,
Member,
Method,
Field,
Property,
Event,
Literal,
Token,
Resource,
Assembly,
Namespace
}
}

2
ILSpy/Search/SearchPane.xaml

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<UserControl x:Class="ICSharpCode.ILSpy.SearchPane" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<UserControl x:Class="ICSharpCode.ILSpy.Search.SearchPane" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:ICSharpCode.ILSpy.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

166
ILSpy/Search/AbstractEntitySearchStrategy.cs → ILSpy/Search/SearchResultFactory.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
// Copyright (c) 2022 Siegfried Pammer
//
// 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
@ -15,98 +15,24 @@ @@ -15,98 +15,24 @@
// 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 System.Collections.Concurrent;
using System.Windows.Media;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.ILSpyX.Abstractions;
using ICSharpCode.ILSpyX.Search;
namespace ICSharpCode.ILSpy.Search
{
using ICSharpCode.Decompiler.TypeSystem;
abstract class AbstractEntitySearchStrategy : AbstractSearchStrategy
internal class SearchResultFactory : ISearchResultFactory
{
protected readonly Language language;
protected readonly ApiVisibility apiVisibility;
readonly Language language;
protected AbstractEntitySearchStrategy(Language language, ApiVisibility apiVisibility,
SearchRequest searchRequest, IProducerConsumerCollection<SearchResult> resultQueue)
: base(searchRequest, resultQueue)
public SearchResultFactory(Language language)
{
this.language = language;
this.apiVisibility = apiVisibility;
}
protected bool CheckVisibility(IEntity entity)
{
if (apiVisibility == ApiVisibility.All)
return true;
do
{
if (apiVisibility == ApiVisibility.PublicOnly)
{
if (!(entity.Accessibility == Accessibility.Public ||
entity.Accessibility == Accessibility.Protected ||
entity.Accessibility == Accessibility.ProtectedOrInternal))
return false;
}
else if (apiVisibility == ApiVisibility.PublicAndInternal)
{
if (!language.ShowMember(entity))
return false;
}
entity = entity.DeclaringTypeDefinition;
}
while (entity != null);
return true;
}
protected bool IsInNamespaceOrAssembly(IEntity entity)
{
if (searchRequest.InAssembly != null)
{
if (!entity.ParentModule.FullAssemblyName.Contains(searchRequest.InAssembly))
{
return false;
}
}
if (searchRequest.InNamespace != null)
{
if (searchRequest.InNamespace.Length == 0)
{
return entity.Namespace.Length == 0;
}
else if (!entity.Namespace.Contains(searchRequest.InNamespace))
{
return false;
}
}
return true;
}
protected void OnFoundResult(IEntity entity)
{
var result = ResultFromEntity(entity);
OnFoundResult(result);
}
SearchResult ResultFromEntity(IEntity item)
{
var declaringType = item.DeclaringTypeDefinition;
return new MemberSearchResult {
Member = item,
Fitness = CalculateFitness(item),
Name = GetLanguageSpecificName(item),
Location = declaringType != null ? language.TypeToString(declaringType, includeNamespace: true) : item.Namespace,
Assembly = item.ParentModule.FullAssemblyName,
ToolTip = item.ParentModule.PEFile?.FileName
};
}
float CalculateFitness(IEntity member)
@ -151,7 +77,7 @@ namespace ICSharpCode.ILSpy.Search @@ -151,7 +77,7 @@ namespace ICSharpCode.ILSpy.Search
}
}
static internal ImageSource GetIcon(IEntity member)
static ImageSource GetIcon(IEntity member)
{
switch (member)
{
@ -169,5 +95,79 @@ namespace ICSharpCode.ILSpy.Search @@ -169,5 +95,79 @@ namespace ICSharpCode.ILSpy.Search
throw new NotSupportedException(member?.GetType() + " not supported!");
}
}
public MemberSearchResult Create(IEntity entity)
{
var declaringType = entity.DeclaringTypeDefinition;
return new MemberSearchResult {
Member = entity,
Fitness = CalculateFitness(entity),
Name = GetLanguageSpecificName(entity),
Location = declaringType != null ? language.TypeToString(declaringType, includeNamespace: true) : entity.Namespace,
Assembly = entity.ParentModule.FullAssemblyName,
ToolTip = entity.ParentModule.PEFile?.FileName,
Image = Images.Assembly,
LocationImage = declaringType != null ? TypeTreeNode.GetIcon(declaringType) : Images.Namespace,
AssemblyImage = Images.Assembly,
};
}
public ResourceSearchResult Create(PEFile module, Resource resource, ITreeNode node, ITreeNode parent)
{
return new ResourceSearchResult {
Resource = resource,
Fitness = 1.0f / resource.Name.Length,
Image = node.Icon,
Name = resource.Name,
LocationImage = parent.Icon,
Location = (string)parent.Text,
Assembly = module.FullName,
ToolTip = module.FileName,
AssemblyImage = Images.Assembly,
};
}
public AssemblySearchResult Create(PEFile module)
{
return new AssemblySearchResult {
Module = module,
Fitness = 1.0f / module.Name.Length,
Name = module.Name,
Location = module.FileName,
Assembly = module.FullName,
ToolTip = module.FileName,
Image = Images.Assembly,
LocationImage = Images.Library,
AssemblyImage = Images.Assembly,
};
}
public NamespaceSearchResult Create(PEFile module, INamespace ns)
{
var name = ns.FullName.Length == 0 ? "-" : ns.FullName;
return new NamespaceSearchResult {
Namespace = ns,
Name = name,
Fitness = 1.0f / name.Length,
Location = module.Name,
Assembly = module.FullName,
Image = Images.Namespace,
LocationImage = Images.Assembly,
AssemblyImage = Images.Assembly,
};
}
}
internal class TreeNodeFactory : ITreeNodeFactory
{
public ITreeNode Create(Resource resource)
{
return ResourceTreeNode.Create(resource);
}
public ITreeNode CreateResourcesList(PEFile module)
{
return new ResourceListTreeNode(module);
}
}
}

1
ILSpy/SessionSettings.cs

@ -28,6 +28,7 @@ using System.Xml.Linq; @@ -28,6 +28,7 @@ using System.Xml.Linq;
using ICSharpCode.ILSpy.Docking;
using ICSharpCode.ILSpy.Themes;
using ICSharpCode.ILSpyX.Search;
namespace ICSharpCode.ILSpy
{

1
ILSpy/TreeNodes/EventTreeNode.cs

@ -25,6 +25,7 @@ using ICSharpCode.Decompiler; @@ -25,6 +25,7 @@ using ICSharpCode.Decompiler;
namespace ICSharpCode.ILSpy.TreeNodes
{
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpyX;
/// <summary>
/// Represents an event in the TreeView.

1
ILSpy/TreeNodes/FieldTreeNode.cs

@ -25,6 +25,7 @@ using ICSharpCode.Decompiler; @@ -25,6 +25,7 @@ using ICSharpCode.Decompiler;
namespace ICSharpCode.ILSpy.TreeNodes
{
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpyX;
/// <summary>
/// Represents a field in the TreeView.

6
ILSpy/TreeNodes/ILSpyTreeNode.cs

@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
@ -28,6 +29,7 @@ using System.Windows.Threading; @@ -28,6 +29,7 @@ using System.Windows.Threading;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.Options;
using ICSharpCode.ILSpyX.Abstractions;
using ICSharpCode.TreeView;
namespace ICSharpCode.ILSpy.TreeNodes
@ -35,7 +37,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -35,7 +37,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
/// <summary>
/// Base class of all ILSpy tree nodes.
/// </summary>
public abstract class ILSpyTreeNode : SharpTreeNode
public abstract class ILSpyTreeNode : SharpTreeNode, ITreeNode
{
FilterSettings filterSettings;
bool childrenNeedFiltering;
@ -202,5 +204,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -202,5 +204,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
public virtual bool IsAutoLoaded {
get { return false; }
}
IEnumerable<ITreeNode> ITreeNode.Children => this.Children.OfType<ILSpyTreeNode>();
}
}

1
ILSpy/TreeNodes/MethodTreeNode.cs

@ -25,6 +25,7 @@ using ICSharpCode.Decompiler; @@ -25,6 +25,7 @@ using ICSharpCode.Decompiler;
namespace ICSharpCode.ILSpy.TreeNodes
{
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpyX;
/// <summary>
/// Tree Node representing a field, method, property, or event.

1
ILSpy/TreeNodes/PropertyTreeNode.cs

@ -25,6 +25,7 @@ using ICSharpCode.Decompiler; @@ -25,6 +25,7 @@ using ICSharpCode.Decompiler;
namespace ICSharpCode.ILSpy.TreeNodes
{
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpyX;
/// <summary>
/// Represents a property in the TreeView.

1
ILSpy/TreeNodes/ResourceListTreeNode.cs

@ -23,6 +23,7 @@ using System.Windows.Threading; @@ -23,6 +23,7 @@ using System.Windows.Threading;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.Properties;
using ICSharpCode.ILSpyX.Abstractions;
namespace ICSharpCode.ILSpy.TreeNodes
{

3
ILSpy/TreeNodes/ResourceNodes/CursorResourceEntryNode.cs

@ -26,6 +26,7 @@ using ICSharpCode.Decompiler.Metadata; @@ -26,6 +26,7 @@ using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.Properties;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.ViewModels;
using ICSharpCode.ILSpyX.Abstractions;
namespace ICSharpCode.ILSpy.TreeNodes
{
@ -34,7 +35,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -34,7 +35,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
{
static readonly string[] imageFileExtensions = { ".cur" };
public ILSpyTreeNode CreateNode(Resource resource)
public ITreeNode CreateNode(Resource resource)
{
string key = resource.Name;
foreach (string fileExt in imageFileExtensions)

3
ILSpy/TreeNodes/ResourceNodes/IResourceNodeFactory.cs

@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpyX.Abstractions;
namespace ICSharpCode.ILSpy.TreeNodes
{
@ -25,6 +26,6 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -25,6 +26,6 @@ namespace ICSharpCode.ILSpy.TreeNodes
/// </summary>
public interface IResourceNodeFactory
{
ILSpyTreeNode CreateNode(Resource resource);
ITreeNode CreateNode(Resource resource);
}
}

3
ILSpy/TreeNodes/ResourceNodes/IconResourceEntryNode.cs

@ -26,13 +26,14 @@ using ICSharpCode.Decompiler.Metadata; @@ -26,13 +26,14 @@ using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.Properties;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.ViewModels;
using ICSharpCode.ILSpyX.Abstractions;
namespace ICSharpCode.ILSpy.TreeNodes
{
[Export(typeof(IResourceNodeFactory))]
sealed class IconResourceNodeFactory : IResourceNodeFactory
{
public ILSpyTreeNode CreateNode(Resource resource)
public ITreeNode CreateNode(Resource resource)
{
if (resource.Name.EndsWith(".ico", StringComparison.OrdinalIgnoreCase))
{

3
ILSpy/TreeNodes/ResourceNodes/ImageListResourceEntryNode.cs

@ -23,13 +23,14 @@ using System.Windows.Forms; @@ -23,13 +23,14 @@ using System.Windows.Forms;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpyX.Abstractions;
namespace ICSharpCode.ILSpy.TreeNodes
{
[Export(typeof(IResourceNodeFactory))]
sealed class ImageListResourceEntryNodeFactory : IResourceNodeFactory
{
public ILSpyTreeNode CreateNode(Resource resource)
public ITreeNode CreateNode(Resource resource)
{
return null;
}

3
ILSpy/TreeNodes/ResourceNodes/ImageResourceEntryNode.cs

@ -26,6 +26,7 @@ using ICSharpCode.Decompiler.Metadata; @@ -26,6 +26,7 @@ using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.Properties;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.ViewModels;
using ICSharpCode.ILSpyX.Abstractions;
namespace ICSharpCode.ILSpy.TreeNodes
{
@ -34,7 +35,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -34,7 +35,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
{
static readonly string[] imageFileExtensions = { ".png", ".gif", ".bmp", ".jpg" };
public ILSpyTreeNode CreateNode(Resource resource)
public ITreeNode CreateNode(Resource resource)
{
string key = resource.Name;
foreach (string fileExt in imageFileExtensions)

3
ILSpy/TreeNodes/ResourceNodes/ResourceEntryNode.cs

@ -22,6 +22,7 @@ using System.IO; @@ -22,6 +22,7 @@ using System.IO;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.CSharp.ProjectDecompiler;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpyX.Abstractions;
using Microsoft.Win32;
@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
ILSpyTreeNode result = null;
foreach (var factory in App.ExportProvider.GetExportedValues<IResourceNodeFactory>())
{
result = factory.CreateNode(resource);
result = factory.CreateNode(resource) as ILSpyTreeNode;
if (result != null)
break;
}

4
ILSpy/TreeNodes/ResourceNodes/ResourceTreeNode.cs

@ -29,6 +29,8 @@ using ICSharpCode.Decompiler.Metadata; @@ -29,6 +29,8 @@ using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.Properties;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.ViewModels;
using ICSharpCode.ILSpyX;
using ICSharpCode.ILSpyX.Abstractions;
using Microsoft.Win32;
@ -38,7 +40,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -38,7 +40,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
/// This is the default resource entry tree node, which is used if no specific
/// <see cref="IResourceNodeFactory"/> exists for the given resource type.
/// </summary>
public class ResourceTreeNode : ILSpyTreeNode
public class ResourceTreeNode : ILSpyTreeNode, IResourcesFileTreeNode
{
public ResourceTreeNode(Resource r)
{

5
ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs

@ -31,6 +31,7 @@ using ICSharpCode.ILSpy.Controls; @@ -31,6 +31,7 @@ using ICSharpCode.ILSpy.Controls;
using ICSharpCode.ILSpy.Properties;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.ViewModels;
using ICSharpCode.ILSpyX.Abstractions;
using Microsoft.Win32;
@ -39,7 +40,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -39,7 +40,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
[Export(typeof(IResourceNodeFactory))]
sealed class ResourcesFileTreeNodeFactory : IResourceNodeFactory
{
public ILSpyTreeNode CreateNode(Resource resource)
public ITreeNode CreateNode(Resource resource)
{
if (resource.Name.EndsWith(".resources", StringComparison.OrdinalIgnoreCase))
{
@ -54,7 +55,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -54,7 +55,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
}
}
sealed class ResourcesFileTreeNode : ResourceTreeNode
sealed class ResourcesFileTreeNode : ResourceTreeNode, IResourcesFileTreeNode
{
readonly ICollection<KeyValuePair<string, string>> stringTableEntries = new ObservableCollection<KeyValuePair<string, string>>();
readonly ICollection<SerializedObjectRepresentation> otherEntries = new ObservableCollection<SerializedObjectRepresentation>();

3
ILSpy/TreeNodes/ResourceNodes/XamlResourceNode.cs

@ -26,13 +26,14 @@ using ICSharpCode.Decompiler.Metadata; @@ -26,13 +26,14 @@ using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.ILSpy.ViewModels;
using ICSharpCode.ILSpyX.Abstractions;
namespace ICSharpCode.ILSpy.Xaml
{
[Export(typeof(IResourceNodeFactory))]
sealed class XamlResourceNodeFactory : IResourceNodeFactory
{
public ILSpyTreeNode CreateNode(Resource resource)
public ITreeNode CreateNode(Resource resource)
{
if (resource.Name.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase))
return new XamlResourceEntryNode(resource.Name, resource.TryOpenStream);

3
ILSpy/TreeNodes/ResourceNodes/XmlResourceNode.cs

@ -26,6 +26,7 @@ using ICSharpCode.Decompiler.Metadata; @@ -26,6 +26,7 @@ using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.ILSpy.ViewModels;
using ICSharpCode.ILSpyX.Abstractions;
namespace ICSharpCode.ILSpy.Xaml
{
@ -34,7 +35,7 @@ namespace ICSharpCode.ILSpy.Xaml @@ -34,7 +35,7 @@ namespace ICSharpCode.ILSpy.Xaml
{
private readonly static string[] xmlFileExtensions = { ".xml", ".xsd", ".xslt" };
public ILSpyTreeNode CreateNode(Resource resource)
public ITreeNode CreateNode(Resource resource)
{
string key = resource.Name;
foreach (string fileExt in xmlFileExtensions)

1
ILSpy/TreeNodes/TypeTreeNode.cs

@ -27,6 +27,7 @@ using SRM = System.Reflection.Metadata; @@ -27,6 +27,7 @@ using SRM = System.Reflection.Metadata;
namespace ICSharpCode.ILSpy.TreeNodes
{
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpyX;
public sealed class TypeTreeNode : ILSpyTreeNode, IMemberTreeNode
{

Loading…
Cancel
Save