示例#1
0
 /// <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) ??
示例#2
0
 /// <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);
示例#3
0
 public SpecializedType(TypeSignature type, params TypeReference[] genericArgs)
     : this(type, genericArgs.ToImmutableArray())
 {
 }
示例#4
0
 /// <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);
示例#5
0
 /// <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());
示例#6
0
 /// <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);
示例#7
0
 /// <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());
示例#8
0
 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)
     );
示例#9
0
 /// <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);
示例#10
0
 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"));
         }
     }
 }
示例#11
0
 /// <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);
示例#12
0
 /// <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);
示例#13
0
 /// <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);
示例#14
0
 /// <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);