mirror of https://github.com/icsharpcode/ILSpy.git
12 changed files with 201 additions and 63 deletions
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
|
||||
namespace ICSharpCode.Decompiler |
||||
{ |
||||
/// <summary>
|
||||
/// Represents an error while resolving a reference to a type or a member.
|
||||
/// </summary>
|
||||
[Serializable] |
||||
public class ReferenceResolvingException : Exception |
||||
{ |
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:ResolveException"/> class
|
||||
/// </summary>
|
||||
public ReferenceResolvingException() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:ResolveException"/> class
|
||||
/// </summary>
|
||||
/// <param name="message">A <see cref="T:System.String"/> that describes the error. The content of message is intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture.</param>
|
||||
public ReferenceResolvingException(string message) |
||||
: base(message) |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:ResolveException"/> class
|
||||
/// </summary>
|
||||
/// <param name="message">A <see cref="T:System.String"/> that describes the error. The content of message is intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture.</param>
|
||||
/// <param name="inner">The exception that is the cause of the current exception. If the innerException parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception.</param>
|
||||
public ReferenceResolvingException(string message, Exception inner) |
||||
: base(message, inner) |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:ResolveException"/> class
|
||||
/// </summary>
|
||||
/// <param name="info">The object that holds the serialized object data.</param>
|
||||
/// <param name="context">The contextual information about the source or destination.</param>
|
||||
protected ReferenceResolvingException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) |
||||
: base(info, context) |
||||
{ |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using Mono.Cecil; |
||||
|
||||
namespace ICSharpCode.ILSpy.TreeNodes.Analyzer |
||||
{ |
||||
static class Helpers |
||||
{ |
||||
public static bool IsReferencedBy(TypeDefinition type, TypeReference typeRef) |
||||
{ |
||||
// TODO: move it to a better place after adding support for more cases.
|
||||
if (type == null) |
||||
throw new ArgumentNullException("type"); |
||||
if (typeRef == null) |
||||
throw new ArgumentNullException("typeRef"); |
||||
|
||||
if (type == typeRef) |
||||
return true; |
||||
if (type.Name != typeRef.Name) |
||||
return false; |
||||
if (type.Namespace != typeRef.Namespace) |
||||
return false; |
||||
|
||||
if (type.DeclaringType != null || typeRef.DeclaringType != null) { |
||||
if (type.DeclaringType == null || typeRef.DeclaringType == null) |
||||
return false; |
||||
if (!IsReferencedBy(type.DeclaringType, typeRef.DeclaringType)) |
||||
return false; |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue