本文整理汇总了C#中Mono.Cecil.TypeReference.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# TypeReference.ToString方法的具体用法?C# TypeReference.ToString怎么用?C# TypeReference.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Cecil.TypeReference
的用法示例。
在下文中一共展示了TypeReference.ToString方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DetermineType
/// <summary>
/// Determine type from field
/// </summary>
/// <param name="typeRef">The type reference.</param>
/// <returns>The type.</returns>
public static int DetermineType(TypeReference typeRef)
{
string type = typeRef.ToString();
// Pointer
if (type.Contains("*"))
return Types.TYPE_OBJ;
if (type == "System.UInt64" || type == "System.Int64")
return Types.TYPE_INT64;
else if (type == "System.Byte" || type == "System.SByte" || type == "System.UInt16" || type == "System.Int16" || type == "System.UInt32" || type == "System.Int32" || type == "System.Boolean")
return Types.TYPE_INT32;
else if (type == "System.Single")
return Types.TYPE_FLOAT;
else if (type == "System.Double")
return Types.TYPE_DOUBLE;
else if (type == "System.Char")
return Types.TYPE_INT32;
else if (type == "System.UIntPtr" || type == "System.IntPtr")
return Types.TYPE_INT32;
return Types.TYPE_OBJ;
}
示例2: TryLookUpTypeDefinition
private static TypeDefinition TryLookUpTypeDefinition(TypeReference reference)
{
// try find in the current assembly
foreach (TypeDefinition tempTypeDef in reference.Module.Types)
if (tempTypeDef.ToString() == reference.ToString())
return tempTypeDef;
return null;
}
示例3: CreateType
/// <summary>
/// Create a SharpDevelop return type from a Cecil type reference.
/// </summary>
internal static IReturnType CreateType(IProjectContent pc, IEntity member, TypeReference type)
{
while (type is TypeSpecification)
{
type = (type as TypeSpecification).ElementType;
}
if (type == null)
{
LoggingService.Warn("CecilReader: Null type for: " + member);
return new VoidReturnType(pc);
}
if (type is ByReferenceType)
{
// TODO: Use ByRefRefReturnType
return CreateType(pc, member, (type as ByReferenceType).ElementType);
} else if (type is PointerType)
{
return new PointerReturnType(CreateType(pc, member, (type as PointerType).ElementType));
} else if (type is ArrayType)
{
return new ArrayReturnType(pc, CreateType(pc, member, (type as ArrayType).ElementType), (type as ArrayType).Rank);
} else if (type is GenericInstanceType)
{
GenericInstanceType gType = (GenericInstanceType)type;
IReturnType[] para = new IReturnType[gType.GenericArguments.Count];
for (int i = 0; i < para.Length; ++i)
{
para[i] = CreateType(pc, member, gType.GenericArguments[i]);
}
return new ConstructedReturnType(CreateType(pc, member, gType.ElementType), para);
} else if (type is GenericParameter)
{
GenericParameter typeGP = type as GenericParameter;
if (typeGP.Owner is MethodDefinition)
{
IMethod method = member as IMethod;
if (method != null)
{
if (typeGP.Position < method.TypeParameters.Count)
{
return new GenericReturnType(method.TypeParameters[typeGP.Position]);
}
}
return new GenericReturnType(new DefaultTypeParameter(method, typeGP.Name, typeGP.Position));
} else {
IClass c = (member is IClass) ? (IClass)member : (member is IMember) ? ((IMember)member).DeclaringType : null;
if (c != null && typeGP.Position < c.TypeParameters.Count) {
if (c.TypeParameters[typeGP.Position].Name == type.Name) {
return new GenericReturnType(c.TypeParameters[typeGP.Position]);
}
}
return new GenericReturnType(new DefaultTypeParameter(c, typeGP.Name, typeGP.Position));
}
} else {
string name = type.FullName;
if (name == null)
throw new ApplicationException("type.FullName returned null. Type: " + type.ToString());
int typeParameterCount;
if (name.IndexOf('/') > 0) {
typeParameterCount = 0;
StringBuilder newName = new StringBuilder();
foreach (string namepart in name.Split('/')) {
if (newName.Length > 0)
newName.Append('.');
int partTypeParameterCount;
newName.Append(ReflectionClass.SplitTypeParameterCountFromReflectionName(namepart, out partTypeParameterCount));
typeParameterCount += partTypeParameterCount;
}
name = newName.ToString();
} else {
name = ReflectionClass.SplitTypeParameterCountFromReflectionName(name, out typeParameterCount);
}
IClass c = pc.GetClass(name, typeParameterCount);
if (c != null) {
return c.DefaultReturnType;
} else {
// example where name is not found: pointers like System.Char*
// or when the class is in a assembly that is not referenced
return new GetClassReturnType(pc, name, typeParameterCount);
}
}
}
示例4: CreateType
/// <summary>
/// Create a SharpDevelop return type from a Cecil type reference.
/// </summary>
internal static IReturnType CreateType(IProjectContent pc, IDecoration member, TypeReference type)
{
while (type is ModType) {
type = (type as ModType).ElementType;
}
if (type == null) {
LoggingService.Warn("CecilReader: Null type for: " + member);
return VoidReturnType.Instance;
}
if (type is ReferenceType) {
// TODO: Use ByRefRefReturnType
return CreateType(pc, member, (type as ReferenceType).ElementType);
} else if (type is ArrayType) {
return new ArrayReturnType(pc, CreateType(pc, member, (type as ArrayType).ElementType), (type as ArrayType).Rank);
} else if (type is GenericInstanceType) {
GenericInstanceType gType = (GenericInstanceType)type;
IReturnType[] para = new IReturnType[gType.GenericArguments.Count];
for (int i = 0; i < para.Length; ++i) {
para[i] = CreateType(pc, member, gType.GenericArguments[i]);
}
return new ConstructedReturnType(CreateType(pc, member, gType.ElementType), para);
} else if (type is GenericParameter) {
GenericParameter typeGP = type as GenericParameter;
if (typeGP.Owner is MethodDefinition) {
IMethod method = member as IMethod;
if (method != null) {
if (typeGP.Position < method.TypeParameters.Count) {
return new GenericReturnType(method.TypeParameters[typeGP.Position]);
}
}
return new GenericReturnType(new DefaultTypeParameter(method, typeGP.Name, typeGP.Position));
} else {
IClass c = (member is IClass) ? (IClass)member : (member is IMember) ? ((IMember)member).DeclaringType : null;
if (c != null && typeGP.Position < c.TypeParameters.Count) {
if (c.TypeParameters[typeGP.Position].Name == type.Name) {
return new GenericReturnType(c.TypeParameters[typeGP.Position]);
}
}
return new GenericReturnType(new DefaultTypeParameter(c, typeGP.Name, typeGP.Position));
}
} else {
string name = type.FullName;
if (name == null)
throw new ApplicationException("type.FullName returned null. Type: " + type.ToString());
if (name.IndexOf('/') > 0) {
name = name.Replace('/', '.');
}
int typeParameterCount = 0;
if (name.Length > 2 && name[name.Length - 2] == '`') {
typeParameterCount = name[name.Length - 1] - '0';
name = name.Substring(0, name.Length - 2);
}
IClass c = pc.GetClass(name, typeParameterCount);
if (c != null) {
return c.DefaultReturnType;
} else {
// example where name is not found: pointers like System.Char*
// or when the class is in a assembly that is not referenced
return new GetClassReturnType(pc, name, typeParameterCount);
}
}
}
示例5: TypeMatch
static bool TypeMatch (TypeReference a, TypeReference b, ref Dictionary<string,string> gp)
{
var gpa = a as GenericParameter;
if (gpa != null) {
if (gp == null)
gp = new Dictionary<string, string> ();
string match;
if (!gp.TryGetValue (gpa.FullName, out match)) {
// first use, we assume it will always be used this way
gp.Add (gpa.FullName, b.ToString ());
return true;
}
// re-use, it should match the previous usage
return match == b.ToString ();
}
if (a is TypeSpecification || b is TypeSpecification) {
if (a.GetType () != b.GetType ())
return false;
return TypeMatch ((TypeSpecification) a, (TypeSpecification) b, ref gp);
}
return a.FullName == b.FullName;
}
示例6: GetClassRef
XNodeOut GetClassRef(TypeReference declaringType)
{
//if(!declaringType.IsGenericParameter && !declaringType.IsFunctionPointer)
// XDef.ParseAndCheck(declaringType.ToString());
if (declaringType.IsGenericParameter)
Debug.WriteLine("GetClassRef for Generic Param - " + declaringType.ToString());
if (declaringType.IsFunctionPointer)
Debug.WriteLine("GetClassRef for Function Pointer - " + declaringType.ToString());
var scope = declaringType.Scope;
if (scope.MetadataScopeType == MetadataScopeType.ModuleReference)
{
// is this scope type internal or external, should it be tracked externally?
Debug.WriteLine("Skipped GetClassRef for - " + declaringType.ToString());
Debug.Assert(false);
return null;
}
//string namespaces = (declaringType.DeclaringType != null) ? declaringType.DeclaringType.Namespace : declaringType.Namespace;
//string className = declaringType.Name;
XNodeOut fileNode = null;
// if xrayed internal
if (scope.MetadataScopeType == MetadataScopeType.ModuleDefinition)
fileNode = XFile.FileNode;
// xrayed, but in diff module
else if (Build.Files.Any(f => f.AssemblyName == scope.Name))
fileNode = Build.Files.First(f => f.AssemblyName == scope.Name).FileNode;
// if not xrayed - map to external root
else
{
string moduleName = scope.Name;
fileNode = ExtRoot.AddNode(moduleName, XObjType.File);
}
return SignatureToClass(declaringType.ToString(), fileNode);
}
示例7: CreateType
ITypeReference CreateType(
TypeReference type,
IEntity entity,
ICustomAttributeProvider typeAttributes, ref int typeIndex)
{
while (type is OptionalModifierType || type is RequiredModifierType) {
type = ((TypeSpecification)type).ElementType;
}
if (type == null) {
return SharedTypes.UnknownType;
}
if (type is Mono.Cecil.ByReferenceType) {
typeIndex++;
return ByReferenceTypeReference.Create(
CreateType(
(type as Mono.Cecil.ByReferenceType).ElementType,
entity, typeAttributes, ref typeIndex));
} else if (type is Mono.Cecil.PointerType) {
typeIndex++;
return PointerTypeReference.Create(
CreateType(
(type as Mono.Cecil.PointerType).ElementType,
entity, typeAttributes, ref typeIndex));
} else if (type is Mono.Cecil.ArrayType) {
typeIndex++;
return ArrayTypeReference.Create(
CreateType(
(type as Mono.Cecil.ArrayType).ElementType,
entity, typeAttributes, ref typeIndex),
(type as Mono.Cecil.ArrayType).Rank);
} else if (type is GenericInstanceType) {
GenericInstanceType gType = (GenericInstanceType)type;
ITypeReference baseType = CreateType(gType.ElementType, entity, typeAttributes, ref typeIndex);
ITypeReference[] para = new ITypeReference[gType.GenericArguments.Count];
for (int i = 0; i < para.Length; ++i) {
typeIndex++;
para[i] = CreateType(gType.GenericArguments[i], entity, typeAttributes, ref typeIndex);
}
return ParameterizedTypeReference.Create(baseType, para);
} else if (type is GenericParameter) {
GenericParameter typeGP = type as GenericParameter;
if (typeGP.Owner is MethodDefinition) {
IMethod method = entity as IMethod;
if (method != null) {
if (typeGP.Position < method.TypeParameters.Count) {
return method.TypeParameters[typeGP.Position];
}
}
return SharedTypes.UnknownType;
} else {
ITypeDefinition c = (entity as ITypeDefinition) ?? (entity is IMember ? ((IMember)entity).DeclaringTypeDefinition : null);
if (c != null && typeGP.Position < c.TypeParameters.Count) {
if (c.TypeParameters[typeGP.Position].Name == type.Name) {
return c.TypeParameters[typeGP.Position];
}
}
return SharedTypes.UnknownType;
}
} else if (type.IsNested) {
ITypeReference typeRef = CreateType(type.DeclaringType, entity, typeAttributes, ref typeIndex);
int partTypeParameterCount;
string namepart = ReflectionHelper.SplitTypeParameterCountFromReflectionName(type.Name, out partTypeParameterCount);
return new NestedTypeReference(typeRef, namepart, partTypeParameterCount);
} else {
string ns = type.Namespace ?? string.Empty;
string name = type.Name;
if (name == null)
throw new InvalidOperationException("type.Name returned null. Type: " + type.ToString());
if (name == "Object" && ns == "System" && HasDynamicAttribute(typeAttributes, typeIndex)) {
return SharedTypes.Dynamic;
} else {
int typeParameterCount;
name = ReflectionHelper.SplitTypeParameterCountFromReflectionName(name, out typeParameterCount);
var earlyBindContext = this.EarlyBindContext;
if (earlyBindContext != null) {
IType c = earlyBindContext.GetClass(ns, name, typeParameterCount, StringComparer.Ordinal);
if (c != null)
return c;
}
return new GetClassTypeReference(ns, name, typeParameterCount);
}
}
}
示例8: ConvertType
static AstType ConvertType(TypeReference type, ICustomAttributeProvider typeAttributes, ref int typeIndex)
{
while (type is OptionalModifierType || type is RequiredModifierType) {
type = ((TypeSpecification)type).ElementType;
}
if (type == null) {
return AstType.Null;
}
if (type is Mono.Cecil.ByReferenceType) {
typeIndex++;
// ignore by reference type (cannot be represented in C#)
return ConvertType((type as Mono.Cecil.ByReferenceType).ElementType, typeAttributes, ref typeIndex);
} else if (type is Mono.Cecil.PointerType) {
typeIndex++;
return ConvertType((type as Mono.Cecil.PointerType).ElementType, typeAttributes, ref typeIndex)
.MakePointerType();
} else if (type is Mono.Cecil.ArrayType) {
typeIndex++;
return ConvertType((type as Mono.Cecil.ArrayType).ElementType, typeAttributes, ref typeIndex)
.MakeArrayType((type as Mono.Cecil.ArrayType).Rank);
} else if (type is GenericInstanceType) {
GenericInstanceType gType = (GenericInstanceType)type;
if (gType.ElementType.Namespace == "System" && gType.ElementType.Name == "Nullable`1" && gType.GenericArguments.Count == 1) {
typeIndex++;
return new ComposedType {
BaseType = ConvertType(gType.GenericArguments[0], typeAttributes, ref typeIndex),
HasNullableSpecifier = true
};
}
AstType baseType = ConvertType(gType.ElementType, typeAttributes, ref typeIndex);
List<AstType> typeArguments = new List<AstType>();
foreach (var typeArgument in gType.GenericArguments) {
typeIndex++;
typeArguments.Add(ConvertType(typeArgument, typeAttributes, ref typeIndex));
}
ApplyTypeArgumentsTo(baseType, typeArguments);
return baseType;
} else if (type is GenericParameter) {
return new SimpleType(type.Name);
} else if (type.IsNested) {
AstType typeRef = ConvertType(type.DeclaringType, typeAttributes, ref typeIndex);
string namepart = ICSharpCode.NRefactory.TypeSystem.ReflectionHelper.SplitTypeParameterCountFromReflectionName(type.Name);
return new MemberType { Target = typeRef, MemberName = namepart }.WithAnnotation(type);
} else {
string ns = type.Namespace ?? string.Empty;
string name = type.Name;
if (name == null)
throw new InvalidOperationException("type.Name returned null. Type: " + type.ToString());
if (name == "Object" && ns == "System" && HasDynamicAttribute(typeAttributes, typeIndex)) {
return new PrimitiveType("dynamic");
} else {
if (ns == "System") {
switch (name) {
case "SByte":
return new PrimitiveType("sbyte");
case "Int16":
return new PrimitiveType("short");
case "Int32":
return new PrimitiveType("int");
case "Int64":
return new PrimitiveType("long");
case "Byte":
return new PrimitiveType("byte");
case "UInt16":
return new PrimitiveType("ushort");
case "UInt32":
return new PrimitiveType("uint");
case "UInt64":
return new PrimitiveType("ulong");
case "String":
return new PrimitiveType("string");
case "Single":
return new PrimitiveType("float");
case "Double":
return new PrimitiveType("double");
case "Decimal":
return new PrimitiveType("decimal");
case "Char":
return new PrimitiveType("char");
case "Boolean":
return new PrimitiveType("bool");
case "Void":
return new PrimitiveType("void");
case "Object":
return new PrimitiveType("object");
}
}
name = ICSharpCode.NRefactory.TypeSystem.ReflectionHelper.SplitTypeParameterCountFromReflectionName(name);
// TODO: Until we can simplify type with 'using', use just the name without namesapce
return new SimpleType(name).WithAnnotation(type);
// if (ns.Length == 0)
// return new SimpleType(name).WithAnnotation(type);
// string[] parts = ns.Split('.');
// AstType nsType = new SimpleType(parts[0]);
// for (int i = 1; i < parts.Length; i++) {
//.........这里部分代码省略.........
示例9: ReferenceTypeSpecification
private TypeReference ReferenceTypeSpecification(TypeReference type, params IGenericParameterProvider[] paramProviders)
{
if (type.IsRequiredModifier)
{
var requiredModifier = (RequiredModifierType)type;
var modifierType = ReferenceType(requiredModifier.ModifierType, paramProviders);
return ReferenceType(requiredModifier.ElementType, paramProviders).MakeRequiredModifierType(modifierType);
}
else if (type.IsByReference)
{
return ReferenceType(((ByReferenceType)type).ElementType, paramProviders).MakeByReferenceType();
}
else if (type.IsArray)
{
var array = (ArrayType)type;
return ReferenceType(array.ElementType, paramProviders).MakeArrayType(array.Rank);
}
else if (type.IsGenericInstance)
{
var genericInstance = (GenericInstanceType)type;
var elementType = ReferenceType(genericInstance.ElementType, paramProviders);
return ReferenceGenericInstanceType(genericInstance, elementType, paramProviders);
}
//TODO PointerType, PinnedType, SentinelType, OptionalModifierType, SzArray ?
else
{
throw new NotSupportedException(type.ToString());
}
}
示例10: GetClass
internal Class GetClass (TypeReference type)
{
if (type is GenericParameter
&& this.genericInstanceType != null) {
GenericParameter genericParameter = type as GenericParameter;
int i = 0;
for (; i < genericParameter.Owner.GenericParameters.Count; i++) {
if (genericParameter.Owner.GenericParameters [i].FullName == genericParameter.FullName)
break;
}
if (i >= genericParameter.Owner.GenericParameters.Count)
throw new EngineException (string.Format ("Type '{0}' was not found in the method '{1}'.", type.ToString (), this.TypeFullName));
type = this.genericInstanceType.GenericArguments [i];
} else if (type is GenericInstanceType
&& (type as GenericInstanceType).GenericArguments [0] is GenericParameter) {
GenericInstanceType _genericInstanceType = new GenericInstanceType ((type as GenericInstanceType).ElementType);
for (int i = 0; i < (type as GenericInstanceType).GenericArguments.Count; i++)
_genericInstanceType.GenericArguments.Add (this.genericInstanceType.GenericArguments [i]);
return this.GetClass (_genericInstanceType);
}
return this.engine.GetClass (type);
}
示例11: ImportType
private ImportedType ImportType(TypeReference tref)
{
if (tref == null) return null;
switch (tref.MetadataType)
{
case MetadataType.Pointer:
case MetadataType.Pinned:
case MetadataType.Array:
ImportType(tref.GetElementType());
return null;
case MetadataType.OptionalModifier:
case MetadataType.RequiredModifier:
case MetadataType.ByReference:
return ImportType(tref.GetElementType());
case MetadataType.Boolean:
case MetadataType.Byte:
case MetadataType.Char:
case MetadataType.Double:
case MetadataType.FunctionPointer:
case MetadataType.GenericInstance:
case MetadataType.Int16:
case MetadataType.Int32:
case MetadataType.Int64:
case MetadataType.IntPtr:
case MetadataType.MVar:
case MetadataType.Object:
case MetadataType.SByte:
case MetadataType.Single:
case MetadataType.String:
case MetadataType.UInt16:
case MetadataType.UInt32:
case MetadataType.UInt64:
case MetadataType.UIntPtr:
case MetadataType.ValueType:
case MetadataType.Var:
case MetadataType.Void:
case MetadataType.TypedByReference:
return null;
}
if (tref is GenericInstanceType)
{
GenericInstanceType gt = (GenericInstanceType)tref;
for (int i = 0; i < gt.GenericArguments.Count; i++)
ImportType(gt.GenericArguments[i]);
if (gt.ElementType is TypeDefinition) return null;
tref = gt.ElementType;
}
if (tref is TypeDefinition) return null;
if (typeCache.ContainsKey(tref)) return typeCache[tref];
if (Program.IsFiltered(tref)) return null;
var mod = output.library.Where(a => a.name == tref.Scope.Name).FirstOrDefault();
if (mod == null)
{
mod = new ImportedLibrary();
mod.name = tref.Scope.Name;
mod.fullname = tref.Module.AssemblyReferences.Where(a => a.Name == tref.Scope.Name).FirstOrDefault().FullName;
output.library.Add(mod);
}
var it = new ImportedType();
it.name = tref.ToString();
mod.type.Add(it);
typeCache.Add(tref, it);
return it;
}
示例12: StringifyTypeRef
string StringifyTypeRef (TypeReference t) {
switch (t.MetadataType) {
case MetadataType.Void:
return "void";
case MetadataType.Boolean:
return "bool";
case MetadataType.Char:
return "char";
case MetadataType.SByte:
return "int8";
case MetadataType.Byte:
return "unsigned int8";
case MetadataType.Int16:
return "int16";
case MetadataType.UInt16:
return "unsigned int16";
case MetadataType.Int32:
return "int32";
case MetadataType.UInt32:
return "unsigned int32";
case MetadataType.Int64:
return "int64";
case MetadataType.UInt64:
return "unsigned int64";
case MetadataType.Single:
return "float32";
case MetadataType.Double:
return "float64";
case MetadataType.String:
return "string";
case MetadataType.IntPtr:
return "native int";
case MetadataType.UIntPtr:
//return "unsigned native int";
return "[mscorlib]System.UIntPtr";
case MetadataType.TypedByReference:
return "typedref";
case MetadataType.Class:
case MetadataType.Object:
case MetadataType.ValueType: {
var sb = new StringBuilder ();
IMetadataScope s = t.Scope;
if (t.MetadataType == MetadataType.ValueType)
sb.Append ("valuetype ");
else
sb.Append ("class ");
EmitScope (s, sb);
sb.Append (EscapeName (t.FullName));
return sb.ToString ();
}
case MetadataType.Array: {
ArrayType at = (t as ArrayType);
if (at.IsVector)
return StringifyTypeRef (at.ElementType) + "[]";
var suffix = new StringBuilder ();
suffix.Append ("[");
for (int i = 0; i < at.Dimensions.Count; i++) {
if (i > 0)
suffix.Append (",");
suffix.Append (at.Dimensions [i].ToString ());
}
suffix.Append ("]");
return StringifyTypeRef (at.ElementType) + suffix;
}
case MetadataType.Pointer:
return StringifyTypeRef ((t as TypeSpecification).ElementType) + "*";
case MetadataType.ByReference:
return StringifyTypeRef ((t as TypeSpecification).ElementType) + "&";
case MetadataType.Pinned:
return StringifyTypeRef ((t as TypeSpecification).ElementType) + " pinned";
case MetadataType.GenericInstance: {
var sb = new StringBuilder ();
var inst = (t as GenericInstanceType);
sb.Append (StringifyTypeRef (inst.ElementType));
sb.Append ("<");
int aindex = 0;
foreach (TypeReference arg in inst.GenericArguments) {
if (aindex > 0)
sb.Append (", ");
sb.Append (StringifyTypeRef (arg));
aindex ++;
}
sb.Append (">");
return sb.ToString ();
}
case MetadataType.Var:
return "!" + (t as GenericParameter).Position;
case MetadataType.MVar:
return "!!" + (t as GenericParameter).Position;
case MetadataType.Sentinel:
return "..., " + StringifyTypeRef ((t as SentinelType).ElementType);
case MetadataType.RequiredModifier: {
var mod = (t as RequiredModifierType);
if (mod.ModifierType.MetadataType != MetadataType.Class)
throw new NotImplementedException ();
var sb = new StringBuilder ();
//.........这里部分代码省略.........
示例13: Element
/// <summary>
/// Elements the specified type definition.
/// </summary>
/// <param name="typeDefinition">The type definition.</param>
public void Element (TypeReference typeDefinition)
{
this.AddElement ("type", typeDefinition.ToString ());
}