/// <summary> Finds ILSpy's ITypeDefinition based on ExprCS TypeSignature. The ITypeDefinition has access to the module contents, so it's much stronger than TypeSignature. </summary> public ITypeDefinition GetTypeDef(TypeSignature type) => (ITypeDefinition)declaredEntities.GetValueOrDefault(type) ??
/// <summary> Creates new method signature that is a constructor </summary> public static MethodSignature Constructor(TypeSignature declaringType, Accessibility accessibility, IEnumerable <MethodParameter> parameters) => new MethodSignature(declaringType, parameters.ToImmutableArray(), ".ctor", TypeSignature.Void, isStatic: false, accessibility, isVirtual: false, isOverride: false, isAbstract: false, hasSpecialName: true, ImmutableArray <GenericParameter> .Empty);
public SpecializedType(TypeSignature type, params TypeReference[] genericArgs) : this(type, genericArgs.ToImmutableArray()) { }
/// <summary> Gets signature of public parameterless constructor. Note that this method does not check if it actually exists, so the compilation may fail in later phase. </summary> public static MethodSignature ImplicitConstructor(TypeSignature declaringType) => Constructor(declaringType, declaringType.IsAbstract ? Accessibility.AProtected : Accessibility.APublic);
/// <summary> Creates new method signature that is a constructor </summary> public static MethodSignature Constructor(TypeSignature declaringType, Accessibility accessibility, params MethodParameter[] parameters) => Constructor(declaringType, accessibility, parameters.AsEnumerable());
/// <summary> Creates new instance method signature. The method is not override, not virtual, not abstract </summary> public static MethodSignature Instance(string name, TypeSignature declaringType, Accessibility accessibility, TypeReference returnType, params MethodParameter[] parameters) => Instance(name, declaringType, accessibility, returnType, ImmutableArray <GenericParameter> .Empty, parameters);
/// <summary> Creates new instance virtual method signature. </summary> public static MethodSignature Virtual(string name, TypeSignature declaringType, Accessibility accessibility, TypeReference returnType, IEnumerable <GenericParameter> typeParameters, params MethodParameter[] parameters) => new MethodSignature(declaringType, parameters.ToImmutableArray(), name, returnType, isStatic: false, accessibility, isVirtual: true, isOverride: false, isAbstract: false, hasSpecialName: false, typeParameters.ToImmutableArray());
public static FullTypeName GetFullTypeName(this TypeSignature t) => t.Parent.Match( ns => new FullTypeName(new TopLevelTypeName(ns.ToString(), t.Name, t.TypeParameters.Length)), parentType => GetFullTypeName(parentType).NestedType(t.Name, t.TypeParameters.Length) );
/// <summary> Creates new static method signature </summary> public static MethodSignature Static(string name, TypeSignature declaringType, Accessibility accessibility, TypeReference returnType, params MethodParameter[] parameters) => Static(name, declaringType, accessibility, returnType, null, parameters);
static partial void ValidateObjectExtension(ref CoreLib.ValidationErrorsBuilder e, TypeSignature t) { if (t.IsValueType) { if (t.CanOverride) { e.Add(ValidationErrors.Create($"Can not override value type {t}").Nest("canOverride")); } if (t.IsAbstract) { e.Add(ValidationErrors.Create($"Can not have abstract value type {t}").Nest("isAbstract")); } } }
/// <summary> Creates a new immutable <see cref="ParameterExpression" /> with name `this` of the specified type. If the <paramref name="declaringType" /> is a value type, the parameter type will be a reference. </summary> public static ParameterExpression CreateThisParam(TypeSignature declaringType, string name = "this") => declaringType.IsValueType ? Create(TypeReference.ByReferenceType(declaringType.SpecializeByItself()), name) : Create(declaringType.SpecializeByItself(), name);
/// <summary> /// Gets whether the type is specialized type with the signature <paramref name="s" /> /// </summary> public static bool IsSpecializationOf(this TypeReference type, TypeSignature s) => type.MatchST(st => st.Type == s, otherwise: _ => false);
/// <summary> Creates a new property signature of an instance property. </summary> public static PropertySignature Instance(string name, TypeSignature declaringType, TypeReference type, Accessibility getter, Accessibility setter = null, bool isVirtual = false, bool isOverride = false) => Create(name, declaringType, type, getter, setter, isOverride: isOverride, isVirtual: isVirtual, isAbstract: false);
/// <summary> Creates a new property signature of a static property. </summary> public static PropertySignature Static(string name, TypeSignature declaringType, TypeReference type, Accessibility getter, Accessibility setter = null) => Create(name, declaringType, type, getter, setter, isStatic: true);