Exemplo n.º 1
0
        public static bool GetSystemNullableFields(this CorType type, out TokenAndName hasValueInfo, out TokenAndName valueInfo)
        {
            hasValueInfo = new TokenAndName();
            valueInfo    = new TokenAndName();
            if (type == null || !type.IsSystemNullable)
            {
                return(false);
            }
            var cls    = type.Class;
            var mdi    = cls?.Module?.GetMetaDataInterface <IMetaDataImport>();
            var fields = MetaDataUtils.GetFields(mdi, cls?.Token ?? 0);

            if (fields.Count != 2)
            {
                return(false);
            }
            if (fields[0].Name != "hasValue")
            {
                return(false);
            }
            if (fields[1].Name != "value")
            {
                return(false);
            }

            hasValueInfo = fields[0];
            valueInfo    = fields[1];
            return(true);
        }
Exemplo n.º 2
0
		public static bool GetSystemNullableFields(this CorType type, out TokenAndName hasValueInfo, out TokenAndName valueInfo, out CorType nullableElemType) {
			nullableElemType = null;
			if (!type.GetSystemNullableFields(out hasValueInfo, out valueInfo))
				return false;
			nullableElemType = type.FirstTypeParameter;
			return nullableElemType != null;
		}
Exemplo n.º 3
0
 public static bool GetSystemNullableFields(this CorType type, out TokenAndName hasValueInfo, out TokenAndName valueInfo, out CorType nullableElemType)
 {
     nullableElemType = null;
     if (!type.GetSystemNullableFields(out hasValueInfo, out valueInfo))
     {
         return(false);
     }
     nullableElemType = type.FirstTypeParameter;
     return(nullableElemType != null);
 }
Exemplo n.º 4
0
		public static bool GetSystemNullableFields(this CorType type, out TokenAndName hasValueInfo, out TokenAndName valueInfo) {
			hasValueInfo = new TokenAndName();
			valueInfo = new TokenAndName();
			if (type == null || !type.IsSystemNullable)
				return false;
			var cls = type.Class;
			var mdi = cls?.Module?.GetMetaDataInterface<IMetaDataImport>();
			var fields = MetaDataUtils.GetFields(mdi, cls?.Token ?? 0);
			if (fields.Count != 2)
				return false;
			if (fields[0].Name != "hasValue")
				return false;
			if (fields[1].Name != "value")
				return false;

			hasValueInfo = fields[0];
			valueInfo = fields[1];
			return true;
		}
Exemplo n.º 5
0
 /// <summary>
 /// Gets the <c>System.Nullable</c> fields if it's a nullable type
 /// </summary>
 /// <param name="hasValueInfo">Updated with <c>hasValue</c> field</param>
 /// <param name="valueInfo">Updated with 'value' field</param>
 /// <param name="nullableElemType">Updated with nullable element type</param>
 /// <returns></returns>
 public bool GetSystemNullableFields(out TokenAndName hasValueInfo, out TokenAndName valueInfo, out CorType nullableElemType)
 {
     return(Utils.GetSystemNullableFields(this, out hasValueInfo, out valueInfo, out nullableElemType));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Gets the <c>System.Nullable</c> fields if it's a nullable type
 /// </summary>
 /// <param name="hasValueInfo">Updated with <c>hasValue</c> field</param>
 /// <param name="valueInfo">Updated with 'value' field</param>
 /// <returns></returns>
 public bool GetSystemNullableFields(out TokenAndName hasValueInfo, out TokenAndName valueInfo)
 {
     return(Utils.GetSystemNullableFields(this, out hasValueInfo, out valueInfo));
 }