C# Class Gendarme.Framework.Rocks.TypeRocks

TypeRocks contains extensions methods for Type[Definition|Reference] and the related collection classes. Note: whenever possible try to use TypeReference since it's extend the reach/usability of the code.
Datei anzeigen Open project: remobjects/mono-tools

Public Methods

Method Description
AllSuperTypes ( this self ) : IEnumerable

Returns an IEnumerable that allows a single loop (like a foreach) to traverse all base classes and interfaces inherited by the type.

GetMethod ( this self, bool>.Func customCondition ) : Mono.Cecil.MethodDefinition

Searches for a method using a custom condition.

GetMethod ( this self, MethodAttributes attributes, string name ) : Mono.Cecil.MethodDefinition

Searches for a method by attributes and by name.

GetMethod ( this self, MethodAttributes attributes, string name, string returnType, string parameters ) : Mono.Cecil.MethodDefinition

Searches for a method by name, returnType, parameters and attributes.

GetMethod ( this self, MethodAttributes attributes, string name, string returnType, string parameters, bool>.Func customCondition ) : Mono.Cecil.MethodDefinition

Searches for a method.

GetMethod ( this self, Gendarme.Framework.Helpers.MethodSignature signature ) : Mono.Cecil.MethodDefinition

Returns the first MethodDefinition that satisfies a given MethodSignature.

Do not allocate a MethodSignature for only one call. Use one of the other GetMethod overloads instead.

GetMethod ( this self, string name ) : Mono.Cecil.MethodDefinition

Searches for a method with a specific name.

GetMethod ( this self, string name, string returnType, string parameters ) : Mono.Cecil.MethodDefinition

Searches for a method by name, returnType and parameters.

HasMethod ( this self, Gendarme.Framework.Helpers.MethodSignature signature ) : bool

Checks if at least one Method satisfies a given MethodSignature.

Implements ( this self, string nameSpace, string name ) : bool

Recursively check if the type implemented a specified interface. Note that it is possible that we might now be able to know everything that a type implements since the assembly where the information resides could be unavailable. False is returned in this case.

Inherits ( this self, string nameSpace, string name ) : bool

Check if the type inherits from the specified type. Note that it is possible that we might not be able to know the complete inheritance chain since the assembly where the information resides could be unavailable.

IsAttribute ( this self ) : bool

Checks if type is attribute. Note that it is possible that we might now be able to know all inheritance since the assembly where the information resides could be unavailable.

IsDelegate ( this self ) : bool

Check if the type is a delegate.

IsFlags ( this self ) : bool

Check if the type is a enumeration flags.

IsFloatingPoint ( this self ) : bool

Check if the type represent a floating-point type.

IsGeneratedCode ( this self ) : bool

Check if the type is generated code, either by the compiler or by a tool.

IsNamed ( this self, string fullName ) : bool

Check if the type full name match the provided parameter. Note: prefer the overload where the namespace and type name can be supplied individually

IsNamed ( this self, string nameSpace, string name ) : bool

Check if the type and its namespace are named like the provided parameters. This is preferred to checking the FullName property since the later can allocate (string) memory.

IsNative ( this self ) : bool

Check if the type refers to native code.

IsStatic ( this self ) : bool

Check if the type is static (2.0+)

IsVisible ( this self ) : bool

Check if the type is visible outside of the assembly.

Private Methods

Method Description
Implements ( Mono.Cecil.TypeDefinition type, string nameSpace, string iname ) : bool
Match ( TypeReference type, string nameSpace, string name ) : bool

Method Details

AllSuperTypes() public static method

Returns an IEnumerable that allows a single loop (like a foreach) to traverse all base classes and interfaces inherited by the type.
public static AllSuperTypes ( this self ) : IEnumerable
self this The TypeReference on which the extension method can be called.
return IEnumerable

GetMethod() public static method

Searches for a method using a custom condition.
public static GetMethod ( this self, bool>.Func customCondition ) : Mono.Cecil.MethodDefinition
self this The TypeReference on which the extension method can be called.
customCondition bool>.Func A custom condition that is called for each MethodDefinition.
return Mono.Cecil.MethodDefinition

GetMethod() public static method

Searches for a method by attributes and by name.
public static GetMethod ( this self, MethodAttributes attributes, string name ) : Mono.Cecil.MethodDefinition
self this The TypeReference on which the extension method can be called.
attributes MethodAttributes An attribute mask matched against the attributes of the method.
name string The name of the method to match. Ignored if null.
return Mono.Cecil.MethodDefinition

GetMethod() public static method

Searches for a method by name, returnType, parameters and attributes.
public static GetMethod ( this self, MethodAttributes attributes, string name, string returnType, string parameters ) : Mono.Cecil.MethodDefinition
self this The TypeReference on which the extension method can be called.
attributes MethodAttributes An attribute mask matched against the attributes of the method.
name string The name of the method to match. Ignored if null.
returnType string The full name (Namespace.Type) of the return type. Ignored if null.
parameters string An array of full names (Namespace.Type) of parameter types. Ignored if null. Null entries act as wildcard.
return Mono.Cecil.MethodDefinition

