mirror of https://github.com/icsharpcode/ILSpy.git
8 changed files with 192 additions and 5 deletions
@ -0,0 +1,36 @@ |
|||||||
|
using System.Collections.Generic; |
||||||
|
using System.ComponentModel.Composition; |
||||||
|
using System.Linq; |
||||||
|
using ICSharpCode.Decompiler.TypeSystem; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpy.Analyzers.Builtin |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Shows events that implement an interface event.
|
||||||
|
/// </summary>
|
||||||
|
[Export(typeof(IAnalyzer<IEvent>))] |
||||||
|
class EventImplementsInterfaceAnalyzer : ITypeDefinitionAnalyzer<IEvent> |
||||||
|
{ |
||||||
|
public string Text => "Implemented By"; |
||||||
|
|
||||||
|
public IEnumerable<IEntity> Analyze(IEvent analyzedEntity, ITypeDefinition type, AnalyzerContext context) |
||||||
|
{ |
||||||
|
var token = analyzedEntity.DeclaringTypeDefinition.MetadataToken; |
||||||
|
var module = analyzedEntity.DeclaringTypeDefinition.ParentAssembly.PEFile; |
||||||
|
if (!type.GetAllBaseTypeDefinitions() |
||||||
|
.Any(t => t.MetadataToken == token && t.ParentAssembly.PEFile == module)) |
||||||
|
yield break; |
||||||
|
|
||||||
|
foreach (var @event in type.GetEvents(options: GetMemberOptions.ReturnMemberDefinitions)) { |
||||||
|
if (InheritanceHelper.GetBaseMembers(@event, true) |
||||||
|
.Any(m => m.DeclaringTypeDefinition.MetadataToken == token && m.ParentAssembly.PEFile == module)) |
||||||
|
yield return @event; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool Show(IEvent entity) |
||||||
|
{ |
||||||
|
return entity.DeclaringType.Kind == TypeKind.Interface; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,37 @@ |
|||||||
|
using System.Collections.Generic; |
||||||
|
using System.ComponentModel.Composition; |
||||||
|
using System.Linq; |
||||||
|
using ICSharpCode.Decompiler.TypeSystem; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpy.Analyzers.Builtin |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Shows events that override an event.
|
||||||
|
/// </summary>
|
||||||
|
[Export(typeof(IAnalyzer<IEvent>))] |
||||||
|
class EventOverriddenByAnalyzer : ITypeDefinitionAnalyzer<IEvent> |
||||||
|
{ |
||||||
|
public string Text => "Overridden By"; |
||||||
|
|
||||||
|
public IEnumerable<IEntity> Analyze(IEvent analyzedEntity, ITypeDefinition type, AnalyzerContext context) |
||||||
|
{ |
||||||
|
if (!analyzedEntity.DeclaringType.GetAllBaseTypeDefinitions() |
||||||
|
.Any(t => t.MetadataToken == analyzedEntity.DeclaringTypeDefinition.MetadataToken && t.ParentAssembly.PEFile == type.ParentAssembly.PEFile)) |
||||||
|
yield break; |
||||||
|
|
||||||
|
foreach (var property in type.Properties) { |
||||||
|
if (!property.IsOverride) continue; |
||||||
|
if (InheritanceHelper.GetBaseMembers(property, false) |
||||||
|
.Any(p => p.MetadataToken == analyzedEntity.MetadataToken && |
||||||
|
p.ParentAssembly.PEFile == analyzedEntity.ParentAssembly.PEFile)) { |
||||||
|
yield return property; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool Show(IEvent entity) |
||||||
|
{ |
||||||
|
return entity.IsOverridable && entity.DeclaringType.Kind != TypeKind.Interface; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,39 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.ComponentModel.Composition; |
||||||
|
using System.Linq; |
||||||
|
using System.Text; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using ICSharpCode.Decompiler.TypeSystem; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpy.Analyzers.Builtin |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Shows methods that implement an interface method.
|
||||||
|
/// </summary>
|
||||||
|
[Export(typeof(IAnalyzer<IMethod>))] |
||||||
|
class MethodImplementsInterfaceAnalyzer : ITypeDefinitionAnalyzer<IMethod> |
||||||
|
{ |
||||||
|
public string Text => "Implemented By"; |
||||||
|
|
||||||
|
public IEnumerable<IEntity> Analyze(IMethod analyzedEntity, ITypeDefinition type, AnalyzerContext context) |
||||||
|
{ |
||||||
|
var token = analyzedEntity.DeclaringTypeDefinition.MetadataToken; |
||||||
|
var module = analyzedEntity.DeclaringTypeDefinition.ParentAssembly.PEFile; |
||||||
|
if (!type.GetAllBaseTypeDefinitions() |
||||||
|
.Any(t => t.MetadataToken == token && t.ParentAssembly.PEFile == module)) |
||||||
|
yield break; |
||||||
|
|
||||||
|
foreach (var method in type.GetMethods(options: GetMemberOptions.ReturnMemberDefinitions)) { |
||||||
|
if (InheritanceHelper.GetBaseMembers(method, true) |
||||||
|
.Any(m => m.DeclaringTypeDefinition.MetadataToken == token && m.ParentAssembly.PEFile == module)) |
||||||
|
yield return method; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool Show(IMethod entity) |
||||||
|
{ |
||||||
|
return entity.DeclaringType.Kind == TypeKind.Interface; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,37 @@ |
|||||||
|
using System.Collections.Generic; |
||||||
|
using System.ComponentModel.Composition; |
||||||
|
using System.Linq; |
||||||
|
using ICSharpCode.Decompiler.TypeSystem; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpy.Analyzers.Builtin |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Shows methods that override a method.
|
||||||
|
/// </summary>
|
||||||
|
[Export(typeof(IAnalyzer<IMethod>))] |
||||||
|
class MethodOverriddenByAnalyzer : ITypeDefinitionAnalyzer<IMethod> |
||||||
|
{ |
||||||
|
public string Text => "Overridden By"; |
||||||
|
|
||||||
|
public IEnumerable<IEntity> Analyze(IMethod analyzedEntity, ITypeDefinition type, AnalyzerContext context) |
||||||
|
{ |
||||||
|
if (!analyzedEntity.DeclaringType.GetAllBaseTypeDefinitions() |
||||||
|
.Any(t => t.MetadataToken == analyzedEntity.DeclaringTypeDefinition.MetadataToken && t.ParentAssembly.PEFile == type.ParentAssembly.PEFile)) |
||||||
|
yield break; |
||||||
|
|
||||||
|
foreach (var property in type.Properties) { |
||||||
|
if (!property.IsOverride) continue; |
||||||
|
if (InheritanceHelper.GetBaseMembers(property, false) |
||||||
|
.Any(p => p.MetadataToken == analyzedEntity.MetadataToken && |
||||||
|
p.ParentAssembly.PEFile == analyzedEntity.ParentAssembly.PEFile)) { |
||||||
|
yield return property; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool Show(IMethod entity) |
||||||
|
{ |
||||||
|
return entity.IsOverridable && entity.DeclaringType.Kind != TypeKind.Interface; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,36 @@ |
|||||||
|
using System.Collections.Generic; |
||||||
|
using System.ComponentModel.Composition; |
||||||
|
using System.Linq; |
||||||
|
using ICSharpCode.Decompiler.TypeSystem; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpy.Analyzers.Builtin |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Shows properties that implement an interface property.
|
||||||
|
/// </summary>
|
||||||
|
[Export(typeof(IAnalyzer<IProperty>))] |
||||||
|
class PropertyImplementsInterfaceAnalyzer : ITypeDefinitionAnalyzer<IProperty> |
||||||
|
{ |
||||||
|
public string Text => "Implemented By"; |
||||||
|
|
||||||
|
public IEnumerable<IEntity> Analyze(IProperty analyzedEntity, ITypeDefinition type, AnalyzerContext context) |
||||||
|
{ |
||||||
|
var token = analyzedEntity.DeclaringTypeDefinition.MetadataToken; |
||||||
|
var module = analyzedEntity.DeclaringTypeDefinition.ParentAssembly.PEFile; |
||||||
|
if (!type.GetAllBaseTypeDefinitions() |
||||||
|
.Any(t => t.MetadataToken == token && t.ParentAssembly.PEFile == module)) |
||||||
|
yield break; |
||||||
|
|
||||||
|
foreach (var property in type.GetProperties(options: GetMemberOptions.ReturnMemberDefinitions)) { |
||||||
|
if (InheritanceHelper.GetBaseMembers(property, true) |
||||||
|
.Any(m => m.DeclaringTypeDefinition.MetadataToken == token && m.ParentAssembly.PEFile == module)) |
||||||
|
yield return property; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool Show(IProperty entity) |
||||||
|
{ |
||||||
|
return entity.DeclaringType.Kind == TypeKind.Interface; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue