Esempio n. 1
0
 /// <summary>
 /// Checks whether it can access a <see cref="TypeSpec"/>
 /// </summary>
 /// <param name="ts">The type spec</param>
 /// <returns><c>true</c> if it has access to it, <c>false</c> if not, and <c>null</c>
 /// if we can't determine it (eg. we couldn't resolve a type or input was <c>null</c>)</returns>
 public bool?CanAccess(TypeSpec ts)
 {
     return(CanAccess(ts.ResolveTypeDef()));
 }
		IAssembly GetDefinitionAssembly(TypeSpec typeSpec) {
			if (typeSpec == null)
				return null;
			return GetDefinitionAssembly(typeSpec.TypeSig);
		}
		/// <summary>
		/// Returns the assembly where this type is defined
		/// </summary>
		/// <param name="typeSpec">The <c>TypeSpec</c></param>
		/// <returns>A <see cref="IAssembly"/> or <c>null</c> if none found</returns>
		public static IAssembly DefinitionAssembly(TypeSpec typeSpec) {
			return new FullNameCreator().GetDefinitionAssembly(typeSpec);
		}
		/// <summary>
		/// Gets the scope
		/// </summary>
		/// <param name="typeSpec">The <c>TypeSpec</c></param>
		/// <returns>The <see cref="IScope"/> or <c>null</c> if none found</returns>
		public static IScope Scope(TypeSpec typeSpec) {
			return new FullNameCreator().GetScope(typeSpec);
		}
		/// <summary>
		/// Returns the full name of a <see cref="TypeSpec"/>
		/// </summary>
		/// <param name="typeSpec">The <c>TypeSpec</c></param>
		/// <param name="isReflection">Set if output should be compatible with reflection</param>
		/// <returns>The full name</returns>
		public static string FullName(TypeSpec typeSpec, bool isReflection) {
			return FullName(typeSpec, isReflection, null);
		}
		/// <summary>
		/// Returns the assembly qualified full name of a <see cref="TypeSpec"/>
		/// </summary>
		/// <param name="typeSpec">The <c>TypeSpec</c></param>
		/// <returns>The assembly qualified full name</returns>
		public static string AssemblyQualifiedName(TypeSpec typeSpec) {
			return AssemblyQualifiedName(typeSpec, null);
		}
Esempio n. 7
0
 /// <summary>
 /// Returns the assembly qualified full name of a <see cref="TypeSpec"/>
 /// </summary>
 /// <param name="typeSpec">The <c>TypeSpec</c></param>
 /// <param name="helper">Helps print the name</param>
 /// <param name="sb">String builder to use or null</param>
 /// <returns>The assembly qualified full name</returns>
 public static StringBuilder AssemblyQualifiedNameSB(TypeSpec typeSpec, IFullNameCreatorHelper helper, StringBuilder sb)
 {
     var fnc = new FullNameCreator(true, helper, sb);
     fnc.CreateAssemblyQualifiedName(typeSpec);
     return fnc.sb ?? new StringBuilder();
 }
		ModuleDef GetOwnerModule(TypeSpec typeSpec) {
			if (typeSpec == null)
				return null;
			return GetOwnerModule(typeSpec.TypeSig);
		}
Esempio n. 9
0
 /// <summary>
 /// Returns the assembly qualified full name of a <see cref="TypeSpec"/>
 /// </summary>
 /// <param name="typeSpec">The <c>TypeSpec</c></param>
 /// <returns>The assembly qualified full name</returns>
 public static string AssemblyQualifiedName(TypeSpec typeSpec)
 {
     return AssemblyQualifiedNameSB(typeSpec, null, null).ToString();
 }
Esempio n. 10
0
 /// <summary>
 /// Returns the assembly qualified full name of a <see cref="TypeSpec"/>
 /// </summary>
 /// <param name="typeSpec">The <c>TypeSpec</c></param>
 /// <param name="helper">Helps print the name</param>
 /// <param name="sb">String builder to use or null</param>
 /// <returns>The assembly qualified full name</returns>
 public static string AssemblyQualifiedName(TypeSpec typeSpec, IFullNameCreatorHelper helper, StringBuilder sb)
 {
     return AssemblyQualifiedNameSB(typeSpec, helper, sb).ToString();
 }
Esempio n. 11
0
 /// <summary>
 /// Returns the namespace of a <see cref="TypeSpec"/>
 /// </summary>
 /// <param name="typeSpec">The <c>TypeSpec</c></param>
 /// <param name="isReflection">Set if output should be compatible with reflection</param>
 /// <param name="sb">String builder to use or null</param>
 /// <returns>The namespace</returns>
 public static StringBuilder NamespaceSB(TypeSpec typeSpec, bool isReflection, StringBuilder sb)
 {
     var fnc = new FullNameCreator(isReflection, null, sb);
     fnc.CreateNamespace(typeSpec);
     return fnc.sb ?? new StringBuilder();
 }
Esempio n. 12
0
 /// <summary>
 /// Returns the namespace of a <see cref="TypeSpec"/>
 /// </summary>
 /// <param name="typeSpec">The <c>TypeSpec</c></param>
 /// <param name="isReflection">Set if output should be compatible with reflection</param>
 /// <param name="sb">String builder to use or null</param>
 /// <returns>The namespace</returns>
 public static string Namespace(TypeSpec typeSpec, bool isReflection, StringBuilder sb)
 {
     return NamespaceSB(typeSpec, isReflection, sb).ToString();
 }
Esempio n. 13
0
 /// <summary>
 /// Returns the namespace of a <see cref="TypeSpec"/>
 /// </summary>
 /// <param name="typeSpec">The <c>TypeSpec</c></param>
 /// <param name="isReflection">Set if output should be compatible with reflection</param>
 /// <returns>The namespace</returns>
 public static string Namespace(TypeSpec typeSpec, bool isReflection)
 {
     return NamespaceSB(typeSpec, isReflection, null).ToString();
 }
		IScope GetScope(TypeSpec typeSpec) {
			if (typeSpec == null)
				return null;
			return GetScope(typeSpec.TypeSig);
		}
Esempio n. 15
0
 /// <summary>
 /// Returns the full name of a <see cref="TypeSpec"/>
 /// </summary>
 /// <param name="typeSpec">The <c>TypeSpec</c></param>
 /// <param name="isReflection">Set if output should be compatible with reflection</param>
 /// <param name="helper">Helps print the name</param>
 /// <param name="sb">String builder to use or null</param>
 /// <returns>The full name</returns>
 public static string FullName(TypeSpec typeSpec, bool isReflection, IFullNameCreatorHelper helper, StringBuilder sb)
 {
     return FullNameSB(typeSpec, isReflection, helper, sb).ToString();
 }
		ITypeDefOrRef GetScopeType(TypeSpec typeSpec) {
			if (typeSpec == null)
				return null;
			return GetScopeType(typeSpec.TypeSig);
		}
Esempio n. 17
0
 /// <summary>
 /// Returns the full name of a <see cref="TypeSpec"/>
 /// </summary>
 /// <param name="typeSpec">The <c>TypeSpec</c></param>
 /// <param name="isReflection">Set if output should be compatible with reflection</param>
 /// <param name="helper">Helps print the name</param>
 /// <param name="sb">String builder to use or null</param>
 /// <returns>The full name</returns>
 public static StringBuilder FullNameSB(TypeSpec typeSpec, bool isReflection, IFullNameCreatorHelper helper, StringBuilder sb)
 {
     var fnc = new FullNameCreator(isReflection, helper, sb);
     fnc.CreateFullName(typeSpec);
     return fnc.sb ?? new StringBuilder();
 }
		/// <summary>
		/// Returns the name of a <see cref="TypeSpec"/>
		/// </summary>
		/// <param name="typeSpec">The <c>TypeSpec</c></param>
		/// <param name="isReflection">Set if output should be compatible with reflection</param>
		/// <returns>The name</returns>
		public static string Name(TypeSpec typeSpec, bool isReflection) {
			var fnc = new FullNameCreator(isReflection, null);
			fnc.CreateName(typeSpec);
			return fnc.Result;
		}
