Show / Hide Table of Contents

Class CilAnalysis

Provides static methods that assist in parsing and analysing CIL bytecode

Inheritance
System.Object
CilAnalysis
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: CilTools.BytecodeAnalysis
Assembly: CilTools.BytecodeAnalysis.dll
Syntax
public static class CilAnalysis

Methods

EscapeString(String)

Escapes special characters in the specified string, preparing it to be used as CIL assembler string literal

Declaration
public static string EscapeString(string str)
Parameters
Type Name Description
System.String str

The string to escape

Returns
Type Description
System.String

The escaped string

Remarks

See ECMA-335 II.5.2 for string literal escaping rules. In CIL Tools 2.3 and earlier versions, this method used string escaping rules for C# string literals.

GetReferencedMembers(Assembly)

Gets all members referenced by the code of specified assembly

Declaration
public static IEnumerable<MemberInfo> GetReferencedMembers(Assembly ass)
Parameters
Type Name Description
System.Reflection.Assembly ass

Assembly for which to retrieve referenced members

Returns
Type Description
System.Collections.Generic.IEnumerable<System.Reflection.MemberInfo>

A collection of MemberInfo objects

Remarks

Referenced member is a member that appears as an operand of instruction in any of the assembly's methods.

Exceptions
Type Condition
System.ArgumentNullException

Source assembly is null

GetReferencedMembers(Assembly, MemberCriteria)

Gets members referenced by the code of specified assembly that match specified criteria

Declaration
public static IEnumerable<MemberInfo> GetReferencedMembers(Assembly ass, MemberCriteria flags)
Parameters
Type Name Description
System.Reflection.Assembly ass

Assembly for which to retrieve referenced members

MemberCriteria flags

A combination of bitwise flags that control what kind of members are retrieved

Returns
Type Description
System.Collections.Generic.IEnumerable<System.Reflection.MemberInfo>

A collection of MemberInfo objects

Remarks

Referenced member is a member that appears as an operand of instruction in any of the assembly's methods.

Exceptions
Type Condition
System.ArgumentNullException

Source assembly is null

GetReferencedMembers(MethodBase)

Gets all members (fields or methods) referenced by specified method

Declaration
public static IEnumerable<MemberInfo> GetReferencedMembers(MethodBase mb)
Parameters
Type Name Description
System.Reflection.MethodBase mb

Method for which to retrieve referenced members

Returns
Type Description
System.Collections.Generic.IEnumerable<System.Reflection.MemberInfo>

A collection of MemberInfo objects

Remarks

Referenced member is a member that appears as an operand of instruction in source method's body. For example, if the source method calls Foo method or creates delegate pointing to Foo, Foo is referenced by the source method.

Exceptions
Type Condition
System.ArgumentNullException

Source method is null

GetReferencedMembers(MethodBase, MemberCriteria)

Gets members (fields or methods) referenced by specified method that match specified criteria

Declaration
public static IEnumerable<MemberInfo> GetReferencedMembers(MethodBase mb, MemberCriteria flags)
Parameters
Type Name Description
System.Reflection.MethodBase mb

Method for which to retrieve referenced members

MemberCriteria flags

A combination of bitwise flags that control what kind of members are retrieved

Returns
Type Description
System.Collections.Generic.IEnumerable<System.Reflection.MemberInfo>

A collection of MemberInfo objects

Remarks

Referenced member is a member that appears as an operand of instruction in source method's body. For example, if the source method calls Foo method or creates delegate pointing to Foo, Foo is referenced by the source method.

Exceptions
Type Condition
System.ArgumentNullException

Source method is null

System.NotSupportedException

CilReader encountered unknown opcode

CilParserException

Failed to retrieve method body for the method

GetReferencedMembers(Type)

Gets all members referenced by the code of specified type

Declaration
public static IEnumerable<MemberInfo> GetReferencedMembers(Type t)
Parameters
Type Name Description
System.Type t

