Browse Source

Move Analyzer types to correct namespaces.

pull/1030/head
Siegfried Pammer 7 years ago
parent
commit
34641c7785
  1. 2
      ILSpy/Analyzers/AnalyzeContextMenuEntry.cs
  2. 22
      ILSpy/Analyzers/AnalyzerSearchTreeNode.cs
  3. 1
      ILSpy/Analyzers/AnalyzerTreeView.cs
  4. 2
      ILSpy/Analyzers/Builtin/FieldAccessAnalyzer.cs
  5. 11
      ILSpy/Analyzers/Builtin/MethodUsedByAnalyzer.cs
  6. 20
      ILSpy/Analyzers/Builtin/MethodUsesAnalyzer.cs
  7. 4
      ILSpy/Analyzers/ScopedWhereUsedAnalyzer.cs

2
ILSpy/Analyzers/AnalyzeContextMenuEntry.cs

@ -19,8 +19,8 @@
using System; using System;
using System.Linq; using System.Linq;
using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.Analyzers.TreeNodes;
using ICSharpCode.ILSpy.TreeNodes; using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.ILSpy.TreeNodes.Analyzer;
namespace ICSharpCode.ILSpy.Analyzers namespace ICSharpCode.ILSpy.Analyzers
{ {

22
ILSpy/Analyzers/AnalyzerSearchTreeNode.cs

@ -20,8 +20,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.Analyzers.TreeNodes;
using ICSharpCode.ILSpy.TreeNodes; using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.ILSpy.TreeNodes.Analyzer;
namespace ICSharpCode.ILSpy.Analyzers namespace ICSharpCode.ILSpy.Analyzers
{ {
@ -46,7 +46,7 @@ namespace ICSharpCode.ILSpy.Analyzers
{ {
threading.LoadChildren(this, FetchChildren); threading.LoadChildren(this, FetchChildren);
} }
protected IEnumerable<AnalyzerTreeNode> FetchChildren(CancellationToken ct) protected IEnumerable<AnalyzerTreeNode> FetchChildren(CancellationToken ct)
{ {
if (analyzer is IEntityAnalyzer<T> entityAnalyzer) { if (analyzer is IEntityAnalyzer<T> entityAnalyzer) {
@ -81,14 +81,14 @@ namespace ICSharpCode.ILSpy.Analyzers
return new AnalyzedMethodTreeNode(md) { return new AnalyzedMethodTreeNode(md) {
Language = this.Language Language = this.Language
}; };
//case IProperty pd: case IProperty pd:
// return new AnalyzedPropertyTreeNode(pd) { return new AnalyzedPropertyTreeNode(pd) {
//Language = this.Language Language = this.Language
//}; };
//case IEvent ed: case IEvent ed:
// return new AnalyzedEventTreeNode(ed) { return new AnalyzedEventTreeNode(ed) {
//Language = this.Language Language = this.Language
//}; };
default: default:
throw new NotSupportedException(); throw new NotSupportedException();
} }
@ -103,7 +103,7 @@ namespace ICSharpCode.ILSpy.Analyzers
this.Children.Clear(); this.Children.Clear();
} }
} }
public override bool HandleAssemblyListChanged(ICollection<LoadedAssembly> removedAssemblies, ICollection<LoadedAssembly> addedAssemblies) public override bool HandleAssemblyListChanged(ICollection<LoadedAssembly> removedAssemblies, ICollection<LoadedAssembly> addedAssemblies)
{ {
// only cancel a running analysis if user has manually added/removed assemblies // only cancel a running analysis if user has manually added/removed assemblies

1
ILSpy/Analyzers/AnalyzerTreeView.cs

@ -20,7 +20,6 @@ using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using ICSharpCode.ILSpy.TreeNodes.Analyzer;
using ICSharpCode.TreeView; using ICSharpCode.TreeView;
namespace ICSharpCode.ILSpy.Analyzers namespace ICSharpCode.ILSpy.Analyzers

2
ILSpy/Analyzers/Builtin/FieldAccessAnalyzer.cs

@ -31,7 +31,7 @@ using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.Analyzers; using ICSharpCode.ILSpy.Analyzers;
using ILOpCode = System.Reflection.Metadata.ILOpCode; using ILOpCode = System.Reflection.Metadata.ILOpCode;
namespace ICSharpCode.ILSpy.TreeNodes.Analyzer namespace ICSharpCode.ILSpy.Analyzers.Builtin
{ {
/// <summary> /// <summary>
/// Finds methods where this field is read. /// Finds methods where this field is read.

11
ILSpy/Analyzers/Builtin/MethodUsedByAnalyzer.cs

@ -51,16 +51,5 @@ namespace ICSharpCode.ILSpy.Analyzers.Builtin
} }
} }
} }
bool ScanMethodBody(PEFile module, int rva)
{
var blob = module.Reader.GetMethodBody(rva).GetILReader();
while (blob.RemainingBytes > 0) {
}
return false;
}
} }
} }