Esempio n. 19
0
		/// <summary>
		/// Checks whether <paramref name="type"/> contains a <see cref="GenericVar"/> or a
		/// <see cref="GenericMVar"/>.
		/// </summary>
		/// <param name="type">Type</param>
		/// <returns><c>true</c> if <paramref name="type"/> contains a <see cref="GenericVar"/> or a
		/// <see cref="GenericMVar"/>.</returns>
		public static bool ContainsGenericParameter(TypeSpec type) {
			return new TypeHelper().ContainsGenericParameterInternal(type);
		}
		/// <summary>
		/// Returns the full name of a <see cref="TypeSpec"/>
		/// </summary>
		/// <param name="typeSpec">The <c>TypeSpec</c></param>
		/// <param name="isReflection">Set if output should be compatible with reflection</param>
		/// <param name="helper">Helps print the name</param>
		/// <returns>The full name</returns>
		public static string FullName(TypeSpec typeSpec, bool isReflection, IFullNameCreatorHelper helper) {
			var fnc = new FullNameCreator(isReflection, helper);
			fnc.CreateFullName(typeSpec);
			return fnc.Result;
		}
Esempio n. 21
0
		bool ContainsGenericParameterInternal(TypeSpec type) {
			if (type == null)
				return false;
			if (!recursionCounter.Increment())
				return false;

			bool res = ContainsGenericParameterInternal(type.TypeSig);

			recursionCounter.Decrement();
			return res;
		}
		/// <summary>
		/// Returns the assembly qualified full name of a <see cref="TypeSpec"/>
		/// </summary>
		/// <param name="typeSpec">The <c>TypeSpec</c></param>
		/// <param name="helper">Helps print the name</param>
		/// <returns>The assembly qualified full name</returns>
		public static string AssemblyQualifiedName(TypeSpec typeSpec, IFullNameCreatorHelper helper) {
			var fnc = new FullNameCreator(true, helper);
			fnc.CreateAssemblyQualifiedName(typeSpec);
			return fnc.Result;
		}
		void CreateAssemblyQualifiedName(TypeSpec typeSpec) {
			if (typeSpec == null) {
				sb.Append(NULLVALUE);
				return;
			}
			CreateAssemblyQualifiedName(typeSpec.TypeSig);
		}
		/// <summary>
		/// Gets the scope type
		/// </summary>
		/// <param name="typeSpec">The <c>TypeSpec</c></param>
		/// <returns>The scope type or <c>null</c> if none found</returns>
		public static ITypeDefOrRef ScopeType(TypeSpec typeSpec) {
			return new FullNameCreator().GetScopeType(typeSpec);
		}
		void CreateName(TypeSpec typeSpec) {
			if (typeSpec == null) {
				sb.Append(NULLVALUE);
				return;
			}
			CreateName(typeSpec.TypeSig);
		}
		/// <summary>
		/// Returns the owner module. The type was created from metadata in this module.
		/// </summary>
		/// <param name="typeSpec">The <c>TypeSpec</c></param>
		/// <returns>A <see cref="ModuleDef"/> or <c>null</c> if none found</returns>
		public static ModuleDef OwnerModule(TypeSpec typeSpec) {
			return new FullNameCreator().GetOwnerModule(typeSpec);
		}
Esempio n. 27
0
 /// <summary>
 /// Checks whether <paramref name="type"/> contains a <see cref="GenericVar"/> or a
 /// <see cref="GenericMVar"/>.
 /// </summary>
 /// <param name="type">Type</param>
 /// <returns><c>true</c> if <paramref name="type"/> contains a <see cref="GenericVar"/> or a
 /// <see cref="GenericMVar"/>.</returns>
 public static bool ContainsGenericParameter(TypeSpec type)
 {
     return(new TypeHelper().ContainsGenericParameterInternal(type));
 }