Type for which to retrieve referenced members

Returns
Type Description
System.Collections.Generic.IEnumerable<System.Reflection.MemberInfo>

A collection of MemberInfo objects

Remarks

Referenced member is a member that appears as an operand of instruction in any of the type's methods.

Exceptions
Type Condition
System.ArgumentNullException

Source type is null

GetReferencedMembers(Type, MemberCriteria)

Gets members referenced by the code of specified type that match specified criteria

Declaration
public static IEnumerable<MemberInfo> GetReferencedMembers(Type t, MemberCriteria flags)
Parameters
Type Name Description
System.Type t

Type for which to retrieve referenced members

MemberCriteria flags

A combination of bitwise flags that control what kind of members are retrieved

Returns
Type Description
System.Collections.Generic.IEnumerable<System.Reflection.MemberInfo>

A collection of MemberInfo objects

Remarks

Referenced member is a member that appears as an operand of instruction in any of the type's methods.

Exceptions
Type Condition
System.ArgumentNullException

Source type is null

GetReferencedMethods(Assembly)

Get all methods that are referenced by the code in the specified assembly

Declaration
public static IEnumerable<MethodBase> GetReferencedMethods(Assembly ass)
Parameters
Type Name Description
System.Reflection.Assembly ass

Assembly for which to retrieve referenced methods

Returns
Type Description
System.Collections.Generic.IEnumerable<System.Reflection.MethodBase>

A collection of referenced methods

Remarks

Referenced member is a member that appears as an operand of instruction in any of the assembly's methods.

Exceptions
Type Condition
System.ArgumentNullException

Source assembly is null

GetReferencedMethods(MethodBase)

Gets all methods that are referenced by the specified method

Declaration
public static IEnumerable<MethodBase> GetReferencedMethods(MethodBase mb)
Parameters
Type Name Description
System.Reflection.MethodBase mb

Method for which to retrieve referenced methods

Returns
Type Description
System.Collections.Generic.IEnumerable<System.Reflection.MethodBase>

A collection of referenced methods

Remarks

Referenced member is a member that appears as an operand of instruction in source method's body. For example, if the source method calls Foo method or creates delegate pointing to Foo, Foo is referenced by the source method.

Exceptions
Type Condition
System.ArgumentNullException

Source method is null

GetReferencedMethods(Type)

Get all methods that are referenced by the code of the specified type

Declaration
public static IEnumerable<MethodBase> GetReferencedMethods(Type t)
Parameters
Type Name Description
System.Type t

Type for which to retrieve referenced methods

Returns
Type Description
System.Collections.Generic.IEnumerable<System.Reflection.MethodBase>

A collection of referenced methods

Remarks

Referenced member is a member that appears as an operand of instruction in any of the type's methods.

Exceptions
Type Condition
System.ArgumentNullException

Source type is null

GetTypeFullName(Type)

Gets the full name of .NET type in CIL notation

Declaration
public static string GetTypeFullName(Type t)
Parameters
Type Name Description
System.Type t

Type for which name is requested

Returns
Type Description
System.String

Full type name

Remarks

Returns fully qualified name, such as class [mscorlib]System.String

Exceptions
Type Condition
System.ArgumentNullException

t is null

GetTypeName(Type)

Gets the name of .NET type in CIL notation

Declaration
public static string GetTypeName(Type t)
Parameters
Type Name Description
System.Type t

Type for which name is requested

Returns
Type Description
System.String

Short of full type name

Remarks

Returns short type name, such as int32, if it exists. Otherwise returns full name.

Exceptions
Type Condition
System.ArgumentNullException

t is null

MethodToText(MethodBase)

Returns specified method CIL code as string

Declaration
public static string MethodToText(MethodBase m)
Parameters
Type Name Description
System.Reflection.MethodBase m

Method for which to retrieve CIL

Returns
Type Description
System.String

CIL code string

Back to top CIL Tools (published from sources in GitHub repository).
Generated by DocFX