20
ILSpy/Analyzers/Builtin/MethodUsesAnalyzer.cs

@ -35,6 +35,7 @@ namespace ICSharpCode.ILSpy.Analyzers.Builtin
if (!md.HasBody()) yield break; if (!md.HasBody()) yield break;
var blob = module.Reader.GetMethodBody(md.RelativeVirtualAddress).GetILReader(); var blob = module.Reader.GetMethodBody(md.RelativeVirtualAddress).GetILReader();
var visitor = new TypeDefinitionCollector();
while (blob.RemainingBytes > 0) { while (blob.RemainingBytes > 0) {
var opCode = blob.DecodeOpCode(); var opCode = blob.DecodeOpCode();
@ -52,9 +53,7 @@ namespace ICSharpCode.ILSpy.Analyzers.Builtin
case HandleKind.TypeDefinition: case HandleKind.TypeDefinition:
case HandleKind.TypeReference: case HandleKind.TypeReference:
case HandleKind.TypeSpecification: case HandleKind.TypeSpecification:
var type = context.TypeSystem.ResolveAsType(member).GetDefinition(); context.TypeSystem.ResolveAsType(member).AcceptVisitor(visitor);
if (type != null)
yield return type;
break; break;
case HandleKind.MethodDefinition: case HandleKind.MethodDefinition:
case HandleKind.MethodSpecification: case HandleKind.MethodSpecification:
@ -71,6 +70,21 @@ namespace ICSharpCode.ILSpy.Analyzers.Builtin
break; break;
} }
} }
foreach (var type in visitor.UsedTypes) {
yield return type;
}
}
class TypeDefinitionCollector : TypeVisitor
{
public readonly List<ITypeDefinition> UsedTypes = new List<ITypeDefinition>();
public override IType VisitTypeDefinition(ITypeDefinition type)
{
UsedTypes.Add(type);
return base.VisitTypeDefinition(type);
}
} }
} }
} }

4
ILSpy/Analyzers/ScopedWhereUsedAnalyzer.cs

@ -28,7 +28,7 @@ using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.Decompiler.Util; using ICSharpCode.Decompiler.Util;
using ICSharpCode.ILSpy.Analyzers; using ICSharpCode.ILSpy.Analyzers;
namespace ICSharpCode.ILSpy.TreeNodes.Analyzer namespace ICSharpCode.ILSpy.Analyzers
{ {
/// <summary> /// <summary>
/// Determines the accessibility domain of a member for where-used analysis. /// Determines the accessibility domain of a member for where-used analysis.
@ -48,7 +48,7 @@ namespace ICSharpCode.ILSpy.TreeNodes.Analyzer
{ {
this.language = language ?? throw new ArgumentNullException(nameof(language)); this.language = language ?? throw new ArgumentNullException(nameof(language));
this.analyzer = analyzer ?? throw new ArgumentNullException(nameof(analyzer)); this.analyzer = analyzer ?? throw new ArgumentNullException(nameof(analyzer));
this.analyzedEntity = analyzedEntity ; this.analyzedEntity = analyzedEntity;
this.assemblyScope = analyzedEntity.ParentAssembly; this.assemblyScope = analyzedEntity.ParentAssembly;
if (analyzedEntity is ITypeDefinition type) { if (analyzedEntity is ITypeDefinition type) {
this.typeScope = type; this.typeScope = type;

Loading…
Cancel
Save