GetMethod() public static method

Searches for a method.
public static GetMethod ( this self, MethodAttributes attributes, string name, string returnType, string parameters, bool>.Func customCondition ) : Mono.Cecil.MethodDefinition
self this The TypeReference on which the extension method can be called.
attributes MethodAttributes An attribute mask matched against the attributes of the method.
name string The name of the method to match. Ignored if null.
returnType string The full name (Namespace.Type) of the return type. Ignored if null.
parameters string An array of full names (Namespace.Type) of parameter types. Ignored if null. Null entries act as wildcards.
customCondition bool>.Func A custom condition that is called for each MethodDefinition that satisfies all other conditions. Ignored if null.
return Mono.Cecil.MethodDefinition

GetMethod() public static method

Returns the first MethodDefinition that satisfies a given MethodSignature.
Do not allocate a MethodSignature for only one call. Use one of the other GetMethod overloads instead.
public static GetMethod ( this self, Gendarme.Framework.Helpers.MethodSignature signature ) : Mono.Cecil.MethodDefinition
self this The TypeReference on which the extension method can be called.
signature Gendarme.Framework.Helpers.MethodSignature The MethodSignature to match.
return Mono.Cecil.MethodDefinition

GetMethod() public static method

Searches for a method with a specific name.
public static GetMethod ( this self, string name ) : Mono.Cecil.MethodDefinition
self this The TypeReference on which the extension method can be called.
name string The name of the method to match.
return Mono.Cecil.MethodDefinition

GetMethod() public static method

Searches for a method by name, returnType and parameters.
public static GetMethod ( this self, string name, string returnType, string parameters ) : Mono.Cecil.MethodDefinition
self this The TypeReference on which the extension method can be called.
name string The name of the method to match. Ignored if null.
returnType string The full name (Namespace.Type) of the return type. Ignored if null.
parameters string An array of full names (Namespace.Type) of parameter types. Ignored if null. Null entries act as wildcards.
return Mono.Cecil.MethodDefinition

HasMethod() public static method

Checks if at least one Method satisfies a given MethodSignature.
public static HasMethod ( this self, Gendarme.Framework.Helpers.MethodSignature signature ) : bool
self this The TypeReference on which the extension method can be called.
signature Gendarme.Framework.Helpers.MethodSignature The MethodSignature to match.
return bool

Implements() public static method

Recursively check if the type implemented a specified interface. Note that it is possible that we might now be able to know everything that a type implements since the assembly where the information resides could be unavailable. False is returned in this case.
public static Implements ( this self, string nameSpace, string name ) : bool
self this The TypeDefinition on which the extension method can be called.
nameSpace string The namespace of the interface to be matched
name string The name of the interface to be matched
return bool

Inherits() public static method

Check if the type inherits from the specified type. Note that it is possible that we might not be able to know the complete inheritance chain since the assembly where the information resides could be unavailable.
public static Inherits ( this self, string nameSpace, string name ) : bool
self this The TypeReference on which the extension method can be called.
nameSpace string The namespace of the base class to be matched
name string The name of the base class to be matched
return bool

IsAttribute() public static method

Checks if type is attribute. Note that it is possible that we might now be able to know all inheritance since the assembly where the information resides could be unavailable.
public static IsAttribute ( this self ) : bool
self this The TypeReference on which the extension method can be called.
return bool

IsDelegate() public static method

Check if the type is a delegate.
public static IsDelegate ( this self ) : bool
self this The TypeReference on which the extension method can be called.
return bool

IsFlags() public static method

Check if the type is a enumeration flags.
public static IsFlags ( this self ) : bool
self this The TypeReference on which the extension method can be called.
return bool

IsFloatingPoint() public static method

Check if the type represent a floating-point type.
public static IsFloatingPoint ( this self ) : bool
self this The TypeReference on which the extension method can be called.
return bool

IsGeneratedCode() public static method

Check if the type is generated code, either by the compiler or by a tool.
public static IsGeneratedCode ( this self ) : bool
self this The TypeReference on which the extension method can be called.
return bool

IsNamed() public static method

Check if the type full name match the provided parameter. Note: prefer the overload where the namespace and type name can be supplied individually
public static IsNamed ( this self, string fullName ) : bool
self this The TypeReference on which the extension method can be called.
fullName string The full name to be matched
return bool

IsNamed() public static method

Check if the type and its namespace are named like the provided parameters. This is preferred to checking the FullName property since the later can allocate (string) memory.
public static IsNamed ( this self, string nameSpace, string name ) : bool
self this The TypeReference on which the extension method can be called.
nameSpace string The namespace to be matched
name string The type name to be matched
return bool

IsNative() public static method

Check if the type refers to native code.
public static IsNative ( this self ) : bool
self this The TypeReference on which the extension method can be called.
return bool

IsStatic() public static method

Check if the type is static (2.0+)
public static IsStatic ( this self ) : bool
self this The TypeReference on which the extension method can be called.
return bool

IsVisible() public static method

Check if the type is visible outside of the assembly.
public static IsVisible ( this self ) : bool
self this The TypeReference on which the extension method can be called.
return bool