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 @@ @@ -19,8 +19,8 @@
using System;
using System.Linq;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.Analyzers.TreeNodes;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.ILSpy.TreeNodes.Analyzer;
namespace ICSharpCode.ILSpy.Analyzers
{

22
ILSpy/Analyzers/AnalyzerSearchTreeNode.cs

@ -20,8 +20,8 @@ using System; @@ -20,8 +20,8 @@ using System;
using System.Collections.Generic;
using System.Threading;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.Analyzers.TreeNodes;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.ILSpy.TreeNodes.Analyzer;
namespace ICSharpCode.ILSpy.Analyzers
{
@ -46,7 +46,7 @@ namespace ICSharpCode.ILSpy.Analyzers @@ -46,7 +46,7 @@ namespace ICSharpCode.ILSpy.Analyzers
{
threading.LoadChildren(this, FetchChildren);
}
protected IEnumerable<AnalyzerTreeNode> FetchChildren(CancellationToken ct)
{
if (analyzer is IEntityAnalyzer<T> entityAnalyzer) {
@ -81,14 +81,14 @@ namespace ICSharpCode.ILSpy.Analyzers @@ -81,14 +81,14 @@ namespace ICSharpCode.ILSpy.Analyzers
return new AnalyzedMethodTreeNode(md) {
Language = this.Language
};
//case IProperty pd:
// return new AnalyzedPropertyTreeNode(pd) {
//Language = this.Language
//};
//case IEvent ed:
// return new AnalyzedEventTreeNode(ed) {
//Language = this.Language
//};
case IProperty pd:
return new AnalyzedPropertyTreeNode(pd) {
Language = this.Language
};
case IEvent ed:
return new AnalyzedEventTreeNode(ed) {
Language = this.Language
};
default:
throw new NotSupportedException();
}
@ -103,7 +103,7 @@ namespace ICSharpCode.ILSpy.Analyzers @@ -103,7 +103,7 @@ namespace ICSharpCode.ILSpy.Analyzers
this.Children.Clear();
}
}
public override bool HandleAssemblyListChanged(ICollection<LoadedAssembly> removedAssemblies, ICollection<LoadedAssembly> addedAssemblies)
{
// 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; @@ -20,7 +20,6 @@ using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Windows;
using ICSharpCode.ILSpy.TreeNodes.Analyzer;
using ICSharpCode.TreeView;
namespace ICSharpCode.ILSpy.Analyzers

2
ILSpy/Analyzers/Builtin/FieldAccessAnalyzer.cs

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

11
ILSpy/Analyzers/Builtin/MethodUsedByAnalyzer.cs

@ -51,16 +51,5 @@ namespace ICSharpCode.ILSpy.Analyzers.Builtin @@ -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 @@ -35,6 +35,7 @@ namespace ICSharpCode.ILSpy.Analyzers.Builtin
if (!md.HasBody()) yield break;
var blob = module.Reader.GetMethodBody(md.RelativeVirtualAddress).GetILReader();
var visitor = new TypeDefinitionCollector();
while (blob.RemainingBytes > 0) {
var opCode = blob.DecodeOpCode();
@ -52,9 +53,7 @@ namespace ICSharpCode.ILSpy.Analyzers.Builtin @@ -52,9 +53,7 @@ namespace ICSharpCode.ILSpy.Analyzers.Builtin
case HandleKind.TypeDefinition:
case HandleKind.TypeReference:
case HandleKind.TypeSpecification:
var type = context.TypeSystem.ResolveAsType(member).GetDefinition();
if (type != null)
yield return type;
context.TypeSystem.ResolveAsType(member).AcceptVisitor(visitor);
break;
case HandleKind.MethodDefinition:
case HandleKind.MethodSpecification:
@ -71,6 +70,21 @@ namespace ICSharpCode.ILSpy.Analyzers.Builtin @@ -71,6 +70,21 @@ namespace ICSharpCode.ILSpy.Analyzers.Builtin
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; @@ -28,7 +28,7 @@ using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.Decompiler.Util;
using ICSharpCode.ILSpy.Analyzers;
namespace ICSharpCode.ILSpy.TreeNodes.Analyzer
namespace ICSharpCode.ILSpy.Analyzers
{
/// <summary>
/// Determines the accessibility domain of a member for where-used analysis.
@ -48,7 +48,7 @@ namespace ICSharpCode.ILSpy.TreeNodes.Analyzer @@ -48,7 +48,7 @@ namespace ICSharpCode.ILSpy.TreeNodes.Analyzer
{
this.language = language ?? throw new ArgumentNullException(nameof(language));
this.analyzer = analyzer ?? throw new ArgumentNullException(nameof(analyzer));
this.analyzedEntity = analyzedEntity ;
this.analyzedEntity = analyzedEntity;
this.assemblyScope = analyzedEntity.ParentAssembly;
if (analyzedEntity is ITypeDefinition type) {
this.typeScope = type;

Loading…
Cancel
Save