private static bool?GetIsValueType(TypeReference typeRef, TypeSignature baseTypeSig, Module module) { if (baseTypeSig == null) { return(false); } var baseTypeRef = baseTypeSig.GetLastElementType() as TypeReference; if (baseTypeRef == null) { return(false); } if (!SignatureUtils.EqualsValueTypeOrEnum(baseTypeRef, module.Assembly)) { return(false); } if (SignatureUtils.EqualsValueTypeOrEnum(typeRef, module.Assembly)) { return(false); } return(true); }
private void WriteType(ref int pos, ITypeSignature type) { _blob.Write(ref pos, (byte)SignatureType.Type); _blob.Write(ref pos, (byte)type.ElementCode); switch (type.ElementCode) { case TypeElementCode.Array: { var arrayDimensions = type.ArrayDimensions; _blob.Write7BitEncodedInt(ref pos, arrayDimensions.Count); for (int i = 0; i < arrayDimensions.Count; i++) { var arrayDimension = arrayDimensions[i]; WriteArrayDimensionBound(ref pos, arrayDimension.LowerBound); WriteArrayDimensionBound(ref pos, arrayDimension.UpperBound); } _blob.Length += 4; WriteReferenced(ref pos, type.ElementType); } break; case TypeElementCode.ByRef: { _blob.Length += 4; WriteReferenced(ref pos, type.ElementType); } break; case TypeElementCode.CustomModifier: { CustomModifierType modifierType; ITypeSignature modifier = type.GetCustomModifier(out modifierType); _blob.Write(ref pos, (byte)modifierType); _blob.Length += 8; WriteReferenced(ref pos, modifier); WriteReferenced(ref pos, type.ElementType); } break; case TypeElementCode.FunctionPointer: { _blob.Length += 4; WriteReferenced(ref pos, type.GetFunctionPointer()); } break; case TypeElementCode.GenericParameter: { bool isMethod; int position; type.GetGenericParameter(out isMethod, out position); _blob.Write(ref pos, (bool)isMethod); _blob.Write7BitEncodedInt(ref pos, position); } break; case TypeElementCode.GenericType: { var genericArguments = type.GenericArguments; _blob.Write7BitEncodedInt(ref pos, genericArguments.Count); _blob.Length += (genericArguments.Count + 1) * 4; WriteReferenced(ref pos, genericArguments); WriteReferenced(ref pos, type.DeclaringType); } break; case TypeElementCode.Pinned: { _blob.Length += 4; WriteReferenced(ref pos, type.ElementType); } break; case TypeElementCode.Pointer: { _blob.Length += 4; WriteReferenced(ref pos, type.ElementType); } break; case TypeElementCode.DeclaringType: { WriteString(ref pos, type.Name); WriteString(ref pos, type.Namespace); _blob.Write(ref pos, (bool?)SignatureUtils.TryGetIsValueType(type)); var owner = type.Owner; if (owner != null) { _blob.Write(ref pos, true); _blob.Length += 4; WriteReferenced(ref pos, owner); } else { _blob.Write(ref pos, false); } } break; default: throw new NotImplementedException(); } }