} // Read public static uint Read(this NativeReader reader, uint offset, out FixedArgumentHandle[] values) { uint count; offset = reader.DecodeUnsigned(offset, out count); if (count == 0) { values = s_emptyFixedArgumentHandleArray; } else { values = new FixedArgumentHandle[count]; for (uint i = 0; i < count; ++i) { FixedArgumentHandle tmp; offset = reader.Read(offset, out tmp); values[i] = tmp; } } return offset; } // Read
// Equals/GetHashCode no need to override (they just implement reference equality but desktop never unified these things.) // // Helper for parsing custom attribute arguments. // // If throwIfMissingMetadata is false, returns default(CustomAttributeTypedArgument) rather than throwing a MissingMetadataException. // private CustomAttributeTypedArgument ParseFixedArgument(MetadataReader reader, FixedArgumentHandle fixedArgumentHandle, bool throwIfMissingMetadata, Func<RuntimeTypeInfo> getTypeFromConstructor) { FixedArgument fixedArgument = fixedArgumentHandle.GetFixedArgument(reader); RuntimeTypeInfo argumentType = null; if (fixedArgument.Type.IsNull(reader)) { argumentType = getTypeFromConstructor(); if (argumentType == null) { Debug.Assert(!throwIfMissingMetadata); return default(CustomAttributeTypedArgument); } } else { Exception exception = null; argumentType = fixedArgument.Type.TryResolve(reader, new TypeContext(null, null), ref exception); if (argumentType == null) { if (throwIfMissingMetadata) throw exception; else return default(CustomAttributeTypedArgument); } } Object value; Exception e = fixedArgument.Value.TryParseConstantValue(reader, out value); if (e != null) { if (throwIfMissingMetadata) throw e; else return default(CustomAttributeTypedArgument); } return WrapInCustomAttributeTypedArgument(value, argumentType); }
} // Read public static uint Read(this NativeReader reader, uint offset, out FixedArgumentHandle handle) { uint value; offset = reader.DecodeUnsigned(offset, out value); handle = new FixedArgumentHandle((int)value); handle._Validate(); return offset; } // Read
} // IsNull internal bool IsNull(FixedArgumentHandle handle) { return (handle._value & 0x00FFFFFF) == 0; } // IsNull
} // ToHandle internal Handle ToHandle(FixedArgumentHandle handle) { return new Handle(handle._value); } // ToHandle
} // GetFieldSignature public FixedArgument GetFixedArgument(FixedArgumentHandle handle) { var record = new FixedArgument() { _reader = this, _handle = handle }; var offset = (uint)handle.Offset; offset = _streamReader.Read(offset, out record._flags); offset = _streamReader.Read(offset, out record._type); offset = _streamReader.Read(offset, out record._value); return record; } // GetFixedArgument
} // Equals public bool Equals(FixedArgumentHandle handle) { return _value == handle._value; } // Equals
} // Read public static uint Read(this NativeReader reader, uint offset, out FixedArgumentHandle[] values) { uint count; offset = reader.DecodeUnsigned(offset, out count); #if !NETFX_45 if (count == 0) { values = Array.Empty<FixedArgumentHandle>(); } else #endif { values = new FixedArgumentHandle[count]; for (uint i = 0; i < count; ++i) { FixedArgumentHandle tmp; offset = reader.Read(offset, out tmp); values[i] = tmp; } } return offset; } // Read