diff options
author | Michal Strehovsky <michals@microsoft.com> | 2015-12-04 08:34:42 +0300 |
---|---|---|
committer | Michal Strehovsky <michals@microsoft.com> | 2015-12-04 08:34:42 +0300 |
commit | aadf9575546350a19813bdd8f1b8d397dc07b840 (patch) | |
tree | bb83448fb3d07353ad1efd79eaf76350bff72d16 | |
parent | a13d6c56ba0a8ff94a051a34951390cb129ca73f (diff) |
Port reflection metadata reader and writer to CoreRT
[tfs-changeset: 1554518]
26 files changed, 28102 insertions, 0 deletions
diff --git a/src/Common/src/Internal/Metadata/NativeFormat/MdBinaryReader.cs b/src/Common/src/Internal/Metadata/NativeFormat/MdBinaryReader.cs new file mode 100644 index 000000000..15b4c78c2 --- /dev/null +++ b/src/Common/src/Internal/Metadata/NativeFormat/MdBinaryReader.cs @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.IO; +using System.Collections.Generic; +using System.Reflection; +using Debug = System.Diagnostics.Debug; +using System.Threading; +using System.Text; +using Internal.NativeFormat; + +namespace Internal.Metadata.NativeFormat +{ + internal static partial class MdBinaryReader + { + static public uint Read(this NativeReader reader, uint offset, out bool value) + { + value = (reader.ReadUInt8(offset) != 0) ? true : false; + return offset + 1; + } + + static public uint Read(this NativeReader reader, uint offset, out string value) + { + return reader.DecodeString(offset, out value); + } + + static public uint Read(this NativeReader reader, uint offset, out char value) + { + uint val; + offset = reader.DecodeUnsigned(offset, out val); + value = (char)val; + return offset; + } + + static public uint Read(this NativeReader reader, uint offset, out short value) + { + int val; + offset = reader.DecodeSigned(offset, out val); + value = (short)val; + return offset; + } + + static public uint Read(this NativeReader reader, uint offset, out sbyte value) + { + value = (sbyte)reader.ReadUInt8(offset); + return offset + 1; + } + + static public uint Read(this NativeReader reader, uint offset, out ulong value) + { + return reader.DecodeUnsignedLong(offset, out value); + } + + static public uint Read(this NativeReader reader, uint offset, out int value) + { + return reader.DecodeSigned(offset, out value); + } + + static public uint Read(this NativeReader reader, uint offset, out uint value) + { + return reader.DecodeUnsigned(offset, out value); + } + + static public uint Read(this NativeReader reader, uint offset, out byte value) + { + value = reader.ReadUInt8(offset); + return offset + 1; + } + + static public uint Read(this NativeReader reader, uint offset, out ushort value) + { + uint val; + offset = reader.DecodeUnsigned(offset, out val); + value = (ushort)val; + return offset; + } + + static public uint Read(this NativeReader reader, uint offset, out long value) + { + return reader.DecodeSignedLong(offset, out value); + } + + static public uint Read(this NativeReader reader, uint offset, out Handle handle) + { + uint rawValue; + offset = reader.DecodeUnsigned(offset, out rawValue); + handle = new Handle((HandleType)(byte)rawValue, (int)(rawValue >> 8)); + return offset; + } + + static public uint Read(this NativeReader reader, uint offset, out float value) + { + value = reader.ReadFloat(offset); + return offset + 4; + } + + static public uint Read(this NativeReader reader, uint offset, out double value) + { + value = reader.ReadDouble(offset); + return offset + 8; + } + } +}
\ No newline at end of file diff --git a/src/Common/src/Internal/Metadata/NativeFormat/MdBinaryReaderGen.cs b/src/Common/src/Internal/Metadata/NativeFormat/MdBinaryReaderGen.cs new file mode 100644 index 000000000..462ab8b9b --- /dev/null +++ b/src/Common/src/Internal/Metadata/NativeFormat/MdBinaryReaderGen.cs @@ -0,0 +1,2339 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +// NOTE: This is a generated file - do not manually edit! + +#pragma warning disable 649 + +using System; +using System.IO; +using System.Collections.Generic; +using System.Reflection; +using Internal.NativeFormat; +using Debug = System.Diagnostics.Debug; + +namespace Internal.Metadata.NativeFormat +{ + /// <summary> + /// MdBinaryReader + /// </summary> + internal static partial class MdBinaryReader + { + public static uint Read(this NativeReader reader, uint offset, out bool[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + values = new bool[count]; + for (uint i = 0; i < count; ++i) + { + bool tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out char[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + values = new char[count]; + for (uint i = 0; i < count; ++i) + { + char tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out string[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + values = new string[count]; + for (uint i = 0; i < count; ++i) + { + string tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out byte[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + values = new byte[count]; + for (uint i = 0; i < count; ++i) + { + byte tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out sbyte[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + values = new sbyte[count]; + for (uint i = 0; i < count; ++i) + { + sbyte tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out short[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + values = new short[count]; + for (uint i = 0; i < count; ++i) + { + short tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ushort[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + values = new ushort[count]; + for (uint i = 0; i < count; ++i) + { + ushort tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out int[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + values = new int[count]; + for (uint i = 0; i < count; ++i) + { + int tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out uint[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + values = new uint[count]; + for (uint i = 0; i < count; ++i) + { + uint tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out long[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + values = new long[count]; + for (uint i = 0; i < count; ++i) + { + long tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ulong[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + values = new ulong[count]; + for (uint i = 0; i < count; ++i) + { + ulong tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out float[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + values = new float[count]; + for (uint i = 0; i < count; ++i) + { + float tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out double[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + values = new double[count]; + for (uint i = 0; i < count; ++i) + { + double tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out Handle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyHandleArray; + } + else + { + values = new Handle[count]; + for (uint i = 0; i < count; ++i) + { + Handle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out AssemblyFlags value) + { + uint ivalue; + offset = reader.DecodeUnsigned(offset, out ivalue); + value = (AssemblyFlags)ivalue; + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out AssemblyHashAlgorithm value) + { + uint ivalue; + offset = reader.DecodeUnsigned(offset, out ivalue); + value = (AssemblyHashAlgorithm)ivalue; + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out CallingConventions value) + { + uint ivalue; + offset = reader.DecodeUnsigned(offset, out ivalue); + value = (CallingConventions)ivalue; + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out EventAttributes value) + { + uint ivalue; + offset = reader.DecodeUnsigned(offset, out ivalue); + value = (EventAttributes)ivalue; + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out FieldAttributes value) + { + uint ivalue; + offset = reader.DecodeUnsigned(offset, out ivalue); + value = (FieldAttributes)ivalue; + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out FixedArgumentAttributes value) + { + uint ivalue; + offset = reader.DecodeUnsigned(offset, out ivalue); + value = (FixedArgumentAttributes)ivalue; + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out GenericParameterAttributes value) + { + uint ivalue; + offset = reader.DecodeUnsigned(offset, out ivalue); + value = (GenericParameterAttributes)ivalue; + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out GenericParameterKind value) + { + uint ivalue; + offset = reader.DecodeUnsigned(offset, out ivalue); + value = (GenericParameterKind)ivalue; + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out MethodAttributes value) + { + uint ivalue; + offset = reader.DecodeUnsigned(offset, out ivalue); + value = (MethodAttributes)ivalue; + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out MethodImplAttributes value) + { + uint ivalue; + offset = reader.DecodeUnsigned(offset, out ivalue); + value = (MethodImplAttributes)ivalue; + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out MethodSemanticsAttributes value) + { + uint ivalue; + offset = reader.DecodeUnsigned(offset, out ivalue); + value = (MethodSemanticsAttributes)ivalue; + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out NamedArgumentMemberKind value) + { + uint ivalue; + offset = reader.DecodeUnsigned(offset, out ivalue); + value = (NamedArgumentMemberKind)ivalue; + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out PInvokeAttributes value) + { + uint ivalue; + offset = reader.DecodeUnsigned(offset, out ivalue); + value = (PInvokeAttributes)ivalue; + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ParameterAttributes value) + { + uint ivalue; + offset = reader.DecodeUnsigned(offset, out ivalue); + value = (ParameterAttributes)ivalue; + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out PropertyAttributes value) + { + uint ivalue; + offset = reader.DecodeUnsigned(offset, out ivalue); + value = (PropertyAttributes)ivalue; + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out TypeAttributes value) + { + uint ivalue; + offset = reader.DecodeUnsigned(offset, out ivalue); + value = (TypeAttributes)ivalue; + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out TypeDefinitionHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new TypeDefinitionHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out TypeDefinitionHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyTypeDefinitionHandleArray; + } + else + { + values = new TypeDefinitionHandle[count]; + for (uint i = 0; i < count; ++i) + { + TypeDefinitionHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out TypeReferenceHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new TypeReferenceHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out TypeReferenceHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyTypeReferenceHandleArray; + } + else + { + values = new TypeReferenceHandle[count]; + for (uint i = 0; i < count; ++i) + { + TypeReferenceHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out TypeSpecificationHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new TypeSpecificationHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out TypeSpecificationHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyTypeSpecificationHandleArray; + } + else + { + values = new TypeSpecificationHandle[count]; + for (uint i = 0; i < count; ++i) + { + TypeSpecificationHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ScopeDefinitionHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ScopeDefinitionHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ScopeDefinitionHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyScopeDefinitionHandleArray; + } + else + { + values = new ScopeDefinitionHandle[count]; + for (uint i = 0; i < count; ++i) + { + ScopeDefinitionHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ScopeReferenceHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ScopeReferenceHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ScopeReferenceHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyScopeReferenceHandleArray; + } + else + { + values = new ScopeReferenceHandle[count]; + for (uint i = 0; i < count; ++i) + { + ScopeReferenceHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out NamespaceDefinitionHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new NamespaceDefinitionHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out NamespaceDefinitionHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyNamespaceDefinitionHandleArray; + } + else + { + values = new NamespaceDefinitionHandle[count]; + for (uint i = 0; i < count; ++i) + { + NamespaceDefinitionHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out NamespaceReferenceHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new NamespaceReferenceHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out NamespaceReferenceHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyNamespaceReferenceHandleArray; + } + else + { + values = new NamespaceReferenceHandle[count]; + for (uint i = 0; i < count; ++i) + { + NamespaceReferenceHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out MethodHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new MethodHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out MethodHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyMethodHandleArray; + } + else + { + values = new MethodHandle[count]; + for (uint i = 0; i < count; ++i) + { + MethodHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out MethodInstantiationHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new MethodInstantiationHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out MethodInstantiationHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyMethodInstantiationHandleArray; + } + else + { + values = new MethodInstantiationHandle[count]; + for (uint i = 0; i < count; ++i) + { + MethodInstantiationHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out MemberReferenceHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new MemberReferenceHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out MemberReferenceHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyMemberReferenceHandleArray; + } + else + { + values = new MemberReferenceHandle[count]; + for (uint i = 0; i < count; ++i) + { + MemberReferenceHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out FieldHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new FieldHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out FieldHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyFieldHandleArray; + } + else + { + values = new FieldHandle[count]; + for (uint i = 0; i < count; ++i) + { + FieldHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out PropertyHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new PropertyHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out PropertyHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyPropertyHandleArray; + } + else + { + values = new PropertyHandle[count]; + for (uint i = 0; i < count; ++i) + { + PropertyHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out EventHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new EventHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out EventHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyEventHandleArray; + } + else + { + values = new EventHandle[count]; + for (uint i = 0; i < count; ++i) + { + EventHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out CustomAttributeHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new CustomAttributeHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out CustomAttributeHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyCustomAttributeHandleArray; + } + else + { + values = new CustomAttributeHandle[count]; + for (uint i = 0; i < count; ++i) + { + CustomAttributeHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // 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 + + 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 + + public static uint Read(this NativeReader reader, uint offset, out NamedArgumentHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new NamedArgumentHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out NamedArgumentHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyNamedArgumentHandleArray; + } + else + { + values = new NamedArgumentHandle[count]; + for (uint i = 0; i < count; ++i) + { + NamedArgumentHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out GenericParameterHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new GenericParameterHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out GenericParameterHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyGenericParameterHandleArray; + } + else + { + values = new GenericParameterHandle[count]; + for (uint i = 0; i < count; ++i) + { + GenericParameterHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out MethodImplHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new MethodImplHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out MethodImplHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyMethodImplHandleArray; + } + else + { + values = new MethodImplHandle[count]; + for (uint i = 0; i < count; ++i) + { + MethodImplHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ParameterHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ParameterHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ParameterHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyParameterHandleArray; + } + else + { + values = new ParameterHandle[count]; + for (uint i = 0; i < count; ++i) + { + ParameterHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out MethodSemanticsHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new MethodSemanticsHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out MethodSemanticsHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyMethodSemanticsHandleArray; + } + else + { + values = new MethodSemanticsHandle[count]; + for (uint i = 0; i < count; ++i) + { + MethodSemanticsHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out TypeInstantiationSignatureHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new TypeInstantiationSignatureHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out TypeInstantiationSignatureHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyTypeInstantiationSignatureHandleArray; + } + else + { + values = new TypeInstantiationSignatureHandle[count]; + for (uint i = 0; i < count; ++i) + { + TypeInstantiationSignatureHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out SZArraySignatureHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new SZArraySignatureHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out SZArraySignatureHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptySZArraySignatureHandleArray; + } + else + { + values = new SZArraySignatureHandle[count]; + for (uint i = 0; i < count; ++i) + { + SZArraySignatureHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ArraySignatureHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ArraySignatureHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ArraySignatureHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyArraySignatureHandleArray; + } + else + { + values = new ArraySignatureHandle[count]; + for (uint i = 0; i < count; ++i) + { + ArraySignatureHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ByReferenceSignatureHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ByReferenceSignatureHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ByReferenceSignatureHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyByReferenceSignatureHandleArray; + } + else + { + values = new ByReferenceSignatureHandle[count]; + for (uint i = 0; i < count; ++i) + { + ByReferenceSignatureHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out PointerSignatureHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new PointerSignatureHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out PointerSignatureHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyPointerSignatureHandleArray; + } + else + { + values = new PointerSignatureHandle[count]; + for (uint i = 0; i < count; ++i) + { + PointerSignatureHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out TypeVariableSignatureHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new TypeVariableSignatureHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out TypeVariableSignatureHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyTypeVariableSignatureHandleArray; + } + else + { + values = new TypeVariableSignatureHandle[count]; + for (uint i = 0; i < count; ++i) + { + TypeVariableSignatureHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out MethodTypeVariableSignatureHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new MethodTypeVariableSignatureHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out MethodTypeVariableSignatureHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyMethodTypeVariableSignatureHandleArray; + } + else + { + values = new MethodTypeVariableSignatureHandle[count]; + for (uint i = 0; i < count; ++i) + { + MethodTypeVariableSignatureHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out FieldSignatureHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new FieldSignatureHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out FieldSignatureHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyFieldSignatureHandleArray; + } + else + { + values = new FieldSignatureHandle[count]; + for (uint i = 0; i < count; ++i) + { + FieldSignatureHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out PropertySignatureHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new PropertySignatureHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out PropertySignatureHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyPropertySignatureHandleArray; + } + else + { + values = new PropertySignatureHandle[count]; + for (uint i = 0; i < count; ++i) + { + PropertySignatureHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out MethodSignatureHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new MethodSignatureHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out MethodSignatureHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyMethodSignatureHandleArray; + } + else + { + values = new MethodSignatureHandle[count]; + for (uint i = 0; i < count; ++i) + { + MethodSignatureHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ReturnTypeSignatureHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ReturnTypeSignatureHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ReturnTypeSignatureHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyReturnTypeSignatureHandleArray; + } + else + { + values = new ReturnTypeSignatureHandle[count]; + for (uint i = 0; i < count; ++i) + { + ReturnTypeSignatureHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ParameterTypeSignatureHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ParameterTypeSignatureHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ParameterTypeSignatureHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyParameterTypeSignatureHandleArray; + } + else + { + values = new ParameterTypeSignatureHandle[count]; + for (uint i = 0; i < count; ++i) + { + ParameterTypeSignatureHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out TypeForwarderHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new TypeForwarderHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out TypeForwarderHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyTypeForwarderHandleArray; + } + else + { + values = new TypeForwarderHandle[count]; + for (uint i = 0; i < count; ++i) + { + TypeForwarderHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out CustomModifierHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new CustomModifierHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out CustomModifierHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyCustomModifierHandleArray; + } + else + { + values = new CustomModifierHandle[count]; + for (uint i = 0; i < count; ++i) + { + CustomModifierHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantBooleanArrayHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantBooleanArrayHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantBooleanArrayHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantBooleanArrayHandleArray; + } + else + { + values = new ConstantBooleanArrayHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantBooleanArrayHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantBooleanValueHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantBooleanValueHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantBooleanValueHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantBooleanValueHandleArray; + } + else + { + values = new ConstantBooleanValueHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantBooleanValueHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantByteArrayHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantByteArrayHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantByteArrayHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantByteArrayHandleArray; + } + else + { + values = new ConstantByteArrayHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantByteArrayHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantByteValueHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantByteValueHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantByteValueHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantByteValueHandleArray; + } + else + { + values = new ConstantByteValueHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantByteValueHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantCharArrayHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantCharArrayHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantCharArrayHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantCharArrayHandleArray; + } + else + { + values = new ConstantCharArrayHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantCharArrayHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantCharValueHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantCharValueHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantCharValueHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantCharValueHandleArray; + } + else + { + values = new ConstantCharValueHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantCharValueHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantDoubleArrayHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantDoubleArrayHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantDoubleArrayHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantDoubleArrayHandleArray; + } + else + { + values = new ConstantDoubleArrayHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantDoubleArrayHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantDoubleValueHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantDoubleValueHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantDoubleValueHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantDoubleValueHandleArray; + } + else + { + values = new ConstantDoubleValueHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantDoubleValueHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantHandleArrayHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantHandleArrayHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantHandleArrayHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantHandleArrayHandleArray; + } + else + { + values = new ConstantHandleArrayHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantHandleArrayHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantInt16ArrayHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantInt16ArrayHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantInt16ArrayHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantInt16ArrayHandleArray; + } + else + { + values = new ConstantInt16ArrayHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantInt16ArrayHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantInt16ValueHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantInt16ValueHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantInt16ValueHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantInt16ValueHandleArray; + } + else + { + values = new ConstantInt16ValueHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantInt16ValueHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantInt32ArrayHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantInt32ArrayHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantInt32ArrayHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantInt32ArrayHandleArray; + } + else + { + values = new ConstantInt32ArrayHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantInt32ArrayHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantInt32ValueHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantInt32ValueHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantInt32ValueHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantInt32ValueHandleArray; + } + else + { + values = new ConstantInt32ValueHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantInt32ValueHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantInt64ArrayHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantInt64ArrayHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantInt64ArrayHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantInt64ArrayHandleArray; + } + else + { + values = new ConstantInt64ArrayHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantInt64ArrayHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantInt64ValueHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantInt64ValueHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantInt64ValueHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantInt64ValueHandleArray; + } + else + { + values = new ConstantInt64ValueHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantInt64ValueHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantReferenceValueHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantReferenceValueHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantReferenceValueHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantReferenceValueHandleArray; + } + else + { + values = new ConstantReferenceValueHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantReferenceValueHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantSByteArrayHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantSByteArrayHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantSByteArrayHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantSByteArrayHandleArray; + } + else + { + values = new ConstantSByteArrayHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantSByteArrayHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantSByteValueHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantSByteValueHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantSByteValueHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantSByteValueHandleArray; + } + else + { + values = new ConstantSByteValueHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantSByteValueHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantSingleArrayHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantSingleArrayHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantSingleArrayHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantSingleArrayHandleArray; + } + else + { + values = new ConstantSingleArrayHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantSingleArrayHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantSingleValueHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantSingleValueHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantSingleValueHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantSingleValueHandleArray; + } + else + { + values = new ConstantSingleValueHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantSingleValueHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantStringArrayHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantStringArrayHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantStringArrayHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantStringArrayHandleArray; + } + else + { + values = new ConstantStringArrayHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantStringArrayHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantStringValueHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantStringValueHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantStringValueHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantStringValueHandleArray; + } + else + { + values = new ConstantStringValueHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantStringValueHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantUInt16ArrayHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantUInt16ArrayHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantUInt16ArrayHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantUInt16ArrayHandleArray; + } + else + { + values = new ConstantUInt16ArrayHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantUInt16ArrayHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantUInt16ValueHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantUInt16ValueHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantUInt16ValueHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantUInt16ValueHandleArray; + } + else + { + values = new ConstantUInt16ValueHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantUInt16ValueHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantUInt32ArrayHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantUInt32ArrayHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantUInt32ArrayHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantUInt32ArrayHandleArray; + } + else + { + values = new ConstantUInt32ArrayHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantUInt32ArrayHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantUInt32ValueHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantUInt32ValueHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantUInt32ValueHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantUInt32ValueHandleArray; + } + else + { + values = new ConstantUInt32ValueHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantUInt32ValueHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantUInt64ArrayHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantUInt64ArrayHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantUInt64ArrayHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantUInt64ArrayHandleArray; + } + else + { + values = new ConstantUInt64ArrayHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantUInt64ArrayHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantUInt64ValueHandle handle) + { + uint value; + offset = reader.DecodeUnsigned(offset, out value); + handle = new ConstantUInt64ValueHandle((int)value); + handle._Validate(); + return offset; + } // Read + + public static uint Read(this NativeReader reader, uint offset, out ConstantUInt64ValueHandle[] values) + { + uint count; + offset = reader.DecodeUnsigned(offset, out count); + if (count == 0) + { + values = s_emptyConstantUInt64ValueHandleArray; + } + else + { + values = new ConstantUInt64ValueHandle[count]; + for (uint i = 0; i < count; ++i) + { + ConstantUInt64ValueHandle tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + } + } + return offset; + } // Read + + private static Handle[] s_emptyHandleArray = new Handle[0]; + + private static TypeDefinitionHandle[] s_emptyTypeDefinitionHandleArray = new TypeDefinitionHandle[0]; + + private static TypeReferenceHandle[] s_emptyTypeReferenceHandleArray = new TypeReferenceHandle[0]; + + private static TypeSpecificationHandle[] s_emptyTypeSpecificationHandleArray = new TypeSpecificationHandle[0]; + + private static ScopeDefinitionHandle[] s_emptyScopeDefinitionHandleArray = new ScopeDefinitionHandle[0]; + + private static ScopeReferenceHandle[] s_emptyScopeReferenceHandleArray = new ScopeReferenceHandle[0]; + + private static NamespaceDefinitionHandle[] s_emptyNamespaceDefinitionHandleArray = new NamespaceDefinitionHandle[0]; + + private static NamespaceReferenceHandle[] s_emptyNamespaceReferenceHandleArray = new NamespaceReferenceHandle[0]; + + private static MethodHandle[] s_emptyMethodHandleArray = new MethodHandle[0]; + + private static MethodInstantiationHandle[] s_emptyMethodInstantiationHandleArray = new MethodInstantiationHandle[0]; + + private static MemberReferenceHandle[] s_emptyMemberReferenceHandleArray = new MemberReferenceHandle[0]; + + private static FieldHandle[] s_emptyFieldHandleArray = new FieldHandle[0]; + + private static PropertyHandle[] s_emptyPropertyHandleArray = new PropertyHandle[0]; + + private static EventHandle[] s_emptyEventHandleArray = new EventHandle[0]; + + private static CustomAttributeHandle[] s_emptyCustomAttributeHandleArray = new CustomAttributeHandle[0]; + + private static FixedArgumentHandle[] s_emptyFixedArgumentHandleArray = new FixedArgumentHandle[0]; + + private static NamedArgumentHandle[] s_emptyNamedArgumentHandleArray = new NamedArgumentHandle[0]; + + private static GenericParameterHandle[] s_emptyGenericParameterHandleArray = new GenericParameterHandle[0]; + + private static MethodImplHandle[] s_emptyMethodImplHandleArray = new MethodImplHandle[0]; + + private static ParameterHandle[] s_emptyParameterHandleArray = new ParameterHandle[0]; + + private static MethodSemanticsHandle[] s_emptyMethodSemanticsHandleArray = new MethodSemanticsHandle[0]; + + private static TypeInstantiationSignatureHandle[] s_emptyTypeInstantiationSignatureHandleArray = new TypeInstantiationSignatureHandle[0]; + + private static SZArraySignatureHandle[] s_emptySZArraySignatureHandleArray = new SZArraySignatureHandle[0]; + + private static ArraySignatureHandle[] s_emptyArraySignatureHandleArray = new ArraySignatureHandle[0]; + + private static ByReferenceSignatureHandle[] s_emptyByReferenceSignatureHandleArray = new ByReferenceSignatureHandle[0]; + + private static PointerSignatureHandle[] s_emptyPointerSignatureHandleArray = new PointerSignatureHandle[0]; + + private static TypeVariableSignatureHandle[] s_emptyTypeVariableSignatureHandleArray = new TypeVariableSignatureHandle[0]; + + private static MethodTypeVariableSignatureHandle[] s_emptyMethodTypeVariableSignatureHandleArray = new MethodTypeVariableSignatureHandle[0]; + + private static FieldSignatureHandle[] s_emptyFieldSignatureHandleArray = new FieldSignatureHandle[0]; + + private static PropertySignatureHandle[] s_emptyPropertySignatureHandleArray = new PropertySignatureHandle[0]; + + private static MethodSignatureHandle[] s_emptyMethodSignatureHandleArray = new MethodSignatureHandle[0]; + + private static ReturnTypeSignatureHandle[] s_emptyReturnTypeSignatureHandleArray = new ReturnTypeSignatureHandle[0]; + + private static ParameterTypeSignatureHandle[] s_emptyParameterTypeSignatureHandleArray = new ParameterTypeSignatureHandle[0]; + + private static TypeForwarderHandle[] s_emptyTypeForwarderHandleArray = new TypeForwarderHandle[0]; + + private static CustomModifierHandle[] s_emptyCustomModifierHandleArray = new CustomModifierHandle[0]; + + private static ConstantBooleanArrayHandle[] s_emptyConstantBooleanArrayHandleArray = new ConstantBooleanArrayHandle[0]; + + private static ConstantBooleanValueHandle[] s_emptyConstantBooleanValueHandleArray = new ConstantBooleanValueHandle[0]; + + private static ConstantByteArrayHandle[] s_emptyConstantByteArrayHandleArray = new ConstantByteArrayHandle[0]; + + private static ConstantByteValueHandle[] s_emptyConstantByteValueHandleArray = new ConstantByteValueHandle[0]; + + private static ConstantCharArrayHandle[] s_emptyConstantCharArrayHandleArray = new ConstantCharArrayHandle[0]; + + private static ConstantCharValueHandle[] s_emptyConstantCharValueHandleArray = new ConstantCharValueHandle[0]; + + private static ConstantDoubleArrayHandle[] s_emptyConstantDoubleArrayHandleArray = new ConstantDoubleArrayHandle[0]; + + private static ConstantDoubleValueHandle[] s_emptyConstantDoubleValueHandleArray = new ConstantDoubleValueHandle[0]; + + private static ConstantHandleArrayHandle[] s_emptyConstantHandleArrayHandleArray = new ConstantHandleArrayHandle[0]; + + private static ConstantInt16ArrayHandle[] s_emptyConstantInt16ArrayHandleArray = new ConstantInt16ArrayHandle[0]; + + private static ConstantInt16ValueHandle[] s_emptyConstantInt16ValueHandleArray = new ConstantInt16ValueHandle[0]; + + private static ConstantInt32ArrayHandle[] s_emptyConstantInt32ArrayHandleArray = new ConstantInt32ArrayHandle[0]; + + private static ConstantInt32ValueHandle[] s_emptyConstantInt32ValueHandleArray = new ConstantInt32ValueHandle[0]; + + private static ConstantInt64ArrayHandle[] s_emptyConstantInt64ArrayHandleArray = new ConstantInt64ArrayHandle[0]; + + private static ConstantInt64ValueHandle[] s_emptyConstantInt64ValueHandleArray = new ConstantInt64ValueHandle[0]; + + private static ConstantReferenceValueHandle[] s_emptyConstantReferenceValueHandleArray = new ConstantReferenceValueHandle[0]; + + private static ConstantSByteArrayHandle[] s_emptyConstantSByteArrayHandleArray = new ConstantSByteArrayHandle[0]; + + private static ConstantSByteValueHandle[] s_emptyConstantSByteValueHandleArray = new ConstantSByteValueHandle[0]; + + private static ConstantSingleArrayHandle[] s_emptyConstantSingleArrayHandleArray = new ConstantSingleArrayHandle[0]; + + private static ConstantSingleValueHandle[] s_emptyConstantSingleValueHandleArray = new ConstantSingleValueHandle[0]; + + private static ConstantStringArrayHandle[] s_emptyConstantStringArrayHandleArray = new ConstantStringArrayHandle[0]; + + private static ConstantStringValueHandle[] s_emptyConstantStringValueHandleArray = new ConstantStringValueHandle[0]; + + private static ConstantUInt16ArrayHandle[] s_emptyConstantUInt16ArrayHandleArray = new ConstantUInt16ArrayHandle[0]; + + private static ConstantUInt16ValueHandle[] s_emptyConstantUInt16ValueHandleArray = new ConstantUInt16ValueHandle[0]; + + private static ConstantUInt32ArrayHandle[] s_emptyConstantUInt32ArrayHandleArray = new ConstantUInt32ArrayHandle[0]; + + private static ConstantUInt32ValueHandle[] s_emptyConstantUInt32ValueHandleArray = new ConstantUInt32ValueHandle[0]; + + private static ConstantUInt64ArrayHandle[] s_emptyConstantUInt64ArrayHandleArray = new ConstantUInt64ArrayHandle[0]; + + private static ConstantUInt64ValueHandle[] s_emptyConstantUInt64ValueHandleArray = new ConstantUInt64ValueHandle[0]; + } // MdBinaryReader +} // Internal.Metadata.NativeFormat diff --git a/src/Common/src/Internal/Metadata/NativeFormat/NativeFormatReaderCommonGen.cs b/src/Common/src/Internal/Metadata/NativeFormat/NativeFormatReaderCommonGen.cs new file mode 100644 index 000000000..37d9594b7 --- /dev/null +++ b/src/Common/src/Internal/Metadata/NativeFormat/NativeFormatReaderCommonGen.cs @@ -0,0 +1,3246 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +// NOTE: This is a generated file - do not manually edit! + +using System; +using System.Reflection; +using System.Collections.Generic; + +#pragma warning disable 108 // base type 'uint' is not CLS-compliant +#pragma warning disable 3009 // base type 'uint' is not CLS-compliant +#pragma warning disable 282 // There is no defined ordering between fields in multiple declarations of partial class or struct + +namespace Internal.Metadata.NativeFormat +{ + /// <summary> + /// AssemblyFlags + /// </summary> + [Flags] + public enum AssemblyFlags : uint + { + /// The assembly reference holds the full (unhashed) public key. + PublicKey = 0x1, + + /// The implementation of this assembly used at runtime is not expected to match the version seen at compile time. + Retargetable = 0x100, + + /// Reserved. + DisableJITcompileOptimizer = 0x4000, + + /// Reserved. + EnableJITcompileTracking = 0x8000, + } // AssemblyFlags + + /// <summary> + /// AssemblyHashAlgorithm + /// </summary> + public enum AssemblyHashAlgorithm : uint + { + None = 0x0, + Reserved = 0x8003, + SHA1 = 0x8004, + } // AssemblyHashAlgorithm + + /// <summary> + /// FixedArgumentAttributes + /// </summary> + [Flags] + public enum FixedArgumentAttributes : byte + { + None = 0x0, + + /// Values should be boxed as Object + Boxed = 0x1, + } // FixedArgumentAttributes + + /// <summary> + /// GenericParameterKind + /// </summary> + public enum GenericParameterKind : byte + { + /// Represents a type parameter for a generic type. + GenericTypeParameter = 0x0, + + /// Represents a type parameter from a generic method. + GenericMethodParameter = 0x1, + } // GenericParameterKind + + /// <summary> + /// HandleType + /// </summary> + public enum HandleType : byte + { + Null = 0x0, + ArraySignature = 0x1, + ByReferenceSignature = 0x2, + ConstantBooleanArray = 0x3, + ConstantBooleanValue = 0x4, + ConstantByteArray = 0x5, + ConstantByteValue = 0x6, + ConstantCharArray = 0x7, + ConstantCharValue = 0x8, + ConstantDoubleArray = 0x9, + ConstantDoubleValue = 0xa, + ConstantHandleArray = 0xb, + ConstantInt16Array = 0xc, + ConstantInt16Value = 0xd, + ConstantInt32Array = 0xe, + ConstantInt32Value = 0xf, + ConstantInt64Array = 0x10, + ConstantInt64Value = 0x11, + ConstantReferenceValue = 0x12, + ConstantSByteArray = 0x13, + ConstantSByteValue = 0x14, + ConstantSingleArray = 0x15, + ConstantSingleValue = 0x16, + ConstantStringArray = 0x17, + ConstantStringValue = 0x18, + ConstantUInt16Array = 0x19, + ConstantUInt16Value = 0x1a, + ConstantUInt32Array = 0x1b, + ConstantUInt32Value = 0x1c, + ConstantUInt64Array = 0x1d, + ConstantUInt64Value = 0x1e, + CustomAttribute = 0x1f, + CustomModifier = 0x20, + Event = 0x21, + Field = 0x22, + FieldSignature = 0x23, + FixedArgument = 0x24, + GenericParameter = 0x25, + MemberReference = 0x26, + Method = 0x27, + MethodImpl = 0x28, + MethodInstantiation = 0x29, + MethodSemantics = 0x2a, + MethodSignature = 0x2b, + MethodTypeVariableSignature = 0x2c, + NamedArgument = 0x2d, + NamespaceDefinition = 0x2e, + NamespaceReference = 0x2f, + Parameter = 0x30, + ParameterTypeSignature = 0x31, + PointerSignature = 0x32, + Property = 0x33, + PropertySignature = 0x34, + ReturnTypeSignature = 0x35, + SZArraySignature = 0x36, + ScopeDefinition = 0x37, + ScopeReference = 0x38, + TypeDefinition = 0x39, + TypeForwarder = 0x3a, + TypeInstantiationSignature = 0x3b, + TypeReference = 0x3c, + TypeSpecification = 0x3d, + TypeVariableSignature = 0x3e, + } // HandleType + + /// <summary> + /// NamedArgumentMemberKind + /// </summary> + public enum NamedArgumentMemberKind : byte + { + /// Specifies the name of a property + Property = 0x0, + + /// Specifies the name of a field + Field = 0x1, + } // NamedArgumentMemberKind + + /// <summary> + /// IArraySignature + /// </summary> + internal interface IArraySignature + { + Handle ElementType + { + get; + } // ElementType + + int Rank + { + get; + } // Rank + + IEnumerable<int> Sizes + { + get; + } // Sizes + + IEnumerable<int> LowerBounds + { + get; + } // LowerBounds + + ArraySignatureHandle Handle + { + get; + } // Handle + } // IArraySignature + + /// <summary> + /// ArraySignature + /// </summary> + public partial struct ArraySignature : IArraySignature + { + } // ArraySignature + + /// <summary> + /// IArraySignatureHandle + /// </summary> + internal interface IArraySignatureHandle : IEquatable<ArraySignatureHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IArraySignatureHandle + + /// <summary> + /// ArraySignatureHandle + /// </summary> + public partial struct ArraySignatureHandle : IArraySignatureHandle + { + } // ArraySignatureHandle + + /// <summary> + /// IByReferenceSignature + /// </summary> + internal interface IByReferenceSignature + { + Handle Type + { + get; + } // Type + + ByReferenceSignatureHandle Handle + { + get; + } // Handle + } // IByReferenceSignature + + /// <summary> + /// ByReferenceSignature + /// </summary> + public partial struct ByReferenceSignature : IByReferenceSignature + { + } // ByReferenceSignature + + /// <summary> + /// IByReferenceSignatureHandle + /// </summary> + internal interface IByReferenceSignatureHandle : IEquatable<ByReferenceSignatureHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IByReferenceSignatureHandle + + /// <summary> + /// ByReferenceSignatureHandle + /// </summary> + public partial struct ByReferenceSignatureHandle : IByReferenceSignatureHandle + { + } // ByReferenceSignatureHandle + + /// <summary> + /// IConstantBooleanArray + /// </summary> + internal interface IConstantBooleanArray + { + IEnumerable<bool> Value + { + get; + } // Value + + ConstantBooleanArrayHandle Handle + { + get; + } // Handle + } // IConstantBooleanArray + + /// <summary> + /// ConstantBooleanArray + /// </summary> + public partial struct ConstantBooleanArray : IConstantBooleanArray + { + } // ConstantBooleanArray + + /// <summary> + /// IConstantBooleanArrayHandle + /// </summary> + internal interface IConstantBooleanArrayHandle : IEquatable<ConstantBooleanArrayHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantBooleanArrayHandle + + /// <summary> + /// ConstantBooleanArrayHandle + /// </summary> + public partial struct ConstantBooleanArrayHandle : IConstantBooleanArrayHandle + { + } // ConstantBooleanArrayHandle + + /// <summary> + /// IConstantBooleanValue + /// </summary> + internal interface IConstantBooleanValue + { + bool Value + { + get; + } // Value + + ConstantBooleanValueHandle Handle + { + get; + } // Handle + } // IConstantBooleanValue + + /// <summary> + /// ConstantBooleanValue + /// </summary> + public partial struct ConstantBooleanValue : IConstantBooleanValue + { + } // ConstantBooleanValue + + /// <summary> + /// IConstantBooleanValueHandle + /// </summary> + internal interface IConstantBooleanValueHandle : IEquatable<ConstantBooleanValueHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantBooleanValueHandle + + /// <summary> + /// ConstantBooleanValueHandle + /// </summary> + public partial struct ConstantBooleanValueHandle : IConstantBooleanValueHandle + { + } // ConstantBooleanValueHandle + + /// <summary> + /// IConstantByteArray + /// </summary> + internal interface IConstantByteArray + { + IEnumerable<byte> Value + { + get; + } // Value + + ConstantByteArrayHandle Handle + { + get; + } // Handle + } // IConstantByteArray + + /// <summary> + /// ConstantByteArray + /// </summary> + public partial struct ConstantByteArray : IConstantByteArray + { + } // ConstantByteArray + + /// <summary> + /// IConstantByteArrayHandle + /// </summary> + internal interface IConstantByteArrayHandle : IEquatable<ConstantByteArrayHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantByteArrayHandle + + /// <summary> + /// ConstantByteArrayHandle + /// </summary> + public partial struct ConstantByteArrayHandle : IConstantByteArrayHandle + { + } // ConstantByteArrayHandle + + /// <summary> + /// IConstantByteValue + /// </summary> + internal interface IConstantByteValue + { + byte Value + { + get; + } // Value + + ConstantByteValueHandle Handle + { + get; + } // Handle + } // IConstantByteValue + + /// <summary> + /// ConstantByteValue + /// </summary> + public partial struct ConstantByteValue : IConstantByteValue + { + } // ConstantByteValue + + /// <summary> + /// IConstantByteValueHandle + /// </summary> + internal interface IConstantByteValueHandle : IEquatable<ConstantByteValueHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantByteValueHandle + + /// <summary> + /// ConstantByteValueHandle + /// </summary> + public partial struct ConstantByteValueHandle : IConstantByteValueHandle + { + } // ConstantByteValueHandle + + /// <summary> + /// IConstantCharArray + /// </summary> + internal interface IConstantCharArray + { + IEnumerable<char> Value + { + get; + } // Value + + ConstantCharArrayHandle Handle + { + get; + } // Handle + } // IConstantCharArray + + /// <summary> + /// ConstantCharArray + /// </summary> + public partial struct ConstantCharArray : IConstantCharArray + { + } // ConstantCharArray + + /// <summary> + /// IConstantCharArrayHandle + /// </summary> + internal interface IConstantCharArrayHandle : IEquatable<ConstantCharArrayHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantCharArrayHandle + + /// <summary> + /// ConstantCharArrayHandle + /// </summary> + public partial struct ConstantCharArrayHandle : IConstantCharArrayHandle + { + } // ConstantCharArrayHandle + + /// <summary> + /// IConstantCharValue + /// </summary> + internal interface IConstantCharValue + { + char Value + { + get; + } // Value + + ConstantCharValueHandle Handle + { + get; + } // Handle + } // IConstantCharValue + + /// <summary> + /// ConstantCharValue + /// </summary> + public partial struct ConstantCharValue : IConstantCharValue + { + } // ConstantCharValue + + /// <summary> + /// IConstantCharValueHandle + /// </summary> + internal interface IConstantCharValueHandle : IEquatable<ConstantCharValueHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantCharValueHandle + + /// <summary> + /// ConstantCharValueHandle + /// </summary> + public partial struct ConstantCharValueHandle : IConstantCharValueHandle + { + } // ConstantCharValueHandle + + /// <summary> + /// IConstantDoubleArray + /// </summary> + internal interface IConstantDoubleArray + { + IEnumerable<double> Value + { + get; + } // Value + + ConstantDoubleArrayHandle Handle + { + get; + } // Handle + } // IConstantDoubleArray + + /// <summary> + /// ConstantDoubleArray + /// </summary> + public partial struct ConstantDoubleArray : IConstantDoubleArray + { + } // ConstantDoubleArray + + /// <summary> + /// IConstantDoubleArrayHandle + /// </summary> + internal interface IConstantDoubleArrayHandle : IEquatable<ConstantDoubleArrayHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantDoubleArrayHandle + + /// <summary> + /// ConstantDoubleArrayHandle + /// </summary> + public partial struct ConstantDoubleArrayHandle : IConstantDoubleArrayHandle + { + } // ConstantDoubleArrayHandle + + /// <summary> + /// IConstantDoubleValue + /// </summary> + internal interface IConstantDoubleValue + { + double Value + { + get; + } // Value + + ConstantDoubleValueHandle Handle + { + get; + } // Handle + } // IConstantDoubleValue + + /// <summary> + /// ConstantDoubleValue + /// </summary> + public partial struct ConstantDoubleValue : IConstantDoubleValue + { + } // ConstantDoubleValue + + /// <summary> + /// IConstantDoubleValueHandle + /// </summary> + internal interface IConstantDoubleValueHandle : IEquatable<ConstantDoubleValueHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantDoubleValueHandle + + /// <summary> + /// ConstantDoubleValueHandle + /// </summary> + public partial struct ConstantDoubleValueHandle : IConstantDoubleValueHandle + { + } // ConstantDoubleValueHandle + + /// <summary> + /// IConstantHandleArray + /// </summary> + internal interface IConstantHandleArray + { + IEnumerable<Handle> Value + { + get; + } // Value + + ConstantHandleArrayHandle Handle + { + get; + } // Handle + } // IConstantHandleArray + + /// <summary> + /// ConstantHandleArray + /// </summary> + public partial struct ConstantHandleArray : IConstantHandleArray + { + } // ConstantHandleArray + + /// <summary> + /// IConstantHandleArrayHandle + /// </summary> + internal interface IConstantHandleArrayHandle : IEquatable<ConstantHandleArrayHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantHandleArrayHandle + + /// <summary> + /// ConstantHandleArrayHandle + /// </summary> + public partial struct ConstantHandleArrayHandle : IConstantHandleArrayHandle + { + } // ConstantHandleArrayHandle + + /// <summary> + /// IConstantInt16Array + /// </summary> + internal interface IConstantInt16Array + { + IEnumerable<short> Value + { + get; + } // Value + + ConstantInt16ArrayHandle Handle + { + get; + } // Handle + } // IConstantInt16Array + + /// <summary> + /// ConstantInt16Array + /// </summary> + public partial struct ConstantInt16Array : IConstantInt16Array + { + } // ConstantInt16Array + + /// <summary> + /// IConstantInt16ArrayHandle + /// </summary> + internal interface IConstantInt16ArrayHandle : IEquatable<ConstantInt16ArrayHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantInt16ArrayHandle + + /// <summary> + /// ConstantInt16ArrayHandle + /// </summary> + public partial struct ConstantInt16ArrayHandle : IConstantInt16ArrayHandle + { + } // ConstantInt16ArrayHandle + + /// <summary> + /// IConstantInt16Value + /// </summary> + internal interface IConstantInt16Value + { + short Value + { + get; + } // Value + + ConstantInt16ValueHandle Handle + { + get; + } // Handle + } // IConstantInt16Value + + /// <summary> + /// ConstantInt16Value + /// </summary> + public partial struct ConstantInt16Value : IConstantInt16Value + { + } // ConstantInt16Value + + /// <summary> + /// IConstantInt16ValueHandle + /// </summary> + internal interface IConstantInt16ValueHandle : IEquatable<ConstantInt16ValueHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantInt16ValueHandle + + /// <summary> + /// ConstantInt16ValueHandle + /// </summary> + public partial struct ConstantInt16ValueHandle : IConstantInt16ValueHandle + { + } // ConstantInt16ValueHandle + + /// <summary> + /// IConstantInt32Array + /// </summary> + internal interface IConstantInt32Array + { + IEnumerable<int> Value + { + get; + } // Value + + ConstantInt32ArrayHandle Handle + { + get; + } // Handle + } // IConstantInt32Array + + /// <summary> + /// ConstantInt32Array + /// </summary> + public partial struct ConstantInt32Array : IConstantInt32Array + { + } // ConstantInt32Array + + /// <summary> + /// IConstantInt32ArrayHandle + /// </summary> + internal interface IConstantInt32ArrayHandle : IEquatable<ConstantInt32ArrayHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantInt32ArrayHandle + + /// <summary> + /// ConstantInt32ArrayHandle + /// </summary> + public partial struct ConstantInt32ArrayHandle : IConstantInt32ArrayHandle + { + } // ConstantInt32ArrayHandle + + /// <summary> + /// IConstantInt32Value + /// </summary> + internal interface IConstantInt32Value + { + int Value + { + get; + } // Value + + ConstantInt32ValueHandle Handle + { + get; + } // Handle + } // IConstantInt32Value + + /// <summary> + /// ConstantInt32Value + /// </summary> + public partial struct ConstantInt32Value : IConstantInt32Value + { + } // ConstantInt32Value + + /// <summary> + /// IConstantInt32ValueHandle + /// </summary> + internal interface IConstantInt32ValueHandle : IEquatable<ConstantInt32ValueHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantInt32ValueHandle + + /// <summary> + /// ConstantInt32ValueHandle + /// </summary> + public partial struct ConstantInt32ValueHandle : IConstantInt32ValueHandle + { + } // ConstantInt32ValueHandle + + /// <summary> + /// IConstantInt64Array + /// </summary> + internal interface IConstantInt64Array + { + IEnumerable<long> Value + { + get; + } // Value + + ConstantInt64ArrayHandle Handle + { + get; + } // Handle + } // IConstantInt64Array + + /// <summary> + /// ConstantInt64Array + /// </summary> + public partial struct ConstantInt64Array : IConstantInt64Array + { + } // ConstantInt64Array + + /// <summary> + /// IConstantInt64ArrayHandle + /// </summary> + internal interface IConstantInt64ArrayHandle : IEquatable<ConstantInt64ArrayHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantInt64ArrayHandle + + /// <summary> + /// ConstantInt64ArrayHandle + /// </summary> + public partial struct ConstantInt64ArrayHandle : IConstantInt64ArrayHandle + { + } // ConstantInt64ArrayHandle + + /// <summary> + /// IConstantInt64Value + /// </summary> + internal interface IConstantInt64Value + { + long Value + { + get; + } // Value + + ConstantInt64ValueHandle Handle + { + get; + } // Handle + } // IConstantInt64Value + + /// <summary> + /// ConstantInt64Value + /// </summary> + public partial struct ConstantInt64Value : IConstantInt64Value + { + } // ConstantInt64Value + + /// <summary> + /// IConstantInt64ValueHandle + /// </summary> + internal interface IConstantInt64ValueHandle : IEquatable<ConstantInt64ValueHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantInt64ValueHandle + + /// <summary> + /// ConstantInt64ValueHandle + /// </summary> + public partial struct ConstantInt64ValueHandle : IConstantInt64ValueHandle + { + } // ConstantInt64ValueHandle + + /// <summary> + /// IConstantReferenceValue + /// </summary> + internal interface IConstantReferenceValue + { + Object Value + { + get; + } // Value + + ConstantReferenceValueHandle Handle + { + get; + } // Handle + } // IConstantReferenceValue + + /// <summary> + /// ConstantReferenceValue + /// </summary> + public partial struct ConstantReferenceValue : IConstantReferenceValue + { + } // ConstantReferenceValue + + /// <summary> + /// IConstantReferenceValueHandle + /// </summary> + internal interface IConstantReferenceValueHandle : IEquatable<ConstantReferenceValueHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantReferenceValueHandle + + /// <summary> + /// ConstantReferenceValueHandle + /// </summary> + public partial struct ConstantReferenceValueHandle : IConstantReferenceValueHandle + { + } // ConstantReferenceValueHandle + + /// <summary> + /// IConstantSByteArray + /// </summary> + internal interface IConstantSByteArray + { + IEnumerable<sbyte> Value + { + get; + } // Value + + ConstantSByteArrayHandle Handle + { + get; + } // Handle + } // IConstantSByteArray + + /// <summary> + /// ConstantSByteArray + /// </summary> + public partial struct ConstantSByteArray : IConstantSByteArray + { + } // ConstantSByteArray + + /// <summary> + /// IConstantSByteArrayHandle + /// </summary> + internal interface IConstantSByteArrayHandle : IEquatable<ConstantSByteArrayHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantSByteArrayHandle + + /// <summary> + /// ConstantSByteArrayHandle + /// </summary> + public partial struct ConstantSByteArrayHandle : IConstantSByteArrayHandle + { + } // ConstantSByteArrayHandle + + /// <summary> + /// IConstantSByteValue + /// </summary> + internal interface IConstantSByteValue + { + sbyte Value + { + get; + } // Value + + ConstantSByteValueHandle Handle + { + get; + } // Handle + } // IConstantSByteValue + + /// <summary> + /// ConstantSByteValue + /// </summary> + public partial struct ConstantSByteValue : IConstantSByteValue + { + } // ConstantSByteValue + + /// <summary> + /// IConstantSByteValueHandle + /// </summary> + internal interface IConstantSByteValueHandle : IEquatable<ConstantSByteValueHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantSByteValueHandle + + /// <summary> + /// ConstantSByteValueHandle + /// </summary> + public partial struct ConstantSByteValueHandle : IConstantSByteValueHandle + { + } // ConstantSByteValueHandle + + /// <summary> + /// IConstantSingleArray + /// </summary> + internal interface IConstantSingleArray + { + IEnumerable<float> Value + { + get; + } // Value + + ConstantSingleArrayHandle Handle + { + get; + } // Handle + } // IConstantSingleArray + + /// <summary> + /// ConstantSingleArray + /// </summary> + public partial struct ConstantSingleArray : IConstantSingleArray + { + } // ConstantSingleArray + + /// <summary> + /// IConstantSingleArrayHandle + /// </summary> + internal interface IConstantSingleArrayHandle : IEquatable<ConstantSingleArrayHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantSingleArrayHandle + + /// <summary> + /// ConstantSingleArrayHandle + /// </summary> + public partial struct ConstantSingleArrayHandle : IConstantSingleArrayHandle + { + } // ConstantSingleArrayHandle + + /// <summary> + /// IConstantSingleValue + /// </summary> + internal interface IConstantSingleValue + { + float Value + { + get; + } // Value + + ConstantSingleValueHandle Handle + { + get; + } // Handle + } // IConstantSingleValue + + /// <summary> + /// ConstantSingleValue + /// </summary> + public partial struct ConstantSingleValue : IConstantSingleValue + { + } // ConstantSingleValue + + /// <summary> + /// IConstantSingleValueHandle + /// </summary> + internal interface IConstantSingleValueHandle : IEquatable<ConstantSingleValueHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantSingleValueHandle + + /// <summary> + /// ConstantSingleValueHandle + /// </summary> + public partial struct ConstantSingleValueHandle : IConstantSingleValueHandle + { + } // ConstantSingleValueHandle + + /// <summary> + /// IConstantStringArray + /// </summary> + internal interface IConstantStringArray + { + IEnumerable<string> Value + { + get; + } // Value + + ConstantStringArrayHandle Handle + { + get; + } // Handle + } // IConstantStringArray + + /// <summary> + /// ConstantStringArray + /// </summary> + public partial struct ConstantStringArray : IConstantStringArray + { + } // ConstantStringArray + + /// <summary> + /// IConstantStringArrayHandle + /// </summary> + internal interface IConstantStringArrayHandle : IEquatable<ConstantStringArrayHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantStringArrayHandle + + /// <summary> + /// ConstantStringArrayHandle + /// </summary> + public partial struct ConstantStringArrayHandle : IConstantStringArrayHandle + { + } // ConstantStringArrayHandle + + /// <summary> + /// IConstantStringValue + /// </summary> + internal interface IConstantStringValue + { + string Value + { + get; + } // Value + + ConstantStringValueHandle Handle + { + get; + } // Handle + } // IConstantStringValue + + /// <summary> + /// ConstantStringValue + /// </summary> + public partial struct ConstantStringValue : IConstantStringValue + { + } // ConstantStringValue + + /// <summary> + /// IConstantStringValueHandle + /// </summary> + internal interface IConstantStringValueHandle : IEquatable<ConstantStringValueHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantStringValueHandle + + /// <summary> + /// ConstantStringValueHandle + /// </summary> + public partial struct ConstantStringValueHandle : IConstantStringValueHandle + { + } // ConstantStringValueHandle + + /// <summary> + /// IConstantUInt16Array + /// </summary> + internal interface IConstantUInt16Array + { + IEnumerable<ushort> Value + { + get; + } // Value + + ConstantUInt16ArrayHandle Handle + { + get; + } // Handle + } // IConstantUInt16Array + + /// <summary> + /// ConstantUInt16Array + /// </summary> + public partial struct ConstantUInt16Array : IConstantUInt16Array + { + } // ConstantUInt16Array + + /// <summary> + /// IConstantUInt16ArrayHandle + /// </summary> + internal interface IConstantUInt16ArrayHandle : IEquatable<ConstantUInt16ArrayHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantUInt16ArrayHandle + + /// <summary> + /// ConstantUInt16ArrayHandle + /// </summary> + public partial struct ConstantUInt16ArrayHandle : IConstantUInt16ArrayHandle + { + } // ConstantUInt16ArrayHandle + + /// <summary> + /// IConstantUInt16Value + /// </summary> + internal interface IConstantUInt16Value + { + ushort Value + { + get; + } // Value + + ConstantUInt16ValueHandle Handle + { + get; + } // Handle + } // IConstantUInt16Value + + /// <summary> + /// ConstantUInt16Value + /// </summary> + public partial struct ConstantUInt16Value : IConstantUInt16Value + { + } // ConstantUInt16Value + + /// <summary> + /// IConstantUInt16ValueHandle + /// </summary> + internal interface IConstantUInt16ValueHandle : IEquatable<ConstantUInt16ValueHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantUInt16ValueHandle + + /// <summary> + /// ConstantUInt16ValueHandle + /// </summary> + public partial struct ConstantUInt16ValueHandle : IConstantUInt16ValueHandle + { + } // ConstantUInt16ValueHandle + + /// <summary> + /// IConstantUInt32Array + /// </summary> + internal interface IConstantUInt32Array + { + IEnumerable<uint> Value + { + get; + } // Value + + ConstantUInt32ArrayHandle Handle + { + get; + } // Handle + } // IConstantUInt32Array + + /// <summary> + /// ConstantUInt32Array + /// </summary> + public partial struct ConstantUInt32Array : IConstantUInt32Array + { + } // ConstantUInt32Array + + /// <summary> + /// IConstantUInt32ArrayHandle + /// </summary> + internal interface IConstantUInt32ArrayHandle : IEquatable<ConstantUInt32ArrayHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantUInt32ArrayHandle + + /// <summary> + /// ConstantUInt32ArrayHandle + /// </summary> + public partial struct ConstantUInt32ArrayHandle : IConstantUInt32ArrayHandle + { + } // ConstantUInt32ArrayHandle + + /// <summary> + /// IConstantUInt32Value + /// </summary> + internal interface IConstantUInt32Value + { + uint Value + { + get; + } // Value + + ConstantUInt32ValueHandle Handle + { + get; + } // Handle + } // IConstantUInt32Value + + /// <summary> + /// ConstantUInt32Value + /// </summary> + public partial struct ConstantUInt32Value : IConstantUInt32Value + { + } // ConstantUInt32Value + + /// <summary> + /// IConstantUInt32ValueHandle + /// </summary> + internal interface IConstantUInt32ValueHandle : IEquatable<ConstantUInt32ValueHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantUInt32ValueHandle + + /// <summary> + /// ConstantUInt32ValueHandle + /// </summary> + public partial struct ConstantUInt32ValueHandle : IConstantUInt32ValueHandle + { + } // ConstantUInt32ValueHandle + + /// <summary> + /// IConstantUInt64Array + /// </summary> + internal interface IConstantUInt64Array + { + IEnumerable<ulong> Value + { + get; + } // Value + + ConstantUInt64ArrayHandle Handle + { + get; + } // Handle + } // IConstantUInt64Array + + /// <summary> + /// ConstantUInt64Array + /// </summary> + public partial struct ConstantUInt64Array : IConstantUInt64Array + { + } // ConstantUInt64Array + + /// <summary> + /// IConstantUInt64ArrayHandle + /// </summary> + internal interface IConstantUInt64ArrayHandle : IEquatable<ConstantUInt64ArrayHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantUInt64ArrayHandle + + /// <summary> + /// ConstantUInt64ArrayHandle + /// </summary> + public partial struct ConstantUInt64ArrayHandle : IConstantUInt64ArrayHandle + { + } // ConstantUInt64ArrayHandle + + /// <summary> + /// IConstantUInt64Value + /// </summary> + internal interface IConstantUInt64Value + { + ulong Value + { + get; + } // Value + + ConstantUInt64ValueHandle Handle + { + get; + } // Handle + } // IConstantUInt64Value + + /// <summary> + /// ConstantUInt64Value + /// </summary> + public partial struct ConstantUInt64Value : IConstantUInt64Value + { + } // ConstantUInt64Value + + /// <summary> + /// IConstantUInt64ValueHandle + /// </summary> + internal interface IConstantUInt64ValueHandle : IEquatable<ConstantUInt64ValueHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IConstantUInt64ValueHandle + + /// <summary> + /// ConstantUInt64ValueHandle + /// </summary> + public partial struct ConstantUInt64ValueHandle : IConstantUInt64ValueHandle + { + } // ConstantUInt64ValueHandle + + /// <summary> + /// ICustomAttribute + /// </summary> + internal interface ICustomAttribute + { + Handle Type + { + get; + } // Type + + Handle Constructor + { + get; + } // Constructor + + IEnumerable<FixedArgumentHandle> FixedArguments + { + get; + } // FixedArguments + + IEnumerable<NamedArgumentHandle> NamedArguments + { + get; + } // NamedArguments + + CustomAttributeHandle Handle + { + get; + } // Handle + } // ICustomAttribute + + /// <summary> + /// CustomAttribute + /// </summary> + public partial struct CustomAttribute : ICustomAttribute + { + } // CustomAttribute + + /// <summary> + /// ICustomAttributeHandle + /// </summary> + internal interface ICustomAttributeHandle : IEquatable<CustomAttributeHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // ICustomAttributeHandle + + /// <summary> + /// CustomAttributeHandle + /// </summary> + public partial struct CustomAttributeHandle : ICustomAttributeHandle + { + } // CustomAttributeHandle + + /// <summary> + /// ICustomModifier + /// </summary> + internal interface ICustomModifier + { + bool IsOptional + { + get; + } // IsOptional + + Handle Type + { + get; + } // Type + + CustomModifierHandle Handle + { + get; + } // Handle + } // ICustomModifier + + /// <summary> + /// CustomModifier + /// </summary> + public partial struct CustomModifier : ICustomModifier + { + } // CustomModifier + + /// <summary> + /// ICustomModifierHandle + /// </summary> + internal interface ICustomModifierHandle : IEquatable<CustomModifierHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // ICustomModifierHandle + + /// <summary> + /// CustomModifierHandle + /// </summary> + public partial struct CustomModifierHandle : ICustomModifierHandle + { + } // CustomModifierHandle + + /// <summary> + /// IEvent + /// </summary> + internal interface IEvent + { + EventAttributes Flags + { + get; + } // Flags + + ConstantStringValueHandle Name + { + get; + } // Name + + Handle Type + { + get; + } // Type + + IEnumerable<MethodSemanticsHandle> MethodSemantics + { + get; + } // MethodSemantics + + IEnumerable<CustomAttributeHandle> CustomAttributes + { + get; + } // CustomAttributes + + EventHandle Handle + { + get; + } // Handle + } // IEvent + + /// <summary> + /// Event + /// </summary> + public partial struct Event : IEvent + { + } // Event + + /// <summary> + /// IEventHandle + /// </summary> + internal interface IEventHandle : IEquatable<EventHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IEventHandle + + /// <summary> + /// EventHandle + /// </summary> + public partial struct EventHandle : IEventHandle + { + } // EventHandle + + /// <summary> + /// IField + /// </summary> + internal interface IField + { + FieldAttributes Flags + { + get; + } // Flags + + ConstantStringValueHandle Name + { + get; + } // Name + + FieldSignatureHandle Signature + { + get; + } // Signature + + Handle DefaultValue + { + get; + } // DefaultValue + + uint Offset + { + get; + } // Offset + + IEnumerable<CustomAttributeHandle> CustomAttributes + { + get; + } // CustomAttributes + + FieldHandle Handle + { + get; + } // Handle + } // IField + + /// <summary> + /// Field + /// </summary> + public partial struct Field : IField + { + } // Field + + /// <summary> + /// IFieldHandle + /// </summary> + internal interface IFieldHandle : IEquatable<FieldHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IFieldHandle + + /// <summary> + /// FieldHandle + /// </summary> + public partial struct FieldHandle : IFieldHandle + { + } // FieldHandle + + /// <summary> + /// IFieldSignature + /// </summary> + internal interface IFieldSignature + { + Handle Type + { + get; + } // Type + + IEnumerable<CustomModifierHandle> CustomModifiers + { + get; + } // CustomModifiers + + FieldSignatureHandle Handle + { + get; + } // Handle + } // IFieldSignature + + /// <summary> + /// FieldSignature + /// </summary> + public partial struct FieldSignature : IFieldSignature + { + } // FieldSignature + + /// <summary> + /// IFieldSignatureHandle + /// </summary> + internal interface IFieldSignatureHandle : IEquatable<FieldSignatureHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IFieldSignatureHandle + + /// <summary> + /// FieldSignatureHandle + /// </summary> + public partial struct FieldSignatureHandle : IFieldSignatureHandle + { + } // FieldSignatureHandle + + /// <summary> + /// IFixedArgument + /// </summary> + internal interface IFixedArgument + { + FixedArgumentAttributes Flags + { + get; + } // Flags + + Handle Type + { + get; + } // Type + + Handle Value + { + get; + } // Value + + FixedArgumentHandle Handle + { + get; + } // Handle + } // IFixedArgument + + /// <summary> + /// FixedArgument + /// </summary> + public partial struct FixedArgument : IFixedArgument + { + } // FixedArgument + + /// <summary> + /// IFixedArgumentHandle + /// </summary> + internal interface IFixedArgumentHandle : IEquatable<FixedArgumentHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IFixedArgumentHandle + + /// <summary> + /// FixedArgumentHandle + /// </summary> + public partial struct FixedArgumentHandle : IFixedArgumentHandle + { + } // FixedArgumentHandle + + /// <summary> + /// IGenericParameter + /// </summary> + internal interface IGenericParameter + { + ushort Number + { + get; + } // Number + + GenericParameterAttributes Flags + { + get; + } // Flags + + GenericParameterKind Kind + { + get; + } // Kind + + ConstantStringValueHandle Name + { + get; + } // Name + + IEnumerable<Handle> Constraints + { + get; + } // Constraints + + IEnumerable<CustomAttributeHandle> CustomAttributes + { + get; + } // CustomAttributes + + GenericParameterHandle Handle + { + get; + } // Handle + } // IGenericParameter + + /// <summary> + /// GenericParameter + /// </summary> + public partial struct GenericParameter : IGenericParameter + { + } // GenericParameter + + /// <summary> + /// IGenericParameterHandle + /// </summary> + internal interface IGenericParameterHandle : IEquatable<GenericParameterHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IGenericParameterHandle + + /// <summary> + /// GenericParameterHandle + /// </summary> + public partial struct GenericParameterHandle : IGenericParameterHandle + { + } // GenericParameterHandle + + /// <summary> + /// IHandle + /// </summary> + internal interface IHandle : IEquatable<Handle>, IEquatable<Object> + { + int GetHashCode(); + HandleType GetHandleType(MetadataReader reader); + + PropertySignatureHandle ToPropertySignatureHandle(MetadataReader reader); + MethodSemanticsHandle ToMethodSemanticsHandle(MetadataReader reader); + ByReferenceSignatureHandle ToByReferenceSignatureHandle(MetadataReader reader); + ConstantStringArrayHandle ToConstantStringArrayHandle(MetadataReader reader); + ConstantInt64ValueHandle ToConstantInt64ValueHandle(MetadataReader reader); + ConstantReferenceValueHandle ToConstantReferenceValueHandle(MetadataReader reader); + NamespaceReferenceHandle ToNamespaceReferenceHandle(MetadataReader reader); + ScopeDefinitionHandle ToScopeDefinitionHandle(MetadataReader reader); + PointerSignatureHandle ToPointerSignatureHandle(MetadataReader reader); + ReturnTypeSignatureHandle ToReturnTypeSignatureHandle(MetadataReader reader); + ConstantSByteArrayHandle ToConstantSByteArrayHandle(MetadataReader reader); + ConstantInt16ArrayHandle ToConstantInt16ArrayHandle(MetadataReader reader); + ConstantStringValueHandle ToConstantStringValueHandle(MetadataReader reader); + MethodTypeVariableSignatureHandle ToMethodTypeVariableSignatureHandle(MetadataReader reader); + TypeForwarderHandle ToTypeForwarderHandle(MetadataReader reader); + ConstantInt16ValueHandle ToConstantInt16ValueHandle(MetadataReader reader); + ConstantUInt32ArrayHandle ToConstantUInt32ArrayHandle(MetadataReader reader); + ConstantByteArrayHandle ToConstantByteArrayHandle(MetadataReader reader); + FieldHandle ToFieldHandle(MetadataReader reader); + NamedArgumentHandle ToNamedArgumentHandle(MetadataReader reader); + TypeReferenceHandle ToTypeReferenceHandle(MetadataReader reader); + ConstantHandleArrayHandle ToConstantHandleArrayHandle(MetadataReader reader); + CustomAttributeHandle ToCustomAttributeHandle(MetadataReader reader); + ConstantByteValueHandle ToConstantByteValueHandle(MetadataReader reader); + ConstantSingleArrayHandle ToConstantSingleArrayHandle(MetadataReader reader); + MemberReferenceHandle ToMemberReferenceHandle(MetadataReader reader); + ArraySignatureHandle ToArraySignatureHandle(MetadataReader reader); + MethodHandle ToMethodHandle(MetadataReader reader); + ConstantUInt32ValueHandle ToConstantUInt32ValueHandle(MetadataReader reader); + ConstantCharArrayHandle ToConstantCharArrayHandle(MetadataReader reader); + TypeVariableSignatureHandle ToTypeVariableSignatureHandle(MetadataReader reader); + ConstantCharValueHandle ToConstantCharValueHandle(MetadataReader reader); + ScopeReferenceHandle ToScopeReferenceHandle(MetadataReader reader); + MethodSignatureHandle ToMethodSignatureHandle(MetadataReader reader); + ConstantSingleValueHandle ToConstantSingleValueHandle(MetadataReader reader); + CustomModifierHandle ToCustomModifierHandle(MetadataReader reader); + ConstantUInt16ArrayHandle ToConstantUInt16ArrayHandle(MetadataReader reader); + ConstantSByteValueHandle ToConstantSByteValueHandle(MetadataReader reader); + ConstantUInt64ValueHandle ToConstantUInt64ValueHandle(MetadataReader reader); + TypeDefinitionHandle ToTypeDefinitionHandle(MetadataReader reader); + ConstantInt32ValueHandle ToConstantInt32ValueHandle(MetadataReader reader); + ConstantInt64ArrayHandle ToConstantInt64ArrayHandle(MetadataReader reader); + FixedArgumentHandle ToFixedArgumentHandle(MetadataReader reader); + ParameterTypeSignatureHandle ToParameterTypeSignatureHandle(MetadataReader reader); + PropertyHandle ToPropertyHandle(MetadataReader reader); + ConstantDoubleArrayHandle ToConstantDoubleArrayHandle(MetadataReader reader); + FieldSignatureHandle ToFieldSignatureHandle(MetadataReader reader); + MethodInstantiationHandle ToMethodInstantiationHandle(MetadataReader reader); + ConstantUInt64ArrayHandle ToConstantUInt64ArrayHandle(MetadataReader reader); + ConstantBooleanValueHandle ToConstantBooleanValueHandle(MetadataReader reader); + NamespaceDefinitionHandle ToNamespaceDefinitionHandle(MetadataReader reader); + MethodImplHandle ToMethodImplHandle(MetadataReader reader); + TypeSpecificationHandle ToTypeSpecificationHandle(MetadataReader reader); + ConstantInt32ArrayHandle ToConstantInt32ArrayHandle(MetadataReader reader); + EventHandle ToEventHandle(MetadataReader reader); + ConstantUInt16ValueHandle ToConstantUInt16ValueHandle(MetadataReader reader); + ConstantBooleanArrayHandle ToConstantBooleanArrayHandle(MetadataReader reader); + GenericParameterHandle ToGenericParameterHandle(MetadataReader reader); + TypeInstantiationSignatureHandle ToTypeInstantiationSignatureHandle(MetadataReader reader); + SZArraySignatureHandle ToSZArraySignatureHandle(MetadataReader reader); + ConstantDoubleValueHandle ToConstantDoubleValueHandle(MetadataReader reader); + ParameterHandle ToParameterHandle(MetadataReader reader); + } // IHandle + + /// <summary> + /// Handle + /// </summary> + public partial struct Handle : IHandle + { + } // Handle + + /// <summary> + /// IMemberReference + /// </summary> + internal interface IMemberReference + { + Handle Parent + { + get; + } // Parent + + ConstantStringValueHandle Name + { + get; + } // Name + + Handle Signature + { + get; + } // Signature + + IEnumerable<CustomAttributeHandle> CustomAttributes + { + get; + } // CustomAttributes + + MemberReferenceHandle Handle + { + get; + } // Handle + } // IMemberReference + + /// <summary> + /// MemberReference + /// </summary> + public partial struct MemberReference : IMemberReference + { + } // MemberReference + + /// <summary> + /// IMemberReferenceHandle + /// </summary> + internal interface IMemberReferenceHandle : IEquatable<MemberReferenceHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IMemberReferenceHandle + + /// <summary> + /// MemberReferenceHandle + /// </summary> + public partial struct MemberReferenceHandle : IMemberReferenceHandle + { + } // MemberReferenceHandle + + /// <summary> + /// IMetadataReader + /// </summary> + public interface IMetadataReader + { + ConstantInt64Value GetConstantInt64Value(ConstantInt64ValueHandle handle); + Property GetProperty(PropertyHandle handle); + SZArraySignature GetSZArraySignature(SZArraySignatureHandle handle); + TypeDefinition GetTypeDefinition(TypeDefinitionHandle handle); + ParameterTypeSignature GetParameterTypeSignature(ParameterTypeSignatureHandle handle); + ConstantDoubleValue GetConstantDoubleValue(ConstantDoubleValueHandle handle); + ConstantCharValue GetConstantCharValue(ConstantCharValueHandle handle); + ConstantBooleanValue GetConstantBooleanValue(ConstantBooleanValueHandle handle); + ConstantSingleArray GetConstantSingleArray(ConstantSingleArrayHandle handle); + ConstantUInt64Array GetConstantUInt64Array(ConstantUInt64ArrayHandle handle); + ConstantInt16Array GetConstantInt16Array(ConstantInt16ArrayHandle handle); + ConstantSByteValue GetConstantSByteValue(ConstantSByteValueHandle handle); + ConstantByteValue GetConstantByteValue(ConstantByteValueHandle handle); + ScopeDefinition GetScopeDefinition(ScopeDefinitionHandle handle); + ArraySignature GetArraySignature(ArraySignatureHandle handle); + ConstantInt32Array GetConstantInt32Array(ConstantInt32ArrayHandle handle); + ConstantUInt32Array GetConstantUInt32Array(ConstantUInt32ArrayHandle handle); + ScopeReference GetScopeReference(ScopeReferenceHandle handle); + MethodInstantiation GetMethodInstantiation(MethodInstantiationHandle handle); + CustomModifier GetCustomModifier(CustomModifierHandle handle); + ConstantDoubleArray GetConstantDoubleArray(ConstantDoubleArrayHandle handle); + Event GetEvent(EventHandle handle); + ConstantSByteArray GetConstantSByteArray(ConstantSByteArrayHandle handle); + ReturnTypeSignature GetReturnTypeSignature(ReturnTypeSignatureHandle handle); + ConstantInt32Value GetConstantInt32Value(ConstantInt32ValueHandle handle); + ConstantSingleValue GetConstantSingleValue(ConstantSingleValueHandle handle); + Parameter GetParameter(ParameterHandle handle); + ConstantUInt16Value GetConstantUInt16Value(ConstantUInt16ValueHandle handle); + ConstantInt16Value GetConstantInt16Value(ConstantInt16ValueHandle handle); + ConstantCharArray GetConstantCharArray(ConstantCharArrayHandle handle); + TypeVariableSignature GetTypeVariableSignature(TypeVariableSignatureHandle handle); + ConstantStringArray GetConstantStringArray(ConstantStringArrayHandle handle); + ByReferenceSignature GetByReferenceSignature(ByReferenceSignatureHandle handle); + TypeReference GetTypeReference(TypeReferenceHandle handle); + ConstantUInt32Value GetConstantUInt32Value(ConstantUInt32ValueHandle handle); + ConstantUInt64Value GetConstantUInt64Value(ConstantUInt64ValueHandle handle); + MethodImpl GetMethodImpl(MethodImplHandle handle); + MethodSemantics GetMethodSemantics(MethodSemanticsHandle handle); + GenericParameter GetGenericParameter(GenericParameterHandle handle); + MethodTypeVariableSignature GetMethodTypeVariableSignature(MethodTypeVariableSignatureHandle handle); + TypeInstantiationSignature GetTypeInstantiationSignature(TypeInstantiationSignatureHandle handle); + FieldSignature GetFieldSignature(FieldSignatureHandle handle); + NamespaceReference GetNamespaceReference(NamespaceReferenceHandle handle); + MethodSignature GetMethodSignature(MethodSignatureHandle handle); + PointerSignature GetPointerSignature(PointerSignatureHandle handle); + NamedArgument GetNamedArgument(NamedArgumentHandle handle); + ConstantStringValue GetConstantStringValue(ConstantStringValueHandle handle); + CustomAttribute GetCustomAttribute(CustomAttributeHandle handle); + ConstantInt64Array GetConstantInt64Array(ConstantInt64ArrayHandle handle); + MemberReference GetMemberReference(MemberReferenceHandle handle); + ConstantReferenceValue GetConstantReferenceValue(ConstantReferenceValueHandle handle); + FixedArgument GetFixedArgument(FixedArgumentHandle handle); + Field GetField(FieldHandle handle); + ConstantByteArray GetConstantByteArray(ConstantByteArrayHandle handle); + ConstantHandleArray GetConstantHandleArray(ConstantHandleArrayHandle handle); + Method GetMethod(MethodHandle handle); + ConstantBooleanArray GetConstantBooleanArray(ConstantBooleanArrayHandle handle); + TypeForwarder GetTypeForwarder(TypeForwarderHandle handle); + NamespaceDefinition GetNamespaceDefinition(NamespaceDefinitionHandle handle); + PropertySignature GetPropertySignature(PropertySignatureHandle handle); + ConstantUInt16Array GetConstantUInt16Array(ConstantUInt16ArrayHandle handle); + TypeSpecification GetTypeSpecification(TypeSpecificationHandle handle); + IEnumerable<ScopeDefinitionHandle> ScopeDefinitions + { + get; + } // ScopeDefinitions + Handle NullHandle + { + get; + } // NullHandle + } // IMetadataReader + + /// <summary> + /// MetadataReader + /// </summary> + public partial class MetadataReader : IMetadataReader + { + } // MetadataReader + + /// <summary> + /// IMethod + /// </summary> + internal interface IMethod + { + uint RVA + { + get; + } // RVA + + MethodAttributes Flags + { + get; + } // Flags + + MethodImplAttributes ImplFlags + { + get; + } // ImplFlags + + ConstantStringValueHandle Name + { + get; + } // Name + + MethodSignatureHandle Signature + { + get; + } // Signature + + IEnumerable<ParameterHandle> Parameters + { + get; + } // Parameters + + IEnumerable<GenericParameterHandle> GenericParameters + { + get; + } // GenericParameters + + IEnumerable<MethodImplHandle> MethodImpls + { + get; + } // MethodImpls + + IEnumerable<CustomAttributeHandle> CustomAttributes + { + get; + } // CustomAttributes + + MethodHandle Handle + { + get; + } // Handle + } // IMethod + + /// <summary> + /// Method + /// </summary> + public partial struct Method : IMethod + { + } // Method + + /// <summary> + /// IMethodHandle + /// </summary> + internal interface IMethodHandle : IEquatable<MethodHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IMethodHandle + + /// <summary> + /// MethodHandle + /// </summary> + public partial struct MethodHandle : IMethodHandle + { + } // MethodHandle + + /// <summary> + /// IMethodImpl + /// </summary> + internal interface IMethodImpl + { + Handle MethodDeclaration + { + get; + } // MethodDeclaration + + IEnumerable<CustomAttributeHandle> CustomAttributes + { + get; + } // CustomAttributes + + MethodImplHandle Handle + { + get; + } // Handle + } // IMethodImpl + + /// <summary> + /// MethodImpl + /// </summary> + public partial struct MethodImpl : IMethodImpl + { + } // MethodImpl + + /// <summary> + /// IMethodImplHandle + /// </summary> + internal interface IMethodImplHandle : IEquatable<MethodImplHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IMethodImplHandle + + /// <summary> + /// MethodImplHandle + /// </summary> + public partial struct MethodImplHandle : IMethodImplHandle + { + } // MethodImplHandle + + /// <summary> + /// IMethodInstantiation + /// </summary> + internal interface IMethodInstantiation + { + Handle Method + { + get; + } // Method + + MethodSignatureHandle Instantiation + { + get; + } // Instantiation + + MethodInstantiationHandle Handle + { + get; + } // Handle + } // IMethodInstantiation + + /// <summary> + /// MethodInstantiation + /// </summary> + public partial struct MethodInstantiation : IMethodInstantiation + { + } // MethodInstantiation + + /// <summary> + /// IMethodInstantiationHandle + /// </summary> + internal interface IMethodInstantiationHandle : IEquatable<MethodInstantiationHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IMethodInstantiationHandle + + /// <summary> + /// MethodInstantiationHandle + /// </summary> + public partial struct MethodInstantiationHandle : IMethodInstantiationHandle + { + } // MethodInstantiationHandle + + /// <summary> + /// IMethodSemantics + /// </summary> + internal interface IMethodSemantics + { + MethodSemanticsAttributes Attributes + { + get; + } // Attributes + + MethodHandle Method + { + get; + } // Method + + IEnumerable<CustomAttributeHandle> CustomAttributes + { + get; + } // CustomAttributes + + MethodSemanticsHandle Handle + { + get; + } // Handle + } // IMethodSemantics + + /// <summary> + /// MethodSemantics + /// </summary> + public partial struct MethodSemantics : IMethodSemantics + { + } // MethodSemantics + + /// <summary> + /// IMethodSemanticsHandle + /// </summary> + internal interface IMethodSemanticsHandle : IEquatable<MethodSemanticsHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IMethodSemanticsHandle + + /// <summary> + /// MethodSemanticsHandle + /// </summary> + public partial struct MethodSemanticsHandle : IMethodSemanticsHandle + { + } // MethodSemanticsHandle + + /// <summary> + /// IMethodSignature + /// </summary> + internal interface IMethodSignature + { + CallingConventions CallingConvention + { + get; + } // CallingConvention + + int GenericParameterCount + { + get; + } // GenericParameterCount + + ReturnTypeSignatureHandle ReturnType + { + get; + } // ReturnType + + IEnumerable<ParameterTypeSignatureHandle> Parameters + { + get; + } // Parameters + + IEnumerable<ParameterTypeSignatureHandle> VarArgParameters + { + get; + } // VarArgParameters + + MethodSignatureHandle Handle + { + get; + } // Handle + } // IMethodSignature + + /// <summary> + /// MethodSignature + /// </summary> + public partial struct MethodSignature : IMethodSignature + { + } // MethodSignature + + /// <summary> + /// IMethodSignatureHandle + /// </summary> + internal interface IMethodSignatureHandle : IEquatable<MethodSignatureHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IMethodSignatureHandle + + /// <summary> + /// MethodSignatureHandle + /// </summary> + public partial struct MethodSignatureHandle : IMethodSignatureHandle + { + } // MethodSignatureHandle + + /// <summary> + /// IMethodTypeVariableSignature + /// </summary> + internal interface IMethodTypeVariableSignature + { + int Number + { + get; + } // Number + + MethodTypeVariableSignatureHandle Handle + { + get; + } // Handle + } // IMethodTypeVariableSignature + + /// <summary> + /// MethodTypeVariableSignature + /// </summary> + public partial struct MethodTypeVariableSignature : IMethodTypeVariableSignature + { + } // MethodTypeVariableSignature + + /// <summary> + /// IMethodTypeVariableSignatureHandle + /// </summary> + internal interface IMethodTypeVariableSignatureHandle : IEquatable<MethodTypeVariableSignatureHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IMethodTypeVariableSignatureHandle + + /// <summary> + /// MethodTypeVariableSignatureHandle + /// </summary> + public partial struct MethodTypeVariableSignatureHandle : IMethodTypeVariableSignatureHandle + { + } // MethodTypeVariableSignatureHandle + + /// <summary> + /// INamedArgument + /// </summary> + internal interface INamedArgument + { + NamedArgumentMemberKind Flags + { + get; + } // Flags + + ConstantStringValueHandle Name + { + get; + } // Name + + FixedArgumentHandle Value + { + get; + } // Value + + NamedArgumentHandle Handle + { + get; + } // Handle + } // INamedArgument + + /// <summary> + /// NamedArgument + /// </summary> + public partial struct NamedArgument : INamedArgument + { + } // NamedArgument + + /// <summary> + /// INamedArgumentHandle + /// </summary> + internal interface INamedArgumentHandle : IEquatable<NamedArgumentHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // INamedArgumentHandle + + /// <summary> + /// NamedArgumentHandle + /// </summary> + public partial struct NamedArgumentHandle : INamedArgumentHandle + { + } // NamedArgumentHandle + + /// <summary> + /// INamespaceDefinition + /// </summary> + internal interface INamespaceDefinition + { + Handle ParentScopeOrNamespace + { + get; + } // ParentScopeOrNamespace + + ConstantStringValueHandle Name + { + get; + } // Name + + IEnumerable<TypeDefinitionHandle> TypeDefinitions + { + get; + } // TypeDefinitions + + IEnumerable<TypeForwarderHandle> TypeForwarders + { + get; + } // TypeForwarders + + IEnumerable<NamespaceDefinitionHandle> NamespaceDefinitions + { + get; + } // NamespaceDefinitions + + NamespaceDefinitionHandle Handle + { + get; + } // Handle + } // INamespaceDefinition + + /// <summary> + /// NamespaceDefinition + /// </summary> + public partial struct NamespaceDefinition : INamespaceDefinition + { + } // NamespaceDefinition + + /// <summary> + /// INamespaceDefinitionHandle + /// </summary> + internal interface INamespaceDefinitionHandle : IEquatable<NamespaceDefinitionHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // INamespaceDefinitionHandle + + /// <summary> + /// NamespaceDefinitionHandle + /// </summary> + public partial struct NamespaceDefinitionHandle : INamespaceDefinitionHandle + { + } // NamespaceDefinitionHandle + + /// <summary> + /// INamespaceReference + /// </summary> + internal interface INamespaceReference + { + Handle ParentScopeOrNamespace + { + get; + } // ParentScopeOrNamespace + + ConstantStringValueHandle Name + { + get; + } // Name + + NamespaceReferenceHandle Handle + { + get; + } // Handle + } // INamespaceReference + + /// <summary> + /// NamespaceReference + /// </summary> + public partial struct NamespaceReference : INamespaceReference + { + } // NamespaceReference + + /// <summary> + /// INamespaceReferenceHandle + /// </summary> + internal interface INamespaceReferenceHandle : IEquatable<NamespaceReferenceHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // INamespaceReferenceHandle + + /// <summary> + /// NamespaceReferenceHandle + /// </summary> + public partial struct NamespaceReferenceHandle : INamespaceReferenceHandle + { + } // NamespaceReferenceHandle + + /// <summary> + /// IParameter + /// </summary> + internal interface IParameter + { + ParameterAttributes Flags + { + get; + } // Flags + + ushort Sequence + { + get; + } // Sequence + + ConstantStringValueHandle Name + { + get; + } // Name + + Handle DefaultValue + { + get; + } // DefaultValue + + IEnumerable<CustomAttributeHandle> CustomAttributes + { + get; + } // CustomAttributes + + ParameterHandle Handle + { + get; + } // Handle + } // IParameter + + /// <summary> + /// Parameter + /// </summary> + public partial struct Parameter : IParameter + { + } // Parameter + + /// <summary> + /// IParameterHandle + /// </summary> + internal interface IParameterHandle : IEquatable<ParameterHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IParameterHandle + + /// <summary> + /// ParameterHandle + /// </summary> + public partial struct ParameterHandle : IParameterHandle + { + } // ParameterHandle + + /// <summary> + /// IParameterTypeSignature + /// </summary> + internal interface IParameterTypeSignature + { + IEnumerable<CustomModifierHandle> CustomModifiers + { + get; + } // CustomModifiers + + Handle Type + { + get; + } // Type + + ParameterTypeSignatureHandle Handle + { + get; + } // Handle + } // IParameterTypeSignature + + /// <summary> + /// ParameterTypeSignature + /// </summary> + public partial struct ParameterTypeSignature : IParameterTypeSignature + { + } // ParameterTypeSignature + + /// <summary> + /// IParameterTypeSignatureHandle + /// </summary> + internal interface IParameterTypeSignatureHandle : IEquatable<ParameterTypeSignatureHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IParameterTypeSignatureHandle + + /// <summary> + /// ParameterTypeSignatureHandle + /// </summary> + public partial struct ParameterTypeSignatureHandle : IParameterTypeSignatureHandle + { + } // ParameterTypeSignatureHandle + + /// <summary> + /// IPointerSignature + /// </summary> + internal interface IPointerSignature + { + Handle Type + { + get; + } // Type + + PointerSignatureHandle Handle + { + get; + } // Handle + } // IPointerSignature + + /// <summary> + /// PointerSignature + /// </summary> + public partial struct PointerSignature : IPointerSignature + { + } // PointerSignature + + /// <summary> + /// IPointerSignatureHandle + /// </summary> + internal interface IPointerSignatureHandle : IEquatable<PointerSignatureHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IPointerSignatureHandle + + /// <summary> + /// PointerSignatureHandle + /// </summary> + public partial struct PointerSignatureHandle : IPointerSignatureHandle + { + } // PointerSignatureHandle + + /// <summary> + /// IProperty + /// </summary> + internal interface IProperty + { + PropertyAttributes Flags + { + get; + } // Flags + + ConstantStringValueHandle Name + { + get; + } // Name + + PropertySignatureHandle Signature + { + get; + } // Signature + + IEnumerable<MethodSemanticsHandle> MethodSemantics + { + get; + } // MethodSemantics + + Handle DefaultValue + { + get; + } // DefaultValue + + IEnumerable<CustomAttributeHandle> CustomAttributes + { + get; + } // CustomAttributes + + PropertyHandle Handle + { + get; + } // Handle + } // IProperty + + /// <summary> + /// Property + /// </summary> + public partial struct Property : IProperty + { + } // Property + + /// <summary> + /// IPropertyHandle + /// </summary> + internal interface IPropertyHandle : IEquatable<PropertyHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IPropertyHandle + + /// <summary> + /// PropertyHandle + /// </summary> + public partial struct PropertyHandle : IPropertyHandle + { + } // PropertyHandle + + /// <summary> + /// IPropertySignature + /// </summary> + internal interface IPropertySignature + { + CallingConventions CallingConvention + { + get; + } // CallingConvention + + IEnumerable<CustomModifierHandle> CustomModifiers + { + get; + } // CustomModifiers + + Handle Type + { + get; + } // Type + + IEnumerable<ParameterTypeSignatureHandle> Parameters + { + get; + } // Parameters + + PropertySignatureHandle Handle + { + get; + } // Handle + } // IPropertySignature + + /// <summary> + /// PropertySignature + /// </summary> + public partial struct PropertySignature : IPropertySignature + { + } // PropertySignature + + /// <summary> + /// IPropertySignatureHandle + /// </summary> + internal interface IPropertySignatureHandle : IEquatable<PropertySignatureHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IPropertySignatureHandle + + /// <summary> + /// PropertySignatureHandle + /// </summary> + public partial struct PropertySignatureHandle : IPropertySignatureHandle + { + } // PropertySignatureHandle + + /// <summary> + /// IReturnTypeSignature + /// </summary> + internal interface IReturnTypeSignature + { + IEnumerable<CustomModifierHandle> CustomModifiers + { + get; + } // CustomModifiers + + Handle Type + { + get; + } // Type + + ReturnTypeSignatureHandle Handle + { + get; + } // Handle + } // IReturnTypeSignature + + /// <summary> + /// ReturnTypeSignature + /// </summary> + public partial struct ReturnTypeSignature : IReturnTypeSignature + { + } // ReturnTypeSignature + + /// <summary> + /// IReturnTypeSignatureHandle + /// </summary> + internal interface IReturnTypeSignatureHandle : IEquatable<ReturnTypeSignatureHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IReturnTypeSignatureHandle + + /// <summary> + /// ReturnTypeSignatureHandle + /// </summary> + public partial struct ReturnTypeSignatureHandle : IReturnTypeSignatureHandle + { + } // ReturnTypeSignatureHandle + + /// <summary> + /// ISZArraySignature + /// </summary> + internal interface ISZArraySignature + { + Handle ElementType + { + get; + } // ElementType + + SZArraySignatureHandle Handle + { + get; + } // Handle + } // ISZArraySignature + + /// <summary> + /// SZArraySignature + /// </summary> + public partial struct SZArraySignature : ISZArraySignature + { + } // SZArraySignature + + /// <summary> + /// ISZArraySignatureHandle + /// </summary> + internal interface ISZArraySignatureHandle : IEquatable<SZArraySignatureHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // ISZArraySignatureHandle + + /// <summary> + /// SZArraySignatureHandle + /// </summary> + public partial struct SZArraySignatureHandle : ISZArraySignatureHandle + { + } // SZArraySignatureHandle + + /// <summary> + /// IScopeDefinition + /// </summary> + internal interface IScopeDefinition + { + AssemblyFlags Flags + { + get; + } // Flags + + ConstantStringValueHandle Name + { + get; + } // Name + + AssemblyHashAlgorithm HashAlgorithm + { + get; + } // HashAlgorithm + + ushort MajorVersion + { + get; + } // MajorVersion + + ushort MinorVersion + { + get; + } // MinorVersion + + ushort BuildNumber + { + get; + } // BuildNumber + + ushort RevisionNumber + { + get; + } // RevisionNumber + + IEnumerable<byte> PublicKey + { + get; + } // PublicKey + + ConstantStringValueHandle Culture + { + get; + } // Culture + + NamespaceDefinitionHandle RootNamespaceDefinition + { + get; + } // RootNamespaceDefinition + + IEnumerable<CustomAttributeHandle> CustomAttributes + { + get; + } // CustomAttributes + + ScopeDefinitionHandle Handle + { + get; + } // Handle + } // IScopeDefinition + + /// <summary> + /// ScopeDefinition + /// </summary> + public partial struct ScopeDefinition : IScopeDefinition + { + } // ScopeDefinition + + /// <summary> + /// IScopeDefinitionHandle + /// </summary> + internal interface IScopeDefinitionHandle : IEquatable<ScopeDefinitionHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IScopeDefinitionHandle + + /// <summary> + /// ScopeDefinitionHandle + /// </summary> + public partial struct ScopeDefinitionHandle : IScopeDefinitionHandle + { + } // ScopeDefinitionHandle + + /// <summary> + /// IScopeReference + /// </summary> + internal interface IScopeReference + { + AssemblyFlags Flags + { + get; + } // Flags + + ConstantStringValueHandle Name + { + get; + } // Name + + ushort MajorVersion + { + get; + } // MajorVersion + + ushort MinorVersion + { + get; + } // MinorVersion + + ushort BuildNumber + { + get; + } // BuildNumber + + ushort RevisionNumber + { + get; + } // RevisionNumber + + IEnumerable<byte> PublicKeyOrToken + { + get; + } // PublicKeyOrToken + + ConstantStringValueHandle Culture + { + get; + } // Culture + + IEnumerable<CustomAttributeHandle> CustomAttributes + { + get; + } // CustomAttributes + + ScopeReferenceHandle Handle + { + get; + } // Handle + } // IScopeReference + + /// <summary> + /// ScopeReference + /// </summary> + public partial struct ScopeReference : IScopeReference + { + } // ScopeReference + + /// <summary> + /// IScopeReferenceHandle + /// </summary> + internal interface IScopeReferenceHandle : IEquatable<ScopeReferenceHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // IScopeReferenceHandle + + /// <summary> + /// ScopeReferenceHandle + /// </summary> + public partial struct ScopeReferenceHandle : IScopeReferenceHandle + { + } // ScopeReferenceHandle + + /// <summary> + /// ITypeDefinition + /// </summary> + internal interface ITypeDefinition + { + TypeAttributes Flags + { + get; + } // Flags + + Handle BaseType + { + get; + } // BaseType + + NamespaceDefinitionHandle NamespaceDefinition + { + get; + } // NamespaceDefinition + + ConstantStringValueHandle Name + { + get; + } // Name + + uint Size + { + get; + } // Size + + uint PackingSize + { + get; + } // PackingSize + + TypeDefinitionHandle EnclosingType + { + get; + } // EnclosingType + + IEnumerable<TypeDefinitionHandle> NestedTypes + { + get; + } // NestedTypes + + IEnumerable<MethodHandle> Methods + { + get; + } // Methods + + IEnumerable<FieldHandle> Fields + { + get; + } // Fields + + IEnumerable<PropertyHandle> Properties + { + get; + } // Properties + + IEnumerable<EventHandle> Events + { + get; + } // Events + + IEnumerable<GenericParameterHandle> GenericParameters + { + get; + } // GenericParameters + + IEnumerable<Handle> Interfaces + { + get; + } // Interfaces + + IEnumerable<CustomAttributeHandle> CustomAttributes + { + get; + } // CustomAttributes + + TypeDefinitionHandle Handle + { + get; + } // Handle + } // ITypeDefinition + + /// <summary> + /// TypeDefinition + /// </summary> + public partial struct TypeDefinition : ITypeDefinition + { + } // TypeDefinition + + /// <summary> + /// ITypeDefinitionHandle + /// </summary> + internal interface ITypeDefinitionHandle : IEquatable<TypeDefinitionHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // ITypeDefinitionHandle + + /// <summary> + /// TypeDefinitionHandle + /// </summary> + public partial struct TypeDefinitionHandle : ITypeDefinitionHandle + { + } // TypeDefinitionHandle + + /// <summary> + /// ITypeForwarder + /// </summary> + internal interface ITypeForwarder + { + ScopeReferenceHandle Scope + { + get; + } // Scope + + ConstantStringValueHandle Name + { + get; + } // Name + + IEnumerable<TypeForwarderHandle> NestedTypes + { + get; + } // NestedTypes + + IEnumerable<CustomAttributeHandle> CustomAttributes + { + get; + } // CustomAttributes + + TypeForwarderHandle Handle + { + get; + } // Handle + } // ITypeForwarder + + /// <summary> + /// TypeForwarder + /// </summary> + public partial struct TypeForwarder : ITypeForwarder + { + } // TypeForwarder + + /// <summary> + /// ITypeForwarderHandle + /// </summary> + internal interface ITypeForwarderHandle : IEquatable<TypeForwarderHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // ITypeForwarderHandle + + /// <summary> + /// TypeForwarderHandle + /// </summary> + public partial struct TypeForwarderHandle : ITypeForwarderHandle + { + } // TypeForwarderHandle + + /// <summary> + /// ITypeInstantiationSignature + /// </summary> + internal interface ITypeInstantiationSignature + { + Handle GenericType + { + get; + } // GenericType + + IEnumerable<Handle> GenericTypeArguments + { + get; + } // GenericTypeArguments + + TypeInstantiationSignatureHandle Handle + { + get; + } // Handle + } // ITypeInstantiationSignature + + /// <summary> + /// TypeInstantiationSignature + /// </summary> + public partial struct TypeInstantiationSignature : ITypeInstantiationSignature + { + } // TypeInstantiationSignature + + /// <summary> + /// ITypeInstantiationSignatureHandle + /// </summary> + internal interface ITypeInstantiationSignatureHandle : IEquatable<TypeInstantiationSignatureHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // ITypeInstantiationSignatureHandle + + /// <summary> + /// TypeInstantiationSignatureHandle + /// </summary> + public partial struct TypeInstantiationSignatureHandle : ITypeInstantiationSignatureHandle + { + } // TypeInstantiationSignatureHandle + + /// <summary> + /// ITypeReference + /// </summary> + internal interface ITypeReference + { + Handle ParentNamespaceOrType + { + get; + } // ParentNamespaceOrType + + ConstantStringValueHandle TypeName + { + get; + } // TypeName + + IEnumerable<CustomAttributeHandle> CustomAttributes + { + get; + } // CustomAttributes + + TypeReferenceHandle Handle + { + get; + } // Handle + } // ITypeReference + + /// <summary> + /// TypeReference + /// </summary> + public partial struct TypeReference : ITypeReference + { + } // TypeReference + + /// <summary> + /// ITypeReferenceHandle + /// </summary> + internal interface ITypeReferenceHandle : IEquatable<TypeReferenceHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // ITypeReferenceHandle + + /// <summary> + /// TypeReferenceHandle + /// </summary> + public partial struct TypeReferenceHandle : ITypeReferenceHandle + { + } // TypeReferenceHandle + + /// <summary> + /// ITypeSpecification + /// </summary> + internal interface ITypeSpecification + { + Handle Signature + { + get; + } // Signature + + IEnumerable<CustomAttributeHandle> CustomAttributes + { + get; + } // CustomAttributes + + TypeSpecificationHandle Handle + { + get; + } // Handle + } // ITypeSpecification + + /// <summary> + /// TypeSpecification + /// </summary> + public partial struct TypeSpecification : ITypeSpecification + { + } // TypeSpecification + + /// <summary> + /// ITypeSpecificationHandle + /// </summary> + internal interface ITypeSpecificationHandle : IEquatable<TypeSpecificationHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // ITypeSpecificationHandle + + /// <summary> + /// TypeSpecificationHandle + /// </summary> + public partial struct TypeSpecificationHandle : ITypeSpecificationHandle + { + } // TypeSpecificationHandle + + /// <summary> + /// ITypeVariableSignature + /// </summary> + internal interface ITypeVariableSignature + { + int Number + { + get; + } // Number + + TypeVariableSignatureHandle Handle + { + get; + } // Handle + } // ITypeVariableSignature + + /// <summary> + /// TypeVariableSignature + /// </summary> + public partial struct TypeVariableSignature : ITypeVariableSignature + { + } // TypeVariableSignature + + /// <summary> + /// ITypeVariableSignatureHandle + /// </summary> + internal interface ITypeVariableSignatureHandle : IEquatable<TypeVariableSignatureHandle>, IEquatable<Handle>, IEquatable<Object> + { + Handle ToHandle(MetadataReader reader); + int GetHashCode(); + } // ITypeVariableSignatureHandle + + /// <summary> + /// TypeVariableSignatureHandle + /// </summary> + public partial struct TypeVariableSignatureHandle : ITypeVariableSignatureHandle + { + } // TypeVariableSignatureHandle +} // Internal.Metadata.NativeFormat diff --git a/src/Common/src/Internal/Metadata/NativeFormat/NativeFormatReaderGen.cs b/src/Common/src/Internal/Metadata/NativeFormat/NativeFormatReaderGen.cs new file mode 100644 index 000000000..3acf547d5 --- /dev/null +++ b/src/Common/src/Internal/Metadata/NativeFormat/NativeFormatReaderGen.cs @@ -0,0 +1,9788 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +// NOTE: This is a generated file - do not manually edit! + +#pragma warning disable 649 +#pragma warning disable 169 +#pragma warning disable 282 // There is no defined ordering between fields in multiple declarations of partial class or struct + +using System; +using System.Reflection; +using System.Collections.Generic; + +namespace Internal.Metadata.NativeFormat +{ + /// <summary> + /// ArraySignature + /// </summary> + public partial struct ArraySignature + { + internal MetadataReader _reader; + internal ArraySignatureHandle _handle; + public ArraySignatureHandle Handle + { + get + { + return _handle; + } + } // Handle + + + /// One of: TypeDefinition, TypeReference, TypeSpecification + public Handle ElementType + { + get + { + return _elementType; + } + } // ElementType + + internal Handle _elementType; + public int Rank + { + get + { + return _rank; + } + } // Rank + + internal int _rank; + public IEnumerable<int> Sizes + { + get + { + return (IEnumerable<int>)_sizes; + } + } // Sizes + + internal int[] _sizes; + public IEnumerable<int> LowerBounds + { + get + { + return (IEnumerable<int>)_lowerBounds; + } + } // LowerBounds + + internal int[] _lowerBounds; + } // ArraySignature + + /// <summary> + /// ArraySignatureHandle + /// </summary> + public partial struct ArraySignatureHandle + { + public override bool Equals(object obj) + { + if (obj is ArraySignatureHandle) + return _value == ((ArraySignatureHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ArraySignatureHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ArraySignatureHandle(Handle handle) : this(handle._value) + { + + } + + internal ArraySignatureHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ArraySignature || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ArraySignature) << 24); + _Validate(); + } + + public static implicit operator Handle(ArraySignatureHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ArraySignature GetArraySignature(MetadataReader reader) + { + return reader.GetArraySignature(this); + } // GetArraySignature + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ArraySignature) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ArraySignatureHandle + + /// <summary> + /// ByReferenceSignature + /// </summary> + public partial struct ByReferenceSignature + { + internal MetadataReader _reader; + internal ByReferenceSignatureHandle _handle; + public ByReferenceSignatureHandle Handle + { + get + { + return _handle; + } + } // Handle + + + /// One of: TypeDefinition, TypeReference, TypeSpecification + public Handle Type + { + get + { + return _type; + } + } // Type + + internal Handle _type; + } // ByReferenceSignature + + /// <summary> + /// ByReferenceSignatureHandle + /// </summary> + public partial struct ByReferenceSignatureHandle + { + public override bool Equals(object obj) + { + if (obj is ByReferenceSignatureHandle) + return _value == ((ByReferenceSignatureHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ByReferenceSignatureHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ByReferenceSignatureHandle(Handle handle) : this(handle._value) + { + + } + + internal ByReferenceSignatureHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ByReferenceSignature || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ByReferenceSignature) << 24); + _Validate(); + } + + public static implicit operator Handle(ByReferenceSignatureHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ByReferenceSignature GetByReferenceSignature(MetadataReader reader) + { + return reader.GetByReferenceSignature(this); + } // GetByReferenceSignature + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ByReferenceSignature) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ByReferenceSignatureHandle + + /// <summary> + /// ConstantBooleanArray + /// </summary> + public partial struct ConstantBooleanArray + { + internal MetadataReader _reader; + internal ConstantBooleanArrayHandle _handle; + public ConstantBooleanArrayHandle Handle + { + get + { + return _handle; + } + } // Handle + + public IEnumerable<bool> Value + { + get + { + return (IEnumerable<bool>)_value; + } + } // Value + + internal bool[] _value; + } // ConstantBooleanArray + + /// <summary> + /// ConstantBooleanArrayHandle + /// </summary> + public partial struct ConstantBooleanArrayHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantBooleanArrayHandle) + return _value == ((ConstantBooleanArrayHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantBooleanArrayHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantBooleanArrayHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantBooleanArrayHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantBooleanArray || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantBooleanArray) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantBooleanArrayHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantBooleanArray GetConstantBooleanArray(MetadataReader reader) + { + return reader.GetConstantBooleanArray(this); + } // GetConstantBooleanArray + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantBooleanArray) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantBooleanArrayHandle + + /// <summary> + /// ConstantBooleanValue + /// </summary> + public partial struct ConstantBooleanValue + { + internal MetadataReader _reader; + internal ConstantBooleanValueHandle _handle; + public ConstantBooleanValueHandle Handle + { + get + { + return _handle; + } + } // Handle + + public bool Value + { + get + { + return _value; + } + } // Value + + internal bool _value; + } // ConstantBooleanValue + + /// <summary> + /// ConstantBooleanValueHandle + /// </summary> + public partial struct ConstantBooleanValueHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantBooleanValueHandle) + return _value == ((ConstantBooleanValueHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantBooleanValueHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantBooleanValueHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantBooleanValueHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantBooleanValue || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantBooleanValue) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantBooleanValueHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantBooleanValue GetConstantBooleanValue(MetadataReader reader) + { + return reader.GetConstantBooleanValue(this); + } // GetConstantBooleanValue + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantBooleanValue) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantBooleanValueHandle + + /// <summary> + /// ConstantByteArray + /// </summary> + public partial struct ConstantByteArray + { + internal MetadataReader _reader; + internal ConstantByteArrayHandle _handle; + public ConstantByteArrayHandle Handle + { + get + { + return _handle; + } + } // Handle + + public IEnumerable<byte> Value + { + get + { + return (IEnumerable<byte>)_value; + } + } // Value + + internal byte[] _value; + } // ConstantByteArray + + /// <summary> + /// ConstantByteArrayHandle + /// </summary> + public partial struct ConstantByteArrayHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantByteArrayHandle) + return _value == ((ConstantByteArrayHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantByteArrayHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantByteArrayHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantByteArrayHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantByteArray || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantByteArray) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantByteArrayHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantByteArray GetConstantByteArray(MetadataReader reader) + { + return reader.GetConstantByteArray(this); + } // GetConstantByteArray + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantByteArray) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantByteArrayHandle + + /// <summary> + /// ConstantByteValue + /// </summary> + public partial struct ConstantByteValue + { + internal MetadataReader _reader; + internal ConstantByteValueHandle _handle; + public ConstantByteValueHandle Handle + { + get + { + return _handle; + } + } // Handle + + public byte Value + { + get + { + return _value; + } + } // Value + + internal byte _value; + } // ConstantByteValue + + /// <summary> + /// ConstantByteValueHandle + /// </summary> + public partial struct ConstantByteValueHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantByteValueHandle) + return _value == ((ConstantByteValueHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantByteValueHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantByteValueHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantByteValueHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantByteValue || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantByteValue) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantByteValueHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantByteValue GetConstantByteValue(MetadataReader reader) + { + return reader.GetConstantByteValue(this); + } // GetConstantByteValue + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantByteValue) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantByteValueHandle + + /// <summary> + /// ConstantCharArray + /// </summary> + public partial struct ConstantCharArray + { + internal MetadataReader _reader; + internal ConstantCharArrayHandle _handle; + public ConstantCharArrayHandle Handle + { + get + { + return _handle; + } + } // Handle + + public IEnumerable<char> Value + { + get + { + return (IEnumerable<char>)_value; + } + } // Value + + internal char[] _value; + } // ConstantCharArray + + /// <summary> + /// ConstantCharArrayHandle + /// </summary> + public partial struct ConstantCharArrayHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantCharArrayHandle) + return _value == ((ConstantCharArrayHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantCharArrayHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantCharArrayHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantCharArrayHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantCharArray || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantCharArray) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantCharArrayHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantCharArray GetConstantCharArray(MetadataReader reader) + { + return reader.GetConstantCharArray(this); + } // GetConstantCharArray + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantCharArray) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantCharArrayHandle + + /// <summary> + /// ConstantCharValue + /// </summary> + public partial struct ConstantCharValue + { + internal MetadataReader _reader; + internal ConstantCharValueHandle _handle; + public ConstantCharValueHandle Handle + { + get + { + return _handle; + } + } // Handle + + public char Value + { + get + { + return _value; + } + } // Value + + internal char _value; + } // ConstantCharValue + + /// <summary> + /// ConstantCharValueHandle + /// </summary> + public partial struct ConstantCharValueHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantCharValueHandle) + return _value == ((ConstantCharValueHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantCharValueHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantCharValueHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantCharValueHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantCharValue || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantCharValue) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantCharValueHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantCharValue GetConstantCharValue(MetadataReader reader) + { + return reader.GetConstantCharValue(this); + } // GetConstantCharValue + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantCharValue) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantCharValueHandle + + /// <summary> + /// ConstantDoubleArray + /// </summary> + public partial struct ConstantDoubleArray + { + internal MetadataReader _reader; + internal ConstantDoubleArrayHandle _handle; + public ConstantDoubleArrayHandle Handle + { + get + { + return _handle; + } + } // Handle + + public IEnumerable<double> Value + { + get + { + return (IEnumerable<double>)_value; + } + } // Value + + internal double[] _value; + } // ConstantDoubleArray + + /// <summary> + /// ConstantDoubleArrayHandle + /// </summary> + public partial struct ConstantDoubleArrayHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantDoubleArrayHandle) + return _value == ((ConstantDoubleArrayHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantDoubleArrayHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantDoubleArrayHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantDoubleArrayHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantDoubleArray || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantDoubleArray) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantDoubleArrayHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantDoubleArray GetConstantDoubleArray(MetadataReader reader) + { + return reader.GetConstantDoubleArray(this); + } // GetConstantDoubleArray + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantDoubleArray) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantDoubleArrayHandle + + /// <summary> + /// ConstantDoubleValue + /// </summary> + public partial struct ConstantDoubleValue + { + internal MetadataReader _reader; + internal ConstantDoubleValueHandle _handle; + public ConstantDoubleValueHandle Handle + { + get + { + return _handle; + } + } // Handle + + public double Value + { + get + { + return _value; + } + } // Value + + internal double _value; + } // ConstantDoubleValue + + /// <summary> + /// ConstantDoubleValueHandle + /// </summary> + public partial struct ConstantDoubleValueHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantDoubleValueHandle) + return _value == ((ConstantDoubleValueHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantDoubleValueHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantDoubleValueHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantDoubleValueHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantDoubleValue || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantDoubleValue) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantDoubleValueHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantDoubleValue GetConstantDoubleValue(MetadataReader reader) + { + return reader.GetConstantDoubleValue(this); + } // GetConstantDoubleValue + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantDoubleValue) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantDoubleValueHandle + + /// <summary> + /// ConstantHandleArray + /// </summary> + public partial struct ConstantHandleArray + { + internal MetadataReader _reader; + internal ConstantHandleArrayHandle _handle; + public ConstantHandleArrayHandle Handle + { + get + { + return _handle; + } + } // Handle + + public IEnumerable<Handle> Value + { + get + { + return (IEnumerable<Handle>)_value; + } + } // Value + + internal Handle[] _value; + } // ConstantHandleArray + + /// <summary> + /// ConstantHandleArrayHandle + /// </summary> + public partial struct ConstantHandleArrayHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantHandleArrayHandle) + return _value == ((ConstantHandleArrayHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantHandleArrayHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantHandleArrayHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantHandleArrayHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantHandleArray || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantHandleArray) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantHandleArrayHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantHandleArray GetConstantHandleArray(MetadataReader reader) + { + return reader.GetConstantHandleArray(this); + } // GetConstantHandleArray + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantHandleArray) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantHandleArrayHandle + + /// <summary> + /// ConstantInt16Array + /// </summary> + public partial struct ConstantInt16Array + { + internal MetadataReader _reader; + internal ConstantInt16ArrayHandle _handle; + public ConstantInt16ArrayHandle Handle + { + get + { + return _handle; + } + } // Handle + + public IEnumerable<short> Value + { + get + { + return (IEnumerable<short>)_value; + } + } // Value + + internal short[] _value; + } // ConstantInt16Array + + /// <summary> + /// ConstantInt16ArrayHandle + /// </summary> + public partial struct ConstantInt16ArrayHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantInt16ArrayHandle) + return _value == ((ConstantInt16ArrayHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantInt16ArrayHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantInt16ArrayHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantInt16ArrayHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantInt16Array || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantInt16Array) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantInt16ArrayHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantInt16Array GetConstantInt16Array(MetadataReader reader) + { + return reader.GetConstantInt16Array(this); + } // GetConstantInt16Array + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantInt16Array) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantInt16ArrayHandle + + /// <summary> + /// ConstantInt16Value + /// </summary> + public partial struct ConstantInt16Value + { + internal MetadataReader _reader; + internal ConstantInt16ValueHandle _handle; + public ConstantInt16ValueHandle Handle + { + get + { + return _handle; + } + } // Handle + + public short Value + { + get + { + return _value; + } + } // Value + + internal short _value; + } // ConstantInt16Value + + /// <summary> + /// ConstantInt16ValueHandle + /// </summary> + public partial struct ConstantInt16ValueHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantInt16ValueHandle) + return _value == ((ConstantInt16ValueHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantInt16ValueHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantInt16ValueHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantInt16ValueHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantInt16Value || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantInt16Value) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantInt16ValueHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantInt16Value GetConstantInt16Value(MetadataReader reader) + { + return reader.GetConstantInt16Value(this); + } // GetConstantInt16Value + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantInt16Value) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantInt16ValueHandle + + /// <summary> + /// ConstantInt32Array + /// </summary> + public partial struct ConstantInt32Array + { + internal MetadataReader _reader; + internal ConstantInt32ArrayHandle _handle; + public ConstantInt32ArrayHandle Handle + { + get + { + return _handle; + } + } // Handle + + public IEnumerable<int> Value + { + get + { + return (IEnumerable<int>)_value; + } + } // Value + + internal int[] _value; + } // ConstantInt32Array + + /// <summary> + /// ConstantInt32ArrayHandle + /// </summary> + public partial struct ConstantInt32ArrayHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantInt32ArrayHandle) + return _value == ((ConstantInt32ArrayHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantInt32ArrayHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantInt32ArrayHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantInt32ArrayHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantInt32Array || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantInt32Array) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantInt32ArrayHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantInt32Array GetConstantInt32Array(MetadataReader reader) + { + return reader.GetConstantInt32Array(this); + } // GetConstantInt32Array + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantInt32Array) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantInt32ArrayHandle + + /// <summary> + /// ConstantInt32Value + /// </summary> + public partial struct ConstantInt32Value + { + internal MetadataReader _reader; + internal ConstantInt32ValueHandle _handle; + public ConstantInt32ValueHandle Handle + { + get + { + return _handle; + } + } // Handle + + public int Value + { + get + { + return _value; + } + } // Value + + internal int _value; + } // ConstantInt32Value + + /// <summary> + /// ConstantInt32ValueHandle + /// </summary> + public partial struct ConstantInt32ValueHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantInt32ValueHandle) + return _value == ((ConstantInt32ValueHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantInt32ValueHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantInt32ValueHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantInt32ValueHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantInt32Value || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantInt32Value) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantInt32ValueHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantInt32Value GetConstantInt32Value(MetadataReader reader) + { + return reader.GetConstantInt32Value(this); + } // GetConstantInt32Value + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantInt32Value) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantInt32ValueHandle + + /// <summary> + /// ConstantInt64Array + /// </summary> + public partial struct ConstantInt64Array + { + internal MetadataReader _reader; + internal ConstantInt64ArrayHandle _handle; + public ConstantInt64ArrayHandle Handle + { + get + { + return _handle; + } + } // Handle + + public IEnumerable<long> Value + { + get + { + return (IEnumerable<long>)_value; + } + } // Value + + internal long[] _value; + } // ConstantInt64Array + + /// <summary> + /// ConstantInt64ArrayHandle + /// </summary> + public partial struct ConstantInt64ArrayHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantInt64ArrayHandle) + return _value == ((ConstantInt64ArrayHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantInt64ArrayHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantInt64ArrayHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantInt64ArrayHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantInt64Array || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantInt64Array) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantInt64ArrayHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantInt64Array GetConstantInt64Array(MetadataReader reader) + { + return reader.GetConstantInt64Array(this); + } // GetConstantInt64Array + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantInt64Array) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantInt64ArrayHandle + + /// <summary> + /// ConstantInt64Value + /// </summary> + public partial struct ConstantInt64Value + { + internal MetadataReader _reader; + internal ConstantInt64ValueHandle _handle; + public ConstantInt64ValueHandle Handle + { + get + { + return _handle; + } + } // Handle + + public long Value + { + get + { + return _value; + } + } // Value + + internal long _value; + } // ConstantInt64Value + + /// <summary> + /// ConstantInt64ValueHandle + /// </summary> + public partial struct ConstantInt64ValueHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantInt64ValueHandle) + return _value == ((ConstantInt64ValueHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantInt64ValueHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantInt64ValueHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantInt64ValueHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantInt64Value || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantInt64Value) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantInt64ValueHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantInt64Value GetConstantInt64Value(MetadataReader reader) + { + return reader.GetConstantInt64Value(this); + } // GetConstantInt64Value + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantInt64Value) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantInt64ValueHandle + + /// <summary> + /// ConstantReferenceValue + /// </summary> + public partial struct ConstantReferenceValue + { + internal MetadataReader _reader; + internal ConstantReferenceValueHandle _handle; + public ConstantReferenceValueHandle Handle + { + get + { + return _handle; + } + } // Handle + } // ConstantReferenceValue + + /// <summary> + /// ConstantReferenceValueHandle + /// </summary> + public partial struct ConstantReferenceValueHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantReferenceValueHandle) + return _value == ((ConstantReferenceValueHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantReferenceValueHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantReferenceValueHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantReferenceValueHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantReferenceValue || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantReferenceValue) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantReferenceValueHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantReferenceValue GetConstantReferenceValue(MetadataReader reader) + { + return reader.GetConstantReferenceValue(this); + } // GetConstantReferenceValue + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantReferenceValue) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantReferenceValueHandle + + /// <summary> + /// ConstantSByteArray + /// </summary> + public partial struct ConstantSByteArray + { + internal MetadataReader _reader; + internal ConstantSByteArrayHandle _handle; + public ConstantSByteArrayHandle Handle + { + get + { + return _handle; + } + } // Handle + + public IEnumerable<sbyte> Value + { + get + { + return (IEnumerable<sbyte>)_value; + } + } // Value + + internal sbyte[] _value; + } // ConstantSByteArray + + /// <summary> + /// ConstantSByteArrayHandle + /// </summary> + public partial struct ConstantSByteArrayHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantSByteArrayHandle) + return _value == ((ConstantSByteArrayHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantSByteArrayHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantSByteArrayHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantSByteArrayHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantSByteArray || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantSByteArray) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantSByteArrayHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantSByteArray GetConstantSByteArray(MetadataReader reader) + { + return reader.GetConstantSByteArray(this); + } // GetConstantSByteArray + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantSByteArray) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantSByteArrayHandle + + /// <summary> + /// ConstantSByteValue + /// </summary> + public partial struct ConstantSByteValue + { + internal MetadataReader _reader; + internal ConstantSByteValueHandle _handle; + public ConstantSByteValueHandle Handle + { + get + { + return _handle; + } + } // Handle + + public sbyte Value + { + get + { + return _value; + } + } // Value + + internal sbyte _value; + } // ConstantSByteValue + + /// <summary> + /// ConstantSByteValueHandle + /// </summary> + public partial struct ConstantSByteValueHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantSByteValueHandle) + return _value == ((ConstantSByteValueHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantSByteValueHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantSByteValueHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantSByteValueHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantSByteValue || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantSByteValue) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantSByteValueHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantSByteValue GetConstantSByteValue(MetadataReader reader) + { + return reader.GetConstantSByteValue(this); + } // GetConstantSByteValue + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantSByteValue) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantSByteValueHandle + + /// <summary> + /// ConstantSingleArray + /// </summary> + public partial struct ConstantSingleArray + { + internal MetadataReader _reader; + internal ConstantSingleArrayHandle _handle; + public ConstantSingleArrayHandle Handle + { + get + { + return _handle; + } + } // Handle + + public IEnumerable<float> Value + { + get + { + return (IEnumerable<float>)_value; + } + } // Value + + internal float[] _value; + } // ConstantSingleArray + + /// <summary> + /// ConstantSingleArrayHandle + /// </summary> + public partial struct ConstantSingleArrayHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantSingleArrayHandle) + return _value == ((ConstantSingleArrayHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantSingleArrayHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantSingleArrayHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantSingleArrayHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantSingleArray || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantSingleArray) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantSingleArrayHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantSingleArray GetConstantSingleArray(MetadataReader reader) + { + return reader.GetConstantSingleArray(this); + } // GetConstantSingleArray + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantSingleArray) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantSingleArrayHandle + + /// <summary> + /// ConstantSingleValue + /// </summary> + public partial struct ConstantSingleValue + { + internal MetadataReader _reader; + internal ConstantSingleValueHandle _handle; + public ConstantSingleValueHandle Handle + { + get + { + return _handle; + } + } // Handle + + public float Value + { + get + { + return _value; + } + } // Value + + internal float _value; + } // ConstantSingleValue + + /// <summary> + /// ConstantSingleValueHandle + /// </summary> + public partial struct ConstantSingleValueHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantSingleValueHandle) + return _value == ((ConstantSingleValueHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantSingleValueHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantSingleValueHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantSingleValueHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantSingleValue || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantSingleValue) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantSingleValueHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantSingleValue GetConstantSingleValue(MetadataReader reader) + { + return reader.GetConstantSingleValue(this); + } // GetConstantSingleValue + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantSingleValue) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantSingleValueHandle + + /// <summary> + /// ConstantStringArray + /// </summary> + public partial struct ConstantStringArray + { + internal MetadataReader _reader; + internal ConstantStringArrayHandle _handle; + public ConstantStringArrayHandle Handle + { + get + { + return _handle; + } + } // Handle + + public IEnumerable<string> Value + { + get + { + return (IEnumerable<string>)_value; + } + } // Value + + internal string[] _value; + } // ConstantStringArray + + /// <summary> + /// ConstantStringArrayHandle + /// </summary> + public partial struct ConstantStringArrayHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantStringArrayHandle) + return _value == ((ConstantStringArrayHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantStringArrayHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantStringArrayHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantStringArrayHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantStringArray || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantStringArray) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantStringArrayHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantStringArray GetConstantStringArray(MetadataReader reader) + { + return reader.GetConstantStringArray(this); + } // GetConstantStringArray + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantStringArray) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantStringArrayHandle + + /// <summary> + /// ConstantStringValue + /// </summary> + public partial struct ConstantStringValue + { + internal MetadataReader _reader; + internal ConstantStringValueHandle _handle; + public ConstantStringValueHandle Handle + { + get + { + return _handle; + } + } // Handle + + public string Value + { + get + { + return _value; + } + } // Value + + internal string _value; + } // ConstantStringValue + + /// <summary> + /// ConstantStringValueHandle + /// </summary> + public partial struct ConstantStringValueHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantStringValueHandle) + return _value == ((ConstantStringValueHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantStringValueHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantStringValueHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantStringValueHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantStringValue || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantStringValue) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantStringValueHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantStringValue GetConstantStringValue(MetadataReader reader) + { + return reader.GetConstantStringValue(this); + } // GetConstantStringValue + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantStringValue) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantStringValueHandle + + /// <summary> + /// ConstantUInt16Array + /// </summary> + public partial struct ConstantUInt16Array + { + internal MetadataReader _reader; + internal ConstantUInt16ArrayHandle _handle; + public ConstantUInt16ArrayHandle Handle + { + get + { + return _handle; + } + } // Handle + + public IEnumerable<ushort> Value + { + get + { + return (IEnumerable<ushort>)_value; + } + } // Value + + internal ushort[] _value; + } // ConstantUInt16Array + + /// <summary> + /// ConstantUInt16ArrayHandle + /// </summary> + public partial struct ConstantUInt16ArrayHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantUInt16ArrayHandle) + return _value == ((ConstantUInt16ArrayHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantUInt16ArrayHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantUInt16ArrayHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantUInt16ArrayHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantUInt16Array || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantUInt16Array) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantUInt16ArrayHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantUInt16Array GetConstantUInt16Array(MetadataReader reader) + { + return reader.GetConstantUInt16Array(this); + } // GetConstantUInt16Array + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantUInt16Array) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantUInt16ArrayHandle + + /// <summary> + /// ConstantUInt16Value + /// </summary> + public partial struct ConstantUInt16Value + { + internal MetadataReader _reader; + internal ConstantUInt16ValueHandle _handle; + public ConstantUInt16ValueHandle Handle + { + get + { + return _handle; + } + } // Handle + + public ushort Value + { + get + { + return _value; + } + } // Value + + internal ushort _value; + } // ConstantUInt16Value + + /// <summary> + /// ConstantUInt16ValueHandle + /// </summary> + public partial struct ConstantUInt16ValueHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantUInt16ValueHandle) + return _value == ((ConstantUInt16ValueHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantUInt16ValueHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantUInt16ValueHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantUInt16ValueHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantUInt16Value || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantUInt16Value) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantUInt16ValueHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantUInt16Value GetConstantUInt16Value(MetadataReader reader) + { + return reader.GetConstantUInt16Value(this); + } // GetConstantUInt16Value + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantUInt16Value) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantUInt16ValueHandle + + /// <summary> + /// ConstantUInt32Array + /// </summary> + public partial struct ConstantUInt32Array + { + internal MetadataReader _reader; + internal ConstantUInt32ArrayHandle _handle; + public ConstantUInt32ArrayHandle Handle + { + get + { + return _handle; + } + } // Handle + + public IEnumerable<uint> Value + { + get + { + return (IEnumerable<uint>)_value; + } + } // Value + + internal uint[] _value; + } // ConstantUInt32Array + + /// <summary> + /// ConstantUInt32ArrayHandle + /// </summary> + public partial struct ConstantUInt32ArrayHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantUInt32ArrayHandle) + return _value == ((ConstantUInt32ArrayHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantUInt32ArrayHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantUInt32ArrayHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantUInt32ArrayHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantUInt32Array || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantUInt32Array) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantUInt32ArrayHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantUInt32Array GetConstantUInt32Array(MetadataReader reader) + { + return reader.GetConstantUInt32Array(this); + } // GetConstantUInt32Array + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantUInt32Array) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantUInt32ArrayHandle + + /// <summary> + /// ConstantUInt32Value + /// </summary> + public partial struct ConstantUInt32Value + { + internal MetadataReader _reader; + internal ConstantUInt32ValueHandle _handle; + public ConstantUInt32ValueHandle Handle + { + get + { + return _handle; + } + } // Handle + + public uint Value + { + get + { + return _value; + } + } // Value + + internal uint _value; + } // ConstantUInt32Value + + /// <summary> + /// ConstantUInt32ValueHandle + /// </summary> + public partial struct ConstantUInt32ValueHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantUInt32ValueHandle) + return _value == ((ConstantUInt32ValueHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantUInt32ValueHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantUInt32ValueHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantUInt32ValueHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantUInt32Value || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantUInt32Value) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantUInt32ValueHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantUInt32Value GetConstantUInt32Value(MetadataReader reader) + { + return reader.GetConstantUInt32Value(this); + } // GetConstantUInt32Value + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantUInt32Value) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantUInt32ValueHandle + + /// <summary> + /// ConstantUInt64Array + /// </summary> + public partial struct ConstantUInt64Array + { + internal MetadataReader _reader; + internal ConstantUInt64ArrayHandle _handle; + public ConstantUInt64ArrayHandle Handle + { + get + { + return _handle; + } + } // Handle + + public IEnumerable<ulong> Value + { + get + { + return (IEnumerable<ulong>)_value; + } + } // Value + + internal ulong[] _value; + } // ConstantUInt64Array + + /// <summary> + /// ConstantUInt64ArrayHandle + /// </summary> + public partial struct ConstantUInt64ArrayHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantUInt64ArrayHandle) + return _value == ((ConstantUInt64ArrayHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantUInt64ArrayHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantUInt64ArrayHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantUInt64ArrayHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantUInt64Array || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantUInt64Array) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantUInt64ArrayHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantUInt64Array GetConstantUInt64Array(MetadataReader reader) + { + return reader.GetConstantUInt64Array(this); + } // GetConstantUInt64Array + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantUInt64Array) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantUInt64ArrayHandle + + /// <summary> + /// ConstantUInt64Value + /// </summary> + public partial struct ConstantUInt64Value + { + internal MetadataReader _reader; + internal ConstantUInt64ValueHandle _handle; + public ConstantUInt64ValueHandle Handle + { + get + { + return _handle; + } + } // Handle + + public ulong Value + { + get + { + return _value; + } + } // Value + + internal ulong _value; + } // ConstantUInt64Value + + /// <summary> + /// ConstantUInt64ValueHandle + /// </summary> + public partial struct ConstantUInt64ValueHandle + { + public override bool Equals(object obj) + { + if (obj is ConstantUInt64ValueHandle) + return _value == ((ConstantUInt64ValueHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ConstantUInt64ValueHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ConstantUInt64ValueHandle(Handle handle) : this(handle._value) + { + + } + + internal ConstantUInt64ValueHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ConstantUInt64Value || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ConstantUInt64Value) << 24); + _Validate(); + } + + public static implicit operator Handle(ConstantUInt64ValueHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ConstantUInt64Value GetConstantUInt64Value(MetadataReader reader) + { + return reader.GetConstantUInt64Value(this); + } // GetConstantUInt64Value + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ConstantUInt64Value) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ConstantUInt64ValueHandle + + /// <summary> + /// CustomAttribute + /// </summary> + public partial struct CustomAttribute + { + internal MetadataReader _reader; + internal CustomAttributeHandle _handle; + public CustomAttributeHandle Handle + { + get + { + return _handle; + } + } // Handle + + + /// One of: TypeDefinition, TypeReference + public Handle Type + { + get + { + return _type; + } + } // Type + + internal Handle _type; + + /// One of: Method, MemberReference + public Handle Constructor + { + get + { + return _constructor; + } + } // Constructor + + internal Handle _constructor; + public IEnumerable<FixedArgumentHandle> FixedArguments + { + get + { + return (IEnumerable<FixedArgumentHandle>)_fixedArguments; + } + } // FixedArguments + + internal FixedArgumentHandle[] _fixedArguments; + public IEnumerable<NamedArgumentHandle> NamedArguments + { + get + { + return (IEnumerable<NamedArgumentHandle>)_namedArguments; + } + } // NamedArguments + + internal NamedArgumentHandle[] _namedArguments; + } // CustomAttribute + + /// <summary> + /// CustomAttributeHandle + /// </summary> + public partial struct CustomAttributeHandle + { + public override bool Equals(object obj) + { + if (obj is CustomAttributeHandle) + return _value == ((CustomAttributeHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(CustomAttributeHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal CustomAttributeHandle(Handle handle) : this(handle._value) + { + + } + + internal CustomAttributeHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.CustomAttribute || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.CustomAttribute) << 24); + _Validate(); + } + + public static implicit operator Handle(CustomAttributeHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public CustomAttribute GetCustomAttribute(MetadataReader reader) + { + return reader.GetCustomAttribute(this); + } // GetCustomAttribute + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.CustomAttribute) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // CustomAttributeHandle + + /// <summary> + /// CustomModifier + /// </summary> + public partial struct CustomModifier + { + internal MetadataReader _reader; + internal CustomModifierHandle _handle; + public CustomModifierHandle Handle + { + get + { + return _handle; + } + } // Handle + + public bool IsOptional + { + get + { + return _isOptional; + } + } // IsOptional + + internal bool _isOptional; + + /// One of: TypeDefinition, TypeReference, TypeSpecification + public Handle Type + { + get + { + return _type; + } + } // Type + + internal Handle _type; + } // CustomModifier + + /// <summary> + /// CustomModifierHandle + /// </summary> + public partial struct CustomModifierHandle + { + public override bool Equals(object obj) + { + if (obj is CustomModifierHandle) + return _value == ((CustomModifierHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(CustomModifierHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal CustomModifierHandle(Handle handle) : this(handle._value) + { + + } + + internal CustomModifierHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.CustomModifier || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.CustomModifier) << 24); + _Validate(); + } + + public static implicit operator Handle(CustomModifierHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public CustomModifier GetCustomModifier(MetadataReader reader) + { + return reader.GetCustomModifier(this); + } // GetCustomModifier + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.CustomModifier) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // CustomModifierHandle + + /// <summary> + /// Event + /// </summary> + public partial struct Event + { + internal MetadataReader _reader; + internal EventHandle _handle; + public EventHandle Handle + { + get + { + return _handle; + } + } // Handle + + public EventAttributes Flags + { + get + { + return _flags; + } + } // Flags + + internal EventAttributes _flags; + public ConstantStringValueHandle Name + { + get + { + return _name; + } + } // Name + + internal ConstantStringValueHandle _name; + + /// One of: TypeDefinition, TypeReference, TypeSpecification + public Handle Type + { + get + { + return _type; + } + } // Type + + internal Handle _type; + public IEnumerable<MethodSemanticsHandle> MethodSemantics + { + get + { + return (IEnumerable<MethodSemanticsHandle>)_methodSemantics; + } + } // MethodSemantics + + internal MethodSemanticsHandle[] _methodSemantics; + public IEnumerable<CustomAttributeHandle> CustomAttributes + { + get + { + return (IEnumerable<CustomAttributeHandle>)_customAttributes; + } + } // CustomAttributes + + internal CustomAttributeHandle[] _customAttributes; + } // Event + + /// <summary> + /// EventHandle + /// </summary> + public partial struct EventHandle + { + public override bool Equals(object obj) + { + if (obj is EventHandle) + return _value == ((EventHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(EventHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal EventHandle(Handle handle) : this(handle._value) + { + + } + + internal EventHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.Event || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.Event) << 24); + _Validate(); + } + + public static implicit operator Handle(EventHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public Event GetEvent(MetadataReader reader) + { + return reader.GetEvent(this); + } // GetEvent + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.Event) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // EventHandle + + /// <summary> + /// Field + /// </summary> + public partial struct Field + { + internal MetadataReader _reader; + internal FieldHandle _handle; + public FieldHandle Handle + { + get + { + return _handle; + } + } // Handle + + public FieldAttributes Flags + { + get + { + return _flags; + } + } // Flags + + internal FieldAttributes _flags; + public ConstantStringValueHandle Name + { + get + { + return _name; + } + } // Name + + internal ConstantStringValueHandle _name; + public FieldSignatureHandle Signature + { + get + { + return _signature; + } + } // Signature + + internal FieldSignatureHandle _signature; + + /// One of: TypeDefinition, TypeReference, TypeSpecification, ConstantBooleanArray, ConstantBooleanValue, ConstantByteArray, ConstantByteValue, ConstantCharArray, ConstantCharValue, ConstantDoubleArray, ConstantDoubleValue, ConstantHandleArray, ConstantInt16Array, ConstantInt16Value, ConstantInt32Array, ConstantInt32Value, ConstantInt64Array, ConstantInt64Value, ConstantReferenceValue, ConstantSByteArray, ConstantSByteValue, ConstantSingleArray, ConstantSingleValue, ConstantStringArray, ConstantStringValue, ConstantUInt16Array, ConstantUInt16Value, ConstantUInt32Array, ConstantUInt32Value, ConstantUInt64Array, ConstantUInt64Value + public Handle DefaultValue + { + get + { + return _defaultValue; + } + } // DefaultValue + + internal Handle _defaultValue; + public uint Offset + { + get + { + return _offset; + } + } // Offset + + internal uint _offset; + public IEnumerable<CustomAttributeHandle> CustomAttributes + { + get + { + return (IEnumerable<CustomAttributeHandle>)_customAttributes; + } + } // CustomAttributes + + internal CustomAttributeHandle[] _customAttributes; + } // Field + + /// <summary> + /// FieldHandle + /// </summary> + public partial struct FieldHandle + { + public override bool Equals(object obj) + { + if (obj is FieldHandle) + return _value == ((FieldHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(FieldHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal FieldHandle(Handle handle) : this(handle._value) + { + + } + + internal FieldHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.Field || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.Field) << 24); + _Validate(); + } + + public static implicit operator Handle(FieldHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public Field GetField(MetadataReader reader) + { + return reader.GetField(this); + } // GetField + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.Field) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // FieldHandle + + /// <summary> + /// FieldSignature + /// </summary> + public partial struct FieldSignature + { + internal MetadataReader _reader; + internal FieldSignatureHandle _handle; + public FieldSignatureHandle Handle + { + get + { + return _handle; + } + } // Handle + + + /// One of: TypeDefinition, TypeReference, TypeSpecification + public Handle Type + { + get + { + return _type; + } + } // Type + + internal Handle _type; + public IEnumerable<CustomModifierHandle> CustomModifiers + { + get + { + return (IEnumerable<CustomModifierHandle>)_customModifiers; + } + } // CustomModifiers + + internal CustomModifierHandle[] _customModifiers; + } // FieldSignature + + /// <summary> + /// FieldSignatureHandle + /// </summary> + public partial struct FieldSignatureHandle + { + public override bool Equals(object obj) + { + if (obj is FieldSignatureHandle) + return _value == ((FieldSignatureHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(FieldSignatureHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal FieldSignatureHandle(Handle handle) : this(handle._value) + { + + } + + internal FieldSignatureHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.FieldSignature || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.FieldSignature) << 24); + _Validate(); + } + + public static implicit operator Handle(FieldSignatureHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public FieldSignature GetFieldSignature(MetadataReader reader) + { + return reader.GetFieldSignature(this); + } // GetFieldSignature + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.FieldSignature) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // FieldSignatureHandle + + /// <summary> + /// FixedArgument + /// </summary> + public partial struct FixedArgument + { + internal MetadataReader _reader; + internal FixedArgumentHandle _handle; + public FixedArgumentHandle Handle + { + get + { + return _handle; + } + } // Handle + + public FixedArgumentAttributes Flags + { + get + { + return _flags; + } + } // Flags + + internal FixedArgumentAttributes _flags; + + /// One of: TypeDefinition, TypeReference, TypeSpecification + public Handle Type + { + get + { + return _type; + } + } // Type + + internal Handle _type; + + /// One of: TypeDefinition, TypeReference, TypeSpecification, ConstantBooleanArray, ConstantBooleanValue, ConstantByteArray, ConstantByteValue, ConstantCharArray, ConstantCharValue, ConstantDoubleArray, ConstantDoubleValue, ConstantHandleArray, ConstantInt16Array, ConstantInt16Value, ConstantInt32Array, ConstantInt32Value, ConstantInt64Array, ConstantInt64Value, ConstantReferenceValue, ConstantSByteArray, ConstantSByteValue, ConstantSingleArray, ConstantSingleValue, ConstantStringArray, ConstantStringValue, ConstantUInt16Array, ConstantUInt16Value, ConstantUInt32Array, ConstantUInt32Value, ConstantUInt64Array, ConstantUInt64Value + public Handle Value + { + get + { + return _value; + } + } // Value + + internal Handle _value; + } // FixedArgument + + /// <summary> + /// FixedArgumentHandle + /// </summary> + public partial struct FixedArgumentHandle + { + public override bool Equals(object obj) + { + if (obj is FixedArgumentHandle) + return _value == ((FixedArgumentHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(FixedArgumentHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal FixedArgumentHandle(Handle handle) : this(handle._value) + { + + } + + internal FixedArgumentHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.FixedArgument || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.FixedArgument) << 24); + _Validate(); + } + + public static implicit operator Handle(FixedArgumentHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public FixedArgument GetFixedArgument(MetadataReader reader) + { + return reader.GetFixedArgument(this); + } // GetFixedArgument + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.FixedArgument) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // FixedArgumentHandle + + /// <summary> + /// GenericParameter + /// </summary> + public partial struct GenericParameter + { + internal MetadataReader _reader; + internal GenericParameterHandle _handle; + public GenericParameterHandle Handle + { + get + { + return _handle; + } + } // Handle + + public ushort Number + { + get + { + return _number; + } + } // Number + + internal ushort _number; + public GenericParameterAttributes Flags + { + get + { + return _flags; + } + } // Flags + + internal GenericParameterAttributes _flags; + public GenericParameterKind Kind + { + get + { + return _kind; + } + } // Kind + + internal GenericParameterKind _kind; + public ConstantStringValueHandle Name + { + get + { + return _name; + } + } // Name + + internal ConstantStringValueHandle _name; + + /// One of: TypeDefinition, TypeReference, TypeSpecification + public IEnumerable<Handle> Constraints + { + get + { + return (IEnumerable<Handle>)_constraints; + } + } // Constraints + + internal Handle[] _constraints; + public IEnumerable<CustomAttributeHandle> CustomAttributes + { + get + { + return (IEnumerable<CustomAttributeHandle>)_customAttributes; + } + } // CustomAttributes + + internal CustomAttributeHandle[] _customAttributes; + } // GenericParameter + + /// <summary> + /// GenericParameterHandle + /// </summary> + public partial struct GenericParameterHandle + { + public override bool Equals(object obj) + { + if (obj is GenericParameterHandle) + return _value == ((GenericParameterHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(GenericParameterHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal GenericParameterHandle(Handle handle) : this(handle._value) + { + + } + + internal GenericParameterHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.GenericParameter || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.GenericParameter) << 24); + _Validate(); + } + + public static implicit operator Handle(GenericParameterHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public GenericParameter GetGenericParameter(MetadataReader reader) + { + return reader.GetGenericParameter(this); + } // GetGenericParameter + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.GenericParameter) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // GenericParameterHandle + + /// <summary> + /// Handle + /// </summary> + public partial struct Handle + { + public TypeDefinitionHandle ToTypeDefinitionHandle(MetadataReader reader) + { + return new TypeDefinitionHandle(this); + } // ToTypeDefinitionHandle + + public TypeReferenceHandle ToTypeReferenceHandle(MetadataReader reader) + { + return new TypeReferenceHandle(this); + } // ToTypeReferenceHandle + + public TypeSpecificationHandle ToTypeSpecificationHandle(MetadataReader reader) + { + return new TypeSpecificationHandle(this); + } // ToTypeSpecificationHandle + + public ScopeDefinitionHandle ToScopeDefinitionHandle(MetadataReader reader) + { + return new ScopeDefinitionHandle(this); + } // ToScopeDefinitionHandle + + public ScopeReferenceHandle ToScopeReferenceHandle(MetadataReader reader) + { + return new ScopeReferenceHandle(this); + } // ToScopeReferenceHandle + + public NamespaceDefinitionHandle ToNamespaceDefinitionHandle(MetadataReader reader) + { + return new NamespaceDefinitionHandle(this); + } // ToNamespaceDefinitionHandle + + public NamespaceReferenceHandle ToNamespaceReferenceHandle(MetadataReader reader) + { + return new NamespaceReferenceHandle(this); + } // ToNamespaceReferenceHandle + + public MethodHandle ToMethodHandle(MetadataReader reader) + { + return new MethodHandle(this); + } // ToMethodHandle + + public MethodInstantiationHandle ToMethodInstantiationHandle(MetadataReader reader) + { + return new MethodInstantiationHandle(this); + } // ToMethodInstantiationHandle + + public MemberReferenceHandle ToMemberReferenceHandle(MetadataReader reader) + { + return new MemberReferenceHandle(this); + } // ToMemberReferenceHandle + + public FieldHandle ToFieldHandle(MetadataReader reader) + { + return new FieldHandle(this); + } // ToFieldHandle + + public PropertyHandle ToPropertyHandle(MetadataReader reader) + { + return new PropertyHandle(this); + } // ToPropertyHandle + + public EventHandle ToEventHandle(MetadataReader reader) + { + return new EventHandle(this); + } // ToEventHandle + + public CustomAttributeHandle ToCustomAttributeHandle(MetadataReader reader) + { + return new CustomAttributeHandle(this); + } // ToCustomAttributeHandle + + public FixedArgumentHandle ToFixedArgumentHandle(MetadataReader reader) + { + return new FixedArgumentHandle(this); + } // ToFixedArgumentHandle + + public NamedArgumentHandle ToNamedArgumentHandle(MetadataReader reader) + { + return new NamedArgumentHandle(this); + } // ToNamedArgumentHandle + + public GenericParameterHandle ToGenericParameterHandle(MetadataReader reader) + { + return new GenericParameterHandle(this); + } // ToGenericParameterHandle + + public MethodImplHandle ToMethodImplHandle(MetadataReader reader) + { + return new MethodImplHandle(this); + } // ToMethodImplHandle + + public ParameterHandle ToParameterHandle(MetadataReader reader) + { + return new ParameterHandle(this); + } // ToParameterHandle + + public MethodSemanticsHandle ToMethodSemanticsHandle(MetadataReader reader) + { + return new MethodSemanticsHandle(this); + } // ToMethodSemanticsHandle + + public TypeInstantiationSignatureHandle ToTypeInstantiationSignatureHandle(MetadataReader reader) + { + return new TypeInstantiationSignatureHandle(this); + } // ToTypeInstantiationSignatureHandle + + public SZArraySignatureHandle ToSZArraySignatureHandle(MetadataReader reader) + { + return new SZArraySignatureHandle(this); + } // ToSZArraySignatureHandle + + public ArraySignatureHandle ToArraySignatureHandle(MetadataReader reader) + { + return new ArraySignatureHandle(this); + } // ToArraySignatureHandle + + public ByReferenceSignatureHandle ToByReferenceSignatureHandle(MetadataReader reader) + { + return new ByReferenceSignatureHandle(this); + } // ToByReferenceSignatureHandle + + public PointerSignatureHandle ToPointerSignatureHandle(MetadataReader reader) + { + return new PointerSignatureHandle(this); + } // ToPointerSignatureHandle + + public TypeVariableSignatureHandle ToTypeVariableSignatureHandle(MetadataReader reader) + { + return new TypeVariableSignatureHandle(this); + } // ToTypeVariableSignatureHandle + + public MethodTypeVariableSignatureHandle ToMethodTypeVariableSignatureHandle(MetadataReader reader) + { + return new MethodTypeVariableSignatureHandle(this); + } // ToMethodTypeVariableSignatureHandle + + public FieldSignatureHandle ToFieldSignatureHandle(MetadataReader reader) + { + return new FieldSignatureHandle(this); + } // ToFieldSignatureHandle + + public PropertySignatureHandle ToPropertySignatureHandle(MetadataReader reader) + { + return new PropertySignatureHandle(this); + } // ToPropertySignatureHandle + + public MethodSignatureHandle ToMethodSignatureHandle(MetadataReader reader) + { + return new MethodSignatureHandle(this); + } // ToMethodSignatureHandle + + public ReturnTypeSignatureHandle ToReturnTypeSignatureHandle(MetadataReader reader) + { + return new ReturnTypeSignatureHandle(this); + } // ToReturnTypeSignatureHandle + + public ParameterTypeSignatureHandle ToParameterTypeSignatureHandle(MetadataReader reader) + { + return new ParameterTypeSignatureHandle(this); + } // ToParameterTypeSignatureHandle + + public TypeForwarderHandle ToTypeForwarderHandle(MetadataReader reader) + { + return new TypeForwarderHandle(this); + } // ToTypeForwarderHandle + + public CustomModifierHandle ToCustomModifierHandle(MetadataReader reader) + { + return new CustomModifierHandle(this); + } // ToCustomModifierHandle + + public ConstantBooleanArrayHandle ToConstantBooleanArrayHandle(MetadataReader reader) + { + return new ConstantBooleanArrayHandle(this); + } // ToConstantBooleanArrayHandle + + public ConstantBooleanValueHandle ToConstantBooleanValueHandle(MetadataReader reader) + { + return new ConstantBooleanValueHandle(this); + } // ToConstantBooleanValueHandle + + public ConstantByteArrayHandle ToConstantByteArrayHandle(MetadataReader reader) + { + return new ConstantByteArrayHandle(this); + } // ToConstantByteArrayHandle + + public ConstantByteValueHandle ToConstantByteValueHandle(MetadataReader reader) + { + return new ConstantByteValueHandle(this); + } // ToConstantByteValueHandle + + public ConstantCharArrayHandle ToConstantCharArrayHandle(MetadataReader reader) + { + return new ConstantCharArrayHandle(this); + } // ToConstantCharArrayHandle + + public ConstantCharValueHandle ToConstantCharValueHandle(MetadataReader reader) + { + return new ConstantCharValueHandle(this); + } // ToConstantCharValueHandle + + public ConstantDoubleArrayHandle ToConstantDoubleArrayHandle(MetadataReader reader) + { + return new ConstantDoubleArrayHandle(this); + } // ToConstantDoubleArrayHandle + + public ConstantDoubleValueHandle ToConstantDoubleValueHandle(MetadataReader reader) + { + return new ConstantDoubleValueHandle(this); + } // ToConstantDoubleValueHandle + + public ConstantHandleArrayHandle ToConstantHandleArrayHandle(MetadataReader reader) + { + return new ConstantHandleArrayHandle(this); + } // ToConstantHandleArrayHandle + + public ConstantInt16ArrayHandle ToConstantInt16ArrayHandle(MetadataReader reader) + { + return new ConstantInt16ArrayHandle(this); + } // ToConstantInt16ArrayHandle + + public ConstantInt16ValueHandle ToConstantInt16ValueHandle(MetadataReader reader) + { + return new ConstantInt16ValueHandle(this); + } // ToConstantInt16ValueHandle + + public ConstantInt32ArrayHandle ToConstantInt32ArrayHandle(MetadataReader reader) + { + return new ConstantInt32ArrayHandle(this); + } // ToConstantInt32ArrayHandle + + public ConstantInt32ValueHandle ToConstantInt32ValueHandle(MetadataReader reader) + { + return new ConstantInt32ValueHandle(this); + } // ToConstantInt32ValueHandle + + public ConstantInt64ArrayHandle ToConstantInt64ArrayHandle(MetadataReader reader) + { + return new ConstantInt64ArrayHandle(this); + } // ToConstantInt64ArrayHandle + + public ConstantInt64ValueHandle ToConstantInt64ValueHandle(MetadataReader reader) + { + return new ConstantInt64ValueHandle(this); + } // ToConstantInt64ValueHandle + + public ConstantReferenceValueHandle ToConstantReferenceValueHandle(MetadataReader reader) + { + return new ConstantReferenceValueHandle(this); + } // ToConstantReferenceValueHandle + + public ConstantSByteArrayHandle ToConstantSByteArrayHandle(MetadataReader reader) + { + return new ConstantSByteArrayHandle(this); + } // ToConstantSByteArrayHandle + + public ConstantSByteValueHandle ToConstantSByteValueHandle(MetadataReader reader) + { + return new ConstantSByteValueHandle(this); + } // ToConstantSByteValueHandle + + public ConstantSingleArrayHandle ToConstantSingleArrayHandle(MetadataReader reader) + { + return new ConstantSingleArrayHandle(this); + } // ToConstantSingleArrayHandle + + public ConstantSingleValueHandle ToConstantSingleValueHandle(MetadataReader reader) + { + return new ConstantSingleValueHandle(this); + } // ToConstantSingleValueHandle + + public ConstantStringArrayHandle ToConstantStringArrayHandle(MetadataReader reader) + { + return new ConstantStringArrayHandle(this); + } // ToConstantStringArrayHandle + + public ConstantStringValueHandle ToConstantStringValueHandle(MetadataReader reader) + { + return new ConstantStringValueHandle(this); + } // ToConstantStringValueHandle + + public ConstantUInt16ArrayHandle ToConstantUInt16ArrayHandle(MetadataReader reader) + { + return new ConstantUInt16ArrayHandle(this); + } // ToConstantUInt16ArrayHandle + + public ConstantUInt16ValueHandle ToConstantUInt16ValueHandle(MetadataReader reader) + { + return new ConstantUInt16ValueHandle(this); + } // ToConstantUInt16ValueHandle + + public ConstantUInt32ArrayHandle ToConstantUInt32ArrayHandle(MetadataReader reader) + { + return new ConstantUInt32ArrayHandle(this); + } // ToConstantUInt32ArrayHandle + + public ConstantUInt32ValueHandle ToConstantUInt32ValueHandle(MetadataReader reader) + { + return new ConstantUInt32ValueHandle(this); + } // ToConstantUInt32ValueHandle + + public ConstantUInt64ArrayHandle ToConstantUInt64ArrayHandle(MetadataReader reader) + { + return new ConstantUInt64ArrayHandle(this); + } // ToConstantUInt64ArrayHandle + + public ConstantUInt64ValueHandle ToConstantUInt64ValueHandle(MetadataReader reader) + { + return new ConstantUInt64ValueHandle(this); + } // ToConstantUInt64ValueHandle + } // Handle + + /// <summary> + /// MemberReference + /// </summary> + public partial struct MemberReference + { + internal MetadataReader _reader; + internal MemberReferenceHandle _handle; + public MemberReferenceHandle Handle + { + get + { + return _handle; + } + } // Handle + + + /// One of: Method, TypeDefinition, TypeReference, TypeSpecification + public Handle Parent + { + get + { + return _parent; + } + } // Parent + + internal Handle _parent; + public ConstantStringValueHandle Name + { + get + { + return _name; + } + } // Name + + internal ConstantStringValueHandle _name; + + /// One of: MethodSignature, FieldSignature + public Handle Signature + { + get + { + return _signature; + } + } // Signature + + internal Handle _signature; + public IEnumerable<CustomAttributeHandle> CustomAttributes + { + get + { + return (IEnumerable<CustomAttributeHandle>)_customAttributes; + } + } // CustomAttributes + + internal CustomAttributeHandle[] _customAttributes; + } // MemberReference + + /// <summary> + /// MemberReferenceHandle + /// </summary> + public partial struct MemberReferenceHandle + { + public override bool Equals(object obj) + { + if (obj is MemberReferenceHandle) + return _value == ((MemberReferenceHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(MemberReferenceHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal MemberReferenceHandle(Handle handle) : this(handle._value) + { + + } + + internal MemberReferenceHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.MemberReference || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.MemberReference) << 24); + _Validate(); + } + + public static implicit operator Handle(MemberReferenceHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public MemberReference GetMemberReference(MetadataReader reader) + { + return reader.GetMemberReference(this); + } // GetMemberReference + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.MemberReference) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // MemberReferenceHandle + + /// <summary> + /// MetadataReader + /// </summary> + public partial class MetadataReader : IMetadataReader + { + public TypeDefinition GetTypeDefinition(TypeDefinitionHandle handle) + { + var record = new TypeDefinition() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._flags); + offset = _streamReader.Read(offset, out record._baseType); + offset = _streamReader.Read(offset, out record._namespaceDefinition); + offset = _streamReader.Read(offset, out record._name); + offset = _streamReader.Read(offset, out record._size); + offset = _streamReader.Read(offset, out record._packingSize); + offset = _streamReader.Read(offset, out record._enclosingType); + offset = _streamReader.Read(offset, out record._nestedTypes); + offset = _streamReader.Read(offset, out record._methods); + offset = _streamReader.Read(offset, out record._fields); + offset = _streamReader.Read(offset, out record._properties); + offset = _streamReader.Read(offset, out record._events); + offset = _streamReader.Read(offset, out record._genericParameters); + offset = _streamReader.Read(offset, out record._interfaces); + offset = _streamReader.Read(offset, out record._customAttributes); + return record; + } // GetTypeDefinition + + public TypeReference GetTypeReference(TypeReferenceHandle handle) + { + var record = new TypeReference() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._parentNamespaceOrType); + offset = _streamReader.Read(offset, out record._typeName); + offset = _streamReader.Read(offset, out record._customAttributes); + return record; + } // GetTypeReference + + public TypeSpecification GetTypeSpecification(TypeSpecificationHandle handle) + { + var record = new TypeSpecification() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._signature); + offset = _streamReader.Read(offset, out record._customAttributes); + return record; + } // GetTypeSpecification + + public ScopeDefinition GetScopeDefinition(ScopeDefinitionHandle handle) + { + var record = new ScopeDefinition() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._flags); + offset = _streamReader.Read(offset, out record._name); + offset = _streamReader.Read(offset, out record._hashAlgorithm); + offset = _streamReader.Read(offset, out record._majorVersion); + offset = _streamReader.Read(offset, out record._minorVersion); + offset = _streamReader.Read(offset, out record._buildNumber); + offset = _streamReader.Read(offset, out record._revisionNumber); + offset = _streamReader.Read(offset, out record._publicKey); + offset = _streamReader.Read(offset, out record._culture); + offset = _streamReader.Read(offset, out record._rootNamespaceDefinition); + offset = _streamReader.Read(offset, out record._customAttributes); + return record; + } // GetScopeDefinition + + public ScopeReference GetScopeReference(ScopeReferenceHandle handle) + { + var record = new ScopeReference() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._flags); + offset = _streamReader.Read(offset, out record._name); + offset = _streamReader.Read(offset, out record._majorVersion); + offset = _streamReader.Read(offset, out record._minorVersion); + offset = _streamReader.Read(offset, out record._buildNumber); + offset = _streamReader.Read(offset, out record._revisionNumber); + offset = _streamReader.Read(offset, out record._publicKeyOrToken); + offset = _streamReader.Read(offset, out record._culture); + offset = _streamReader.Read(offset, out record._customAttributes); + return record; + } // GetScopeReference + + public NamespaceDefinition GetNamespaceDefinition(NamespaceDefinitionHandle handle) + { + var record = new NamespaceDefinition() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._parentScopeOrNamespace); + offset = _streamReader.Read(offset, out record._name); + offset = _streamReader.Read(offset, out record._typeDefinitions); + offset = _streamReader.Read(offset, out record._typeForwarders); + offset = _streamReader.Read(offset, out record._namespaceDefinitions); + return record; + } // GetNamespaceDefinition + + public NamespaceReference GetNamespaceReference(NamespaceReferenceHandle handle) + { + var record = new NamespaceReference() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._parentScopeOrNamespace); + offset = _streamReader.Read(offset, out record._name); + return record; + } // GetNamespaceReference + + public Method GetMethod(MethodHandle handle) + { + var record = new Method() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._RVA); + offset = _streamReader.Read(offset, out record._flags); + offset = _streamReader.Read(offset, out record._implFlags); + offset = _streamReader.Read(offset, out record._name); + offset = _streamReader.Read(offset, out record._signature); + offset = _streamReader.Read(offset, out record._parameters); + offset = _streamReader.Read(offset, out record._genericParameters); + offset = _streamReader.Read(offset, out record._methodImpls); + offset = _streamReader.Read(offset, out record._customAttributes); + return record; + } // GetMethod + + public MethodInstantiation GetMethodInstantiation(MethodInstantiationHandle handle) + { + var record = new MethodInstantiation() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._method); + offset = _streamReader.Read(offset, out record._instantiation); + return record; + } // GetMethodInstantiation + + public MemberReference GetMemberReference(MemberReferenceHandle handle) + { + var record = new MemberReference() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._parent); + offset = _streamReader.Read(offset, out record._name); + offset = _streamReader.Read(offset, out record._signature); + offset = _streamReader.Read(offset, out record._customAttributes); + return record; + } // GetMemberReference + + public Field GetField(FieldHandle handle) + { + var record = new Field() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._flags); + offset = _streamReader.Read(offset, out record._name); + offset = _streamReader.Read(offset, out record._signature); + offset = _streamReader.Read(offset, out record._defaultValue); + offset = _streamReader.Read(offset, out record._offset); + offset = _streamReader.Read(offset, out record._customAttributes); + return record; + } // GetField + + public Property GetProperty(PropertyHandle handle) + { + var record = new Property() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._flags); + offset = _streamReader.Read(offset, out record._name); + offset = _streamReader.Read(offset, out record._signature); + offset = _streamReader.Read(offset, out record._methodSemantics); + offset = _streamReader.Read(offset, out record._defaultValue); + offset = _streamReader.Read(offset, out record._customAttributes); + return record; + } // GetProperty + + public Event GetEvent(EventHandle handle) + { + var record = new Event() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._flags); + offset = _streamReader.Read(offset, out record._name); + offset = _streamReader.Read(offset, out record._type); + offset = _streamReader.Read(offset, out record._methodSemantics); + offset = _streamReader.Read(offset, out record._customAttributes); + return record; + } // GetEvent + + public CustomAttribute GetCustomAttribute(CustomAttributeHandle handle) + { + var record = new CustomAttribute() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._type); + offset = _streamReader.Read(offset, out record._constructor); + offset = _streamReader.Read(offset, out record._fixedArguments); + offset = _streamReader.Read(offset, out record._namedArguments); + return record; + } // GetCustomAttribute + + 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 + + public NamedArgument GetNamedArgument(NamedArgumentHandle handle) + { + var record = new NamedArgument() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._flags); + offset = _streamReader.Read(offset, out record._name); + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetNamedArgument + + public GenericParameter GetGenericParameter(GenericParameterHandle handle) + { + var record = new GenericParameter() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._number); + offset = _streamReader.Read(offset, out record._flags); + offset = _streamReader.Read(offset, out record._kind); + offset = _streamReader.Read(offset, out record._name); + offset = _streamReader.Read(offset, out record._constraints); + offset = _streamReader.Read(offset, out record._customAttributes); + return record; + } // GetGenericParameter + + public MethodImpl GetMethodImpl(MethodImplHandle handle) + { + var record = new MethodImpl() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._methodDeclaration); + offset = _streamReader.Read(offset, out record._customAttributes); + return record; + } // GetMethodImpl + + public Parameter GetParameter(ParameterHandle handle) + { + var record = new Parameter() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._flags); + offset = _streamReader.Read(offset, out record._sequence); + offset = _streamReader.Read(offset, out record._name); + offset = _streamReader.Read(offset, out record._defaultValue); + offset = _streamReader.Read(offset, out record._customAttributes); + return record; + } // GetParameter + + public MethodSemantics GetMethodSemantics(MethodSemanticsHandle handle) + { + var record = new MethodSemantics() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._attributes); + offset = _streamReader.Read(offset, out record._method); + offset = _streamReader.Read(offset, out record._customAttributes); + return record; + } // GetMethodSemantics + + public TypeInstantiationSignature GetTypeInstantiationSignature(TypeInstantiationSignatureHandle handle) + { + var record = new TypeInstantiationSignature() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._genericType); + offset = _streamReader.Read(offset, out record._genericTypeArguments); + return record; + } // GetTypeInstantiationSignature + + public SZArraySignature GetSZArraySignature(SZArraySignatureHandle handle) + { + var record = new SZArraySignature() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._elementType); + return record; + } // GetSZArraySignature + + public ArraySignature GetArraySignature(ArraySignatureHandle handle) + { + var record = new ArraySignature() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._elementType); + offset = _streamReader.Read(offset, out record._rank); + offset = _streamReader.Read(offset, out record._sizes); + offset = _streamReader.Read(offset, out record._lowerBounds); + return record; + } // GetArraySignature + + public ByReferenceSignature GetByReferenceSignature(ByReferenceSignatureHandle handle) + { + var record = new ByReferenceSignature() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._type); + return record; + } // GetByReferenceSignature + + public PointerSignature GetPointerSignature(PointerSignatureHandle handle) + { + var record = new PointerSignature() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._type); + return record; + } // GetPointerSignature + + public TypeVariableSignature GetTypeVariableSignature(TypeVariableSignatureHandle handle) + { + var record = new TypeVariableSignature() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._number); + return record; + } // GetTypeVariableSignature + + public MethodTypeVariableSignature GetMethodTypeVariableSignature(MethodTypeVariableSignatureHandle handle) + { + var record = new MethodTypeVariableSignature() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._number); + return record; + } // GetMethodTypeVariableSignature + + public FieldSignature GetFieldSignature(FieldSignatureHandle handle) + { + var record = new FieldSignature() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._type); + offset = _streamReader.Read(offset, out record._customModifiers); + return record; + } // GetFieldSignature + + public PropertySignature GetPropertySignature(PropertySignatureHandle handle) + { + var record = new PropertySignature() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._callingConvention); + offset = _streamReader.Read(offset, out record._customModifiers); + offset = _streamReader.Read(offset, out record._type); + offset = _streamReader.Read(offset, out record._parameters); + return record; + } // GetPropertySignature + + public MethodSignature GetMethodSignature(MethodSignatureHandle handle) + { + var record = new MethodSignature() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._callingConvention); + offset = _streamReader.Read(offset, out record._genericParameterCount); + offset = _streamReader.Read(offset, out record._returnType); + offset = _streamReader.Read(offset, out record._parameters); + offset = _streamReader.Read(offset, out record._varArgParameters); + return record; + } // GetMethodSignature + + public ReturnTypeSignature GetReturnTypeSignature(ReturnTypeSignatureHandle handle) + { + var record = new ReturnTypeSignature() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._customModifiers); + offset = _streamReader.Read(offset, out record._type); + return record; + } // GetReturnTypeSignature + + public ParameterTypeSignature GetParameterTypeSignature(ParameterTypeSignatureHandle handle) + { + var record = new ParameterTypeSignature() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._customModifiers); + offset = _streamReader.Read(offset, out record._type); + return record; + } // GetParameterTypeSignature + + public TypeForwarder GetTypeForwarder(TypeForwarderHandle handle) + { + var record = new TypeForwarder() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._scope); + offset = _streamReader.Read(offset, out record._name); + offset = _streamReader.Read(offset, out record._nestedTypes); + offset = _streamReader.Read(offset, out record._customAttributes); + return record; + } // GetTypeForwarder + + public CustomModifier GetCustomModifier(CustomModifierHandle handle) + { + var record = new CustomModifier() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._isOptional); + offset = _streamReader.Read(offset, out record._type); + return record; + } // GetCustomModifier + + public ConstantBooleanArray GetConstantBooleanArray(ConstantBooleanArrayHandle handle) + { + var record = new ConstantBooleanArray() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantBooleanArray + + public ConstantBooleanValue GetConstantBooleanValue(ConstantBooleanValueHandle handle) + { + var record = new ConstantBooleanValue() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantBooleanValue + + public ConstantByteArray GetConstantByteArray(ConstantByteArrayHandle handle) + { + var record = new ConstantByteArray() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantByteArray + + public ConstantByteValue GetConstantByteValue(ConstantByteValueHandle handle) + { + var record = new ConstantByteValue() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantByteValue + + public ConstantCharArray GetConstantCharArray(ConstantCharArrayHandle handle) + { + var record = new ConstantCharArray() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantCharArray + + public ConstantCharValue GetConstantCharValue(ConstantCharValueHandle handle) + { + var record = new ConstantCharValue() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantCharValue + + public ConstantDoubleArray GetConstantDoubleArray(ConstantDoubleArrayHandle handle) + { + var record = new ConstantDoubleArray() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantDoubleArray + + public ConstantDoubleValue GetConstantDoubleValue(ConstantDoubleValueHandle handle) + { + var record = new ConstantDoubleValue() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantDoubleValue + + public ConstantHandleArray GetConstantHandleArray(ConstantHandleArrayHandle handle) + { + var record = new ConstantHandleArray() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantHandleArray + + public ConstantInt16Array GetConstantInt16Array(ConstantInt16ArrayHandle handle) + { + var record = new ConstantInt16Array() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantInt16Array + + public ConstantInt16Value GetConstantInt16Value(ConstantInt16ValueHandle handle) + { + var record = new ConstantInt16Value() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantInt16Value + + public ConstantInt32Array GetConstantInt32Array(ConstantInt32ArrayHandle handle) + { + var record = new ConstantInt32Array() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantInt32Array + + public ConstantInt32Value GetConstantInt32Value(ConstantInt32ValueHandle handle) + { + var record = new ConstantInt32Value() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantInt32Value + + public ConstantInt64Array GetConstantInt64Array(ConstantInt64ArrayHandle handle) + { + var record = new ConstantInt64Array() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantInt64Array + + public ConstantInt64Value GetConstantInt64Value(ConstantInt64ValueHandle handle) + { + var record = new ConstantInt64Value() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantInt64Value + + public ConstantReferenceValue GetConstantReferenceValue(ConstantReferenceValueHandle handle) + { + var record = new ConstantReferenceValue() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + return record; + } // GetConstantReferenceValue + + public ConstantSByteArray GetConstantSByteArray(ConstantSByteArrayHandle handle) + { + var record = new ConstantSByteArray() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantSByteArray + + public ConstantSByteValue GetConstantSByteValue(ConstantSByteValueHandle handle) + { + var record = new ConstantSByteValue() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantSByteValue + + public ConstantSingleArray GetConstantSingleArray(ConstantSingleArrayHandle handle) + { + var record = new ConstantSingleArray() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantSingleArray + + public ConstantSingleValue GetConstantSingleValue(ConstantSingleValueHandle handle) + { + var record = new ConstantSingleValue() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantSingleValue + + public ConstantStringArray GetConstantStringArray(ConstantStringArrayHandle handle) + { + var record = new ConstantStringArray() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantStringArray + + public ConstantStringValue GetConstantStringValue(ConstantStringValueHandle handle) + { + if (IsNull(handle)) + return new ConstantStringValue(); + var record = new ConstantStringValue() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantStringValue + + public ConstantUInt16Array GetConstantUInt16Array(ConstantUInt16ArrayHandle handle) + { + var record = new ConstantUInt16Array() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantUInt16Array + + public ConstantUInt16Value GetConstantUInt16Value(ConstantUInt16ValueHandle handle) + { + var record = new ConstantUInt16Value() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantUInt16Value + + public ConstantUInt32Array GetConstantUInt32Array(ConstantUInt32ArrayHandle handle) + { + var record = new ConstantUInt32Array() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantUInt32Array + + public ConstantUInt32Value GetConstantUInt32Value(ConstantUInt32ValueHandle handle) + { + var record = new ConstantUInt32Value() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantUInt32Value + + public ConstantUInt64Array GetConstantUInt64Array(ConstantUInt64ArrayHandle handle) + { + var record = new ConstantUInt64Array() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantUInt64Array + + public ConstantUInt64Value GetConstantUInt64Value(ConstantUInt64ValueHandle handle) + { + var record = new ConstantUInt64Value() { _reader = this, _handle = handle }; + var offset = (uint)handle.Offset; + offset = _streamReader.Read(offset, out record._value); + return record; + } // GetConstantUInt64Value + + internal TypeDefinitionHandle ToTypeDefinitionHandle(Handle handle) + { + return new TypeDefinitionHandle(handle._value); + } // ToTypeDefinitionHandle + + internal Handle ToHandle(TypeDefinitionHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(TypeReferenceHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(TypeSpecificationHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ScopeDefinitionHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ScopeReferenceHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(NamespaceDefinitionHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(NamespaceReferenceHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(MethodHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(MethodInstantiationHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(MemberReferenceHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(FieldHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(PropertyHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(EventHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(CustomAttributeHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(FixedArgumentHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(NamedArgumentHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(GenericParameterHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(MethodImplHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ParameterHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(MethodSemanticsHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(TypeInstantiationSignatureHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(SZArraySignatureHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ArraySignatureHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ByReferenceSignatureHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(PointerSignatureHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(TypeVariableSignatureHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(MethodTypeVariableSignatureHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(FieldSignatureHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(PropertySignatureHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(MethodSignatureHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ReturnTypeSignatureHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ParameterTypeSignatureHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(TypeForwarderHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(CustomModifierHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantBooleanArrayHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantBooleanValueHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantByteArrayHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantByteValueHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantCharArrayHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantCharValueHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantDoubleArrayHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantDoubleValueHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantHandleArrayHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantInt16ArrayHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantInt16ValueHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantInt32ArrayHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantInt32ValueHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantInt64ArrayHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantInt64ValueHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantReferenceValueHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantSByteArrayHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantSByteValueHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantSingleArrayHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantSingleValueHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantStringArrayHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantStringValueHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantUInt16ArrayHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantUInt16ValueHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantUInt32ArrayHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantUInt32ValueHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantUInt64ArrayHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal Handle ToHandle(ConstantUInt64ValueHandle handle) + { + return new Handle(handle._value); + } // ToHandle + + internal TypeReferenceHandle ToTypeReferenceHandle(Handle handle) + { + return new TypeReferenceHandle(handle._value); + } // ToTypeReferenceHandle + + internal TypeSpecificationHandle ToTypeSpecificationHandle(Handle handle) + { + return new TypeSpecificationHandle(handle._value); + } // ToTypeSpecificationHandle + + internal ScopeDefinitionHandle ToScopeDefinitionHandle(Handle handle) + { + return new ScopeDefinitionHandle(handle._value); + } // ToScopeDefinitionHandle + + internal ScopeReferenceHandle ToScopeReferenceHandle(Handle handle) + { + return new ScopeReferenceHandle(handle._value); + } // ToScopeReferenceHandle + + internal NamespaceDefinitionHandle ToNamespaceDefinitionHandle(Handle handle) + { + return new NamespaceDefinitionHandle(handle._value); + } // ToNamespaceDefinitionHandle + + internal NamespaceReferenceHandle ToNamespaceReferenceHandle(Handle handle) + { + return new NamespaceReferenceHandle(handle._value); + } // ToNamespaceReferenceHandle + + internal MethodHandle ToMethodHandle(Handle handle) + { + return new MethodHandle(handle._value); + } // ToMethodHandle + + internal MethodInstantiationHandle ToMethodInstantiationHandle(Handle handle) + { + return new MethodInstantiationHandle(handle._value); + } // ToMethodInstantiationHandle + + internal MemberReferenceHandle ToMemberReferenceHandle(Handle handle) + { + return new MemberReferenceHandle(handle._value); + } // ToMemberReferenceHandle + + internal FieldHandle ToFieldHandle(Handle handle) + { + return new FieldHandle(handle._value); + } // ToFieldHandle + + internal PropertyHandle ToPropertyHandle(Handle handle) + { + return new PropertyHandle(handle._value); + } // ToPropertyHandle + + internal EventHandle ToEventHandle(Handle handle) + { + return new EventHandle(handle._value); + } // ToEventHandle + + internal CustomAttributeHandle ToCustomAttributeHandle(Handle handle) + { + return new CustomAttributeHandle(handle._value); + } // ToCustomAttributeHandle + + internal FixedArgumentHandle ToFixedArgumentHandle(Handle handle) + { + return new FixedArgumentHandle(handle._value); + } // ToFixedArgumentHandle + + internal NamedArgumentHandle ToNamedArgumentHandle(Handle handle) + { + return new NamedArgumentHandle(handle._value); + } // ToNamedArgumentHandle + + internal GenericParameterHandle ToGenericParameterHandle(Handle handle) + { + return new GenericParameterHandle(handle._value); + } // ToGenericParameterHandle + + internal MethodImplHandle ToMethodImplHandle(Handle handle) + { + return new MethodImplHandle(handle._value); + } // ToMethodImplHandle + + internal ParameterHandle ToParameterHandle(Handle handle) + { + return new ParameterHandle(handle._value); + } // ToParameterHandle + + internal MethodSemanticsHandle ToMethodSemanticsHandle(Handle handle) + { + return new MethodSemanticsHandle(handle._value); + } // ToMethodSemanticsHandle + + internal TypeInstantiationSignatureHandle ToTypeInstantiationSignatureHandle(Handle handle) + { + return new TypeInstantiationSignatureHandle(handle._value); + } // ToTypeInstantiationSignatureHandle + + internal SZArraySignatureHandle ToSZArraySignatureHandle(Handle handle) + { + return new SZArraySignatureHandle(handle._value); + } // ToSZArraySignatureHandle + + internal ArraySignatureHandle ToArraySignatureHandle(Handle handle) + { + return new ArraySignatureHandle(handle._value); + } // ToArraySignatureHandle + + internal ByReferenceSignatureHandle ToByReferenceSignatureHandle(Handle handle) + { + return new ByReferenceSignatureHandle(handle._value); + } // ToByReferenceSignatureHandle + + internal PointerSignatureHandle ToPointerSignatureHandle(Handle handle) + { + return new PointerSignatureHandle(handle._value); + } // ToPointerSignatureHandle + + internal TypeVariableSignatureHandle ToTypeVariableSignatureHandle(Handle handle) + { + return new TypeVariableSignatureHandle(handle._value); + } // ToTypeVariableSignatureHandle + + internal MethodTypeVariableSignatureHandle ToMethodTypeVariableSignatureHandle(Handle handle) + { + return new MethodTypeVariableSignatureHandle(handle._value); + } // ToMethodTypeVariableSignatureHandle + + internal FieldSignatureHandle ToFieldSignatureHandle(Handle handle) + { + return new FieldSignatureHandle(handle._value); + } // ToFieldSignatureHandle + + internal PropertySignatureHandle ToPropertySignatureHandle(Handle handle) + { + return new PropertySignatureHandle(handle._value); + } // ToPropertySignatureHandle + + internal MethodSignatureHandle ToMethodSignatureHandle(Handle handle) + { + return new MethodSignatureHandle(handle._value); + } // ToMethodSignatureHandle + + internal ReturnTypeSignatureHandle ToReturnTypeSignatureHandle(Handle handle) + { + return new ReturnTypeSignatureHandle(handle._value); + } // ToReturnTypeSignatureHandle + + internal ParameterTypeSignatureHandle ToParameterTypeSignatureHandle(Handle handle) + { + return new ParameterTypeSignatureHandle(handle._value); + } // ToParameterTypeSignatureHandle + + internal TypeForwarderHandle ToTypeForwarderHandle(Handle handle) + { + return new TypeForwarderHandle(handle._value); + } // ToTypeForwarderHandle + + internal CustomModifierHandle ToCustomModifierHandle(Handle handle) + { + return new CustomModifierHandle(handle._value); + } // ToCustomModifierHandle + + internal ConstantBooleanArrayHandle ToConstantBooleanArrayHandle(Handle handle) + { + return new ConstantBooleanArrayHandle(handle._value); + } // ToConstantBooleanArrayHandle + + internal ConstantBooleanValueHandle ToConstantBooleanValueHandle(Handle handle) + { + return new ConstantBooleanValueHandle(handle._value); + } // ToConstantBooleanValueHandle + + internal ConstantByteArrayHandle ToConstantByteArrayHandle(Handle handle) + { + return new ConstantByteArrayHandle(handle._value); + } // ToConstantByteArrayHandle + + internal ConstantByteValueHandle ToConstantByteValueHandle(Handle handle) + { + return new ConstantByteValueHandle(handle._value); + } // ToConstantByteValueHandle + + internal ConstantCharArrayHandle ToConstantCharArrayHandle(Handle handle) + { + return new ConstantCharArrayHandle(handle._value); + } // ToConstantCharArrayHandle + + internal ConstantCharValueHandle ToConstantCharValueHandle(Handle handle) + { + return new ConstantCharValueHandle(handle._value); + } // ToConstantCharValueHandle + + internal ConstantDoubleArrayHandle ToConstantDoubleArrayHandle(Handle handle) + { + return new ConstantDoubleArrayHandle(handle._value); + } // ToConstantDoubleArrayHandle + + internal ConstantDoubleValueHandle ToConstantDoubleValueHandle(Handle handle) + { + return new ConstantDoubleValueHandle(handle._value); + } // ToConstantDoubleValueHandle + + internal ConstantHandleArrayHandle ToConstantHandleArrayHandle(Handle handle) + { + return new ConstantHandleArrayHandle(handle._value); + } // ToConstantHandleArrayHandle + + internal ConstantInt16ArrayHandle ToConstantInt16ArrayHandle(Handle handle) + { + return new ConstantInt16ArrayHandle(handle._value); + } // ToConstantInt16ArrayHandle + + internal ConstantInt16ValueHandle ToConstantInt16ValueHandle(Handle handle) + { + return new ConstantInt16ValueHandle(handle._value); + } // ToConstantInt16ValueHandle + + internal ConstantInt32ArrayHandle ToConstantInt32ArrayHandle(Handle handle) + { + return new ConstantInt32ArrayHandle(handle._value); + } // ToConstantInt32ArrayHandle + + internal ConstantInt32ValueHandle ToConstantInt32ValueHandle(Handle handle) + { + return new ConstantInt32ValueHandle(handle._value); + } // ToConstantInt32ValueHandle + + internal ConstantInt64ArrayHandle ToConstantInt64ArrayHandle(Handle handle) + { + return new ConstantInt64ArrayHandle(handle._value); + } // ToConstantInt64ArrayHandle + + internal ConstantInt64ValueHandle ToConstantInt64ValueHandle(Handle handle) + { + return new ConstantInt64ValueHandle(handle._value); + } // ToConstantInt64ValueHandle + + internal ConstantReferenceValueHandle ToConstantReferenceValueHandle(Handle handle) + { + return new ConstantReferenceValueHandle(handle._value); + } // ToConstantReferenceValueHandle + + internal ConstantSByteArrayHandle ToConstantSByteArrayHandle(Handle handle) + { + return new ConstantSByteArrayHandle(handle._value); + } // ToConstantSByteArrayHandle + + internal ConstantSByteValueHandle ToConstantSByteValueHandle(Handle handle) + { + return new ConstantSByteValueHandle(handle._value); + } // ToConstantSByteValueHandle + + internal ConstantSingleArrayHandle ToConstantSingleArrayHandle(Handle handle) + { + return new ConstantSingleArrayHandle(handle._value); + } // ToConstantSingleArrayHandle + + internal ConstantSingleValueHandle ToConstantSingleValueHandle(Handle handle) + { + return new ConstantSingleValueHandle(handle._value); + } // ToConstantSingleValueHandle + + internal ConstantStringArrayHandle ToConstantStringArrayHandle(Handle handle) + { + return new ConstantStringArrayHandle(handle._value); + } // ToConstantStringArrayHandle + + internal ConstantStringValueHandle ToConstantStringValueHandle(Handle handle) + { + return new ConstantStringValueHandle(handle._value); + } // ToConstantStringValueHandle + + internal ConstantUInt16ArrayHandle ToConstantUInt16ArrayHandle(Handle handle) + { + return new ConstantUInt16ArrayHandle(handle._value); + } // ToConstantUInt16ArrayHandle + + internal ConstantUInt16ValueHandle ToConstantUInt16ValueHandle(Handle handle) + { + return new ConstantUInt16ValueHandle(handle._value); + } // ToConstantUInt16ValueHandle + + internal ConstantUInt32ArrayHandle ToConstantUInt32ArrayHandle(Handle handle) + { + return new ConstantUInt32ArrayHandle(handle._value); + } // ToConstantUInt32ArrayHandle + + internal ConstantUInt32ValueHandle ToConstantUInt32ValueHandle(Handle handle) + { + return new ConstantUInt32ValueHandle(handle._value); + } // ToConstantUInt32ValueHandle + + internal ConstantUInt64ArrayHandle ToConstantUInt64ArrayHandle(Handle handle) + { + return new ConstantUInt64ArrayHandle(handle._value); + } // ToConstantUInt64ArrayHandle + + internal ConstantUInt64ValueHandle ToConstantUInt64ValueHandle(Handle handle) + { + return new ConstantUInt64ValueHandle(handle._value); + } // ToConstantUInt64ValueHandle + + internal bool IsNull(TypeDefinitionHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(TypeReferenceHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(TypeSpecificationHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ScopeDefinitionHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ScopeReferenceHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(NamespaceDefinitionHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(NamespaceReferenceHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(MethodHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(MethodInstantiationHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(MemberReferenceHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(FieldHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(PropertyHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(EventHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(CustomAttributeHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(FixedArgumentHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(NamedArgumentHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(GenericParameterHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(MethodImplHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ParameterHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(MethodSemanticsHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(TypeInstantiationSignatureHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(SZArraySignatureHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ArraySignatureHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ByReferenceSignatureHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(PointerSignatureHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(TypeVariableSignatureHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(MethodTypeVariableSignatureHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(FieldSignatureHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(PropertySignatureHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(MethodSignatureHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ReturnTypeSignatureHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ParameterTypeSignatureHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(TypeForwarderHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(CustomModifierHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantBooleanArrayHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantBooleanValueHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantByteArrayHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantByteValueHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantCharArrayHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantCharValueHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantDoubleArrayHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantDoubleValueHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantHandleArrayHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantInt16ArrayHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantInt16ValueHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantInt32ArrayHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantInt32ValueHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantInt64ArrayHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantInt64ValueHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantReferenceValueHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantSByteArrayHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantSByteValueHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantSingleArrayHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantSingleValueHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantStringArrayHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantStringValueHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantUInt16ArrayHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantUInt16ValueHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantUInt32ArrayHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantUInt32ValueHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantUInt64ArrayHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + + internal bool IsNull(ConstantUInt64ValueHandle handle) + { + return (handle._value & 0x00FFFFFF) == 0; + } // IsNull + } // MetadataReader + + /// <summary> + /// Method + /// </summary> + public partial struct Method + { + internal MetadataReader _reader; + internal MethodHandle _handle; + public MethodHandle Handle + { + get + { + return _handle; + } + } // Handle + + public uint RVA + { + get + { + return _RVA; + } + } // RVA + + internal uint _RVA; + public MethodAttributes Flags + { + get + { + return _flags; + } + } // Flags + + internal MethodAttributes _flags; + public MethodImplAttributes ImplFlags + { + get + { + return _implFlags; + } + } // ImplFlags + + internal MethodImplAttributes _implFlags; + public ConstantStringValueHandle Name + { + get + { + return _name; + } + } // Name + + internal ConstantStringValueHandle _name; + public MethodSignatureHandle Signature + { + get + { + return _signature; + } + } // Signature + + internal MethodSignatureHandle _signature; + public IEnumerable<ParameterHandle> Parameters + { + get + { + return (IEnumerable<ParameterHandle>)_parameters; + } + } // Parameters + + internal ParameterHandle[] _parameters; + public IEnumerable<GenericParameterHandle> GenericParameters + { + get + { + return (IEnumerable<GenericParameterHandle>)_genericParameters; + } + } // GenericParameters + + internal GenericParameterHandle[] _genericParameters; + public IEnumerable<MethodImplHandle> MethodImpls + { + get + { + return (IEnumerable<MethodImplHandle>)_methodImpls; + } + } // MethodImpls + + internal MethodImplHandle[] _methodImpls; + public IEnumerable<CustomAttributeHandle> CustomAttributes + { + get + { + return (IEnumerable<CustomAttributeHandle>)_customAttributes; + } + } // CustomAttributes + + internal CustomAttributeHandle[] _customAttributes; + } // Method + + /// <summary> + /// MethodHandle + /// </summary> + public partial struct MethodHandle + { + public override bool Equals(object obj) + { + if (obj is MethodHandle) + return _value == ((MethodHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(MethodHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal MethodHandle(Handle handle) : this(handle._value) + { + + } + + internal MethodHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.Method || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.Method) << 24); + _Validate(); + } + + public static implicit operator Handle(MethodHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public Method GetMethod(MetadataReader reader) + { + return reader.GetMethod(this); + } // GetMethod + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.Method) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // MethodHandle + + /// <summary> + /// MethodImpl + /// </summary> + public partial struct MethodImpl + { + internal MetadataReader _reader; + internal MethodImplHandle _handle; + public MethodImplHandle Handle + { + get + { + return _handle; + } + } // Handle + + + /// One of: Method, MemberReference + public Handle MethodDeclaration + { + get + { + return _methodDeclaration; + } + } // MethodDeclaration + + internal Handle _methodDeclaration; + public IEnumerable<CustomAttributeHandle> CustomAttributes + { + get + { + return (IEnumerable<CustomAttributeHandle>)_customAttributes; + } + } // CustomAttributes + + internal CustomAttributeHandle[] _customAttributes; + } // MethodImpl + + /// <summary> + /// MethodImplHandle + /// </summary> + public partial struct MethodImplHandle + { + public override bool Equals(object obj) + { + if (obj is MethodImplHandle) + return _value == ((MethodImplHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(MethodImplHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal MethodImplHandle(Handle handle) : this(handle._value) + { + + } + + internal MethodImplHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.MethodImpl || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.MethodImpl) << 24); + _Validate(); + } + + public static implicit operator Handle(MethodImplHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public MethodImpl GetMethodImpl(MetadataReader reader) + { + return reader.GetMethodImpl(this); + } // GetMethodImpl + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.MethodImpl) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // MethodImplHandle + + /// <summary> + /// MethodInstantiation + /// </summary> + public partial struct MethodInstantiation + { + internal MetadataReader _reader; + internal MethodInstantiationHandle _handle; + public MethodInstantiationHandle Handle + { + get + { + return _handle; + } + } // Handle + + + /// One of: Method, MemberReference + public Handle Method + { + get + { + return _method; + } + } // Method + + internal Handle _method; + public MethodSignatureHandle Instantiation + { + get + { + return _instantiation; + } + } // Instantiation + + internal MethodSignatureHandle _instantiation; + } // MethodInstantiation + + /// <summary> + /// MethodInstantiationHandle + /// </summary> + public partial struct MethodInstantiationHandle + { + public override bool Equals(object obj) + { + if (obj is MethodInstantiationHandle) + return _value == ((MethodInstantiationHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(MethodInstantiationHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal MethodInstantiationHandle(Handle handle) : this(handle._value) + { + + } + + internal MethodInstantiationHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.MethodInstantiation || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.MethodInstantiation) << 24); + _Validate(); + } + + public static implicit operator Handle(MethodInstantiationHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public MethodInstantiation GetMethodInstantiation(MetadataReader reader) + { + return reader.GetMethodInstantiation(this); + } // GetMethodInstantiation + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.MethodInstantiation) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // MethodInstantiationHandle + + /// <summary> + /// MethodSemantics + /// </summary> + public partial struct MethodSemantics + { + internal MetadataReader _reader; + internal MethodSemanticsHandle _handle; + public MethodSemanticsHandle Handle + { + get + { + return _handle; + } + } // Handle + + public MethodSemanticsAttributes Attributes + { + get + { + return _attributes; + } + } // Attributes + + internal MethodSemanticsAttributes _attributes; + public MethodHandle Method + { + get + { + return _method; + } + } // Method + + internal MethodHandle _method; + public IEnumerable<CustomAttributeHandle> CustomAttributes + { + get + { + return (IEnumerable<CustomAttributeHandle>)_customAttributes; + } + } // CustomAttributes + + internal CustomAttributeHandle[] _customAttributes; + } // MethodSemantics + + /// <summary> + /// MethodSemanticsHandle + /// </summary> + public partial struct MethodSemanticsHandle + { + public override bool Equals(object obj) + { + if (obj is MethodSemanticsHandle) + return _value == ((MethodSemanticsHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(MethodSemanticsHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal MethodSemanticsHandle(Handle handle) : this(handle._value) + { + + } + + internal MethodSemanticsHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.MethodSemantics || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.MethodSemantics) << 24); + _Validate(); + } + + public static implicit operator Handle(MethodSemanticsHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public MethodSemantics GetMethodSemantics(MetadataReader reader) + { + return reader.GetMethodSemantics(this); + } // GetMethodSemantics + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.MethodSemantics) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // MethodSemanticsHandle + + /// <summary> + /// MethodSignature + /// </summary> + public partial struct MethodSignature + { + internal MetadataReader _reader; + internal MethodSignatureHandle _handle; + public MethodSignatureHandle Handle + { + get + { + return _handle; + } + } // Handle + + public CallingConventions CallingConvention + { + get + { + return _callingConvention; + } + } // CallingConvention + + internal CallingConventions _callingConvention; + public int GenericParameterCount + { + get + { + return _genericParameterCount; + } + } // GenericParameterCount + + internal int _genericParameterCount; + public ReturnTypeSignatureHandle ReturnType + { + get + { + return _returnType; + } + } // ReturnType + + internal ReturnTypeSignatureHandle _returnType; + public IEnumerable<ParameterTypeSignatureHandle> Parameters + { + get + { + return (IEnumerable<ParameterTypeSignatureHandle>)_parameters; + } + } // Parameters + + internal ParameterTypeSignatureHandle[] _parameters; + public IEnumerable<ParameterTypeSignatureHandle> VarArgParameters + { + get + { + return (IEnumerable<ParameterTypeSignatureHandle>)_varArgParameters; + } + } // VarArgParameters + + internal ParameterTypeSignatureHandle[] _varArgParameters; + } // MethodSignature + + /// <summary> + /// MethodSignatureHandle + /// </summary> + public partial struct MethodSignatureHandle + { + public override bool Equals(object obj) + { + if (obj is MethodSignatureHandle) + return _value == ((MethodSignatureHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(MethodSignatureHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal MethodSignatureHandle(Handle handle) : this(handle._value) + { + + } + + internal MethodSignatureHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.MethodSignature || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.MethodSignature) << 24); + _Validate(); + } + + public static implicit operator Handle(MethodSignatureHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public MethodSignature GetMethodSignature(MetadataReader reader) + { + return reader.GetMethodSignature(this); + } // GetMethodSignature + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.MethodSignature) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // MethodSignatureHandle + + /// <summary> + /// MethodTypeVariableSignature + /// </summary> + public partial struct MethodTypeVariableSignature + { + internal MetadataReader _reader; + internal MethodTypeVariableSignatureHandle _handle; + public MethodTypeVariableSignatureHandle Handle + { + get + { + return _handle; + } + } // Handle + + public int Number + { + get + { + return _number; + } + } // Number + + internal int _number; + } // MethodTypeVariableSignature + + /// <summary> + /// MethodTypeVariableSignatureHandle + /// </summary> + public partial struct MethodTypeVariableSignatureHandle + { + public override bool Equals(object obj) + { + if (obj is MethodTypeVariableSignatureHandle) + return _value == ((MethodTypeVariableSignatureHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(MethodTypeVariableSignatureHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal MethodTypeVariableSignatureHandle(Handle handle) : this(handle._value) + { + + } + + internal MethodTypeVariableSignatureHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.MethodTypeVariableSignature || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.MethodTypeVariableSignature) << 24); + _Validate(); + } + + public static implicit operator Handle(MethodTypeVariableSignatureHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public MethodTypeVariableSignature GetMethodTypeVariableSignature(MetadataReader reader) + { + return reader.GetMethodTypeVariableSignature(this); + } // GetMethodTypeVariableSignature + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.MethodTypeVariableSignature) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // MethodTypeVariableSignatureHandle + + /// <summary> + /// NamedArgument + /// </summary> + public partial struct NamedArgument + { + internal MetadataReader _reader; + internal NamedArgumentHandle _handle; + public NamedArgumentHandle Handle + { + get + { + return _handle; + } + } // Handle + + public NamedArgumentMemberKind Flags + { + get + { + return _flags; + } + } // Flags + + internal NamedArgumentMemberKind _flags; + public ConstantStringValueHandle Name + { + get + { + return _name; + } + } // Name + + internal ConstantStringValueHandle _name; + public FixedArgumentHandle Value + { + get + { + return _value; + } + } // Value + + internal FixedArgumentHandle _value; + } // NamedArgument + + /// <summary> + /// NamedArgumentHandle + /// </summary> + public partial struct NamedArgumentHandle + { + public override bool Equals(object obj) + { + if (obj is NamedArgumentHandle) + return _value == ((NamedArgumentHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(NamedArgumentHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal NamedArgumentHandle(Handle handle) : this(handle._value) + { + + } + + internal NamedArgumentHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.NamedArgument || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.NamedArgument) << 24); + _Validate(); + } + + public static implicit operator Handle(NamedArgumentHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public NamedArgument GetNamedArgument(MetadataReader reader) + { + return reader.GetNamedArgument(this); + } // GetNamedArgument + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.NamedArgument) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // NamedArgumentHandle + + /// <summary> + /// NamespaceDefinition + /// </summary> + public partial struct NamespaceDefinition + { + internal MetadataReader _reader; + internal NamespaceDefinitionHandle _handle; + public NamespaceDefinitionHandle Handle + { + get + { + return _handle; + } + } // Handle + + + /// One of: NamespaceDefinition, ScopeDefinition + public Handle ParentScopeOrNamespace + { + get + { + return _parentScopeOrNamespace; + } + } // ParentScopeOrNamespace + + internal Handle _parentScopeOrNamespace; + public ConstantStringValueHandle Name + { + get + { + return _name; + } + } // Name + + internal ConstantStringValueHandle _name; + public IEnumerable<TypeDefinitionHandle> TypeDefinitions + { + get + { + return (IEnumerable<TypeDefinitionHandle>)_typeDefinitions; + } + } // TypeDefinitions + + internal TypeDefinitionHandle[] _typeDefinitions; + public IEnumerable<TypeForwarderHandle> TypeForwarders + { + get + { + return (IEnumerable<TypeForwarderHandle>)_typeForwarders; + } + } // TypeForwarders + + internal TypeForwarderHandle[] _typeForwarders; + public IEnumerable<NamespaceDefinitionHandle> NamespaceDefinitions + { + get + { + return (IEnumerable<NamespaceDefinitionHandle>)_namespaceDefinitions; + } + } // NamespaceDefinitions + + internal NamespaceDefinitionHandle[] _namespaceDefinitions; + } // NamespaceDefinition + + /// <summary> + /// NamespaceDefinitionHandle + /// </summary> + public partial struct NamespaceDefinitionHandle + { + public override bool Equals(object obj) + { + if (obj is NamespaceDefinitionHandle) + return _value == ((NamespaceDefinitionHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(NamespaceDefinitionHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal NamespaceDefinitionHandle(Handle handle) : this(handle._value) + { + + } + + internal NamespaceDefinitionHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.NamespaceDefinition || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.NamespaceDefinition) << 24); + _Validate(); + } + + public static implicit operator Handle(NamespaceDefinitionHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public NamespaceDefinition GetNamespaceDefinition(MetadataReader reader) + { + return reader.GetNamespaceDefinition(this); + } // GetNamespaceDefinition + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.NamespaceDefinition) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // NamespaceDefinitionHandle + + /// <summary> + /// NamespaceReference + /// </summary> + public partial struct NamespaceReference + { + internal MetadataReader _reader; + internal NamespaceReferenceHandle _handle; + public NamespaceReferenceHandle Handle + { + get + { + return _handle; + } + } // Handle + + + /// One of: NamespaceReference, ScopeReference + public Handle ParentScopeOrNamespace + { + get + { + return _parentScopeOrNamespace; + } + } // ParentScopeOrNamespace + + internal Handle _parentScopeOrNamespace; + public ConstantStringValueHandle Name + { + get + { + return _name; + } + } // Name + + internal ConstantStringValueHandle _name; + } // NamespaceReference + + /// <summary> + /// NamespaceReferenceHandle + /// </summary> + public partial struct NamespaceReferenceHandle + { + public override bool Equals(object obj) + { + if (obj is NamespaceReferenceHandle) + return _value == ((NamespaceReferenceHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(NamespaceReferenceHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal NamespaceReferenceHandle(Handle handle) : this(handle._value) + { + + } + + internal NamespaceReferenceHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.NamespaceReference || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.NamespaceReference) << 24); + _Validate(); + } + + public static implicit operator Handle(NamespaceReferenceHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public NamespaceReference GetNamespaceReference(MetadataReader reader) + { + return reader.GetNamespaceReference(this); + } // GetNamespaceReference + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.NamespaceReference) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // NamespaceReferenceHandle + + /// <summary> + /// Parameter + /// </summary> + public partial struct Parameter + { + internal MetadataReader _reader; + internal ParameterHandle _handle; + public ParameterHandle Handle + { + get + { + return _handle; + } + } // Handle + + public ParameterAttributes Flags + { + get + { + return _flags; + } + } // Flags + + internal ParameterAttributes _flags; + public ushort Sequence + { + get + { + return _sequence; + } + } // Sequence + + internal ushort _sequence; + public ConstantStringValueHandle Name + { + get + { + return _name; + } + } // Name + + internal ConstantStringValueHandle _name; + + /// One of: TypeDefinition, TypeReference, TypeSpecification, ConstantBooleanArray, ConstantBooleanValue, ConstantByteArray, ConstantByteValue, ConstantCharArray, ConstantCharValue, ConstantDoubleArray, ConstantDoubleValue, ConstantHandleArray, ConstantInt16Array, ConstantInt16Value, ConstantInt32Array, ConstantInt32Value, ConstantInt64Array, ConstantInt64Value, ConstantReferenceValue, ConstantSByteArray, ConstantSByteValue, ConstantSingleArray, ConstantSingleValue, ConstantStringArray, ConstantStringValue, ConstantUInt16Array, ConstantUInt16Value, ConstantUInt32Array, ConstantUInt32Value, ConstantUInt64Array, ConstantUInt64Value + public Handle DefaultValue + { + get + { + return _defaultValue; + } + } // DefaultValue + + internal Handle _defaultValue; + public IEnumerable<CustomAttributeHandle> CustomAttributes + { + get + { + return (IEnumerable<CustomAttributeHandle>)_customAttributes; + } + } // CustomAttributes + + internal CustomAttributeHandle[] _customAttributes; + } // Parameter + + /// <summary> + /// ParameterHandle + /// </summary> + public partial struct ParameterHandle + { + public override bool Equals(object obj) + { + if (obj is ParameterHandle) + return _value == ((ParameterHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ParameterHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ParameterHandle(Handle handle) : this(handle._value) + { + + } + + internal ParameterHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.Parameter || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.Parameter) << 24); + _Validate(); + } + + public static implicit operator Handle(ParameterHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public Parameter GetParameter(MetadataReader reader) + { + return reader.GetParameter(this); + } // GetParameter + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.Parameter) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ParameterHandle + + /// <summary> + /// ParameterTypeSignature + /// </summary> + public partial struct ParameterTypeSignature + { + internal MetadataReader _reader; + internal ParameterTypeSignatureHandle _handle; + public ParameterTypeSignatureHandle Handle + { + get + { + return _handle; + } + } // Handle + + public IEnumerable<CustomModifierHandle> CustomModifiers + { + get + { + return (IEnumerable<CustomModifierHandle>)_customModifiers; + } + } // CustomModifiers + + internal CustomModifierHandle[] _customModifiers; + + /// One of: TypeDefinition, TypeReference, TypeSpecification + public Handle Type + { + get + { + return _type; + } + } // Type + + internal Handle _type; + } // ParameterTypeSignature + + /// <summary> + /// ParameterTypeSignatureHandle + /// </summary> + public partial struct ParameterTypeSignatureHandle + { + public override bool Equals(object obj) + { + if (obj is ParameterTypeSignatureHandle) + return _value == ((ParameterTypeSignatureHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ParameterTypeSignatureHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ParameterTypeSignatureHandle(Handle handle) : this(handle._value) + { + + } + + internal ParameterTypeSignatureHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ParameterTypeSignature || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ParameterTypeSignature) << 24); + _Validate(); + } + + public static implicit operator Handle(ParameterTypeSignatureHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ParameterTypeSignature GetParameterTypeSignature(MetadataReader reader) + { + return reader.GetParameterTypeSignature(this); + } // GetParameterTypeSignature + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ParameterTypeSignature) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ParameterTypeSignatureHandle + + /// <summary> + /// PointerSignature + /// </summary> + public partial struct PointerSignature + { + internal MetadataReader _reader; + internal PointerSignatureHandle _handle; + public PointerSignatureHandle Handle + { + get + { + return _handle; + } + } // Handle + + + /// One of: TypeDefinition, TypeReference, TypeSpecification + public Handle Type + { + get + { + return _type; + } + } // Type + + internal Handle _type; + } // PointerSignature + + /// <summary> + /// PointerSignatureHandle + /// </summary> + public partial struct PointerSignatureHandle + { + public override bool Equals(object obj) + { + if (obj is PointerSignatureHandle) + return _value == ((PointerSignatureHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(PointerSignatureHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal PointerSignatureHandle(Handle handle) : this(handle._value) + { + + } + + internal PointerSignatureHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.PointerSignature || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.PointerSignature) << 24); + _Validate(); + } + + public static implicit operator Handle(PointerSignatureHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public PointerSignature GetPointerSignature(MetadataReader reader) + { + return reader.GetPointerSignature(this); + } // GetPointerSignature + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.PointerSignature) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // PointerSignatureHandle + + /// <summary> + /// Property + /// </summary> + public partial struct Property + { + internal MetadataReader _reader; + internal PropertyHandle _handle; + public PropertyHandle Handle + { + get + { + return _handle; + } + } // Handle + + public PropertyAttributes Flags + { + get + { + return _flags; + } + } // Flags + + internal PropertyAttributes _flags; + public ConstantStringValueHandle Name + { + get + { + return _name; + } + } // Name + + internal ConstantStringValueHandle _name; + public PropertySignatureHandle Signature + { + get + { + return _signature; + } + } // Signature + + internal PropertySignatureHandle _signature; + public IEnumerable<MethodSemanticsHandle> MethodSemantics + { + get + { + return (IEnumerable<MethodSemanticsHandle>)_methodSemantics; + } + } // MethodSemantics + + internal MethodSemanticsHandle[] _methodSemantics; + + /// One of: TypeDefinition, TypeReference, TypeSpecification, ConstantBooleanArray, ConstantBooleanValue, ConstantByteArray, ConstantByteValue, ConstantCharArray, ConstantCharValue, ConstantDoubleArray, ConstantDoubleValue, ConstantHandleArray, ConstantInt16Array, ConstantInt16Value, ConstantInt32Array, ConstantInt32Value, ConstantInt64Array, ConstantInt64Value, ConstantReferenceValue, ConstantSByteArray, ConstantSByteValue, ConstantSingleArray, ConstantSingleValue, ConstantStringArray, ConstantStringValue, ConstantUInt16Array, ConstantUInt16Value, ConstantUInt32Array, ConstantUInt32Value, ConstantUInt64Array, ConstantUInt64Value + public Handle DefaultValue + { + get + { + return _defaultValue; + } + } // DefaultValue + + internal Handle _defaultValue; + public IEnumerable<CustomAttributeHandle> CustomAttributes + { + get + { + return (IEnumerable<CustomAttributeHandle>)_customAttributes; + } + } // CustomAttributes + + internal CustomAttributeHandle[] _customAttributes; + } // Property + + /// <summary> + /// PropertyHandle + /// </summary> + public partial struct PropertyHandle + { + public override bool Equals(object obj) + { + if (obj is PropertyHandle) + return _value == ((PropertyHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(PropertyHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal PropertyHandle(Handle handle) : this(handle._value) + { + + } + + internal PropertyHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.Property || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.Property) << 24); + _Validate(); + } + + public static implicit operator Handle(PropertyHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public Property GetProperty(MetadataReader reader) + { + return reader.GetProperty(this); + } // GetProperty + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.Property) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // PropertyHandle + + /// <summary> + /// PropertySignature + /// </summary> + public partial struct PropertySignature + { + internal MetadataReader _reader; + internal PropertySignatureHandle _handle; + public PropertySignatureHandle Handle + { + get + { + return _handle; + } + } // Handle + + public CallingConventions CallingConvention + { + get + { + return _callingConvention; + } + } // CallingConvention + + internal CallingConventions _callingConvention; + public IEnumerable<CustomModifierHandle> CustomModifiers + { + get + { + return (IEnumerable<CustomModifierHandle>)_customModifiers; + } + } // CustomModifiers + + internal CustomModifierHandle[] _customModifiers; + + /// One of: TypeDefinition, TypeReference, TypeSpecification + public Handle Type + { + get + { + return _type; + } + } // Type + + internal Handle _type; + public IEnumerable<ParameterTypeSignatureHandle> Parameters + { + get + { + return (IEnumerable<ParameterTypeSignatureHandle>)_parameters; + } + } // Parameters + + internal ParameterTypeSignatureHandle[] _parameters; + } // PropertySignature + + /// <summary> + /// PropertySignatureHandle + /// </summary> + public partial struct PropertySignatureHandle + { + public override bool Equals(object obj) + { + if (obj is PropertySignatureHandle) + return _value == ((PropertySignatureHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(PropertySignatureHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal PropertySignatureHandle(Handle handle) : this(handle._value) + { + + } + + internal PropertySignatureHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.PropertySignature || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.PropertySignature) << 24); + _Validate(); + } + + public static implicit operator Handle(PropertySignatureHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public PropertySignature GetPropertySignature(MetadataReader reader) + { + return reader.GetPropertySignature(this); + } // GetPropertySignature + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.PropertySignature) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // PropertySignatureHandle + + /// <summary> + /// ReturnTypeSignature + /// </summary> + public partial struct ReturnTypeSignature + { + internal MetadataReader _reader; + internal ReturnTypeSignatureHandle _handle; + public ReturnTypeSignatureHandle Handle + { + get + { + return _handle; + } + } // Handle + + public IEnumerable<CustomModifierHandle> CustomModifiers + { + get + { + return (IEnumerable<CustomModifierHandle>)_customModifiers; + } + } // CustomModifiers + + internal CustomModifierHandle[] _customModifiers; + + /// One of: TypeDefinition, TypeReference, TypeSpecification + public Handle Type + { + get + { + return _type; + } + } // Type + + internal Handle _type; + } // ReturnTypeSignature + + /// <summary> + /// ReturnTypeSignatureHandle + /// </summary> + public partial struct ReturnTypeSignatureHandle + { + public override bool Equals(object obj) + { + if (obj is ReturnTypeSignatureHandle) + return _value == ((ReturnTypeSignatureHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ReturnTypeSignatureHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ReturnTypeSignatureHandle(Handle handle) : this(handle._value) + { + + } + + internal ReturnTypeSignatureHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ReturnTypeSignature || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ReturnTypeSignature) << 24); + _Validate(); + } + + public static implicit operator Handle(ReturnTypeSignatureHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ReturnTypeSignature GetReturnTypeSignature(MetadataReader reader) + { + return reader.GetReturnTypeSignature(this); + } // GetReturnTypeSignature + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ReturnTypeSignature) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ReturnTypeSignatureHandle + + /// <summary> + /// SZArraySignature + /// </summary> + public partial struct SZArraySignature + { + internal MetadataReader _reader; + internal SZArraySignatureHandle _handle; + public SZArraySignatureHandle Handle + { + get + { + return _handle; + } + } // Handle + + + /// One of: TypeDefinition, TypeReference, TypeSpecification + public Handle ElementType + { + get + { + return _elementType; + } + } // ElementType + + internal Handle _elementType; + } // SZArraySignature + + /// <summary> + /// SZArraySignatureHandle + /// </summary> + public partial struct SZArraySignatureHandle + { + public override bool Equals(object obj) + { + if (obj is SZArraySignatureHandle) + return _value == ((SZArraySignatureHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(SZArraySignatureHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal SZArraySignatureHandle(Handle handle) : this(handle._value) + { + + } + + internal SZArraySignatureHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.SZArraySignature || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.SZArraySignature) << 24); + _Validate(); + } + + public static implicit operator Handle(SZArraySignatureHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public SZArraySignature GetSZArraySignature(MetadataReader reader) + { + return reader.GetSZArraySignature(this); + } // GetSZArraySignature + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.SZArraySignature) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // SZArraySignatureHandle + + /// <summary> + /// ScopeDefinition + /// </summary> + public partial struct ScopeDefinition + { + internal MetadataReader _reader; + internal ScopeDefinitionHandle _handle; + public ScopeDefinitionHandle Handle + { + get + { + return _handle; + } + } // Handle + + public AssemblyFlags Flags + { + get + { + return _flags; + } + } // Flags + + internal AssemblyFlags _flags; + public ConstantStringValueHandle Name + { + get + { + return _name; + } + } // Name + + internal ConstantStringValueHandle _name; + public AssemblyHashAlgorithm HashAlgorithm + { + get + { + return _hashAlgorithm; + } + } // HashAlgorithm + + internal AssemblyHashAlgorithm _hashAlgorithm; + public ushort MajorVersion + { + get + { + return _majorVersion; + } + } // MajorVersion + + internal ushort _majorVersion; + public ushort MinorVersion + { + get + { + return _minorVersion; + } + } // MinorVersion + + internal ushort _minorVersion; + public ushort BuildNumber + { + get + { + return _buildNumber; + } + } // BuildNumber + + internal ushort _buildNumber; + public ushort RevisionNumber + { + get + { + return _revisionNumber; + } + } // RevisionNumber + + internal ushort _revisionNumber; + public IEnumerable<byte> PublicKey + { + get + { + return (IEnumerable<byte>)_publicKey; + } + } // PublicKey + + internal byte[] _publicKey; + public ConstantStringValueHandle Culture + { + get + { + return _culture; + } + } // Culture + + internal ConstantStringValueHandle _culture; + public NamespaceDefinitionHandle RootNamespaceDefinition + { + get + { + return _rootNamespaceDefinition; + } + } // RootNamespaceDefinition + + internal NamespaceDefinitionHandle _rootNamespaceDefinition; + public IEnumerable<CustomAttributeHandle> CustomAttributes + { + get + { + return (IEnumerable<CustomAttributeHandle>)_customAttributes; + } + } // CustomAttributes + + internal CustomAttributeHandle[] _customAttributes; + } // ScopeDefinition + + /// <summary> + /// ScopeDefinitionHandle + /// </summary> + public partial struct ScopeDefinitionHandle + { + public override bool Equals(object obj) + { + if (obj is ScopeDefinitionHandle) + return _value == ((ScopeDefinitionHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ScopeDefinitionHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ScopeDefinitionHandle(Handle handle) : this(handle._value) + { + + } + + internal ScopeDefinitionHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ScopeDefinition || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ScopeDefinition) << 24); + _Validate(); + } + + public static implicit operator Handle(ScopeDefinitionHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ScopeDefinition GetScopeDefinition(MetadataReader reader) + { + return reader.GetScopeDefinition(this); + } // GetScopeDefinition + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ScopeDefinition) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ScopeDefinitionHandle + + /// <summary> + /// ScopeReference + /// </summary> + public partial struct ScopeReference + { + internal MetadataReader _reader; + internal ScopeReferenceHandle _handle; + public ScopeReferenceHandle Handle + { + get + { + return _handle; + } + } // Handle + + public AssemblyFlags Flags + { + get + { + return _flags; + } + } // Flags + + internal AssemblyFlags _flags; + public ConstantStringValueHandle Name + { + get + { + return _name; + } + } // Name + + internal ConstantStringValueHandle _name; + public ushort MajorVersion + { + get + { + return _majorVersion; + } + } // MajorVersion + + internal ushort _majorVersion; + public ushort MinorVersion + { + get + { + return _minorVersion; + } + } // MinorVersion + + internal ushort _minorVersion; + public ushort BuildNumber + { + get + { + return _buildNumber; + } + } // BuildNumber + + internal ushort _buildNumber; + public ushort RevisionNumber + { + get + { + return _revisionNumber; + } + } // RevisionNumber + + internal ushort _revisionNumber; + public IEnumerable<byte> PublicKeyOrToken + { + get + { + return (IEnumerable<byte>)_publicKeyOrToken; + } + } // PublicKeyOrToken + + internal byte[] _publicKeyOrToken; + public ConstantStringValueHandle Culture + { + get + { + return _culture; + } + } // Culture + + internal ConstantStringValueHandle _culture; + public IEnumerable<CustomAttributeHandle> CustomAttributes + { + get + { + return (IEnumerable<CustomAttributeHandle>)_customAttributes; + } + } // CustomAttributes + + internal CustomAttributeHandle[] _customAttributes; + } // ScopeReference + + /// <summary> + /// ScopeReferenceHandle + /// </summary> + public partial struct ScopeReferenceHandle + { + public override bool Equals(object obj) + { + if (obj is ScopeReferenceHandle) + return _value == ((ScopeReferenceHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(ScopeReferenceHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal ScopeReferenceHandle(Handle handle) : this(handle._value) + { + + } + + internal ScopeReferenceHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.ScopeReference || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.ScopeReference) << 24); + _Validate(); + } + + public static implicit operator Handle(ScopeReferenceHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public ScopeReference GetScopeReference(MetadataReader reader) + { + return reader.GetScopeReference(this); + } // GetScopeReference + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.ScopeReference) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // ScopeReferenceHandle + + /// <summary> + /// TypeDefinition + /// </summary> + public partial struct TypeDefinition + { + internal MetadataReader _reader; + internal TypeDefinitionHandle _handle; + public TypeDefinitionHandle Handle + { + get + { + return _handle; + } + } // Handle + + public TypeAttributes Flags + { + get + { + return _flags; + } + } // Flags + + internal TypeAttributes _flags; + + /// One of: TypeDefinition, TypeReference, TypeSpecification + public Handle BaseType + { + get + { + return _baseType; + } + } // BaseType + + internal Handle _baseType; + public NamespaceDefinitionHandle NamespaceDefinition + { + get + { + return _namespaceDefinition; + } + } // NamespaceDefinition + + internal NamespaceDefinitionHandle _namespaceDefinition; + public ConstantStringValueHandle Name + { + get + { + return _name; + } + } // Name + + internal ConstantStringValueHandle _name; + public uint Size + { + get + { + return _size; + } + } // Size + + internal uint _size; + public uint PackingSize + { + get + { + return _packingSize; + } + } // PackingSize + + internal uint _packingSize; + public TypeDefinitionHandle EnclosingType + { + get + { + return _enclosingType; + } + } // EnclosingType + + internal TypeDefinitionHandle _enclosingType; + public IEnumerable<TypeDefinitionHandle> NestedTypes + { + get + { + return (IEnumerable<TypeDefinitionHandle>)_nestedTypes; + } + } // NestedTypes + + internal TypeDefinitionHandle[] _nestedTypes; + public IEnumerable<MethodHandle> Methods + { + get + { + return (IEnumerable<MethodHandle>)_methods; + } + } // Methods + + internal MethodHandle[] _methods; + public IEnumerable<FieldHandle> Fields + { + get + { + return (IEnumerable<FieldHandle>)_fields; + } + } // Fields + + internal FieldHandle[] _fields; + public IEnumerable<PropertyHandle> Properties + { + get + { + return (IEnumerable<PropertyHandle>)_properties; + } + } // Properties + + internal PropertyHandle[] _properties; + public IEnumerable<EventHandle> Events + { + get + { + return (IEnumerable<EventHandle>)_events; + } + } // Events + + internal EventHandle[] _events; + public IEnumerable<GenericParameterHandle> GenericParameters + { + get + { + return (IEnumerable<GenericParameterHandle>)_genericParameters; + } + } // GenericParameters + + internal GenericParameterHandle[] _genericParameters; + + /// One of: TypeDefinition, TypeReference, TypeSpecification + public IEnumerable<Handle> Interfaces + { + get + { + return (IEnumerable<Handle>)_interfaces; + } + } // Interfaces + + internal Handle[] _interfaces; + public IEnumerable<CustomAttributeHandle> CustomAttributes + { + get + { + return (IEnumerable<CustomAttributeHandle>)_customAttributes; + } + } // CustomAttributes + + internal CustomAttributeHandle[] _customAttributes; + } // TypeDefinition + + /// <summary> + /// TypeDefinitionHandle + /// </summary> + public partial struct TypeDefinitionHandle + { + public override bool Equals(object obj) + { + if (obj is TypeDefinitionHandle) + return _value == ((TypeDefinitionHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(TypeDefinitionHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal TypeDefinitionHandle(Handle handle) : this(handle._value) + { + + } + + internal TypeDefinitionHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.TypeDefinition || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.TypeDefinition) << 24); + _Validate(); + } + + public static implicit operator Handle(TypeDefinitionHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public TypeDefinition GetTypeDefinition(MetadataReader reader) + { + return reader.GetTypeDefinition(this); + } // GetTypeDefinition + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.TypeDefinition) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // TypeDefinitionHandle + + /// <summary> + /// TypeForwarder + /// </summary> + public partial struct TypeForwarder + { + internal MetadataReader _reader; + internal TypeForwarderHandle _handle; + public TypeForwarderHandle Handle + { + get + { + return _handle; + } + } // Handle + + public ScopeReferenceHandle Scope + { + get + { + return _scope; + } + } // Scope + + internal ScopeReferenceHandle _scope; + public ConstantStringValueHandle Name + { + get + { + return _name; + } + } // Name + + internal ConstantStringValueHandle _name; + public IEnumerable<TypeForwarderHandle> NestedTypes + { + get + { + return (IEnumerable<TypeForwarderHandle>)_nestedTypes; + } + } // NestedTypes + + internal TypeForwarderHandle[] _nestedTypes; + public IEnumerable<CustomAttributeHandle> CustomAttributes + { + get + { + return (IEnumerable<CustomAttributeHandle>)_customAttributes; + } + } // CustomAttributes + + internal CustomAttributeHandle[] _customAttributes; + } // TypeForwarder + + /// <summary> + /// TypeForwarderHandle + /// </summary> + public partial struct TypeForwarderHandle + { + public override bool Equals(object obj) + { + if (obj is TypeForwarderHandle) + return _value == ((TypeForwarderHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(TypeForwarderHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal TypeForwarderHandle(Handle handle) : this(handle._value) + { + + } + + internal TypeForwarderHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.TypeForwarder || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.TypeForwarder) << 24); + _Validate(); + } + + public static implicit operator Handle(TypeForwarderHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public TypeForwarder GetTypeForwarder(MetadataReader reader) + { + return reader.GetTypeForwarder(this); + } // GetTypeForwarder + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.TypeForwarder) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // TypeForwarderHandle + + /// <summary> + /// TypeInstantiationSignature + /// </summary> + public partial struct TypeInstantiationSignature + { + internal MetadataReader _reader; + internal TypeInstantiationSignatureHandle _handle; + public TypeInstantiationSignatureHandle Handle + { + get + { + return _handle; + } + } // Handle + + + /// One of: TypeDefinition, TypeReference, TypeSpecification + public Handle GenericType + { + get + { + return _genericType; + } + } // GenericType + + internal Handle _genericType; + + /// One of: TypeDefinition, TypeReference, TypeSpecification + public IEnumerable<Handle> GenericTypeArguments + { + get + { + return (IEnumerable<Handle>)_genericTypeArguments; + } + } // GenericTypeArguments + + internal Handle[] _genericTypeArguments; + } // TypeInstantiationSignature + + /// <summary> + /// TypeInstantiationSignatureHandle + /// </summary> + public partial struct TypeInstantiationSignatureHandle + { + public override bool Equals(object obj) + { + if (obj is TypeInstantiationSignatureHandle) + return _value == ((TypeInstantiationSignatureHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(TypeInstantiationSignatureHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal TypeInstantiationSignatureHandle(Handle handle) : this(handle._value) + { + + } + + internal TypeInstantiationSignatureHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.TypeInstantiationSignature || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.TypeInstantiationSignature) << 24); + _Validate(); + } + + public static implicit operator Handle(TypeInstantiationSignatureHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public TypeInstantiationSignature GetTypeInstantiationSignature(MetadataReader reader) + { + return reader.GetTypeInstantiationSignature(this); + } // GetTypeInstantiationSignature + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.TypeInstantiationSignature) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // TypeInstantiationSignatureHandle + + /// <summary> + /// TypeReference + /// </summary> + public partial struct TypeReference + { + internal MetadataReader _reader; + internal TypeReferenceHandle _handle; + public TypeReferenceHandle Handle + { + get + { + return _handle; + } + } // Handle + + + /// One of: NamespaceReference, TypeReference + public Handle ParentNamespaceOrType + { + get + { + return _parentNamespaceOrType; + } + } // ParentNamespaceOrType + + internal Handle _parentNamespaceOrType; + public ConstantStringValueHandle TypeName + { + get + { + return _typeName; + } + } // TypeName + + internal ConstantStringValueHandle _typeName; + public IEnumerable<CustomAttributeHandle> CustomAttributes + { + get + { + return (IEnumerable<CustomAttributeHandle>)_customAttributes; + } + } // CustomAttributes + + internal CustomAttributeHandle[] _customAttributes; + } // TypeReference + + /// <summary> + /// TypeReferenceHandle + /// </summary> + public partial struct TypeReferenceHandle + { + public override bool Equals(object obj) + { + if (obj is TypeReferenceHandle) + return _value == ((TypeReferenceHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(TypeReferenceHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal TypeReferenceHandle(Handle handle) : this(handle._value) + { + + } + + internal TypeReferenceHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.TypeReference || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.TypeReference) << 24); + _Validate(); + } + + public static implicit operator Handle(TypeReferenceHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public TypeReference GetTypeReference(MetadataReader reader) + { + return reader.GetTypeReference(this); + } // GetTypeReference + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.TypeReference) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // TypeReferenceHandle + + /// <summary> + /// TypeSpecification + /// </summary> + public partial struct TypeSpecification + { + internal MetadataReader _reader; + internal TypeSpecificationHandle _handle; + public TypeSpecificationHandle Handle + { + get + { + return _handle; + } + } // Handle + + + /// One of: TypeDefinition, TypeReference, TypeInstantiationSignature, SZArraySignature, ArraySignature, PointerSignature, ByReferenceSignature, TypeVariableSignature, MethodTypeVariableSignature + public Handle Signature + { + get + { + return _signature; + } + } // Signature + + internal Handle _signature; + public IEnumerable<CustomAttributeHandle> CustomAttributes + { + get + { + return (IEnumerable<CustomAttributeHandle>)_customAttributes; + } + } // CustomAttributes + + internal CustomAttributeHandle[] _customAttributes; + } // TypeSpecification + + /// <summary> + /// TypeSpecificationHandle + /// </summary> + public partial struct TypeSpecificationHandle + { + public override bool Equals(object obj) + { + if (obj is TypeSpecificationHandle) + return _value == ((TypeSpecificationHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(TypeSpecificationHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal TypeSpecificationHandle(Handle handle) : this(handle._value) + { + + } + + internal TypeSpecificationHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.TypeSpecification || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.TypeSpecification) << 24); + _Validate(); + } + + public static implicit operator Handle(TypeSpecificationHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public TypeSpecification GetTypeSpecification(MetadataReader reader) + { + return reader.GetTypeSpecification(this); + } // GetTypeSpecification + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.TypeSpecification) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // TypeSpecificationHandle + + /// <summary> + /// TypeVariableSignature + /// </summary> + public partial struct TypeVariableSignature + { + internal MetadataReader _reader; + internal TypeVariableSignatureHandle _handle; + public TypeVariableSignatureHandle Handle + { + get + { + return _handle; + } + } // Handle + + public int Number + { + get + { + return _number; + } + } // Number + + internal int _number; + } // TypeVariableSignature + + /// <summary> + /// TypeVariableSignatureHandle + /// </summary> + public partial struct TypeVariableSignatureHandle + { + public override bool Equals(object obj) + { + if (obj is TypeVariableSignatureHandle) + return _value == ((TypeVariableSignatureHandle)obj)._value; + else if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } // Equals + + public bool Equals(TypeVariableSignatureHandle handle) + { + return _value == handle._value; + } // Equals + + public bool Equals(Handle handle) + { + return _value == handle._value; + } // Equals + + public override int GetHashCode() + { + return (int)_value; + } // GetHashCode + + internal int _value; + internal TypeVariableSignatureHandle(Handle handle) : this(handle._value) + { + + } + + internal TypeVariableSignatureHandle(int value) + { + HandleType hType = (HandleType)(value >> 24); + if (!(hType == 0 || hType == HandleType.TypeVariableSignature || hType == HandleType.Null)) + throw new ArgumentException(); + _value = (value & 0x00FFFFFF) | (((int)HandleType.TypeVariableSignature) << 24); + _Validate(); + } + + public static implicit operator Handle(TypeVariableSignatureHandle handle) + { + return new Handle(handle._value); + } // Handle + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } // Offset + + public TypeVariableSignature GetTypeVariableSignature(MetadataReader reader) + { + return reader.GetTypeVariableSignature(this); + } // GetTypeVariableSignature + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } // IsNull + + public Handle ToHandle(MetadataReader reader) + { + return reader.ToHandle(this); + } // ToHandle + + [System.Diagnostics.Conditional("DEBUG")] + internal void _Validate() + { + if ((HandleType)((_value & 0xFF000000) >> 24) != HandleType.TypeVariableSignature) + throw new ArgumentException(); + } // _Validate + + public override String ToString() + { + return String.Format("{0:X8}", _value); + } // ToString + } // TypeVariableSignatureHandle +} // Internal.Metadata.NativeFormat diff --git a/src/Common/src/Internal/Metadata/NativeFormat/NativeMetadataReader.cs b/src/Common/src/Internal/Metadata/NativeFormat/NativeMetadataReader.cs new file mode 100644 index 000000000..b0519c4a9 --- /dev/null +++ b/src/Common/src/Internal/Metadata/NativeFormat/NativeMetadataReader.cs @@ -0,0 +1,264 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + + +#pragma warning disable 169 + +// There is no defined ordering between fields in multiple declarations of partial class or struct +#pragma warning disable 282 + + +using System; +using System.IO; +using System.Collections.Generic; +using System.Reflection; +using System.Runtime.CompilerServices; +using Internal.NativeFormat; + +namespace Internal.Metadata.NativeFormat +{ + // This Enum matches CorMethodSemanticsAttr defined in CorHdr.h + [Flags] + public enum MethodSemanticsAttributes + { + Setter = 0x0001, + Getter = 0x0002, + Other = 0x0004, + AddOn = 0x0008, + RemoveOn = 0x0010, + Fire = 0x0020, + } + + // This Enum matches CorPInvokeMap defined in CorHdr.h + [Flags] + public enum PInvokeAttributes + { + NoMangle = 0x0001, + + CharSetMask = 0x0006, + CharSetNotSpec = 0x0000, + CharSetAnsi = 0x0002, + CharSetUnicode = 0x0004, + CharSetAuto = 0x0006, + + BestFitUseAssem = 0x0000, + BestFitEnabled = 0x0010, + BestFitDisabled = 0x0020, + BestFitMask = 0x0030, + + ThrowOnUnmappableCharUseAssem = 0x0000, + ThrowOnUnmappableCharEnabled = 0x1000, + ThrowOnUnmappableCharDisabled = 0x2000, + ThrowOnUnmappableCharMask = 0x3000, + + SupportsLastError = 0x0040, + + CallConvMask = 0x0700, + CallConvWinapi = 0x0100, + CallConvCdecl = 0x0200, + CallConvStdcall = 0x0300, + CallConvThiscall = 0x0400, + CallConvFastcall = 0x0500, + + MaxValue = 0xFFFF, + } + + public partial struct Handle : IHandle + { + public override bool Equals(Object obj) + { + if (obj is Handle) + return _value == ((Handle)obj)._value; + else + return false; + } + + public bool Equals(Handle handle) + { + return _value == handle._value; + } + + public override int GetHashCode() + { + return (int)_value; + } + + internal Handle(int value) + { + _value = value; + } + + internal void Validate(params HandleType[] permittedTypes) + { + var myHandleType = (HandleType)(_value >> 24); + foreach (var hType in permittedTypes) + { + if (myHandleType == hType) + { + return; + } + } + if (myHandleType == HandleType.Null) + { + return; + } + throw new ArgumentException("Invalid handle type"); + } + + public Handle(HandleType type, int offset) + { + _value = (int)type << 24 | (int)offset; + } + + internal HandleType HandleType + { + get + { + return (HandleType)(_value >> 24); + } + } + + internal int Offset + { + get + { + return (this._value & 0x00FFFFFF); + } + } + + public HandleType GetHandleType(MetadataReader reader) + { + return (reader as MetadataReader).GetHandleType(this); + } + + public bool IsNull(MetadataReader reader) + { + return reader.IsNull(this); + } + + internal int _value; + + public override string ToString() + { + return String.Format("{1} : {0,8:X8}", _value, Enum.GetName(typeof(HandleType), this.HandleType)); + } + } + + public static class NativeFormatReaderExtensions + { + public static string GetString(this MetadataReader reader, ConstantStringValueHandle handle) + { + return reader.GetConstantStringValue(handle).Value; + } + } + + /// <summary> + /// ConstantReferenceValue can only be used to encapsulate null reference values, + /// and therefore does not actually store the value. + /// </summary> + public partial struct ConstantReferenceValue + { + /// Always returns null value. + public Object Value + { get { return null; } } + } // ConstantReferenceValue + + public partial struct ConstantStringValueHandle + { + public bool StringEquals(string value, MetadataReader reader) + { + return reader.StringEquals(this, value); + } + } + + public sealed partial class MetadataReader : IMetadataReader + { + private MetadataHeader _header; + + internal NativeReader _streamReader; + + // Creates a metadata reader on a memory-mapped file block + public unsafe MetadataReader(IntPtr pBuffer, int cbBuffer) + { + _streamReader = new NativeReader((byte*)pBuffer, (uint)cbBuffer); + + _header = new MetadataHeader(); + _header.Decode(_streamReader); + } + + /// <summary> + /// Used as the root entrypoint for metadata, this is where all top-down + /// structural walks of metadata must start. + /// </summary> + public IEnumerable<ScopeDefinitionHandle> ScopeDefinitions + { + get + { + return _header.ScopeDefinitions; + } + } + + /// <summary> + /// Fetches the HandleType from a given Handle. + /// </summary> + public HandleType GetHandleType(Handle handle) + { + return (HandleType)(handle._value >> 24); + } + + /// <summary> + /// Returns a Handle value representing the null value. Can be used + /// to test handle values of all types for null. + /// </summary> + public Handle NullHandle + { + get + { + return new Handle() { _value = ((int)HandleType.Null) << 24 }; + } + } + + /// <summary> + /// Returns true if handle is null. + /// </summary> + public bool IsNull(Handle handle) + { + return handle._value == NullHandle._value; + } + + /// <summary> + /// Idempotent - simply returns the provided handle value. Exists for + /// consistency so that generated code does not need to handle this + /// as a special case. + /// </summary> + public Handle ToHandle(Handle handle) + { + return handle; + } + + internal bool StringEquals(ConstantStringValueHandle handle, string value) + { + return _streamReader.StringEquals((uint)handle.Offset, value); + } + } + + internal partial class MetadataHeader + { + /// <todo> + /// Signature should be updated every time the metadata schema changes. + /// </todo> + public const uint Signature = 0xDEADDFFD; + + /// <summary> + /// The set of ScopeDefinitions contained within this metadata resource. + /// </summary> + public ScopeDefinitionHandle[] ScopeDefinitions; + + public void Decode(NativeReader reader) + { + if (reader.ReadUInt32(0) != Signature) + reader.ThrowBadImageFormatException(); + reader.Read(4, out ScopeDefinitions); + } + } +} diff --git a/src/Common/src/Internal/Metadata/NativeFormat/Script/CsCommonGen2.py b/src/Common/src/Internal/Metadata/NativeFormat/Script/CsCommonGen2.py new file mode 100644 index 000000000..1f3a6650c --- /dev/null +++ b/src/Common/src/Internal/Metadata/NativeFormat/Script/CsCommonGen2.py @@ -0,0 +1,1006 @@ +# Copyright (c) Microsoft. All rights reserved. +# Licensed under the MIT license. See LICENSE file in the project root for full license information. + +""" +Defines classes that can be used to build up a set of symbols similar to those of C# +(namespace, type, method, property, etc.) that may be manipulated and subsequently +emitted as C# source code. +""" + +import sys +import re +import copy +import itertools +from odict import odict + +#========================================================================================================== +def classinit(cls, realcls = None): + """ + Automatically initialize a class by calling __clsinit__ if it exists on cls and its base types. + Currently used to implement class static initialization, and in particular the Flags functionality. + """ + for base in cls.__bases__: + classinit(base, cls) + f = getattr(cls, '__clsinit__', None) + if f: + f.__func__(realcls or cls) + return cls + +#========================================================================================================== +class Flags(int): + """ + Base class for easily defining sets of flags. Values should be added within a __clsinit__ method. + """ + + def __apply_op(self, op, other): + if isinstance(other, type(self)): + return type(other)(op(int(self), int(other))) + elif isinstance(self, type(other)): + return type(self)(op(int(self), int(other))) + else: + raise Exception('Incompatible flag types.') + + def __init__(self, value = 0): + """ Used to construct an instance object with value 'value' """ + super(Flags, self).__init__(int(value)) + + def __or__(self, other): + return self.__apply_op(int.__or__, other) + + def __xor__(self, other): + return self.__apply_op(int.__xor__, other) + + def __and__(self, other): + return self.__apply_op(int.__and__, other) + + def __invert__(self): + return type(self)(~(int(self))) + + @classmethod + def __clsinit__(cls): + """ Creates internal structures to track flag values. """ + cls.__values = list() + cls.__masks = list() + cls.__next_value = 0x1 + + @classmethod + def AddFlag(cls, name): + """ Add a flag value. Adds attribute '<name>' instance method 'Is<name>'. """ + value = cls.__next_value + cls.__next_value = cls.__next_value << 1 + cls.__values.append((name, value)) + setattr(cls, name, cls(value)) + def isFn(self): + return (self & getattr(cls, name)) != 0 + setattr(cls, 'Is' + name, isFn) + + @classmethod + def AddMask(cls, name, *args): + """ Create a mask from a set of flag names. Adds attribute '<name>Mask' and function 'Is<name>'. """ + value = 0 + for arg in args: + value = value | getattr(cls, arg) + cls.__masks.append((name + 'Mask', value)) + setattr(cls, name + 'Mask', cls(value)) + def isFn(self): + return (self & getattr(cls, name + 'Mask')) != 0 + setattr(cls, 'Is' + name, isFn) + + def __str__(self): + """ Returns a textual representation of the set flag values. """ + return '(' + '|'.join(map(lambda (n,f): n, filter(lambda (n,f): (self & f), self.__values))) + ')' + + @classmethod + def iterflags(cls): + return cls.__values.__iter__() + + @classmethod + def itermasks(cls): + return cls.__masks.__iter__() + +#========================================================================================================== +class StrictlyType(object): + """Returns a strictly typed function""" + def __init__(self,*args): + self.args = args + def __call__(self, f): + def func(*args, **kv): + for a in zip(args[1:min(len(args), len(self.args))] if len(args) == len(self.args) + 1 else args[min(len(args), len(self.args)):], self.args): + if a[1] != None and not isinstance(a[0], a[1]): + raise TypeError, 'Expected %s, got %s (%s)' % (a[1], type(a[0]), a[0]) + v = f(*args, **kv) + return v + func.func_name = f.func_name + return func + +#========================================================================================================== +class IPrint: + def __init__(self, *args): + self.output = None + self.cur_indent = 0 + self.parent = None + self.addWhitespace = False + self.pendingWhitespace = False + + for arg in args: + if isinstance(arg, int): + self.cur_indent += arg + elif isinstance(arg, IPrint): + self.parent = arg + self.output = arg.output + self.cur_indent += arg.cur_indent + 1 + self.addWhitespace = False + self.pendingWhitespace = False + elif isinstance(arg, file): + self.output = arg + + if not self.output: + self.output = sys.stdout + + def __write(self, *args, **kv): + indent = 0 + + if len(args) == 0: return '' + elif len(args) == 1: (arg,) = args + elif len(args) == 2: (indent, arg) = args + elif len(args) > 2: raise Exception('Invalid arguments') + + indent += self.cur_indent + + isFirst = True + outstr = '\n' if self.pendingWhitespace and self.addWhitespace else '' + self.pendingWhitespace = False + for line in map(lambda a: a.rstrip(), arg.split('\n')): + if not isFirst: outstr += '\n' + if (not isFirst) or ('indentFirstLine' not in kv) or (kv['indentFirstLine']): + outstr += ' ' * (indent * 4) + outstr += line.rstrip() + isFirst = False + outstr = outstr.rstrip() + if arg.endswith('\n'): + outstr += '\n' + self.addWhitespace = True + return outstr + + def append(self, *args, **kv): + self.output.write(self.__write(indentFirstLine = False, *args, **kv)) + + def write(self, *args, **kv): + self.output.write(self.__write(*args, **kv)) + + def writeline(self, *args, **kv): + self.output.write(self.__write(*args, **kv)) + self.output.write('\n') + + def __call__(self, *args): + return self.writeline(*args) + + def indent(self): + return IPrint(self) + + def outdent(self): + return self.parent + + def AddWhitespace(self): + self.pendingWhitespace = True + p = self.parent + while p: + p.addWhitespace = True + p = p.parent + + +#========================================================================================================== +# @classinit +class AccessFlags(Flags): + def __init__(self, value): + super(AccessFlags, self).__init__(value) + + @classmethod + def __clsinit__(cls): + cls.AddFlag('Public') + cls.AddFlag('Internal') + cls.AddFlag('Protected') + cls.AddFlag('Private') + cls.AddMask('Visibility', 'Public', 'Internal', 'Protected', 'Private') + cls.All = cls.VisibilityMask + cls.AddFlag('CsExclude') +classinit(AccessFlags) + +#========================================================================================================== +# @classinit +class MemberFlags(AccessFlags): + def __init__(self, value): + super(MemberFlags, self).__init__(value) + + @classmethod + def __clsinit__(cls): + cls.AddFlag('Static') + cls.AddFlag('Method') + cls.AddFlag('Property') + cls.AddMask('Type', 'Method', 'Property') + cls.AddFlag('Override') + cls.AddFlag('Serialize') + cls.AddFlag('Explicit') + cls.AddFlag('Implicit') + cls.AddFlag('Operator') + cls.AddFlag('Abstract') + cls.AddFlag('Partial') + cls.AddFlag('Virtual') + cls.AddFlag('Extension') + cls.AddFlag('New') + cls.AddFlag('DebugOnly') + cls.AddFlag('Sealed') +classinit(MemberFlags) + + +#========================================================================================================== +# @classinit +class TypeFlags(AccessFlags): + def __init__(self, value): + super(TypeFlags, self).__init__(value) + + @classmethod + def __clsinit__(cls): + cls.AddFlag('Class') + cls.AddFlag('Struct') + cls.AddFlag('Interface') + cls.AddFlag('Enum') + cls.AddMask('Type', 'Class', 'Struct', 'Interface', 'Enum') + cls.AddFlag('Abstract') + cls.AddFlag('Partial') + cls.AddFlag('Static') + cls.AddFlag('Array') +classinit(TypeFlags) + +#========================================================================================================== +# @classinit +class EnumFlags(TypeFlags): + def __init__(self, value): + super(EnumFlags, self).__init__(value) + + @classmethod + def __clsinit__(cls): + cls.AddFlag('HasFlagValues') +classinit(EnumFlags) + +#========================================================================================================== +class CsScopeBlock(object): + def __init__(self, iprint): + self.iprint = iprint + + def __enter__(self): + self.iprint('{') + self.iprint.cur_indent += 1 + + def __exit__(self, exc_type, exc_value, traceback, comment = None): + self.iprint.cur_indent -= 1 + if comment: + self.iprint('}} // {0}'.format(comment)) + else: + self.iprint('}') + +#========================================================================================================== +class CsNamespace(CsScopeBlock): + def __init__(self, iprint, name): + super(CsNamespace, self).__init__(iprint) + self.name = name + + def __enter__(self): + self.iprint('\nnamespace {0}'.format(self)) + super(CsNamespace, self).__enter__() + + def __exit__(self, exc_type, exc_value, traceback): + super(CsNamespace, self).__exit__(exc_type, exc_value, traceback, 'namespace ' + str(self)) + + def __str__(self): + return self.name + +#========================================================================================================== +def CsMakePrivateName(name): + name = str(name) + if re.match(r'[A-Z][a-z0-9_]', name): + return '_' + name[0].lower() + name[1:] + else: + return '_' + name + +#========================================================================================================== +def CsMakeArgumentName(name): + name = str(name) + if re.match(r'I[A-Z][a-z0-9_]', name): + return name[1].lower() + name[2:] + else: + return name[0].lower() + name[1:] + +#========================================================================================================== +def CsAccessKeyword(flags): + if flags & AccessFlags.Public: + return 'public' + elif flags & AccessFlags.Internal: + return 'internal' + elif flags & AccessFlags.Protected: + return 'protected' + elif flags & AccessFlags.Private: + return 'private' + else: + return '' + +#========================================================================================================== + + +#========================================================================================================== +def CsMemberDeclaration(m): + out = [] + if m.flags & MemberFlags.Partial: + return 'partial' + if '.' not in str(m) and not m.parentScope.IsInterface(): + out.append(m.CsVisibility()) + if m.flags & MemberFlags.Static: + out.append('static') + if m.flags & MemberFlags.Explicit: + out.append('explicit') + if m.flags & MemberFlags.Implicit: + out.append('implicit') + if m.flags & MemberFlags.Virtual: + out.append('virtual') + if m.flags & MemberFlags.Operator: + out.append('operator') + if m.flags & MemberFlags.New: + out.append('new') + if not m.parentScope.IsInterface(): + if m.flags & MemberFlags.Override: + out.append('override') + if m.flags & MemberFlags.Abstract: + out.append('abstract') + if m.flags & MemberFlags.Sealed: + out.append('sealed') + return ' '.join(out) + +#========================================================================================================== +def Singular(x): + if x == 'MethodSemantics': + return x + elif x.endswith('ies'): + return x[:-3] + 'y' + elif x.endswith('ses'): + return x[:-3] + elif x.endswith('s'): + return x[:-1] + else: + return x + +#========================================================================================================== +def Plural(x): + x = Singular(x) + if x == 'MethodSemantics': + return x + elif x.endswith('y'): + return x[:-1] + 'ies' + elif x.endswith('s'): + return x + 'ses' + else: + return x + 's' + +#========================================================================================================== +def CsEmitFileHeader(iprint): + iprint( +'''// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +// NOTE: This is a generated file - do not manually edit! +''') + +#========================================================================================================== +class MemberSet(object): + def __init__(self, parentScope, *args, **kv): + self.__dict = odict() + self.parentScope = parentScope + + def add(self, item): + if item == None: + return + item.parentScope = self.parentScope + self.__dict.setdefault(str(item), list()).append(item) + return item + + def clear(self): + self.__dict.clear() + + def __iadd__(self, iter): + for item in iter: + self.add(item) + return self + + def __iter__(self): + return itertools.chain(*self.__dict.values()) + + def __getitem__(self, name): + val = self.__dict.get(name) + if type(val) != str and len(val) == 1: + return val[0] + else: + return val + + def __len__(self): + return len(self.__dict) + +#========================================================================================================== +class TypeDefOrRef(object): + def __init__(self, name, comment = None, typeParams = None, **kv): + if type(name) != str: + raise Exception('Must provide name for type.') + self.name = name + self.comment = comment + self.typeParams = typeParams or [] + for n,v in kv.iteritems(): + setattr(self, n, v) + + def UnderlyingType(self): + return getattr(self, 'underlyingType', self) + + def ElementType(self): + return getattr(self, 'elementType', self) + + def IsGeneric(self): + return len(self.typeParams) != 0 + + def Instantiate(self, *args): + if not self.IsGeneric(): + raise Exception('Attempt to instantiate non-generic type.') + return TypeInst(self, *args) + + def __str__(self): + return self.name + +#========================================================================================================== +class TypeRef(TypeDefOrRef): + def __init__(self, *args, **kv): + super(TypeRef, self).__init__(*args, **kv) + + def CsDefine(self, iprint): + pass + + def CsComment(self, iprint): + pass + +#========================================================================================================== +class TypeDef(TypeDefOrRef): + def __init__(self, name, baseType = None, flags = AccessFlags.Public, + typeParams = None, interfaces = None, members = None, + underlyingType = None, comment = None, **kv): + super(TypeDef, self).__init__(name, typeParams = typeParams or [], **kv) + if not (flags & AccessFlags.VisibilityMask): + flags = flags | AccessFlags.Public + self.flags = TypeFlags(flags) + if type(baseType) == str: + baseType = TypeRef(baseType) + self.interfaces = interfaces or list() + if self.IsInterface() and baseType: + self.interfaces.append(baseType) + baseType = None + self.baseType = baseType + self.members = MemberSet(self) + if members: + self.members += members + self.parentScope = None + if type(underlyingType) == str: + underlyingType = TypeRef(underlyingType) + self.underlyingType = underlyingType or self + self.comment = comment + + def CsDefine(self, iprint): + # If this is a struct and there is a base type specified, fold the base + # type members into the child + if self.flags.IsStruct() and self.baseType != None: + self.members += getattr(self.baseType, 'members', []) + self.baseType = None + + # self.CsComment(iprint) + self.CsDefineHeader(iprint) + self.CsDefineBegin(iprint) + self.CsDefineMembers(iprint.indent()) + self.CsDefineEnd(iprint) + + def CsComment(self, iprint): + if self.comment: + iprint('\n/// ' + self.comment) + + def CsTypeName(self): + return str(self) + + def CsDefineHeader(self, iprint): + iprint( +'''/// <summary> +/// {}{} +/// </summary>'''.format(self, ' : ' + self.comment if self.comment else '')) + + def __CsTypeDeclaration(self): + out = [CsAccessKeyword(self.flags)] + if not self.IsInterface(): + if self.flags & TypeFlags.Abstract: + out += ['abstract'] + if self.flags & TypeFlags.Static: + out += ['static'] + if self.flags & TypeFlags.Partial: + out += ['partial'] + if (self.flags & TypeFlags.TypeMask) == TypeFlags.Class: + out += ['class'] + elif (self.flags & TypeFlags.TypeMask) == TypeFlags.Struct: + out += ['struct'] + elif (self.flags & TypeFlags.TypeMask) == TypeFlags.Interface: + out += ['interface'] + elif (self.flags & TypeFlags.TypeMask) == TypeFlags.Enum: + out += ['enum'] + out += [self.CsTypeName()] + return ' '.join(out) + + def CsDefineBegin(self, iprint): + iprint.write(self.__CsTypeDeclaration()) + if self.flags.IsArray(): + iprint.append('[]') + if self.typeParams: + iprint.append('<{0}>'.format(', '.join(self.typeParams))) + if self.baseType or self.interfaces: + lst = map(lambda t: str(t), ([self.baseType] if self.baseType else []) + (self.interfaces or [])) + iprint.append(' : {0}'.format(', '.join(lst))) + del(lst) + iprint() + iprint('{') + + def CsDefineMembers(self, iprint): + members = list() + + if self.IsStruct() and self.baseType: + members += filter(lambda t: not isinstance(t, CtorDef), getattr(self.baseType, 'members', [])) + + members += self.members + + if self.IsInterface(): + members = filter(lambda m: not isinstance(m, FieldDef), members) + + for m in members: + m.CsDefine(iprint) + if not (isinstance(m, FieldDef) or (m.flags & MemberFlags.Abstract)): + iprint.AddWhitespace() + + def CsDefineEnd(self, iprint): + iprint('}} // {0}'.format(self)) + + def FullName(self): + if self.parentScope: + return str(self.parentScope) + '.' + str(self) + else: + return str(self) + + def IsInterface(self): + return self.flags & TypeFlags.Interface + + def IsStruct(self): + return self.flags & TypeFlags.Struct + + def IsClass(self): + return self.flags & TypeFlags.Class + + def IsEnum(self): + return self.flags & TypeFlags.Enum + + def CsVisibility(self): + return CsAccessKeyword(self.flags) + + def __str__(self): + name = super(TypeDef, self).__str__() + if self.IsInterface(): + if not name.startswith('I') or (name[1] != name[1].upper()): + return 'I' + name + return name + +#========================================================================================================== +def ClassDef(*args, **kv): + t = TypeDef(*args, **kv) + t.flags = TypeFlags((t.flags & ~TypeFlags.TypeMask) | TypeFlags.Class) + return t + +#========================================================================================================== +def StructDef(*args, **kv): + t = TypeDef(*args, **kv) + t.flags = TypeFlags((t.flags & ~TypeFlags.TypeMask) | TypeFlags.Struct) + return t + +#========================================================================================================== +def InterfaceDef(*args, **kv): + t = TypeDef(*args, **kv) + t.flags = TypeFlags((t.flags & ~TypeFlags.TypeMask) | TypeFlags.Interface) + return t + +#========================================================================================================== +class TypeInst(TypeDefOrRef): + def __init__(self, genericType, *typeArgs): + if not typeArgs: + raise Exception('Invalid type instantiation.') + while isinstance(genericType, TypeInst): + typeArgs = genericType.typeArgs + typeArgs + genericType = genericType.genericType + if not isinstance(genericType, TypeDef): + raise Exception('Invalid argument: genericType') + self.genericType = genericType + self.typeArgs = typeArgs + + def __str__(self): + if len(self.genericType.typeParams) != len(self.typeArgs): + raise Exception('Incomplete type instantiation: {0}<{1}> / {0}<{2}>'.format(self.genericType, self.genericType.typeParams, map(lambda a: str(a), self.typeArgs))) + return str(self.genericType) + '<{0}>'.format(', '.join(map(lambda a: str(a), self.typeArgs))) + +#========================================================================================================== +class MemberDefBase(object): + @StrictlyType(str, None) + def __init__(self, name, flags, comment = None): + self.name = name + self.flags = flags + self.comment = comment + + def __str__(self): + return self.name + + def CsDefineHeader(self, iprint): + iprint( +'''/// <summary> +/// {} +/// </summary>'''.format(self)) + + def CsDefine(self, iprint): + self.CsComment(iprint) + self.CsDefineMember(iprint) + + def CsComment(self, iprint): + if self.comment: + iprint('\n/// ' + self.comment) + + def CsDefineMember(self, iprint): + pass + + def CsVisibility(self): + if '.' in str(self): + return '' + else: + return CsAccessKeyword(self.flags) + +#========================================================================================================== +class FieldDef(MemberDefBase): + def __init__(self, name, fieldType, flags = AccessFlags.Public, autoInitialize = False, *args, **kv): + if not isinstance(fieldType, TypeDefOrRef): + raise Exception('Invalid field type: {0}'.format(type(fieldType))) + super(FieldDef, self).__init__(name, flags, *args, **kv) + if type(fieldType) == str: + fieldType = TypeDef(fieldType) + self.fieldType = fieldType + self.autoInitialize = autoInitialize + + def CsDefineMember(self, iprint): + decl = ' '.join([self.CsVisibility(), str(self.fieldType), str(self)]) + if self.autoInitialize: + decl += ' = new {0}()'.format(self.fieldType) + decl += ';' + iprint(decl) + +#========================================================================================================== +class EmptyArrayDef(MemberDefBase): + def __init__(self, name, fieldType, flags = AccessFlags.Public, *args, **kv): + super(EmptyArrayDef, self).__init__(name, flags, *args, **kv) + self.fieldType = fieldType + + def CsDefineMember(self, iprint): + decl = self.CsVisibility() + ' static ' + str(self.fieldType) + '[]' + ' ' + str(self) + decl += ' = new ' + str(self.fieldType) + '[0];'; + iprint(decl) + +#========================================================================================================== +def ShouldEmitMethodBody(m): + if m.flags & MemberFlags.Abstract: + return False + elif m.flags & MemberFlags.Partial: + return False + # elif m.parentScope.flags & TypeFlags.Abstract: + # return False + elif m.parentScope.flags & TypeFlags.Interface: + return False + else: + return True + +#========================================================================================================== +class PropertyDef(MemberDefBase): + def __init__(self, name, propertyType, flags = AccessFlags.Public, getter = None, setter = None, field = None, *args, **kv): + super(PropertyDef, self).__init__(name, flags, *args, **kv) + self.propertyType = propertyType + if not getter and not setter: + getter = PropertyGetter() + setter = PropertySetter() + self.getter = getter + self.setter = setter + self.field = field + if self.field: + if self.getter: + self.getter.body = 'return {0};'.format(field) + if self.setter: + self.setter.body = '{0} = value;'.format(field) + + def CsDefineMember(self, iprint): + iprint(' '.join([CsMemberDeclaration(self), str(self.propertyType), str(self)]).strip()) + iprint('{') + for op in filter(lambda op: op != None, [self.getter, self.setter]): + op.parentScope = self + iprint.write(1, ' '.join([op.CsVisibility() if self.flags != op.flags else '', str(op)]).strip()) + if op.body and ShouldEmitMethodBody(self): + iprint.append('\n') + iprint(1, '{') + iprint(2, op.body.strip()) + iprint(1, '}') + else: + iprint.append(';\n') + iprint('}} // {}'.format(self)) + +#========================================================================================================== +class PropertyOp(object): + def __init__(self, name, flags = AccessFlags.Public, body = None): + self.name = name + self.flags = flags + self.body = body + + def __str__(self): + return self.name + + def CsVisibility(self): + if (self.parentScope.flags & AccessFlags.Public) == 0: + return '' + elif (self.flags & AccessFlags.All) != (self.parentScope.flags & AccessFlags.All): + return CsAccessKeyword(self.flags) + else: + return '' + +#========================================================================================================== +class PropertyGetter(PropertyOp): + def __init__(self, flags = AccessFlags.Public, body = None): + super(PropertyGetter, self).__init__('get', flags, body) + +#========================================================================================================== +class PropertySetter(PropertyOp): + def __init__(self, flags = AccessFlags.Public, body = None): + super(PropertySetter, self).__init__('set', flags, body) + +#========================================================================================================== +class MethodDef(MemberDefBase): + def __init__(self, name, flags = AccessFlags.Public, sig = ['void', []], + body = 'throw new NotImplementedException();', typeParams = None, + constraints = None): + super(MethodDef, self).__init__(name, flags) + self.sig = sig + self.body = body + self.typeParams = typeParams + self.constraints = constraints + if flags & MemberFlags.Extension: + self.flags = MemberFlags(flags | MemberFlags.Static) + + def __str__(self): + if self.typeParams: + return self.name + '<' + ', '.join(typeParams) + '>' + else: + return self.name + + def IsGeneric(self): + return self.typeParams != None + + def ReturnType(self): + return str(self.sig[0] or '') + + def Parameters(self): + params = '(' + if self.flags & MemberFlags.Extension: + params += 'this ' + params += ', '.join([' '.join(map(lambda a: str(a), a)) for a in self.sig[1]]) + params += ')' + return params + + def TypeParameters(self): + return '<' + ', '.join([str(x) for x in self.typeParams]) + '>' + + def CsDefineBody(self, iprint): + if self.body != None and ShouldEmitMethodBody(self): + iprint.append('\n') + iprint('{') + iprint(1, self.body.strip()) + iprint('}} // {}'.format(self)) + else: + iprint.append(';\n') + + def CsDefineMember(self, iprint): + if self.flags & MemberFlags.DebugOnly: + iprint('[System.Diagnostics.Conditional("DEBUG")]') + super(MethodDef, self).CsDefineMember(iprint) + decl = [CsMemberDeclaration(self), self.ReturnType(), self] + if self.IsGeneric(): + decl += [self.TypeParameters()] + if self.constraints: + for constraint in self.constraints: + decl.append('where {0} : {1}'.format(*constraint)) + iprint.write(' '.join(map(lambda i: str(i).strip(), decl)).strip() + self.Parameters()) + self.CsDefineBody(iprint) + + def CsDefineHeader(self, iprint): + iprint(''' +/// <summary> +/// {} +/// </summary>'''.format(self)) + + for pType,pName in self.sig[1]: + iprint('/// <param name="{}"></param>'.format(pName)) + if self.sig[0] and str(self.sig[0]) != 'void': + iprint('/// <returns></returns>') + +#========================================================================================================== +class CtorDef(MethodDef): + def __init__(self, flags = AccessFlags.Public, sig = [], + body = 'throw new NotImplementedException();', typeParams = None, + ctorDelegation = None): + super(CtorDef, self).__init__('.ctor', flags, [None, sig], body) + self.name = None + self.ctorDelegation = ctorDelegation + + def __str__(self): + return str(self.parentScope) + + def CsDefineMember(self, iprint): + if (self.flags & AccessFlags.Public) and not self.body: + return + + decl = [CsMemberDeclaration(self), self] + if self.IsGeneric(): + decl += [self.TypeParameters()] + ctorDel = '' + if self.ctorDelegation: + ctorDel = ' : this(' + ', '.join(self.ctorDelegation) + ')' + iprint.write(' '.join(map(lambda i: str(i).strip(), decl)) + self.Parameters() + ctorDel) + if ShouldEmitMethodBody(self): + iprint.append('\n') + iprint('{') + iprint(1, self.body.strip()) + iprint('}') + else: + iprint.append(';\n') + +#========================================================================================================== +class MethodInst(object): + def __init__(self, methodDef, typeArgs): + if typeArgs and type(typeArgs) != list: + typeArgs = [typeArgs] + if (not typeArgs) or (type(typeArgs) != list): + raise Exception('Invalid type instantiation.') + while isinstance(methodDef, MethodInst): + methodDef = methodDef.methodDef + typeArgs = methodDef.typeArgs + typeArgs + self.methodDef = methodDef + self.typeArgs = typeArgs + def __str__(self): + if len(self.methodDef.typeParams) != len(self.typeArgs): + raise Exception('Incomplete type instantiation.') + return str(self.methodDef) + '<{0}>'.format(', '.join(self.typeArgs)) + +#========================================================================================================== +class NamespaceDef(object): + def __init__(self, name): + self.parentScope = None + self.members = MemberSet(self) + if '.' in name: + pname, name = '.'.join(name.split('.')[:-1]), name.split('.')[-1] + self.name = name + NamespaceDef(pname).members.add(self) + else: + self.name = name + + def __str__(self): + if self.parentScope: + return str(self.parentScope) + '.' + self.name + else: + return self.name + + def CsDefineBegin(self, iprint): + iprint('namespace {0}\n{{'.format(str(self))) + + def CsDefineEnd(self, iprint): + iprint('}} // {0}'.format(str(self))) + + def CsDefine(self, iprint): + # Sort the member types in a predictable way. + def typesortkey(t): + name = str(t) + # Remove 'I' prefix from interfaces for sorting. + if t.IsInterface() and re.match(r'I[A-Z]', name): + name = name[1:] + if isinstance(t, EnumDef): + return (1, name) + else: + return (2, name) + + # Sort members for consistent source generation, which enables easier diffing. + typeMembers = sorted(filter(lambda m: not isinstance(m, NamespaceDef), self.members),lambda x,y: cmp(typesortkey(x), typesortkey(y))) + + if len(typeMembers) > 0: + self.CsDefineBegin(iprint) + iprint = iprint.indent() + for m in typeMembers: + m.CsDefine(iprint) + iprint.AddWhitespace() + iprint = iprint.outdent() + self.CsDefineEnd(iprint) + + nsMembers = filter(lambda m: isinstance(m, NamespaceDef), self.members) + for m in nsMembers: + m.CsDefine(iprint) + iprint.AddWhitespace() + +#========================================================================================================== +class CodeBlockDef(object): + def __init__(self, codeBlock): + self.codeBlock = codeBlock + + def CsDefine(self, iprint): + iprint(self.codeBlock) + +#========================================================================================================== +class EnumDef(TypeDef): + def __init__(self, *args, **kv): + super(EnumDef, self).__init__(*args, **kv) + self.flags = EnumFlags((self.flags & ~TypeFlags.TypeMask) | TypeFlags.Enum) + + def CsDefineHeader(self, iprint): + super(EnumDef, self).CsDefineHeader(iprint) + if self.flags.IsHasFlagValues(): + iprint('[Flags]') + + def CsDefineMembers(self, iprint): + for m in self.members: + if not isinstance(m, EnumValue): + raise Exception('Expected enum value') + if m.value == None: + m.value = self.__FindValue() + m.CsDefine(iprint) + + def CalculateValues(self): + for m in self.members: + if m.value == None: + m.value = self.__FindValue() + + def __FindValue(self): + value = 1 if self.flags.IsHasFlagValues() else 0 + while reduce(lambda x, y: x or y.value == value, self.members, False): + if self.flags.IsHasFlagValues(): + value <<= 1 + else: + value += 1 + return value + +#========================================================================================================== +class EnumValue(object): + def __init__(self, name, value = None, comment = None): + self.name = name + self.value = value + self.flags = 0 + self.comment = comment + + def CsDefineHeader(self, iprint): + if self.comment: + iprint.AddWhitespace() + iprint('/// {}'.format(self.comment)) + + def CsDefine(self, iprint): + self.CsDefineHeader(iprint) + if self.value != None: + if self.parentScope.flags & EnumFlags.HasFlagValues: + iprint('{0} = {1},'.format(self.name, hex(self.value))) + else: + iprint('{0} = {1},'.format(self.name, hex(self.value))) + else: + iprint('{0},'.format(self.name)) + + def __str__(self): + if self.parentScope: + return str(self.parentScope) + '.' + self.name + else: + return self.name diff --git a/src/Common/src/Internal/Metadata/NativeFormat/Script/CsGenTemplate2.py b/src/Common/src/Internal/Metadata/NativeFormat/Script/CsGenTemplate2.py new file mode 100644 index 000000000..1f3be3ac0 --- /dev/null +++ b/src/Common/src/Internal/Metadata/NativeFormat/Script/CsGenTemplate2.py @@ -0,0 +1,85 @@ +# Copyright (c) Microsoft. All rights reserved. +# Licensed under the MIT license. See LICENSE file in the project root for full license information. + +""" +Template for consuming SchemaDef2 module contents and generating scenario-specific C# code. +""" + +import sys +import os +import copy +import itertools + +if __name__ == '__main__': + #Dynamically append current script path to PYTHONPATH + sys.path.append(os.path.dirname(sys.argv[0])) + +from odict import odict +import SchemaDef2 as sd +from CsCommonGen2 import * +from CsNativeFormatGen2 import * + +#========================================================================================================== +class GenTemplate(object): + #========================================================================================================== + def __init__(self, sourceFile, rootNamespace): + self.sourceFile = sourceFile + self.rootNamespace = rootNamespace + + #========================================================================================================== + def CreateRecordMembers(self, rec): + pass + + #========================================================================================================== + def CreateHandleMembers(self, hnd): + pass + + #========================================================================================================== + def CsEmitSource(self): + self.Ty = TypeContainer() + PublishWellKnownTypes(self.Ty) + + ns = NamespaceDef(self.rootNamespace) + + recs = odict() + hnds = odict() + + self.Ty.Handle = hnds['Handle'] = StructDef('Handle', flags = TypeFlags.Partial) + ns.members.add(self.Ty.Handle) + + for (rName,rMembers) in sd.recordSchema.iteritems(): + rec = recs[rName] = StructDef(rName, flags = TypeFlags.Partial) + hnd = hnds[rName + 'Handle'] = StructDef(rName + 'Handle', flags = TypeFlags.Partial) + rec.handle = hnd + rec.schemaMembers = rMembers + hnd.record = rec + ns.members.add(rec) + ns.members.add(hnd) + + for hName in sd.handleSchema: + if hName + 'Handle' not in hnds: + hnd = hnds[hName + 'Handle'] = StructDef(hName + 'Handle', flags = TypeFlags.Partial) + hnd.record = None + ns.members.add(hnd) + + for rec in recs.itervalues(): + self.CreateRecordMembers(rec) + + for hnd in hnds.itervalues(): + self.CreateHandleMembers(hnd) + + # Source NativeFormatReaderHashEqualGen.cs + with open(self.sourceFile, 'w') as output : + iprint = IPrint(output) + CsEmitFileHeader(iprint) + iprint('using System;') + iprint('using System.Linq;') + iprint('using System.Reflection;') + iprint('using System.Reflection.Metadata;') + iprint('using System.Collections.Generic;') + iprint() + + ns.CsDefine(iprint) + +if __name__ == '__main__': + GenTemplate(r'System\Reflection\Metadata\TemplateGen.cs', r'System.Reflection.Metadata.Template').CsEmitSource() diff --git a/src/Common/src/Internal/Metadata/NativeFormat/Script/CsMdBinaryRWCommonGen.py b/src/Common/src/Internal/Metadata/NativeFormat/Script/CsMdBinaryRWCommonGen.py new file mode 100644 index 000000000..f355ba575 --- /dev/null +++ b/src/Common/src/Internal/Metadata/NativeFormat/Script/CsMdBinaryRWCommonGen.py @@ -0,0 +1,217 @@ +# Copyright (c) Microsoft. All rights reserved. +# Licensed under the MIT license. See LICENSE file in the project root for full license information. + +""" +Generates the C# classes MdBinaryWriterGen.cs and MdBinaryReaderGen.cs, which define the classes +MdBinaryReader and MdBinaryWriter. These classes are responsible for correctly encoding and decoding +data members into the .metadata file. See NativeFormatReaderGen.cs and NativeFormatWriterGen.cs for +how the MetadataReader and MetadataWriter use these classes. +""" + +import sys +import os + +if __name__ == '__main__': + #Dynamically append current script path to PYTHONPATH + sys.path.append(os.path.dirname(sys.argv[0])) + +import SchemaDef2 as sd +from CsCommonGen2 import * +from CsNativeFormatGen2 import * +from odict import odict + +#========================================================================================================== +class MdBinaryRWGen(object): + #------------------------------------------------------------------------------------------------------ + def __init__(self): + self.Ty = TypeContainer() + PublishWellKnownTypes(self.Ty) + self.recs = odict([(rName, self.Ty.get(rName)) for rName in sd.recordSchema.iterkeys()]) + self.hnds = odict([(hName + 'Handle', self.Ty.get(hName + 'Handle')) for hName in sd.handleSchema]) + for rec in self.recs.itervalues(): + rec.handle = self.hnds[str(rec) + 'Handle'] + self.Ty.NativeReader = ClassDef('NativeReader') + self.Ty.NativeWriter = ClassDef('NativeWriter') + + #------------------------------------------------------------------------------------------------------ + def CreateMdBinaryReaderClass(self): + + c = ClassDef( + 'MdBinaryReader', + flags = AccessFlags.Internal | TypeFlags.Partial | TypeFlags.Static) + + def GenArrayReadMethodWithOffset(typeName): + return MethodDef( + 'Read', + sig = [self.Ty.uint, [(self.Ty.NativeReader, 'reader'), (self.Ty.uint, 'offset'), ('out ' + str(typeName) + '[]', 'values')]], + flags = AccessFlags.Public | MemberFlags.Extension, + body = ''' +uint count; +offset = reader.DecodeUnsigned(offset, out count); +values = new {0}[count]; +for (uint i = 0; i < count; ++i) +{{ + {0} tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; +}} +return offset;'''.format(typeName)) + + def GenArrayReadMethodWithOffset_Empty(typeName): + return MethodDef( + 'Read', + sig = [self.Ty.uint, [(self.Ty.NativeReader, 'reader'), (self.Ty.uint, 'offset'), ('out ' + str(typeName) + '[]', 'values')]], + flags = AccessFlags.Public | MemberFlags.Extension, + body = ''' +uint count; +offset = reader.DecodeUnsigned(offset, out count); +if (count == 0) +{{ + values = s_empty{0}Array; +}} +else +{{ + values = new {0}[count]; + for (uint i = 0; i < count; ++i) + {{ + {0} tmp; + offset = reader.Read(offset, out tmp); + values[i] = tmp; + }} +}} +return offset;'''.format(typeName)) + + for pCsType,pType in sd.primitiveTypes.iteritems(): + c.members.add(GenArrayReadMethodWithOffset(pCsType)) + + hType = self.Ty.Handle + c.members.add(GenArrayReadMethodWithOffset_Empty(hType)) + c.members.add(EmptyArrayDef('s_empty' + str(hType) + 'Array', hType, AccessFlags.Private)) + + for eType in map(lambda eName: self.Ty[eName], sd.enumTypes.iterkeys()): + + c.members.add(MethodDef( + 'Read', + sig = [self.Ty.uint, [(self.Ty.NativeReader, 'reader'), (self.Ty.uint, 'offset'), ('out ' + str(eType), 'value')]], + flags = AccessFlags.Public | MemberFlags.Extension, + body = ''' +uint ivalue; +offset = reader.DecodeUnsigned(offset, out ivalue); +value = ({0})ivalue; +return offset;'''.format(eType, eType.underlyingType))) + + # c.members.add(GenArrayReadMethodWithOffset(eType)) + + for hType in map(lambda hnd: hnd + 'Handle', sd.handleSchema): + + c.members.add(MethodDef( + 'Read', + sig = [self.Ty.uint, [(self.Ty.NativeReader, 'reader'), (self.Ty.uint, 'offset'), ('out ' + hType, 'handle')]], + flags = AccessFlags.Public | MemberFlags.Extension, + body = ''' +uint value; +offset = reader.DecodeUnsigned(offset, out value); +handle = new {}((int)value); +handle._Validate(); +return offset;'''.format(hType))) + + c.members.add(GenArrayReadMethodWithOffset_Empty(hType)) + c.members.add(EmptyArrayDef('s_empty' + str(hType) + 'Array', hType, AccessFlags.Private)) + + return c + + #------------------------------------------------------------------------------------------------------ + def CreateMdBinaryWriterClass(self): + c = self.Ty.MdBinaryWriter = ClassDef( + 'MdBinaryWriter', + flags = AccessFlags.Internal | TypeFlags.Partial | TypeFlags.Static) + + def GenArrayWriteMethod(typeName): + return MethodDef( + 'Write', + sig = [self.Ty.void, [(self.Ty.NativeWriter, 'writer'), ('IEnumerable<' + str(typeName) + '>', 'values')]], + flags = AccessFlags.Public | MemberFlags.Extension, + body = ''' +if (values == null) +{{ + writer.WriteUnsigned(0); + return; +}} +writer.WriteUnsigned((uint)values.Count()); +foreach ({0} value in values) +{{ + writer.Write(value); +}}'''.format(typeName)) + + for pType in sd.primitiveTypes.iterkeys(): + c.members.add(GenArrayWriteMethod(pType)) + + for eType in map(lambda (eName, eType): self.Ty.get(eName, EnumDef(eName, underlyingType = self.Ty[eType])), sd.enumTypes.iteritems()): + c.members.add(MethodDef( + 'Write', + sig = [self.Ty.void, [(self.Ty.NativeWriter, 'writer'), (eType, 'value')]], + flags = AccessFlags.Public | MemberFlags.Extension, + body = 'writer.WriteUnsigned((uint)value);')) + + c.members.add(GenArrayWriteMethod('MetadataRecord')) + + for rec in self.recs.itervalues(): + c.members.add(MethodDef( + 'Write', + sig = [self.Ty.void, [(self.Ty.NativeWriter, 'writer'), (str(rec), 'record')]], + flags = AccessFlags.Public | MemberFlags.Extension, + body = ''' +if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); +else + writer.WriteUnsigned(0); +'''.format(rec.handle))) + + c.members.add(GenArrayWriteMethod(str(rec))) + + return c + + #------------------------------------------------------------------------------------------------------ + def CsEmitSource(self): + # Source MdBinaryReaderGen.cs + with open(r'System\Reflection\Metadata\MdBinaryReaderGen.cs', 'w') as output : + ns = NamespaceDef('Internal.Metadata.NativeFormat') + ns.members.add(self.CreateMdBinaryReaderClass()) + + iprint = IPrint(output) + CsEmitFileHeader(iprint) + iprint('#pragma warning disable 649') + iprint() + iprint('using System;') + iprint('using System.IO;') + iprint('using System.Collections.Generic;') + iprint('using System.Reflection;') + iprint('using Internal.NativeFormat;') + iprint('using Debug = System.Diagnostics.Debug;') + iprint() + + ns.CsDefine(iprint) + + # Source MdBinaryWriterGen.cs + with open(r'..\..\..\PnToolChain\Metadata\NativeFormatWriter\MdBinaryWriterGen.cs', 'w') as output : + ns = NamespaceDef('Internal.Metadata.NativeFormat.Writer') + ns.members.add(self.CreateMdBinaryWriterClass()) + + iprint = IPrint(output) + CsEmitFileHeader(iprint) + iprint('#pragma warning disable 649') + iprint() + iprint('using System;') + iprint('using System.IO;') + iprint('using System.Linq;') + iprint('using System.Collections.Generic;') + iprint('using System.Reflection;') + iprint('using Internal.NativeFormat;') + iprint('using Debug = System.Diagnostics.Debug;') + iprint() + + ns.CsDefine(iprint) + +#========================================================================================================== +if __name__ == '__main__': + MdBinaryRWGen().CsEmitSource() diff --git a/src/Common/src/Internal/Metadata/NativeFormat/Script/CsNativeFormatGen2.py b/src/Common/src/Internal/Metadata/NativeFormat/Script/CsNativeFormatGen2.py new file mode 100644 index 000000000..32cfaccd1 --- /dev/null +++ b/src/Common/src/Internal/Metadata/NativeFormat/Script/CsNativeFormatGen2.py @@ -0,0 +1,93 @@ +# Copyright (c) Microsoft. All rights reserved. +# Licensed under the MIT license. See LICENSE file in the project root for full license information. + +""" +Provides TypeContainer class and utility function PublishWellKnownTypes which can populate a +TypeContainer instance with standard .NET classes and primitive types. +""" + +import sys +import os + +if __name__ == '__main__': + #Dynamically append current script path to PYTHONPATH + sys.path.append(os.path.dirname(sys.argv[0])) + +import SchemaDef2 as sd +from CsCommonGen2 import * +from odict import odict + +#========================================================================================================== +class TypeContainer(odict): + def __init__(self, default = lambda tn: TypeRef(str(tn)), *args, **kv): + super(TypeContainer, self).__init__(*args, **kv) + self.__default = default + + def get(self, name, default = None): + value = super(TypeContainer, self).get(name) + if value: + return value + + if isinstance(name, TypeDefOrRef): + default = default or name + name = str(name) + + if type(name) != str: + raise Exception('unexpected argument type {0}'.format(type(name))) + + if default != None and not isinstance(default, TypeDefOrRef): + raise Exception('unexpected argument {} (type: {})'.format(str(name), type(name))) + + return self.setdefault(name, default or self.__default(name)) + + # Overriding __getitem__ and __setitem__ allows 'dot name' use of types that have not + # yet been published, with the default behavior of inserting a type reference for the + # provided name. I.e., 'Ty.int', where 'Ty' is an instance of TypeContainer that does + # not contain a pre-existing 'int' member will automatically generate a type reference + # named 'int' and return it. + def __getitem__(self, name): + return super(TypeContainer, self).get(name, None) or self.get(name) + + def __setitem__(self, name, value): + super(TypeContainer, self).__setitem__(name, value) + + def __getattr__(self, name): + if name in self: + return super(TypeContainer, self).get(name) + elif name in self.__dict__: + return self.__dict__[name] + else: + return self.get(name) + + def __setattr__(self, name, value): + if isinstance(value, TypeDefOrRef): + self.__setitem__(name, value) + else: + self.__dict__[name] = value + +#========================================================================================================== +def PublishWellKnownTypes(Ty): + # Intrinsics + for tName,tValueTypeName in sd.primitiveTypes.iteritems(): + t = TypeRef(tName) + t.valueTypeName = tValueTypeName + Ty[tName] = t + + for (eName, eType) in sd.enumTypes.iteritems(): + Ty[eName] = EnumDef(eName, underlyingType = Ty[eType]) + + # Some standard .NET types. Extend as needed. + Ty.IEnumerable = InterfaceDef('IEnumerable') + Ty.IEnumerable.parentScope = 'System.Collections' + Ty.IEnumerator = InterfaceDef('IEnumerator', parentScope = 'System.Collections') + Ty.IEnumerator.parentScope = 'System.Collections' + Ty.IEnumerableT = InterfaceDef('IEnumerable', typeParams = ['T'], interfaces = [Ty.IEnumerable]) + Ty.IEnumeratorT = InterfaceDef('IEnumerator', typeParams = ['T'], interfaces = [Ty.IEnumerator]) + Ty.IEquatableT = InterfaceDef('IEquatable', typeParams = ['T']) + Ty.Dictionary = ClassDef('Dictionary', typeParams = ['K', 'V']) + Ty.List = ClassDef('List', typeParams = ['T']) + Ty.IListT = InterfaceDef('IList', typeParams = ['T']) + # Add Tuple`2 through Tuple`5 + for i in range(2,5): + Ty['Tuple`' + str(i)] = TypeRef('Tuple`', typeParams = ['T' + str(j) for j in range(2, i)]) + Ty.ThreadLocal = ClassDef('ThreadLocal', typeParams = ['T']) diff --git a/src/Common/src/Internal/Metadata/NativeFormat/Script/CsPublicGen2.py b/src/Common/src/Internal/Metadata/NativeFormat/Script/CsPublicGen2.py new file mode 100644 index 000000000..dbef8d78b --- /dev/null +++ b/src/Common/src/Internal/Metadata/NativeFormat/Script/CsPublicGen2.py @@ -0,0 +1,334 @@ +# Copyright (c) Microsoft. All rights reserved. +# Licensed under the MIT license. See LICENSE file in the project root for full license information. + +""" +This script generates the common API declarations that any metadata reader must implement. +In general, this script consumes the metadata record schema defined in SchemaDef2.py and +generates two interfaces and two structs for each - one (interface, struct) pair corresponding +to the metadata record itself, and one (interface, struct) pair corresponding to the 'Handle' +used to reference the specific record type. The interfaces are used as a way of +enforcing that the structs implement all required public members, but are not publicly consumed +and are declared as internal. The use of structs instead of classes for each record was driven +by a requirement from the Roslyn team that a metadata reader must minimize as much as possible +the number of allocations made; thus, structs are allocated on the stack and exist only as +long as the declaring scope remains on the stack. + +Each record interface simply declares as properties the members declared in the schema definition, +and each struct is declared as partial and as implmenting the interface, thus requiring all +interface properties to be supplied by the metadata reader implementation. + +Each handle interface requires type-specific equality functionality by itself implementing +IEquatable<XXXHandle>, and the handle structs similarly declare this interface to require that +the implementation be supplied by the reader. + +This script generates NativeFormatReaderCommonGen.cs. + +This script also generates IMetadataReader, which defines what the reader class itself must +implement. +""" + +import sys +import os +import copy +import itertools +import re + +if __name__ == '__main__': + #Dynamically append current script path to PYTHONPATH + sys.path.append(os.path.dirname(sys.argv[0])) + +import SchemaDef2 as sd +from CsCommonGen2 import * +from CsNativeFormatGen2 import * + +#========================================================================================================== +system = NamespaceDef('System') +system.collections = system.members.add(NamespaceDef('Collections')) +system.collections.generic = system.collections.members.add(NamespaceDef('Generic')) + +sys_coll_enumable = system.collections.members.add(InterfaceDef('IEnumerable')) +sys_coll_enumator = system.collections.members.add(InterfaceDef('IEnumerator')) +sys_coll_gen_enumableT = system.collections.generic.members.add(InterfaceDef('IEnumerable', typeParams = ['T'], interfaces = [sys_coll_enumable])) +sys_coll_gen_enumatorT = system.collections.generic.members.add(InterfaceDef('IEnumerator', typeParams = ['T'], interfaces = [sys_coll_enumator])) + +#========================================================================================================== +def GetOrCreateType(ty, flags): + if isinstance(ty, TypeDefOrRef): + return ty + + if type(ty) == tuple: + ty = str(Ty.Handle) + + if flags.IsCollection(): + elementType = GetOrCreateType(ty, flags & (~sd.MemberDefFlags.CollectionMask)) + return Ty.get(str(elementType) + '[]', TypeRef( + name = str(elementType) + '[]', + flags = TypeFlags.Public | TypeFlags.Array, + elementType = elementType)) + + if flags.IsRef() and str(ty) != 'Handle': + ty = ty + 'Handle' + + return Ty[ty] + +#========================================================================================================== +def CreateCommonHandleMembers(): + members = list() + + # members.append(MethodDef( + # 'Equals', + # flags = AccessFlags.Public | MemberFlags.Abstract, + # sig = ['bool', [('Object', 'obj')]])) + + members.append(MethodDef( + 'GetHashCode', + flags = AccessFlags.Public | MemberFlags.Abstract, + sig = ['int', []])) + + return members + +#========================================================================================================== +def GetEnumerableForHandle(hnd): + # return str(hnd) + 'Enumerable' + return TypeInst(sys_coll_gen_enumableT, hnd) + +#========================================================================================================== +def CreateRecordMembers(recordType, mName, mType, flags): + members = list() + mType = GetOrCreateType(mType, flags) + field = FieldDef(CsMakePrivateName(mName), mType, AccessFlags.Internal | MemberFlags.Serialize) + members.append(field) + if flags.IsCollection(): + members.append(PropertyDef(mName, GetEnumerableForHandle(mType.ElementType()), getter = PropertyGetter())) + else: + members.append(PropertyDef(mName, mType, getter = PropertyGetter())) + + return members + +#========================================================================================================== +def CreateRecord(name, handle, schemaMembers): + irec = InterfaceDef(name, flags = AccessFlags.Internal) + Ty[str(irec)] = irec + rec = StructDef(name, flags = AccessFlags.Public | TypeFlags.Partial, interfaces = [irec]) + Ty[str(rec)] = rec + rec.handle = handle + handle.record = rec + for m in schemaMembers: + irec.members += CreateRecordMembers(rec, *m) + irec.members.add(PropertyDef( + 'Handle', + handle, + getter = PropertyGetter())) + return rec + +#========================================================================================================== +def CreateHandleMembers(handleType): + members = CreateCommonHandleMembers() + + # if handleType != Ty.Handle: + # members.append(MethodDef( + # 'Equals', + # flags = AccessFlags.Public | MemberFlags.Abstract, + # sig = ['bool', [(Ty.Handle, 'handle')]])) + + return members + +#========================================================================================================== +def CreateHandle(name): + ihnd = InterfaceDef(name + str(Ty.Handle), flags = AccessFlags.Internal)#, interfaces = [Ty.IHandle]) + Ty[str(ihnd)] = ihnd + + ihnd.members.add(MethodDef( + 'ToHandle', + flags = AccessFlags.Public | MemberFlags.Abstract, + sig = [Ty.Handle, [(Ty.MetadataReader, 'reader')]])) + + + hnd = StructDef(name + str(Ty.Handle), flags = AccessFlags.Public | TypeFlags.Partial, interfaces = [ihnd]) + Ty[str(hnd)] = hnd + + ihnd.interfaces += [Ty.IEquatableT.Instantiate(hnd), Ty.IEquatableOfHandle, Ty.IEquatableOfObject] + + hnd.record = None + hnd.enumType = 'HandleType' + hnd.enumValue = '{0}'.format(name) + + return hnd + +#========================================================================================================== +def CreateReaderRecordDecodeMethods(rec): + methods = list() + + # Method 'GetXXX' + params = [(str(rec.handle), 'handle')] + methods.append(MethodDef( + 'Get%s' % rec, + flags = AccessFlags.Public | MemberFlags.Abstract, + sig = [str(rec), params])) + + return methods + +#========================================================================================================== +def CreateReaderMembers(reader, recs, hnds): + members = list() + name = str(reader) + + def __GetRecordMember(name, type, flags = sd.MemberDefFlags(0)): + return (name, type, flags) + + # Generate all of the enumerator-based GetXForY (eg GetCustomAttributesForTypeDefinition) + for (rName,rMembers) in sd.recordSchema.iteritems(): + rec = recs[rName] + # for (mName,mType,mFlags) in rMembers: + # mType = GetOrCreateType(mType, mFlags) + # if mFlags.IsCollection() and mFlags.IsChild(): + # members.append(MethodDef( + # 'Get{0}For{1}'.format(mName, str(rec)), + # flags = AccessFlags.Public | MemberFlags.Abstract, + # sig = [GetEnumerableForHandle(mType), [(str(rec), 'record')]])) + # members.append(MethodDef( + # 'Get{0}For{1}'.format(mName, str(rec)), + # flags = AccessFlags.Public | MemberFlags.Abstract, + # sig = [GetEnumerableForHandle(mType), [(str(rec.handle), 'handle')]])) + + # Generate all of the record decoding methods GetX (eg GetTypeDefinition) + for rec in recs.itervalues(): + recMembers = CreateReaderRecordDecodeMethods(rec) + members += recMembers + + # Generate all of the ToHandle and ToXHandle methods (eg ToHandle(TypeDefinitionHandle) and ToTypeDefinitionHandle(Handle)) + # for hnd in hnds.itervalues(): + # members.append(MethodDef( + # 'To{0}'.format(str(hnd)), + # flags = AccessFlags.Public | MemberFlags.Abstract, + # sig = [hnd, [(Ty.Handle, 'handle')]])) + # members.append(MethodDef( + # 'ToHandle'.format(str(hnd)), + # flags = AccessFlags.Public | MemberFlags.Abstract, + # sig = [Ty.Handle, [(str(hnd), 'handle')]])) + + # members.append(MethodDef( + # 'GetHandleType', + # flags = AccessFlags.Public | MemberFlags.Abstract, + # sig = ['HandleType', [(Ty.Handle, 'handle')]])) + + members.append(PropertyDef( + 'ScopeDefinitions', + Ty.get(TypeInst(sys_coll_gen_enumableT, hnds['ScopeDefinitionHandle'])), + flags = AccessFlags.Public | MemberFlags.Abstract, + getter = PropertyGetter())) + + members.append(PropertyDef( + 'NullHandle', + str(Ty.Handle), + flags = AccessFlags.Public | MemberFlags.Abstract, + getter = PropertyGetter())) + + # members.append(MethodDef( + # 'IsNull', + # flags = AccessFlags.Public | MemberFlags.Abstract, + # sig = ['bool', [(Ty.Handle, 'handle')]])) + + # for hnd in hnds.values(): + # members.append(MethodDef( + # 'IsNull', + # flags = AccessFlags.Public | MemberFlags.Abstract, + # sig = ['bool', [(str(hnd), 'handle')]])) + + return members + +#========================================================================================================== +def CreateReader(name, recs, hnds): + reader = InterfaceDef(name, flags = AccessFlags.Public) + reader.members += CreateReaderMembers(reader, recs, hnds) + return reader + +#========================================================================================================== +def AsInterface(td): + i = InterfaceDef( + str(td), + flags = type(td.flags)((td.flags & ~(TypeFlags.Partial | AccessFlags.All)) | AccessFlags.Internal), + # flags = type(td.flags)((td.flags & ~(TypeFlags.Partial | AccessFlags.All)) | AccessFlags.Public), + interfaces = copy.copy(td.interfaces), + members = copy.copy(td.members)) + return i + +#========================================================================================================== +def CreateEnumFromSchema(item): + enum = EnumDef(item.name, baseType = Ty.get(item.baseTypeName), comment = item.comment) + if item.flags.IsFlags(): + enum.flags |= EnumFlags.HasFlagValues + + enum.members += [EnumValue(member.name, comment = member.comment, value = getattr(member, 'value', None)) for member in item.members] + + return enum + +#========================================================================================================== +Ty = TypeContainer() + +#========================================================================================================== +def CsEmitSource(): + ns = NamespaceDef('Internal.Metadata.NativeFormat') + + # ns.members.add(CreateIHandle()) + # Ty = TypeContainer() + PublishWellKnownTypes(Ty) + + ns.members += [CreateEnumFromSchema(item) for item in sd.enumSchema] + + Ty.IHandle = InterfaceDef('Handle', flags = AccessFlags.Internal) + Ty.Handle = StructDef('Handle', flags = AccessFlags.Public | TypeFlags.Partial, interfaces = [Ty.IHandle]) + Ty.IEquatableOfHandle = Ty.IEquatableT.Instantiate(Ty.Handle) + Ty.IEquatableOfObject = Ty.IEquatableT.Instantiate(Ty.Object) + Ty.IHandle.interfaces = [Ty.IEquatableOfHandle, Ty.IEquatableOfObject] + Ty.IHandle.members += CreateHandleMembers(Ty.Handle) + ns.members += [Ty.IHandle, Ty.Handle] + + hnds = dict([(h + 'Handle', CreateHandle(h)) for h in sd.handleSchema]) + recs = dict([(rName, CreateRecord(rName, hnds[rName + 'Handle'], rMembers)) for (rName,rMembers) in sd.recordSchema.iteritems()]) + + # Add handles and records to namespace + for hnd in hnds.itervalues(): + ns.members += hnd.interfaces + [hnd] + for rec in recs.itervalues(): + ns.members += rec.interfaces + [rec] + + for hnd in hnds.itervalues(): + hnd.interfaces[0].members += CreateHandleMembers(hnd) + + Ty.HandleType = EnumDef('HandleType', baseType = Ty.byte) + Ty.HandleType.members += [EnumValue('Null')] + Ty.HandleType.members += [EnumValue(hnd) for hnd in sorted(map(lambda hnd: str(hnd.enumValue), hnds.itervalues()))] + ns.members.add(Ty.HandleType) + + Ty.IMetadataReader = CreateReader('IMetadataReader', recs, hnds) + Ty.MetadataReader = ClassDef('MetadataReader', flags = TypeFlags.Partial, interfaces = [Ty.IMetadataReader]) + Ty.IHandle.members.add(MethodDef('GetHandleType', sig = [Ty.HandleType, [(Ty.MetadataReader, 'reader')]])) + ns.members.add(Ty.IMetadataReader) + ns.members.add(Ty.MetadataReader) + + for hnd in hnds.itervalues(): + Ty.IHandle.members.add(MethodDef( + 'To{0}'.format(str(hnd)), + flags = AccessFlags.Public | MemberFlags.Abstract, + sig = [hnd, [(Ty.MetadataReader, 'reader')]])) + + # Source NativeFormatReaderCommonGen.cs + with open(r'System\Reflection\Metadata\NativeFormatReaderCommonGen.cs', 'w') as output : + iprint = IPrint(output) + CsEmitFileHeader(iprint) + iprint('using System;') + iprint('using System.Reflection;') + iprint('using System.Collections.Generic;') + iprint() + + iprint("#pragma warning disable 108 // base type 'uint' is not CLS-compliant") + iprint("#pragma warning disable 3009 // base type 'uint' is not CLS-compliant") + iprint("#pragma warning disable 282 // There is no defined ordering between fields in multiple declarations of partial class or struct") + iprint() + + ns.CsDefine(iprint) + +#========================================================================================================== +if __name__ == '__main__': + CsEmitSource() diff --git a/src/Common/src/Internal/Metadata/NativeFormat/Script/CsReaderGen2.py b/src/Common/src/Internal/Metadata/NativeFormat/Script/CsReaderGen2.py new file mode 100644 index 000000000..dba885efa --- /dev/null +++ b/src/Common/src/Internal/Metadata/NativeFormat/Script/CsReaderGen2.py @@ -0,0 +1,571 @@ +# Copyright (c) Microsoft. All rights reserved. +# Licensed under the MIT license. See LICENSE file in the project root for full license information. + +""" +This script file generates most of the implementation of the MetadataReader for the ProjectN format, +ensuring that the contract defined by CsPublicGen2 is implemented. The generated file is +'NativeFormatReaderGen.cs', and any missing implementation is the supplied in the human-authored +source counterpart 'NativeFormatReader.cs'. +""" +import sys +import os + +if __name__ == '__main__': + #Dynamically append current script path to PYTHONPATH + sys.path.append(os.path.dirname(sys.argv[0])) + +import SchemaDef2 as sd +from CsCommonGen2 import * +from CsNativeFormatGen2 import * +from odict import odict + +Ty = None +handles = None +records = None + +#========================================================================================================== +def GetOrCreateType(ty, flags): + if isinstance(ty, TypeDefOrRef): + return ty + + if type(ty) == tuple: + ty = str(Ty.Handle) + + if flags.IsCollection(): + elementType = GetOrCreateType(ty, flags & (~sd.MemberDefFlags.CollectionMask)) + return Ty.get(str(elementType) + '[]', TypeRef( + name = str(elementType) + '[]', + flags = TypeFlags.Public | TypeFlags.Array, + elementType = elementType)) + + if flags.IsRef() and str(ty) != 'Handle': + ty = ty + 'Handle' + + return Ty[ty] + +#========================================================================================================== +def CreateRecordDecodeMethods(rec): + methods = list() + + # Code snipped to calculate size of record + sizeBody = 'uint recordSize =\n ' + + # Method 'GetXXX' + decodeBodyGetPrefix = '' + decodeBody = '' + + # Null handles for string types are automatically promoted to records with Value property set to null. + if str(rec) in sd.stringRecordTypes: + decodeBodyGetPrefix = ''' +if (IsNull(handle)) + return new {}();'''.format(rec) + + decodeBody = ''' +var record = new {0}() {{ _reader = this, _handle = handle }}; +var offset = (uint)handle.Offset;'''.format(rec) + + for m in filter(lambda f: (f.flags & MemberFlags.Serialize) and isinstance(f, FieldDef), rec.members): + decodeBody += '\noffset = _streamReader.Read(offset, out record.{0});'.format(m) + + params = [(rec.handle, 'handle')] + methods.append(MethodDef( + 'Get{}'.format(rec), + sig = [rec, params], + body = decodeBodyGetPrefix + decodeBody + '\nreturn record;')) + + return methods + +#========================================================================================================== +def GetEnumerableForType(ty): + return TypeInst(Ty.IEnumerableT, ty) + +#========================================================================================================== +def CreateRecordMembers(rType, mName, mType, flags): + members = list() + if flags.IsNotPersisted(): + return members + + comment = None + if type(mType) == tuple: + comment = 'One of: ' + ', '.join(mType) + + mType = GetOrCreateType(mType, flags) + field = FieldDef(CsMakePrivateName(mName), mType, MemberFlags.Internal | MemberFlags.Serialize) + + if flags.IsCollection(): + members.append(PropertyDef(mName, GetEnumerableForType(mType.ElementType()), + getter = PropertyGetter(body = 'return ({}){};'.format(GetEnumerableForType(mType.ElementType()), field)), comment = comment)) + else: + members.append(PropertyDef(mName, mType, field = field, getter = PropertyGetter(), comment = comment)) + + members.append(field) + + return members + +#========================================================================================================== +def CreateRecord(name): + if name in Ty: + return Ty[name] + recordDef = sd.recordDefs[name] + baseType = Ty.get(recordDef.baseTypeName) if recordDef.baseTypeName else None + rec = Ty.get(name, StructDef(name, baseType, AccessFlags.Public | TypeFlags.Partial | TypeFlags.Struct)) + rec.handle = None + rec.members.add(FieldDef(CsMakePrivateName('Reader'), Ty.NativeFormatReader, AccessFlags.Internal)) + rec.decodeMethod = None + + return rec + +#========================================================================================================== +def CreateHandleMembers(hnd): + hnd.members.add(MethodDef( + 'Equals', + MemberFlags.Public | MemberFlags.Override, + ['bool', [('object', 'obj')]], + body = '''\ +if (obj is {0}) + return _value == (({0})obj)._value; +else if (obj is Handle) + return _value == ((Handle)obj)._value; +else + return false;'''.format(hnd))) + + hnd.members.add(MethodDef( + 'Equals', + MemberFlags.Public, + ['bool', [(hnd, 'handle')]], + body = 'return _value == handle._value;')) + + hnd.members.add(MethodDef( + 'Equals', + MemberFlags.Public, + ['bool', [(Ty.Handle, 'handle')]], + body = 'return _value == handle._value;')) + + hnd.members.add(MethodDef( + 'GetHashCode', + MemberFlags.Public | MemberFlags.Override, + [Ty.int, []], + body = 'return (int)_value;')) + + hnd.members.add(FieldDef(CsMakePrivateName('Value'), Ty.int, AccessFlags.Internal)) + + hnd.members.add(CtorDef( + MemberFlags.Internal, + sig = [(Ty.Handle, 'handle')], + ctorDelegation = ['handle._value'], + body = '')) + + hnd.members.add(CtorDef( + flags = AccessFlags.Internal, + sig = [(Ty.int, 'value')], + body = ''' +HandleType hType = (HandleType)(value >> 24); +if (!(hType == 0 || hType == {0} || hType == {1})) + throw new ArgumentException(); +_value = (value & 0x00FFFFFF) | (((int){0}) << 24); +_Validate();'''.format(hnd.enumValue, Ty.HandleType.members['HandleType.Null']))) + + hnd.members.add(MethodDef( + str(Ty.Handle), + AccessFlags.Public | MemberFlags.Static | MemberFlags.Implicit | MemberFlags.Operator, + [None, [(hnd, 'handle')]], + body ='return new Handle(handle._value);'.format())) + + hnd.members.add(PropertyDef( + 'Offset', + Ty.int, + flags = AccessFlags.Internal, + getter = PropertyGetter(body = 'return (this._value & 0x00FFFFFF);'))) + + if hnd.record: + hnd.members.add(MethodDef( + 'Get{}'.format(hnd.record), + flags = AccessFlags.Public, + sig = [hnd.record, [(Ty.NativeFormatReader, 'reader')]], + body = 'return reader.Get{}(this);'.format(hnd.record))) + + hnd.members.add(MethodDef( + 'IsNull', + flags = AccessFlags.Public, + sig = [Ty.bool, [(Ty.NativeFormatReader, 'reader')]], + body = 'return reader.IsNull(this);')) + + hnd.members.add(MethodDef( + 'ToHandle', + flags = AccessFlags.Public, + sig = [Ty.Handle, [(Ty.NativeFormatReader, 'reader')]], + body = 'return reader.ToHandle(this);')) + + hnd.members.add(MethodDef( + '_Validate', + flags = AccessFlags.Internal | MemberFlags.DebugOnly, + sig = [Ty.void, []], + body = ''' +if ((HandleType)((_value & 0xFF000000) >> 24) != {}) + throw new ArgumentException();'''.format(hnd.enumValue))) + + hnd.members.add(MethodDef( + 'ToString', + flags = AccessFlags.Public | MemberFlags.Override, + sig = [Ty.String, []], + body = 'return String.Format("{0:X8}", _value);')) + +#========================================================================================================== +def CreateHandle(name): + hName = name + str(Ty.Handle) + hnd = Ty.get(hName, StructDef(hName, None, AccessFlags.Public | TypeFlags.Partial)) + hnd.record = None + hnd.enumValueName = '{0}'.format(name) + return hnd + +#========================================================================================================== +def CreateBaseHandleEnumerator(hnds): + eName = str(Ty.Handle) + 'Enumerator' + eType = StructDef( + eName, + flags = AccessFlags.Public | TypeFlags.Partial, + interfaces = [TypeInst(Ty.IEnumeratorT, Ty.Handle)]) + + moveNext = MethodDef( + 'MoveNext', + sig = [Ty.bool, []], + body = ''' +if (_curCount == _count || ++_curCount == _count) + return false; + +if (_curCount != 0) +{ + switch (_type) + { +''') + + for hnd in hnds: + moveNext.body += ''' + case {}: + _curHandle = _reader.MoveNext(new {}(_curHandle)).ToHandle(_reader); + break;'''.format(hnd.enumValue, hnd) + + moveNext.body += ''' + } +} + +return true;''' + + eType.members.add(moveNext) + setattr(Ty, eName, eType) + return eType + +#========================================================================================================== +def CreateBaseHandleConversions(recs): + members = list() + + for rec in recs: + members.append(MethodDef( + 'To{}'.format(rec.handle), + sig = [rec.handle, [(Ty.MetadataReader, 'reader')]], + body = 'return new {}(this);'.format(rec.handle))) + + return members + +#========================================================================================================== +def CreateReaderMembers(reader, recs, hnds): + members = list() + name = str(reader) + + # Generate all of the enumerator-based GetXForY (eg GetCustomAttributesForTypeDefinition) + for (rName,rMembers) in sd.recordSchema.iteritems(): + rec = recs[rName] + for (mName,mType,mFlags) in rMembers: + mType = GetOrCreateType(mType, mFlags) + # if mFlags.IsCollection() and mFlags.IsChild(): + # if not mFlags.IsRef(): raise Exception('Unexpected collection element type') + # members.append(MethodDef( + # 'Get{0}For{1}'.format(mName, rec), + # flags = MemberFlags.Internal, + # sig = [GetEnumerableForType(mType), [(rec, 'record')]], + # body = 'return new {0}(this, record.{1}, (int)record.{2});'.format(str(mType) + 'Enumerable', CsMakePrivateName(mName), CsMakePrivateName(Singular(mName) + 'Count')))) + # members.append(MethodDef( + # 'Get{0}For{1}'.format(mName, rec), + # flags = MemberFlags.Internal, + # sig = [GetEnumerableForType(mType), [(rec.handle, 'handle')]], + # body = 'return Get{0}For{1}(Get{1}(handle));'.format(mName, rec))) + + # Generate all of the record decoding methods GetX (eg GetTypeDefinition) + for rec in recs.itervalues(): + recMembers = CreateRecordDecodeMethods(rec) + members += recMembers + + # Generate all of the ToHandle and ToXHandle methods (eg ToHandle(TypeDefinitionHandle) and ToTypeDefinitionHandle(Handle)) + for hnd in hnds.itervalues(): + members.append(MethodDef( + 'To{0}'.format(hnd), + flags = AccessFlags.Internal, + sig = [hnd, [(Ty.Handle, 'handle')]], + body = 'return new {0}(handle._value);'.format(hnd))) + + members.append(MethodDef( + 'ToHandle'.format(hnd), + flags = AccessFlags.Internal, + sig = [Ty.Handle, [(hnd, 'handle')]], + body = 'return new Handle(handle._value);'.format())) + + for hnd in hnds.itervalues(): + members.append(MethodDef( + 'IsNull', + flags = AccessFlags.Internal, + sig = ['bool', [(hnd, 'handle')]], + body = 'return (handle._value & 0x00FFFFFF) == 0;')) + + return members + +#========================================================================================================== +def CreateReader(name, baseType = None, interfaces = []): + return ClassDef( + name, + flags = AccessFlags.Public | TypeFlags.Partial, + baseType = baseType, + interfaces = interfaces) + +#========================================================================================================== +def CreateHandleEnumerator(hnd): + e = ClassDef( + str(hnd) + 'Enumerator', + flags = AccessFlags.Public | TypeFlags.Partial, + interfaces = [TypeInst(Ty.IEnumeratorT, hnd), Ty.IEnumerator.FullName()]) + + e.members.add(FieldDef( + CsMakePrivateName('Reader'), + Ty.NativeFormatReader, + flags = AccessFlags.Internal)) + + e.members.add(FieldDef( + CsMakePrivateName(str(Ty.Handle)), + hnd, + flags = AccessFlags.Internal)) + + e.members.add(FieldDef( + CsMakePrivateName('Count'), + Ty.int, + flags = AccessFlags.Internal)) + + e.members.add(FieldDef( + CsMakePrivateName('Cur' + str(Ty.Handle)), + hnd, + flags = AccessFlags.Internal)) + + e.members.add(FieldDef( + CsMakePrivateName('CurCount'), + Ty.int, + flags = AccessFlags.Internal)) + + e.members.add(CtorDef( + sig = [(Ty.NativeFormatReader, 'reader'), (hnd, 'handle'), (Ty.int, 'count')], + body = +'''_reader = reader; +_handle = handle; +_count = count; +_curCount = -1; +_curHandle = handle;''')) + + e.members.add(MethodDef( + 'MoveNext', + sig = [Ty.bool, []], + body = +'''if (_curCount == _count || ++_curCount == _count) + return false; + +if (_curCount != 0) + _curHandle = _reader.MoveNext(_curHandle); + +return true;''')) + + e.members.add(PropertyDef( + 'System.Collections.IEnumerator.Current', + Ty.object, + getter = PropertyGetter(), + field = e.members[CsMakePrivateName('CurHandle')])) + + e.members.add(PropertyDef( + 'Current', + hnd, + getter = PropertyGetter(), + field = e.members[CsMakePrivateName('CurHandle')])) + + e.members.add(MethodDef( + 'Dispose', + sig = [Ty.void, []], + body ='_reader = null;')) + + e.members.add(MethodDef( + 'Reset', + sig = [Ty.void, []], + body ='_curCount = -1;\n_curHandle = _handle;')) + + hnd.enumerator = e + return e + +#========================================================================================================== +def CreateHandleEnumerable(hnd): + e = ClassDef( + str(hnd) + 'Enumerable', + flags = AccessFlags.Public | TypeFlags.Partial, + interfaces = [TypeInst(Ty.IEnumerableT, hnd), Ty.IEnumerable.FullName()]) + + e.members.add(FieldDef( + CsMakePrivateName('Reader'), + Ty.NativeFormatReader, + flags = AccessFlags.Internal)) + + e.members.add(FieldDef( + CsMakePrivateName('Start'), + hnd, + flags = AccessFlags.Internal)) + + e.members.add(FieldDef( + CsMakePrivateName('Count'), + Ty.int, + flags = AccessFlags.Internal)) + + e.members.add(CtorDef( + sig = [(Ty.NativeFormatReader, 'reader'), (hnd, 'start'), ('int', 'count')], + body = +'''_reader = reader; +_start = start; +_count = count;''')) + + e.members.add(MethodDef( + 'GetEnumerator', + sig = [hnd.enumerator, []], + body = 'return new {0}(_reader, _start, _count);'.format(hnd.enumerator))) + + e.members.add(MethodDef( + '{0}.GetEnumerator'.format(TypeInst(Ty.IEnumerableT, hnd)), + sig = [TypeInst(Ty.IEnumeratorT, hnd), []], + body = 'return new {0}(_reader, _start, _count);'.format(hnd.enumerator))) + + e.members.add(MethodDef( + '{0}.GetEnumerator'.format(Ty.IEnumerable.FullName()), + sig = [Ty.IEnumerator.FullName(), []], + body = 'return new {0}(_reader, _start, _count);'.format(hnd.enumerator.FullName()))) + + hnd.enumerable = e + return e + +#========================================================================================================== +def CreateBinaryReaderExtensionMethod(tDecl, tReal = None, body = None): + tReal = tReal or tDecl + body = body or 'value = ({0})reader.Read{1}();'.format(tDecl, tReal) + return MethodDef( + 'Read', + sig = [Ty.void, [(Ty.MdBinaryReader, 'reader'), ('out ' + str(tDecl), 'value')]], + flags = AccessFlags.Internal | MemberFlags.Extension, + body = body) + +#========================================================================================================== +def CreateBinaryReaderExtensionClass(hnds): + cl = ClassDef( + 'BinaryReaderExtensions', + flags = AccessFlags.Internal | TypeFlags.Static | TypeFlags.Partial) + # for iName, iValueType in sd.primitiveTypes.iteritems(): + # cl.members.add(CreateBinaryReaderExtensionMethod(Ty[iName], Ty[iValueType])) + for eName, eType in sd.enumTypes.iteritems(): + enum = Ty.get(eName, EnumDef(eName, underlyingType = Ty[eType])) + cl.members.add(CreateBinaryReaderExtensionMethod(enum, enum.underlyingType.valueTypeName)) + for hnd in hnds.itervalues(): + cl.members.add(CreateBinaryReaderExtensionMethod(hnd, body = 'reader.UnencodedRead(out value._value);')) + return cl + +#========================================================================================================== +def CreateHandleTypeEnum(hnds): + eName = str(Ty.Handle) + 'Type' + eType = EnumDef(eName) + eType.members.add(EnumValue('Null')) + for hnd in hnds: + eValue = EnumValue(hnd.enumValueName) + eType.members.add(eValue) + hnd.enumValue = eValue + + Ty.HandleType = eType + +#========================================================================================================== +def CsEmitSource(): + globals()['Ty'] = TypeContainer() + PublishWellKnownTypes(Ty) + + Ty.Handle = StructDef('Handle', flags = AccessFlags.Public | TypeFlags.Partial) + Ty.IMetadataReader = InterfaceDef('IMetadataReader') + Ty.MetadataReader = CreateReader('MetadataReader', interfaces = [Ty.IMetadataReader]) + Ty.NativeFormatReader = Ty.MetadataReader + + ns = NamespaceDef('Internal.Metadata.NativeFormat') + ns.members.add(Ty.MetadataReader) + + globals()['handles'] = odict([(str(hnd), hnd) for hnd in map(lambda hName: CreateHandle(hName), sd.handleSchema)]) + globals()['records'] = odict([(str(rec), rec) for rec in map(lambda rName: CreateRecord(rName), sd.recordSchema.iterkeys())]) + + CreateHandleTypeEnum(handles.values()) + + # Associate records and handles + for rec in records.itervalues(): + hnd = handles[str(rec) + str(Ty.Handle)] + rec.handle = hnd + hnd.record = rec + + # Create record members + for rName,rMembers in sd.recordSchema.iteritems(): + rec = records[rName] + rec.members.add(FieldDef(CsMakePrivateName('Handle'), rec.handle, flags = AccessFlags.Internal)) + rec.members.add(PropertyDef('Handle', rec.handle, getter = PropertyGetter(body = 'return _handle;'))) + for rMember in rMembers: + rec.members += CreateRecordMembers(rec, *rMember) + + # Create handle members + for hnd in handles.itervalues(): + CreateHandleMembers(hnd) + + # Add base handle helper functions + baseHandle = StructDef( + str(Ty.Handle), + flags = AccessFlags.Public | TypeFlags.Partial) + + baseHandle.members += CreateBaseHandleConversions(records.itervalues()) + ns.members.add(baseHandle) + + # Add handles and records to namespace + ns.members += handles.itervalues() + ns.members += records.itervalues() + + Ty.MetadataReader.members += CreateReaderMembers(Ty.MetadataReader, records, handles) + + # Source NativeFormatReaderGen.cs + with open(r'System\Reflection\Metadata\NativeFormatReaderGen.cs', 'w') as output : + iprint = IPrint(output) + CsEmitFileHeader(iprint) + iprint('#pragma warning disable 649') + iprint('#pragma warning disable 169') + iprint('#pragma warning disable 282 // There is no defined ordering between fields in multiple declarations of partial class or struct') + iprint() + iprint('using System;') + iprint('using System.Reflection;') + iprint('using System.Collections.Generic;') + iprint() + + ns.CsDefine(iprint) + +#========================================================================================================== +# Ty = TypeContainer() +# PublishWellKnownTypes(Ty) + +# Ty.Handle = StructDef('Handle', flags = AccessFlags.Public | TypeFlags.Partial) +# handles = odict([(str(hnd), hnd) for hnd in map(lambda hName: CreateHandle(hName), sd.handleSchema)]) +# records = odict([(str(rec), rec) for rec in map(lambda rName: CreateRecord(rName), sd.recordSchema.iterkeys())]) + +def IsHandle(t): + return isinstance(t, TypeDef) and (str(t) in handles or t == Ty.Handle) + +def IsRecord(t): + return isinstance(t, TypeDef) and str(t) in records + +#========================================================================================================== +if __name__ == '__main__': + CsEmitSource() diff --git a/src/Common/src/Internal/Metadata/NativeFormat/Script/CsWalkerGen2.py b/src/Common/src/Internal/Metadata/NativeFormat/Script/CsWalkerGen2.py new file mode 100644 index 000000000..bda895309 --- /dev/null +++ b/src/Common/src/Internal/Metadata/NativeFormat/Script/CsWalkerGen2.py @@ -0,0 +1,292 @@ +# Copyright (c) Microsoft. All rights reserved. +# Licensed under the MIT license. See LICENSE file in the project root for full license information. + +""" +This is a script that I wrote while trying to automatically generate the equivalent of MetaInfo +for desktop CLR. It did not work out very well, and is largely replaced by CsWalkerGen3.py, which +simply generates an event-based visitor pattern for walking the metadata. The manually authored +portion for the MetaInfo equivalent functionality is located in fx/src/tools/metadata/MdWalker. +""" + +import sys +import os + +if __name__ == '__main__': + #Dynamically append current script path to PYTHONPATH + sys.path.append(os.path.dirname(sys.argv[0])) + +import SchemaDef2 as sd +from CsCommonGen2 import * +# from CsNativeFormatGen2 import * +from odict import odict + +customWalkers = set( + ['MetadataString', 'TypeSpecification', 'Method', 'Field', 'Property', 'TypeVariableSignature', 'MethodTypeVariableSignature', 'TypeSpecification'] + \ + filter(lambda rName: rName.endswith('Signature'), sd.recordSchema.iterkeys())) + +#========================================================================================================== +class AttrDict(odict): + @staticmethod + def RaiseEntryNotFound(name): + raise Exception("AttrDict: entry '{}' not found.".format(name)) + + def __init__(self, default = lambda x: TypeRef(x), *args, **kv): + super(AttrDict, self).__init__(*args, **kv) + self.__default = default + + def get(self, name, default = None): + value = super(AttrDict, self).get(name) + if value: + return value + + if type(name) != str: + default = default or name + name = str(name) + + if type(name) != str: + raise Exception('unexpected argument type {0} ({1})'.format(type(name), name)) + + return self.setdefault(name, default or self.__default(name)) + + def __getitem__(self, name): + return super(AttrDict, self).get(name, None) or self.get(name) + + def __setitem__(self, name, value): + super(AttrDict, self).__setitem__(name, value) + + def __getattr__(self, name): + if name in self: + return super(AttrDict, self).get(name) + elif name in self.__dict__: + return self.__dict__[name] + else: + return self.get(name) + + def __setattr__(self, name, value): + if isinstance(value, TypeDefOrRef): + self.__setitem__(name, value) + else: + self.__dict__[name] = value + +#========================================================================================================== +class BaseWalker(TypeDef): + def __init__(self, name, types, flags = TypeFlags.Class, *args, **kv): + super(BaseWalker, self).__init__(name, flags = flags, *args, **kv) + self.Ty = types + if (self.flags & TypeFlags.TypeMask) == 0: + self.flags = self.flags | TypeFlags.Class + + # self.members.add(MethodDef( + # 'Indent', + # flags = AccessFlags.Private | MemberFlags.Static, + # sig = ['void', [('int', 'indent')]], + # body = 'for (int i = 0; i < indent * 4; ++i) Console.Write(" ");')) + + def CsTypeName(self): + return str(self) + 'Extensions' + + def CsDefineMembers(self, iprint): + super(BaseWalker, self).CsDefineMembers(iprint) + + +#========================================================================================================== +class RecordWalker(BaseWalker): + def __init__(self, name, *args, **kv): + super(RecordWalker, self).__init__(name, flags = AccessFlags.Public | TypeFlags.Static | TypeFlags.Partial, *args, **kv) + self.handle = HandleWalker(self, *args, **kv) + self.record = self + +#========================================================================================================== +class HandleWalker(BaseWalker): + def __init__(self, rec, *args, **kv): + super(HandleWalker, self).__init__(str(rec) + 'Handle', flags = AccessFlags.Public | TypeFlags.Static | TypeFlags.Partial, *args, **kv) + self.record = rec + self.handle = self + +#========================================================================================================== +class WalkerField(FieldDef): + def __init__(self, name, fieldType, flags, parent, *args, **kv): + super(WalkerField, self).__init__(name, fieldType, *args, **kv) + self.schemaFlags = flags + self.parent = parent + + def CsDefine(self, iprint): + pass + +#========================================================================================================== +class RecordWalkerMethod(MethodDef): + def FindIdentityField(self): + for field in filter(lambda m: isinstance(m, FieldDef), self.parentScope.members): + if field.schemaFlags.IsIdentity(): + return field + for field in filter(lambda m: isinstance(m, FieldDef), self.parentScope.members): + if str(field) == 'Name': + return field + + def CsDefineBody(self, iprint): + indent = 'MdWalkerHelpers.Indent(indent); ' + iprint('\n{') + identField = self.FindIdentityField() + if identField: + iprint(1, r'Console.Write("\"{{0}}\" (0x{{2}}){{1}}", record.{}.GetString(reader), (deep || newline ? "\n" : ""), record.Handle.ToString());'.format(identField)) + else: + iprint(1, 'Console.Write("{{0}} ({{1}}){{2}}", Enum.GetName(typeof(HandleType), record.Handle.ToHandle(reader).GetHandleType(reader)), record.Handle, (deep || newline ? "\\n" : ""));'.format()) + if not str(self.parentScope).startswith('Constant'): + iprint(1, 'if (!deep) return;') + iprint(1, '{}Console.WriteLine("{{");'.format(indent)) + iprint(1, '++indent;') + for field in filter(lambda m: isinstance(m, FieldDef), self.parentScope.members): + if field == identField: + continue + if field.schemaFlags.IsRef(): + if field.schemaFlags.IsCollection(): + iprint(1, 'if (record.{}.Count() != 0)'.format(field)) + else: + iprint(1, 'if (!record.{}.IsNull(reader))'.format(field)) + iprint(1, '{') + if str(field.fieldType) == 'Handle': + iprint(2, 'var handleType = Enum.GetName(typeof(HandleType), record.{}.GetHandleType(reader));'.format(field)) + iprint(2, '{1}Console.Write("{{0}}Handle {0} = ", handleType);'.format(field, indent)) + else: + iprint(2, '{2}Console.Write("{0} {1} = ");'.format(field.fieldType, field, indent)) + deep = 'true && deep' if field.schemaFlags.IsChild() else 'false && deep' + if field.schemaFlags.IsRef(): + if field.schemaFlags.IsCollection(): + iprint(2, '''Console.WriteLine(); +MdWalkerHelpers.Indent(indent); Console.WriteLine("{{"); +foreach (var entry in record.{0}) +{{ + MdWalkerHelpers.Indent(indent + 1); + entry.Walk(reader, indent + 1, {1}, newline); +}} +MdWalkerHelpers.Indent(indent); Console.WriteLine("}}");'''.format(field, deep)) + else: + iprint(2, 'record.{}.Walk(reader, indent, {}, newline);'.format(field, deep)) + else: + iprint(2, 'Console.WriteLine("{{0}}", record.{1});'.format(field.fieldType, field, indent)) + iprint(1, '}') + iprint(1, '\n--indent;') + iprint(1, '{}Console.WriteLine("}}");'.format(indent)) + iprint('}} // {}'.format(self)) + +#========================================================================================================== +class HandleWalkerMethod(MethodDef): + def CsDefineBody(self, iprint): + iprint('\n{') + iprint(1, 'if (handle.IsNull(reader)) { Console.Write("<null>" + (newline ? "\\n" : "")); return; }') + iprint(1, 'handle.Get{}(reader).Walk(reader, indent, deep, newline);'.format(self.parentScope.record)) + iprint('}} // {}'.format(self)) + +#========================================================================================================== +class WalkerGen(object): + #------------------------------------------------------------------------------------------------------ + def PublishWellKnownTypes(self): + # Intrinsics + for tName,tValueTypeName in sd.primitiveTypes.iteritems(): + t = TypeRef(tName) + t.valueTypeName = tValueTypeName + self.Ty[tName] = t + + # Flags + for (eName, eType) in sd.enumTypes.iteritems(): + self.Ty[eName] = EnumDef(eName, underlyingType = self.Ty[eType]) + + # Some standard .NET types + self.Ty.IEnumerable = InterfaceDef('IEnumerable') + self.Ty.IEnumerable.parentScope = 'System.Collections' + self.Ty.IEnumerator = InterfaceDef('IEnumerator', parentScope = 'System.Collections') + self.Ty.IEnumerator.parentScope = 'System.Collections' + self.Ty.IEnumerableT = InterfaceDef('IEnumerable', typeParams = ['T'], interfaces = [self.Ty.IEnumerable]) + self.Ty.IEnumeratorT = InterfaceDef('IEnumerator', typeParams = ['T'], interfaces = [self.Ty.IEnumerator]) + self.Ty.Dictionary = ClassDef('Dictionary', typeParams = ['K', 'V']) + self.Ty.List = ClassDef('List', typeParams = ['T']) + + #------------------------------------------------------------------------------------------------------ + def __init__(self): + self.nsReader = 'Internal.Metadata.NativeFormat' + + self.Ty = AttrDict() + self.PublishWellKnownTypes() + + self.Ty.Handle = HandleWalker('', self.Ty) + self.Ty.Record = ClassDef('Record') + self.Ty.Record.handle = self.Ty.Handle + self.Ty.Record.record = self.Ty.Record + self.Ty.Handle.record = self.Ty.Record + self.Ty.Handle.handle = self.Ty.Handle + + self.Ty.Handle.Walker = MethodDef( + 'Walk', + flags = AccessFlags.Public | MemberFlags.Extension, + sig = [self.Ty.void, [(self.Ty.Handle, 'handle'), (self.Ty.MetadataReader, 'reader'), (self.Ty.int, 'indent'), (self.Ty.bool, 'deep'), (self.Ty.bool, 'newline = true')]], + body = ''' +switch (handle.GetHandleType(reader)) +{ +case HandleType.Null: + Console.Write("<null>" + (newline ? "\\n" : "")); + break;''') + self.Ty.Handle.members.add(self.Ty.Handle.Walker) + + for (rName, rMembers) in sd.recordSchema.iteritems(): + rec = RecordWalker(rName, self.Ty) + hnd = rec.handle + self.Ty[str(rec)] = rec + self.Ty[str(hnd)] = hnd + self.Ty.Handle.Walker.body += '\ncase HandleType.{}:\n handle.To{}(reader).Walk(reader, indent, deep, newline);\n break;'.format(rec, hnd) + + self.Ty.Handle.Walker.body += ''' +default: + throw new ArgumentException(); +} ''' + + for (rName, rMembers) in sd.recordSchema.iteritems(): + rec = self.Ty[rName] + rec.members.add(RecordWalkerMethod( + 'Walk' if str(rec) not in customWalkers else 'ReferenceWalk', + flags = AccessFlags.Public | MemberFlags.Static | MemberFlags.Extension, + sig = [self.Ty.void, [(rec, 'record'), (self.Ty.MetadataReader, 'reader'), (self.Ty.int, 'indent'), (self.Ty.bool, 'deep'), (self.Ty.bool, 'newline = true')]] + )) + + if str(rec.handle) not in customWalkers: + rec.handle.members.add(HandleWalkerMethod( + 'Walk', + flags = AccessFlags.Public | MemberFlags.Static | MemberFlags.Extension, + sig = [self.Ty.void, [(rec.handle, 'handle'), (self.Ty.MetadataReader, 'reader'), (self.Ty.int, 'indent'), (self.Ty.bool, 'deep'), (self.Ty.bool, 'newline = true')]] + )) + + for (mName, mType, mFlags) in rMembers: + if type(mType) == tuple: + mType = 'Record' + fieldType = self.Ty[mType] + if mFlags.IsRef(): + fieldType = fieldType.handle + if mFlags.IsCollection(): + fieldType = TypeInst(self.Ty.IEnumerableT, fieldType) + rec.members.add(WalkerField(mName, fieldType, mFlags, rec)) + + #------------------------------------------------------------------------------------------------------ + def CsEmitSource(self): + ns = NamespaceDef('System.Reflection.Metadata.Test') + + for walker in filter(lambda m: isinstance(m, BaseWalker), self.Ty.itervalues()): + ns.members.add(walker) + + with open(r'..\..\..\PnToolChain\Metadata\MdWalker\MdWalkerGen.cs', 'w') as output : + iprint = IPrint(output) + CsEmitFileHeader(iprint) + iprint('#pragma warning disable 649') + iprint() + iprint('using System;') + iprint('using System.Linq;') + iprint('using System.IO;') + iprint('using System.Collections.Generic;') + iprint('using System.Reflection;') + iprint('using Internal.Metadata.NativeFormat;') + iprint('using Debug = System.Diagnostics.Debug;') + iprint() + + ns.CsDefine(iprint) + +#========================================================================================================== +if __name__ == '__main__': + WalkerGen().CsEmitSource() diff --git a/src/Common/src/Internal/Metadata/NativeFormat/Script/CsWalkerGen3.py b/src/Common/src/Internal/Metadata/NativeFormat/Script/CsWalkerGen3.py new file mode 100644 index 000000000..1b5725d6c --- /dev/null +++ b/src/Common/src/Internal/Metadata/NativeFormat/Script/CsWalkerGen3.py @@ -0,0 +1,233 @@ +# Copyright (c) Microsoft. All rights reserved. +# Licensed under the MIT license. See LICENSE file in the project root for full license information. + +""" +This script generates much of the implementation of that provides a +""" + +import sys +import os + +if __name__ == '__main__': + #Dynamically append current script path to PYTHONPATH + sys.path.append(os.path.dirname(sys.argv[0])) + +import SchemaDef2 as sd +from CsCommonGen2 import * +from CsNativeFormatGen2 import TypeContainer +from CsNativeFormatGen2 import PublishWellKnownTypes +from odict import odict + +#========================================================================================================== +def AsHandle(rec): + if isinstance(rec, sd.RecordDef): + return AsHandle(rec.name) + elif isinstance(rec, sd.MemberDef): + return AsHandle(rec.typeName) + elif type(rec) == tuple: + return 'Handle' + else: + return rec + 'Handle' + +#========================================================================================================== +class Walker(object): + #------------------------------------------------------------------------------------------------------ + def __init__(self): + self.csClass = None + self.Ty = TypeContainer() + PublishWellKnownTypes(self.Ty) + + #------------------------------------------------------------------------------------------------------ + def GenerateHandleVisitWorker(self): + code = 'switch (handle.GetHandleType(_reader))\n{' + for rec in sorted(sd.recordDefs.itervalues()): + code += '\ncase HandleType.{0}:\n Visit(handle.To{0}Handle(_reader), recurse);\n break;'.format(rec.name) + code += '\ndefault:\n throw new ArgumentException();\n}' + + self.csClass.members.add(MethodDef( + 'Visit', + flags = MemberFlags.Protected, + sig = [self.Ty.void, [(self.Ty.Handle, 'handle'), (self.Ty.bool, 'recurse')]], + body = code)); + + #------------------------------------------------------------------------------------------------------ + def GenerateHandleVisitFunctions(self): + for rec in sorted(sd.recordDefs.itervalues()): + self.csClass.members.add(MethodDef( + 'Visit', + flags = MemberFlags.Protected | MemberFlags.Virtual, + sig = [self.Ty.void, [(self.Ty[AsHandle(rec)], 'handle'), (self.Ty.bool, 'recurse')]], + body = ''' +_visiting.Push(handle); +_visited.Add(handle); +Visit(handle.Get{0}(_reader), recurse); +_visiting.Pop();'''.format(rec.name))) + + self.csClass.members.add(MethodDef( + 'Visit', + flags = MemberFlags.Protected | MemberFlags.Virtual, + sig = [self.Ty.void, [(self.Ty[TypeInst(self.Ty.IEnumerableT, AsHandle(rec))], 'handles'), (self.Ty.bool, 'recurse')]], + body = 'foreach (var handle in handles) Visit(handle, recurse);')); + + #------------------------------------------------------------------------------------------------------ + def GenerateRecordVisitFunctions(self): + for rec in sorted(sd.recordDefs.itervalues()): + stmts = list() + stmts.append(''' +if ({0}Event != null) +{{ + {0}Event(record); +}}'''.format(rec.name)) + + # Don't do any recursion or queue any pending handles if 'recurse' is set to false + stmts.append('if (!recurse) return;') + + for mem in sorted(rec.members, key = lambda m: '0' + m.name if m.name == 'Name' else m.name): + if mem.flags.IsRef(): + if mem.flags.IsChild(): + stmts.append('Visit(record.{0}, recurse);'.format(mem.name)) + else: + if mem.flags.IsSequence(): + stmts.append(''' +foreach (var handle in record.{0}) +{{ + //Debug.Assert(((Handle)handle).GetHandleType(_reader) != HandleType.TypeDefinition); + if (!_visited.Contains(handle)) + _pending.Add(handle); +}}'''.format(mem.name)) + else: + stmts.append(''' +if (!record.{0}.IsNull(_reader) && !_visited.Contains(record.{0})) +{{ + //Debug.Assert(((Handle)record.{0}).GetHandleType(_reader) != HandleType.TypeDefinition); + _pending.Add(record.{0}); +}}'''.format(mem.name)) + + self.csClass.members.add(MethodDef( + 'Visit', + flags = MemberFlags.Protected | MemberFlags.Virtual, + sig = [self.Ty.void, [(self.Ty[rec.name], 'record'), (self.Ty.bool, 'recurse')]], + body = '\n'.join(stmts))); + + #------------------------------------------------------------------------------------------------------ + def GenerateRecordVisitEvents(self): + for rec in sorted(sd.recordDefs.itervalues()): + # self.csClass.members.add(EventDef( + # '{}BeginEvent'.format(rec), + # self.Ty['VisitBeginHandler<{}>'.format(rec)], + # flags = AccessFlags.Public)) + + self.csClass.members.add(EventDef( + '{}Event'.format(rec), + self.Ty['VisitHandler<{}>'.format(rec)], + flags = AccessFlags.Public)) + + # self.csClass.members.add(EventDef( + # '{}EndEvent'.format(rec), + # self.Ty['VisitEndHandler<{}>'.format(rec)], + # flags = AccessFlags.Public)) + + #------------------------------------------------------------------------------------------------------ + def GenerateHandleDisplayWorker(self): + code = 'switch (handle.GetHandleType(_reader))\n{' + for rec in sorted(sd.recordDefs.itervalues()): + code += '\ncase HandleType.{0}:\n Display(handle.To{0}Handle(_reader).Get{0}(_reader));\n break;'.format(rec.name) + code += '\ndefault:\n throw new ArgumentException();\n}' + + self.csClass.members.add(MethodDef( + 'Display', + flags = MemberFlags.Public, + sig = [self.Ty.void, [(self.Ty.Handle, 'handle')]], + body = code)); + + #------------------------------------------------------------------------------------------------------ + def GenerateHandleDisplayFunctions(self): + for rec in sorted(sd.recordDefs.itervalues()): + self.csClass.members.add(MethodDef( + 'Display', + flags = MemberFlags.Public | MemberFlags.Virtual, + sig = [self.Ty.void, [(self.Ty[AsHandle(rec)], 'handle')]], + # body = 'Display(handle.Get{0}(_reader));'.format(rec))); + body = ''' +if (!_visited.Contains(handle)) +{{ + _visited.Add(handle); + Display(handle.Get{0}(_reader)); +}}'''.format(rec.name))) + + self.csClass.members.add(MethodDef( + 'Display', + flags = MemberFlags.Public | MemberFlags.Virtual, + sig = [self.Ty.void, [(self.Ty[TypeInst(self.Ty.IEnumerableT, AsHandle(rec))], 'handles')]], + body = 'foreach (var handle in handles) Display(handle);')); + + #------------------------------------------------------------------------------------------------------ + def GenerateRecordDisplayFunctions(self): + for rec in sorted(sd.recordDefs.itervalues()): + stmts = ['var sb = new System.Text.StringBuilder();'] + for mem in sorted(rec.members, key = lambda m: '0' + m.name if m.name == 'Name' else m.name): + if mem.flags.IsRef(): + pass + # if mem.flags.IsNotPersisted(): + # pass + # elif mem.flags.IsSequence(): + # if mem.flags.IsRef() and (mem.flags.IsChild() or mem.typeName == 'ConstantStringValue'): + # stmts.append('_sw.WriteLine(" {0} :\\n [");\nforeach (var handle in record.{0}) Display(handle);\n_sw.WriteLine("\\n ]");'.format(mem.name)) + # else: + # stmts.append('_sw.WriteLine(" {0} :\\n [");\nforeach (var handle in record.{0}) _sw.WriteLine(" {{0}}", handle.ToString());\n_sw.WriteLine("\\n ]");'.format(mem.name)) + # elif mem.flags.IsRef() and (mem.flags.IsChild() or mem.typeName == 'ConstantStringValue'): + # stmts.append('_sw.Write(" {0} : ");\nDisplay(record.{0});'.format(mem.name)) + else: + stmts.append('sb.AppendFormat(" {0} : {{0}},\\n", record.{0}.ToString());'.format(mem.name, mem.typeName)) + + stmts.append('return sb.ToString();') + + self.csClass.members.add(MethodDef( + 'Display', + flags = MemberFlags.Public | MemberFlags.Virtual, + sig = [self.Ty.string, [(self.Ty[str(rec)], 'record')]], + body = '\n'.join(stmts))); + + #------------------------------------------------------------------------------------------------------ + def GenerateCsClass(self): + if self.csClass == None: + self.csClass = ClassDef( + 'Walker', + flags = TypeFlags.Public | TypeFlags.Partial) + + + self.GenerateHandleVisitWorker() + self.GenerateHandleVisitFunctions() + self.GenerateRecordVisitFunctions() + self.GenerateRecordVisitEvents() + + # self.GenerateHandleDisplayWorker() + # self.GenerateHandleDisplayFunctions() + # self.GenerateRecordDisplayFunctions() + + self.Ty[self.csClass] = self.csClass + + return self.csClass + + #------------------------------------------------------------------------------------------------------ + def CsEmitSource(self): + ns = NamespaceDef('MdWalker') + ns.members.add(Walker().GenerateCsClass()) + + with open(r'..\..\..\PnToolChain\Metadata\MdWalker\MdWalkerGen.cs', 'w') as output: + iprint = IPrint(output) + CsEmitFileHeader(iprint) + iprint('using System;') + iprint('using System.Linq;') + iprint('using System.IO;') + iprint('using System.Collections.Generic;') + iprint('using System.Reflection;') + iprint('using Internal.Metadata.NativeFormat;') + iprint('using Debug = System.Diagnostics.Debug;') + iprint() + + ns.CsDefine(iprint) + +#========================================================================================================== +if __name__ == '__main__': + Walker().CsEmitSource() diff --git a/src/Common/src/Internal/Metadata/NativeFormat/Script/CsWriterGen2.py b/src/Common/src/Internal/Metadata/NativeFormat/Script/CsWriterGen2.py new file mode 100644 index 000000000..79302b9e8 --- /dev/null +++ b/src/Common/src/Internal/Metadata/NativeFormat/Script/CsWriterGen2.py @@ -0,0 +1,413 @@ +# Copyright (c) Microsoft. All rights reserved. +# Licensed under the MIT license. See LICENSE file in the project root for full license information. + +import sys +import os + +if __name__ == '__main__': + #Dynamically append current script path to PYTHONPATH + sys.path.append(os.path.dirname(sys.argv[0])) + +import SchemaDef2 as sd +from CsCommonGen2 import * +from CsNativeFormatGen2 import * +from odict import odict + +class WriterGen(object): + #========================================================================================================== + def __init__(self): + self.nsReader = 'Internal.Metadata.NativeFormat' + + self.Ty = TypeContainer() + PublishWellKnownTypes(self.Ty) + + self.Ty.MetadataRecord = StructDef('MetadataRecord', flags = AccessFlags.Public | TypeFlags.Partial) + self.Ty.Handle = self.Ty.MetadataRecord + + self.Ty.NativeWriter = ClassDef('NativeWriter') + + self.records = odict([(rName, self.CreateRecord(rName, rMembers)) for (rName,rMembers) in sd.recordSchema.iteritems()]) + + #========================================================================================================== + def IsRecord(self, t): + return isinstance(t, TypeDef) and str(t) in sd.recordSchema.iterkeys() + + #========================================================================================================== + def GetOrCreateType(self, ty, flags): + if type(ty) == tuple: + if not flags.IsRef(): raise Exception('Unexpected ty type.') + ty = self.Ty.Handle + + if flags.IsArray(): + return self.Ty.get(ty + '[]', TypeRef( + name = ty + '[]', + flags = TypeFlags.Public | TypeFlags.Array, + underlyingType = self.GetOrCreateType(ty, flags ^ sd.MemberDefFlags.Array))) + + if type(ty) == str: + if ty == 'Handle': + ty = 'MetadataRecord' + if ty == 'Handle[]': + ty = 'MetadataRecord[]' + ty = self.Ty[ty] + + if flags.IsCollection() and not flags.IsRef() and not flags.IsArray(): + raise Exception('Unexpected collection element type "{}" (flags = {}.'.format(type(ty), flags)) + + if flags.IsMap(): + # return self.Ty[TypeInst(self.Ty.Dictionary, self.Ty.string, ty)] + return self.Ty[TypeInst(self.Ty.List, ty)] + elif flags.IsList(): + return self.Ty[TypeInst(self.Ty.List, ty)] + else: + return ty + + #========================================================================================================== + def ProcessRecordMemberForVisitor(self, rec, mName, mType, flags): + if flags.IsRef(): + if flags.IsMap(): + if flags.IsChild(): + # rec.onVisit.body += '\n{0} = visitor.Visit(this, {0}.AsEnumerable());'.format(mName) + rec.onVisit.body += '\n{0} = visitor.Visit(this, {0}.AsEnumerable());'.format(mName) + else: + # rec.onVisit.body += '\nforeach (var key in {0}.Keys)\n {0}[key] = visitor.Visit(this, {0}[key]);'.format(mName) + rec.onVisit.body += '\n{0} = {0}.Select(value => visitor.Visit(this, value)).ToList();'.format(mName) + elif flags.IsSequence(): + if flags.IsChild(): + rec.onVisit.body += '\n{0} = visitor.Visit(this, {0}.AsEnumerable());'.format(mName) + else: + rec.onVisit.body += '\n{0} = {0}.Select(value => visitor.Visit(this, value)).ToList();'.format(mName) + else: + if flags.IsChild(): + rec.onVisit.body += '\n{0} = visitor.Visit(this, {0}.AsSingleEnumerable()).FirstOrDefault();'.format(mName) + else: + rec.onVisit.body += '\n{0} = visitor.Visit(this, {0});'.format(mName) + + #========================================================================================================== + def ProcessRecordMember(self, rec, mName, mType, flags): + members = list() + if flags.IsNotPersisted(): + return members + + mTypeSet = mType if type(mType) == tuple else (mType,) + mType = self.GetOrCreateType(mType, flags) + mType.schemaFlags = flags + + field = FieldDef(mName, mType, flags = AccessFlags.Public | MemberFlags.Serialize) + field.schemaFlags = flags + members.append(field) + + if flags.IsCollection() and not flags.IsArray(): + field.autoInitialize = True + + if (flags.IsCompare() or not rec.defFlags.IsCustomCompare()): + if flags.IsCollection(): + rec.mEquals.body += '\nif (!{0}.SequenceEqual(other.{0})) return false;'.format(field) + elif str(field.fieldType) in sd.primitiveTypes or str(field.fieldType) in sd.enumTypes: + rec.mEquals.body += '\nif ({0} != other.{0}) return false;'.format(field) + else: + rec.mEquals.body += '\nif (!Object.Equals({0}, other.{0})) return false;'.format(field) + + # Being very selective here to prevent reentrancy in GetHashCode. + if str(field.fieldType) in sd.stringRecordTypes: + rec.mHashCode.body += '\nhash = ((hash << 13) - (hash >> 19)) ^ ({0} == null ? 0 : {0}.GetHashCode());'.format(field) + elif str(field.fieldType) == 'string': + rec.mHashCode.body += '\nhash = ((hash << 13) - (hash >> 19)) ^ ({0} == null ? 0 : {0}.GetHashCode());'.format(field) + elif str(field.fieldType) in sd.primitiveTypes or str(field.fieldType) in sd.enumTypes: + rec.mHashCode.body += '\nhash = ((hash << 13) - (hash >> 19)) ^ {0}.GetHashCode();'.format(field) + elif flags.IsArray() and (str(field.fieldType.underlyingType) in sd.primitiveTypes): + rec.mHashCode.body += ''' +if ({0} != null) +{{ + for (int i = 0; i < {0}.Length; i++) + {{ + hash = ((hash << 13) - (hash >> 19)) ^ {0}[i].GetHashCode(); + }} +}}'''.format(field) + elif flags.IsList() and flags.IsEnumerateForHashCode(): + rec.mHashCode.body += ''' +if ({0} != null) +{{ + for (int i = 0; i < {0}.Count; i++) + {{ + hash = ((hash << 13) - (hash >> 19)) ^ ({0}[i] == null ? 0 : {0}[i].GetHashCode()); + }} +}}'''.format(field) + elif not flags.IsCollection(): + rec.mHashCode.body += '\nhash = ((hash << 13) - (hash >> 19)) ^ ({0} == null ? 0 : {0}.GetHashCode());'.format(field) + + if flags.IsRef() and len(mTypeSet) > 1: + valueName = str(field) + rec.recordEmit.body += '\nDebug.Assert(' + if flags.IsSequence(): + rec.recordEmit.body += '{}.TrueForAll(handle => '.format(field) + valueName = 'handle' + rec.recordEmit.body += ' ||\n '.join(['{} == null'.format(valueName)] + ['{}.HandleType == HandleType.{}'.format(valueName, ty) for ty in mTypeSet]) + if flags.IsSequence(): + rec.recordEmit.body += ')' + rec.recordEmit.body += ');' + + if flags.IsRef() and flags.IsMap(): + # rec.recordEmit.body += '\nwriter.Write({}.Values);'.format(field) + rec.recordEmit.body += '\nwriter.Write({0});'.format(field) + else: + rec.recordEmit.body += '\nwriter.Write({0});'.format(field) + + # if mName == "CustomAttributes": + # rec.interfaces += [self.Ty.ICustomAttributeMetadataRecord] + # members.append(MethodDef( + # 'ICustomAttributeMetadataRecord.GetCustomAttributes', + # flags = MemberFlags(0), + # sig = [TypeInst(self.Ty.IListT, self.Ty.CustomAttribute), []], + # body = 'return CustomAttributes;')) + + return members + + #========================================================================================================== + def CreateRecord(self, name, members): + flags = AccessFlags.Public | TypeFlags.Partial | TypeFlags.Struct + recordDef = sd.recordDefs[name] + rec = ClassDef(name, self.Ty.get(recordDef.baseTypeName or 'MetadataRecord'), flags) + rec.enumType = self.Ty.HandleType + rec.enumValue = str(rec) + rec.handle = self.Ty['{}Handle'.format(rec)] + rec.defFlags = recordDef.flags + self.Ty[name] = rec + + rec.ctor = CtorDef(body = '') + rec.members.add(rec.ctor) + + rec.members.add(PropertyDef( + 'HandleType', + self.Ty.HandleType, + flags = AccessFlags.Public | MemberFlags.Override, + getter = PropertyGetter( + body = 'return HandleType.{0};'.format(str(rec))))) + + rec.onVisit = rec.members.add(MethodDef( + 'Visit', + flags = AccessFlags.Internal | MemberFlags.Override, + sig = [self.Ty.void, [(self.Ty.IRecordVisitor, 'visitor')]], + body = '')) + + rec.mEquals = rec.members.add(MethodDef( + 'Equals', + flags = AccessFlags.Public | MemberFlags.Override | MemberFlags.Sealed, + sig = [self.Ty.bool, [(self.Ty.Object, 'obj')]], + body = ''' +if (Object.ReferenceEquals(this, obj)) return true; +var other = obj as {0}; +if (other == null) return false;'''.format(rec))) + + if rec.defFlags.IsReentrantEquals(): + rec.members.add(FieldDef( + '_equalsReentrancyGuard', + fieldType = self.Ty[TypeInst(self.Ty.ThreadLocal, self.Ty['ReentrancyGuardStack'])], + flags = AccessFlags.Private, + autoInitialize = False)) + rec.mEquals.body += ''' +if (_equalsReentrancyGuard.Value.Contains(other)) + return true; +_equalsReentrancyGuard.Value.Push(other); +try +{''' + rec.ctor.body += '_equalsReentrancyGuard = new ThreadLocal<ReentrancyGuardStack>(() => new ReentrancyGuardStack());' + + rec.mHashCode = rec.members.add(MethodDef( + 'GetHashCode', + flags = AccessFlags.Public | MemberFlags.Override | MemberFlags.Sealed, + sig = [self.Ty.int, []], + body = ''' +if (_hash != 0) + return _hash; +EnterGetHashCode(); +int hash = {};'''.format(hash(str(rec))))) + + rec.recordEmit = MethodDef( + 'Save', + flags = AccessFlags.Internal | MemberFlags.Override, + sig = [self.Ty.void, [(self.Ty.NativeWriter, 'writer')]], + body = ''' +''') + rec.members.add(rec.recordEmit) + + rec.members.add(MethodDef( + 'AsHandle'.format(rec), + sig = [rec.handle, [(rec, 'record')]], + flags = AccessFlags.Internal | MemberFlags.Static, + body = ''' +if (record == null) +{{ + return new {0}(0); +}} +else +{{ + return record.Handle; +}} +'''.format(rec.handle, rec.enumType, rec.enumValue))) + + # String records with a null Value property are translated to null handle values so that + # we can tell the difference between the empty and null string values. + if str(rec) in sd.stringRecordTypes: + rec.recordEmit.body = 'if (Value == null)\n return;\n' + rec.recordEmit.body + + rec.members.add(PropertyDef( + 'Handle'.format(rec), + '{}Handle'.format(rec), + flags = AccessFlags.Internal | MemberFlags.New, + getter = PropertyGetter(body = ''' +if (Value == null) + return new {0}Handle(0); +else + return new {0}Handle(HandleOffset); +'''.format(rec, rec.enumType, rec.enumValue)))) + else: + rec.members.add(PropertyDef( + 'Handle'.format(rec), + '{}Handle'.format(rec), + flags = AccessFlags.Internal | MemberFlags.New, + getter = PropertyGetter(body = ''' +return new {0}Handle(HandleOffset); +'''.format(rec, rec.enumType, rec.enumValue)))) + + for m in members: + rec.members += self.ProcessRecordMember(rec, *m) + + for m in sorted(members, lambda (m1,t1,f1),(m2,t2,f2): cmp(not f1.IsChild(), not f2.IsChild())): + self.ProcessRecordMemberForVisitor(rec, *m) + + if rec.defFlags.IsReentrantEquals(): + rec.mEquals.body += ''' +} +finally +{ + var popped = _equalsReentrancyGuard.Value.Pop(); + Debug.Assert(Object.ReferenceEquals(other, popped)); +}''' + rec.mEquals.body += '\nreturn true;' + rec.mHashCode.body += '\nLeaveGetHashCode();\n_hash = hash;\nreturn _hash;' + + return rec + + #========================================================================================================== + def CreateWriterMembers(self, reader, recs): + members = list() + + # for rec in recs: + # field = FieldDef( + # CsMakePrivateName(Plural(str(rec))), + # self.Ty[TypeInst(self.Ty.List, rec)], + # flags = AccessFlags.Internal, + # autoInitialize = True) + # members.append(field) + + # members.append(MethodDef( + # 'AddRecord', + # flags = AccessFlags.Internal, + # sig = [self.Ty.void, [(rec, 'record')]], + # body = '{0}.Add(record);'.format(field))) + + return members + + #========================================================================================================== + def CreateWriter(self, name, recs): + writer = ClassDef(name, flags = AccessFlags.Public | TypeFlags.Partial) + writer.members += self.CreateWriterMembers(writer, recs) + return writer + + #========================================================================================================== + def CreateBinaryWriterExtensionMethod(self, tDecl, tReal = None, body = None, argName = 'value'): + tReal = tReal or tDecl + body = body or 'writer.Write(({}){});'.format(tReal, argName) + return MethodDef( + 'Write', + sig = [self.Ty.void, [(self.Ty.MdBinaryWriter, 'writer'), (tDecl, argName)]], + flags = AccessFlags.Internal | MemberFlags.Extension, + body = body) + + #========================================================================================================== + def CreateDictionaryExtensionClass(self, recs): + cl = ClassDef( + 'DictionaryExtensions', + flags = AccessFlags.Public | TypeFlags.Static | TypeFlags.Partial) + for rec in recs.itervalues(): + if len(filter(lambda field: isinstance(field, FieldDef) and str(field) == 'Name', rec.members)) > 0: + cl.members.add(MethodDef( + 'Add', + flags = AccessFlags.Public | MemberFlags.Extension, + sig = [self.Ty.void, [(TypeInst(self.Ty.Dictionary, self.Ty.string, rec), 'dict'), (rec, 'record')]], + body = 'dict.Add(record.Name.Value ?? "<null>", record);')) + return cl + + #========================================================================================================== + # def CreateVisitorInterface(self): + # itf = InterfaceDef( + # 'IRecordVisitor', + # flags = AccessFlags.Internal | TypeFlags.Partial) + + # for item in itertools.chain( + # self.records.itervalues(), + # map(lambda k: self.Ty[k], sd.primitiveTypes.iterkeys()), + # map(lambda e: self.Ty[e], sd.enumTypes.iterkeys())): + # itf.members.add(MethodDef( + # 'Visit', + # sig = [self.Ty.void, [(item, 'item')]])) + + # return itf + + #========================================================================================================== + # def CreateVisitorEnumerate(self): + # cls = ClassDef( + # 'IRecordVisitor', + # flags = AccessFlags.Internal | TypeFlags.Partial) + + # for item in itertools.chain( + # self.records.itervalues(), + # map(lambda k: self.Ty[k], sd.primitiveTypes.iterkeys()), + # map(lambda e: self.Ty[e], sd.enumTypes.iterkeys())): + # cls.members.add(MethodDef( + # 'Visit', + # sig = [self.Ty.void, [(item, 'item')]])) + + # return cls + + #========================================================================================================== + def CsEmitSource(self): + ns = NamespaceDef('Internal.Metadata.NativeFormat.Writer') + + ns.members += self.records.values() + + writer = self.CreateWriter('MetadataWriter', self.records.values()) + ns.members.add(writer) + + # ns.members.add(self.CreateDictionaryExtensionClass(self.records)) + + # ns.members.add(self.CreateVisitorInterface()) + + # for hnd in filter(lambda h: getattr(h, 'record', None), hnds.values()): + # ns.members.add(CreateHandleEnumerator(reader, hnd)) + # ns.members.add(CreateHandleEnumerable(reader, hnd)) + + # Source NativeFormatReaderGen.cs + with open(r'..\..\..\PnToolChain\Metadata\NativeFormatWriter\NativeFormatWriterGen.cs', 'w') as output : + iprint = IPrint(output) + CsEmitFileHeader(iprint) + iprint('#pragma warning disable 649') + iprint() + iprint('using System;') + iprint('using System.Linq;') + iprint('using System.IO;') + iprint('using System.Collections.Generic;') + iprint('using System.Reflection;') + iprint('using System.Threading;') + iprint('using Internal.Metadata.NativeFormat.Writer;') + iprint('using Internal.NativeFormat;') + iprint('using HandleType = Internal.Metadata.NativeFormat.HandleType;') + iprint('using Debug = System.Diagnostics.Debug;') + iprint() + + ns.CsDefine(iprint) + +#========================================================================================================== +if __name__ == '__main__': + WriterGen().CsEmitSource() diff --git a/src/Common/src/Internal/Metadata/NativeFormat/Script/DocGen.py b/src/Common/src/Internal/Metadata/NativeFormat/Script/DocGen.py new file mode 100644 index 000000000..611029b8d --- /dev/null +++ b/src/Common/src/Internal/Metadata/NativeFormat/Script/DocGen.py @@ -0,0 +1,73 @@ +# Copyright (c) Microsoft. All rights reserved. +# Licensed under the MIT license. See LICENSE file in the project root for full license information. + +""" +Quick script used to generate documentation-like output for all of the metadata records +defined in SchemaDef2.py +""" +import sys +import os +import re + +if __name__ == '__main__': + #Dynamically append current script path to PYTHONPATH + sys.path.append(os.path.dirname(sys.argv[0])) + +import SchemaDef2 as sd + +allConstantHandles = list() +allConstantValueHandles = list() +allConstantArrayHandles = list() +for record in sd.recordDefs.itervalues(): + if record.name.startswith('Constant'): + allConstantHandles.append(record.name + 'Handle') + if record.name.endswith('Array'): + allConstantArrayHandles.append(record.name + 'Handle') + elif record.name.endswith('Value'): + allConstantValueHandles.append(record.name + 'Handle') + +for record in sorted(sd.recordDefs.itervalues(), lambda r1, r2: cmp(r1.name, r2.name)): + sys.stdout.write(record.name) + # members = filter(lambda member: member.name != 'Value', record.members) + members = record.members + # if len(members) == 1: + # print ' {{ {} }}'.format(member.name) + # elif len(members) > 1: + if len(members) > 0: + print ' {' + for member in members: + typeNamePrefix = '' + typeNameSuffix = '' + if member.flags.IsRef() and member.typeName != 'Handle': + typeNameSuffix += 'Handle' + if type(member.typeName) == str: + typeName = member.typeName + typeNameSuffix + else: + constants = list() + others = list() + types = sorted(map(lambda name: typeNamePrefix + name + typeNameSuffix, member.typeName)) + for t in types: + m = re.match(r'Constant(.*)(Array|Value)Handle', t) + if m: + constants.append(t) + else: + others.append(t) + typeName = ' { \n' + ' ' * 8 + typeName += (' |\n' + ' ' * 8).join(others) + if constants == allConstantHandles: + typeName += (' |\n' + ' ' * 8) + 'Constant*ValueHandle' + typeName += (' |\n' + ' ' * 8) + 'Constant*ArrayHandle' + elif constants == allConstantValueHandles: + typeName += (' |\n' + ' ' * 8) + 'Constant*ValueHandle' + elif constants == allConstantArrayHandles: + typeName += (' |\n' + ' ' * 8) + 'Constant*ArrayHandle' + typeName += '\n' + ' ' * 4 + '}' + if member.flags.IsSequence(): + typeName += '[]' + if member.flags.IsMap(): + typeName = 'Dictionary<string, ' + typeName + '>' + print '{}{} : {}'.format(' ' * 4, member.name, typeName) + if sorted(constants) == sorted(allConstantHandles): + print '{}{} : {}'.format(' ' * 4, member.name, typeName) + print '}' +
\ No newline at end of file diff --git a/src/Common/src/Internal/Metadata/NativeFormat/Script/GetHashCode-Dependencies.dgml b/src/Common/src/Internal/Metadata/NativeFormat/Script/GetHashCode-Dependencies.dgml new file mode 100644 index 000000000..9ada59f14 --- /dev/null +++ b/src/Common/src/Internal/Metadata/NativeFormat/Script/GetHashCode-Dependencies.dgml @@ -0,0 +1,174 @@ +<?xml version="1.0" encoding="utf-8"?> +<DirectedGraph GraphDirection="BottomToTop" Layout="Sugiyama" xmlns="http://schemas.microsoft.com/vs/2009/dgml"> + <Nodes> + <Node Id="ArraySignature" Bounds="857.725,172.9425,98.55,25.96" ErrorMessage="Circular reference found involving: ArraySignature (ArraySignature)" IsStronglyConnected="True" /> + <Node Id="ByReferenceSignature" Bounds="987.108333333333,172.9425,135.783333333333,25.96" ErrorMessage="Circular reference found involving: ByReferenceSignature (ByReferenceSignature)" IsStronglyConnected="True" /> + <Node Id="CustomAttribute" Bounds="582.056666666667,518.8275,107.886666666667,25.96" /> + <Node Id="CustomModifier" Bounds="191.18,288.2375,105.64,25.96" /> + <Node Id="Event" Bounds="490,634.1225,50,25.96" /> + <Node Id="Field" Bounds="1616,576.475,50,25.96" /> + <Node Id="FieldSignature" Bounds="1657.21666666667,288.2375,95.5666666666666,25.96" /> + <Node Id="FixedArgument" Bounds="1783.57166666667,288.2375,100.856666666667,25.96" /> + <Node Id="FixedArgument1" Bounds="554.571666666667,288.2375,100.856666666667,25.96" Label="FixedArgument" /> + <Node Id="GenericParameter" Bounds="971.781666666667,288.2375,114.436666666667,25.96" /> + <Node Id="MemberReference" Bounds="962.28,461.18,117.44,25.96" /> + <Node Id="Method" Bounds="755.996666666667,403.5325,62.0066666666667,25.96" /> + <Node Id="MethodImpl" Bounds="686.251666666667,576.475,85.4966666666667,25.9599999999999" /> + <Node Id="MethodInstantiation" Bounds="862.04,518.8275,127.92,25.9599999999999" /> + <Node Id="MethodSemantics" Bounds="457.25,576.475,115.5,25.96" /> + <Node Id="MethodSignature" Bounds="964.721666666667,345.885,112.556666666667,25.96" /> + <Node Id="MethodTypeVariableSignature" Bounds="615.518333333333,172.9425,180.963333333333,25.96" /> + <Node Id="NamedArgument" Bounds="579.998333333333,345.885,112.003333333333,25.96" /> + <Node Id="NamespaceDefinition" Bounds="1688.19333333333,57.6475,133.613333333333,25.96" /> + <Node Id="NamespaceReference" Bounds="252.841666666667,57.6475,134.316666666667,25.96" /> + <Node Id="Parameter" Bounds="685.881666666667,288.2375,74.2366666666667,25.96" /> + <Node Id="ParameterTypeSignature" Bounds="790.895,288.2375,150.21,25.96" /> + <Node Id="PointerSignature" Bounds="1487.74333333333,172.9425,108.513333333333,25.96" ErrorMessage="Circular reference found involving: PointerSignature (PointerSignature)" IsStronglyConnected="True" /> + <Node Id="Property" Bounds="571.35,634.1225,65.3,25.96" /> + <Node Id="PropertySignature" Bounds="818.075,345.885,115.85,25.96" /> + <Node Id="ReturnTypeSignature" Bounds="1148.37666666667,288.2375,131.246666666667,25.96" /> + <Node Id="SZArraySignature" Bounds="1345.11666666667,172.9425,111.766666666667,25.96" ErrorMessage="Circular reference found involving: SZArraySignature (SZArraySignature)" IsStronglyConnected="True" /> + <Node Id="ScopeDefinition" Bounds="1702.94,0,104.12,25.96" /> + <Node Id="ScopeReference" Bounds="458.588333333333,0,104.823333333333,25.96" /> + <Node Id="TypeDefinition" Bounds="1706.36666666667,115.295,97.2666666666664,25.96" /> + <Node Id="TypeForwarder" Bounds="461.521666666667,57.6475,98.9566666666667,25.96" /> + <Node Id="TypeInstantiationSignature" Bounds="1153.05666666667,172.9425,161.886666666667,25.96" ErrorMessage="Circular reference found involving: TypeInstantiationSignature (TypeInstantiationSignature)" IsStronglyConnected="True" /> + <Node Id="TypeReference" Bounds="271.015,115.295,97.97,25.96" /> + <Node Id="TypeSpecification" Bounds="1060.65833333333,230.59,112.683333333333,25.96" ErrorMessage="Circular reference found involving: TypeSpecification (TypeSpecification)" IsStronglyConnected="True" /> + <Node Id="TypeVariableSignature" Bounds="446.521666666667,172.9425,138.956666666666,25.96" Label="TypeVariableSignature" /> + </Nodes> + <Links> + <Link Source="ArraySignature" Target="TypeDefinition" Bounds="907,130.233795166016,790.371826171875,42.7087097167969" /> + <Link Source="ArraySignature" Target="TypeReference" Bounds="377.97216796875,131.375137329102,507.412353515625,41.5673675537109" /> + <Link Source="ArraySignature" Target="TypeSpecification" Bounds="948.880065917969,198.902496337891,106.693786621094,29.5329132080078" IsCircularLink="True" /> + <Link Source="ByReferenceSignature" Target="TypeDefinition" Bounds="1055,130.647842407227,642.374267578125,42.2946624755859" /> + <Link Source="ByReferenceSignature" Target="TypeReference" Bounds="377.975250244141,130.974624633789,624.787261962891,41.9678802490234" /> + <Link Source="ByReferenceSignature" Target="TypeSpecification" Bounds="1082.92004394531,198.902496337891,32.0693359375,22.9149627685547" IsCircularLink="True" /> + <Link Source="CustomAttribute" Target="FixedArgument1" Bounds="519.365600585938,319.129272460938,65.3670043945313,199.715759277344" /> + <Link Source="CustomAttribute" Target="MemberReference" Bounds="689.943359375,484.637878417969,263.442810058594,39.3563232421875" /> + <Link Source="CustomAttribute" Target="Method" Bounds="664.820678710938,435.837036132813,102.736633300781,82.990478515625" /> + <Link Source="CustomAttribute" Target="NamedArgument" Bounds="636,380.845001220703,0,137.982513427734" /> + <Link Source="CustomAttribute" Target="TypeDefinition" Bounds="689.943359375,146.124664306641,1224.39245605469,377.748565673828" /> + <Link Source="CustomAttribute" Target="TypeReference" Bounds="149.55339050293,146.124664306641,432.575759887695,375.047515869141" /> + <Link Source="CustomModifier" Target="TypeDefinition" Bounds="232.888885498047,129.486633300781,1464.4797668457,158.750854492188" /> + <Link Source="CustomModifier" Target="TypeReference" Bounds="192,141.243347167969,70.410400390625,146.994140625" /> + <Link Source="CustomModifier" Target="TypeSpecification" Bounds="278.224548339844,245.932891845703,773.439636230469,42.3045959472656" /> + <Link Source="Event" Target="CustomAttribute" Bounds="539.056030273438,552.021606445313,81.98291015625,82.916259765625" /> + <Link Source="Event" Target="MethodSemantics" Bounds="515,611.434997558594,0,22.6875" /> + <Link Source="Event" Target="TypeDefinition" Bounds="539.396911621094,145.282577514648,1503.60308837891,490.035781860352" /> + <Link Source="Event" Target="TypeReference" Bounds="0,133.494689941406,490,512.208618164063" /> + <Link Source="Event" Target="TypeSpecification" Bounds="352,246.031707763672,699.664672851563,396.649993896484" /> + <Link Source="Field" Target="CustomAttribute" Bounds="698.410827636719,545.034790039063,917.589172363281,43.5910034179688" /> + <Link Source="Field" Target="FieldSignature" Bounds="1665.76159667969,323.197509765625,39.2384033203125,255.105590820313" /> + <Link Source="Field" Target="TypeDefinition" Bounds="1666,134.757736206055,345,452.749710083008" /> + <Link Source="Field" Target="TypeReference" Bounds="149.634170532227,146.826034545898,1466.36582946777,441.863174438477" /> + <Link Source="Field" Target="TypeSpecification" Bounds="1182.22155761719,254.332962036133,458.778442382813,322.142013549805" /> + <Link Source="FieldSignature" Target="TypeDefinition" Bounds="1741.47619628906,150.053756713867,33.31396484375,138.183731079102" /> + <Link Source="FieldSignature" Target="TypeReference" Bounds="377.970489501953,131.570709228516,1315.32113647461,156.666778564453" /> + <Link Source="FieldSignature" Target="TypeSpecification" Bounds="1180.13537597656,257.678527832031,503.699462890625,30.5589599609375" /> + <Link Source="FixedArgument" Target="TypeDefinition" Bounds="1812.26318359375,141.169830322266,70.73681640625,147.067657470703" /> + <Link Source="FixedArgument" Target="TypeReference" Bounds="377.98291015625,129.523162841797,1440.25573730469,158.714324951172" /> + <Link Source="FixedArgument" Target="TypeSpecification" Bounds="1179.83081054688,257.747589111328,603.743041992188,33.3763427734375" /> + <Link Source="FixedArgument1" Target="TypeDefinition" Bounds="619.410339355469,147.278427124023,1114.49212646484,140.959060668945" /> + <Link Source="FixedArgument1" Target="TypeReference" Bounds="283.041168212891,149.480422973633,271.530487060547,147.572219848633" /> + <Link Source="FixedArgument1" Target="TypeSpecification" Bounds="605,247.247695922852,446.672607421875,40.9897918701172" /> + <Link Source="GenericParameter" Target="TypeDefinition" Bounds="1083.32104492188,150.255004882813,671.678955078125,137.984252929688" /> + <Link Source="GenericParameter" Target="TypeReference" Bounds="320,150.255004882813,651.781677246094,141.657867431641" /> + <Link Source="GenericParameter" Target="TypeSpecification" Bounds="1039.80773925781,260.2939453125,40.187255859375,27.9435424804688" /> + <Link Source="MemberReference" Target="FieldSignature" Bounds="1075.13610839844,315.424530029297,574.126953125,145.755462646484" /> + <Link Source="MemberReference" Target="Method" Bounds="826.719299316406,426.734466552734,139.34130859375,34.4455261230469" /> + <Link Source="MemberReference" Target="MethodSignature" Bounds="1021,380.845001220703,0,80.3349914550781" /> + <Link Source="MemberReference" Target="TypeDefinition" Bounds="1075.60888671875,148.175109863281,824.22314453125,313.0048828125" /> + <Link Source="MemberReference" Target="TypeReference" Bounds="178.475769042969,147.774795532227,816.405517578125,313.405197143555" /> + <Link Source="MemberReference" Target="TypeSpecification" Bounds="1047.11877441406,253.439208984375,263.881225585938,207.740783691406" /> + <Link Source="Method" Target="GenericParameter" Bounds="787,313.024322509766,175.931945800781,90.5081787109375" /> + <Link Source="Method" Target="MethodSignature" Bounds="809.065856933594,369.673828125,146.772033691406,33.8586730957031" /> + <Link Source="Method" Target="Parameter" Bounds="723,323.197509765625,35.340576171875,80.4076232910156" /> + <Link Source="MethodImpl" Target="CustomAttribute" Bounds="657.248107910156,550.639404296875,44.2821655273438,25.8355712890625" /> + <Link Source="MethodImpl" Target="MemberReference" Bounds="771.64453125,496.140014648438,249.35546875,82.552734375" /> + <Link Source="MethodImpl" Target="Method" Bounds="730.350952148438,437.901000976563,48.486572265625,138.573974609375" /> + <Link Source="MethodInstantiation" Target="MemberReference" Bounds="947.390319824219,491.808959960938,44.525146484375,27.0185546875" /> + <Link Source="MethodInstantiation" Target="Method" Bounds="810.935913085938,434.992584228516,102.905334472656,83.8349304199219" /> + <Link Source="MethodInstantiation" Target="MethodSignature" Bounds="928.251586914063,379.478759765625,79.8754272460938,139.348754882813" /> + <Link Source="MethodSemantics" Target="CustomAttribute" Bounds="541.118713378906,548.538024902344,58.3296508789063,27.9369506835938" /> + <Link Source="MethodSemantics" Target="Method" Bounds="458,420.014190673828,289.031005859375,156.460784912109" /> + <Link Source="MethodSignature" Target="Parameter" Bounds="768.834350585938,313.01318359375,195.887329101563,36.4409484863281" /> + <Link Source="MethodSignature" Target="ReturnTypeSignature" Bounds="1076.0546875,317.780731201172,100.418334960938,28.6867370605469" /> + <Link Source="NamedArgument" Target="FixedArgument1" Bounds="616.242553710938,322.124084472656,12.7774658203125,23.7609252929688" /> + <Link Source="NamespaceDefinition" Target="NamespaceDefinition" Bounds="1821.806640625,64.4211807250977,43.5,12.6150436401367" Label="Enclosing Namespace" LabelBounds="1865.30666666667,62.6475,115.253333333334,15.96" /> + <Link Source="NamespaceDefinition" Target="ScopeDefinition" Bounds="1755,34.9599990844727,0,22.6875" /> + <Link Source="NamespaceReference" Target="NamespaceReference" Bounds="387.158325195313,64.4245986938477,43.5,12.6095657348633" /> + <Link Source="NamespaceReference" Target="ScopeReference" Bounds="363.005859375,28.5605087280273,96.3721618652344,29.0869903564453" /> + <Link Source="Parameter" Target="TypeDefinition" Bounds="759.636962890625,148.489120483398,980.401977539063,141.118515014648" /> + <Link Source="Parameter" Target="TypeReference" Bounds="284.143127441406,146.869812011719,402.070861816406,142.995330810547" /> + <Link Source="Parameter" Target="TypeSpecification" Bounds="760.118347167969,251.481781005859,291.605407714844,39.8078308105469" /> + <Link Source="ParameterTypeSignature" Target="TypeDefinition" Bounds="939.762756347656,150.255004882813,815.237243652344,138.482147216797" /> + <Link Source="ParameterTypeSignature" Target="TypeReference" Bounds="320,150.255004882813,471.508178710938,139.165069580078" /> + <Link Source="ParameterTypeSignature" Target="TypeSpecification" Bounds="921.389709472656,257.955596923828,131.726989746094,30.2818908691406" /> + <Link Source="PointerSignature" Target="TypeDefinition" Bounds="1565.86706542969,138.631866455078,131.642211914063,34.3106384277344" /> + <Link Source="PointerSignature" Target="TypeReference" Bounds="377.982147216797,129.734619140625,1129.34292602539,43.2078857421875" /> + <Link Source="PointerSignature" Target="TypeSpecification" Bounds="1181.63891601563,198.902496337891,327.037231445313,31.5540313720703" IsCircularLink="True" /> + <Link Source="Property" Target="CustomAttribute" Bounds="618.410339355469,553.787475585938,17.5896606445313,80.3350219726563" /> + <Link Source="Property" Target="MethodSemantics" Bounds="563.63134765625,605.237426757813,40.36865234375,28.8850708007813" /> + <Link Source="Property" Target="PropertySignature" Bounds="636.650024414063,380.508514404297,233.259399414063,261.864837646484" /> + <Link Source="Property" Target="TypeDefinition" Bounds="636.650024414063,133.463012695313,1438.34997558594,513.010009765625" /> + <Link Source="Property" Target="TypeReference" Bounds="32,144.599899291992,539.349975585938,494.276260375977" /> + <Link Source="Property" Target="TypeSpecification" Bounds="426,246.295272827148,625.666137695313,391.70588684082" /> + <Link Source="PropertySignature" Target="ParameterTypeSignature" Bounds="866.344116210938,323.19091796875,5.15264892578125,22.694091796875" /> + <Link Source="PropertySignature" Target="TypeDefinition" Bounds="923.042602539063,145.534072875977,979.640258789063,200.350936889648" /> + <Link Source="PropertySignature" Target="TypeReference" Bounds="172.597366333008,145.534072875977,645.709335327148,202.194839477539" /> + <Link Source="PropertySignature" Target="TypeSpecification" Bounds="933.675231933594,265.549987792969,183.324768066406,82.1365966796875" /> + <Link Source="ReturnTypeSignature" Target="TypeDefinition" Bounds="1268.48913574219,148.913803100586,520.058349609375,139.323684692383" /> + <Link Source="ReturnTypeSignature" Target="TypeReference" Bounds="334.961090087891,148.489120483398,820.947235107422,139.74836730957" /> + <Link Source="ReturnTypeSignature" Target="TypeSpecification" Bounds="1169.30224609375,259.134765625,44.69775390625,29.1027221679688" /> + <Link Source="SZArraySignature" Target="TypeDefinition" Bounds="1415.41027832031,133.43083190918,281.9921875,39.5116729736328" /> + <Link Source="SZArraySignature" Target="TypeReference" Bounds="377.981811523438,129.821029663086,1023.01818847656,43.1214752197266" /> + <Link Source="SZArraySignature" Target="TypeSpecification" Bounds="1182.23889160156,198.902496337891,196.244995117188,33.4663238525391" IsCircularLink="True" /> + <Link Source="TypeDefinition" Target="NamespaceDefinition" Bounds="1755,92.6074981689453,0,22.6875" /> + <Link Source="TypeDefinition" Target="TypeDefinition" Bounds="1803.63330078125,121.902565002441,43.5,12.8572463989258" Label="Enclosing Type" LabelBounds="1847.13333333333,120.295,78.9066666666668,15.96" /> + <Link Source="TypeForwarder" Target="ScopeReference" Bounds="511,34.9599990844727,0,22.6875" /> + <Link Source="TypeInstantiationSignature" Target="TypeDefinition" Bounds="1294.79357910156,132.576782226563,402.598022460938,40.36572265625" /> + <Link Source="TypeInstantiationSignature" Target="TypeReference" Bounds="377.978637695313,130.453826904297,789.823852539063,42.4886779785156" /> + <Link Source="TypeInstantiationSignature" Target="TypeSpecification" Bounds="1178.42431640625,198.902496337891,55.57568359375,29.5259552001953" IsCircularLink="True" /> + <Link Source="TypeReference" Target="NamespaceReference" Bounds="320,92.6074981689453,0,22.6875" /> + <Link Source="TypeReference" Target="TypeReference" Bounds="368.984985351563,121.905464172363,43.5,12.8536605834961" Label="Parent Type" LabelBounds="412.485,120.295,62.8433333333332,15.96" /> + <Link Source="TypeSpecification" Target="ArraySignature" Bounds="919.956298828125,205.424911499023,140.702026367188,29.8170013427734" IsCircularLink="True" /> + <Link Source="TypeSpecification" Target="ByReferenceSignature" Bounds="1045.98571777344,207.718811035156,35.8890380859375,22.8711853027344" IsCircularLink="True" /> + <Link Source="TypeSpecification" Target="MethodTypeVariableSignature" Bounds="796.396484375,200.317886352539,264.261840820313,36.1913452148438" /> + <Link Source="TypeSpecification" Target="PointerSignature" Bounds="1173.24865722656,197.885009765625,305.667846679688,34.9638671875" IsCircularLink="True" /> + <Link Source="TypeSpecification" Target="SZArraySignature" Bounds="1173.3115234375,200.228485107422,164.15869140625,32.9369812011719" IsCircularLink="True" /> + <Link Source="TypeSpecification" Target="TypeDefinition" Bounds="1171.75183105469,145.534072875977,551.313232421875,85.4080047607422" /> + <Link Source="TypeSpecification" Target="TypeInstantiationSignature" Bounds="1134.56262207031,202.04443359375,55.87841796875,28.5455627441406" IsCircularLink="True" /> + <Link Source="TypeSpecification" Target="TypeReference" Bounds="341.097503662109,147.278427124023,719.560821533203,93.9749145507813" /> + <Link Source="TypeSpecification" Target="TypeVariableSignature" Bounds="593.442077636719,199.265121459961,467.216247558594,39.9042510986328" /> + </Links> + <Properties> + <Property Id="Bounds" DataType="System.Windows.Rect" /> + <Property Id="ErrorMessage" Label="Error" Description="Error" DataType="System.String" /> + <Property Id="Expression" DataType="System.String" /> + <Property Id="GraphDirection" DataType="Microsoft.VisualStudio.Diagrams.Layout.LayoutOrientation" /> + <Property Id="GroupLabel" DataType="System.String" /> + <Property Id="IsCircularLink" Label="Circular Link" Description="Link connects part of a strongly coupled component" DataType="System.Boolean" /> + <Property Id="IsEnabled" DataType="System.Boolean" /> + <Property Id="IsStronglyConnected" Label="Circular References" Description="Node is part of a strongly coupled component" DataType="System.Boolean" /> + <Property Id="Label" Label="Label" Description="Displayable label of an Annotatable object" DataType="System.String" /> + <Property Id="LabelBounds" DataType="System.Windows.Rect" /> + <Property Id="Layout" DataType="System.String" /> + <Property Id="TargetType" DataType="System.Type" /> + <Property Id="ToolTip" DataType="System.String" /> + <Property Id="Value" DataType="System.String" /> + <Property Id="ValueLabel" DataType="System.String" /> + </Properties> + <Styles> + <Style TargetType="Node" GroupLabel="Circular References" ToolTip="Node is part of a strongly coupled component" ValueLabel="Nodes"> + <Condition Expression="IsStronglyConnected" /> + <Setter Property="Stroke" Value="#D02030" /> + <Setter Property="StrokeThickness" Value="2" /> + </Style> + <Style TargetType="Link" GroupLabel="Circular References" ToolTip="Node is part of a strongly coupled component" ValueLabel="Links"> + <Condition Expression="IsCircularLink" /> + <Setter Property="Stroke" Value="#D02030" /> + <Setter Property="StrokeThickness" Value="2" /> + </Style> + </Styles> +</DirectedGraph>
\ No newline at end of file diff --git a/src/Common/src/Internal/Metadata/NativeFormat/Script/Run2.py b/src/Common/src/Internal/Metadata/NativeFormat/Script/Run2.py new file mode 100644 index 000000000..510cda4a7 --- /dev/null +++ b/src/Common/src/Internal/Metadata/NativeFormat/Script/Run2.py @@ -0,0 +1,31 @@ +# Copyright (c) Microsoft. All rights reserved. +# Licensed under the MIT license. See LICENSE file in the project root for full license information. + +""" +A convenience script used to drive each individual source generation script. Replace by +batch script GenerateNativeFormatSources.bat. +""" + +import sys +import os + +if __name__ == '__main__': + #Dynamically append current script path to PYTHONPATH + sys.path.append(os.path.dirname(sys.argv[0])) + +import CsNativeFormatGen2 + +if __name__ == '__main__': + reload(CsNativeFormatGen2) + from CsPublicGen2 import CsEmitSource as PublicEmitSource + PublicEmitSource() + reload(CsNativeFormatGen2) + from CsReaderGen2 import CsEmitSource as ReaderEmitSource + ReaderEmitSource() + reload(CsNativeFormatGen2) + from CsWriterGen2 import WriterGen + WriterGen().CsEmitSource() + from CsMdBinaryRWCommonGen import MdBinaryRWGen + MdBinaryRWGen().CsEmitSource() + from CsWalkerGen3 import Walker + Walker().CsEmitSource() diff --git a/src/Common/src/Internal/Metadata/NativeFormat/Script/SchemaDef2.py b/src/Common/src/Internal/Metadata/NativeFormat/Script/SchemaDef2.py new file mode 100644 index 000000000..6cfd71d1a --- /dev/null +++ b/src/Common/src/Internal/Metadata/NativeFormat/Script/SchemaDef2.py @@ -0,0 +1,483 @@ +# Copyright (c) Microsoft. All rights reserved. +# Licensed under the MIT license. See LICENSE file in the project root for full license information. + +""" +This script defines the metadata schema that is consumed by all of the other scripts. It contains +the following main parts: + - Declaration of pre-existing types (enums, primitives) + - Types that encapsulate the schema definition (MemberDef, RecordDef). These are consumed by + some scripts, but some others consume the schema definition directly (they were not updated + to consume the encapsulating class instances). + - Introduced enum definitions (attribute name: enumSchema) + - +""" + +import os +import sys + +if __name__ == '__main__': + #Dynamically append current script path to PYTHONPATH + sys.path.append(os.path.dirname(sys.argv[0])) + +# from BaseGen import classinit +from copy import copy +from CsCommonGen2 import * +from odict import odict + +#========================================================================================================== +enumTypes = odict(sorted([ + ('AssemblyFlags', 'uint'), + ('AssemblyHashAlgorithm', 'uint'), + ('CallingConventions', 'ushort'), # System.Reflection.CallingConventions + ('EventAttributes', 'ushort'), + ('FieldAttributes', 'ushort'), + ('FixedArgumentAttributes', 'byte'), + ('GenericParameterAttributes', 'ushort'), + ('GenericParameterKind', 'byte'), + ('MethodAttributes', 'ushort'), + ('MethodImplAttributes', 'ushort'), + ('MethodSemanticsAttributes', 'ushort'), + ('NamedArgumentMemberKind', 'byte'), + ('ParameterAttributes', 'ushort'), + ('PInvokeAttributes', 'ushort'), + ('PropertyAttributes', 'ushort'), + ('TypeAttributes', 'uint'), +])) + +#========================================================================================================== +primitiveTypes = odict(sorted([( + ('bool', 'Boolean'), + ('char', 'Char'), + ('string', 'String'), + ('byte', 'Byte'), + ('sbyte', 'SByte'), + ('short', 'Int16'), + ('ushort', 'UInt16'), + ('int', 'Int32'), + ('uint', 'UInt32'), + ('long', 'Int64'), + ('ulong', 'UInt64'), + ('float', 'Single'), + ('double', 'Double'))])) + +#========================================================================================================== +class RecordDefFlags(Flags): + """ + Defines the set of flags that may be applied to a schema record definition. + """ + @classmethod + def __clsinit__(cls): + cls.AddFlag('Enum') # Indicates that the record is actually an enum. + cls.AddFlag('Flags') # Indicates that [Flags] should be applied to enum definition. + cls.AddFlag('CustomCompare') # Indicates a specific set of members have been flagged for use in + # implementing equality functionality; else all members are used. + cls.AddFlag('ReentrantEquals') # The generated Equals method is potentially reentrant on the same instance + # and should have a fast exit path to protect from infinite recursion. +classinit(RecordDefFlags) + +#========================================================================================================== +class MemberDefFlags(Flags): + """ + Defines the set of flags that may be applied to the member definition of a schema record. + """ + @classmethod + def __clsinit__(cls): + cls.AddFlag('Map') # => Dictionary<string, RecordType> for MetadataWriter + # => List<RecordType> for MetadataReader + cls.AddFlag('List') # => List<RecordType> + cls.AddFlag('Array') # => RecordType[] + cls.AddMask('Collection', 'Map', 'List', 'Array') + cls.AddMask('Sequence', 'List', 'Array') + cls.AddFlag('RecordRef') # => RecordTypeHandle + cls.AddMask('Ref', 'RecordRef') + cls.AddFlag('Child') # Member instance is logically defined and owned by record; + # otherwise instance may be shared (such as a TypeRef). + cls.AddFlag('Name') # May be used as the member's simple name for diagnostics. + cls.AddFlag('NotPersisted') # Indicates member is not written to or read from metadata. + cls.AddFlag('Compare') # Indicates member should be used for equality functionality. + cls.AddFlag('EnumerateForHashCode') # Indicates that the collection is safe to be enumerated in GetHashCode + # without causing reentrancy +classinit(MemberDefFlags) + +#========================================================================================================== +class MemberDef(object): + """ + Encapsulates definition of member in schema record definition. + """ + def __init__(self, name, typeName = None, flags = MemberDefFlags(0), comment = None, **kv): + self.name = name + self.typeName = typeName + self.flags = MemberDefFlags(int(flags)) + self.comment = comment + # Add additional (name,value) argument pairs as attributes on this instance. + for k,v in kv.iteritems(): + setattr(self, k, v) + + def __cmp__(self, other): + return cmp(self.name, other.name) + +#========================================================================================================== +class RecordDef(object): + """ + Encapsulates definition of schema record. + """ + def __init__(self, name, baseTypeName = None, flags = RecordDefFlags(0), members = [], comment = None, **kv): + self.name = name + self.baseTypeName = baseTypeName + self.flags = RecordDefFlags(int(flags)) + self.comment = comment + self.members = list() + for member in members: + self.members.append(MemberDef(**member)) + # Add additional (name,value) argument pairs as attributes on this instance. + for k,v in kv.iteritems(): + setattr(self, k, v) + + def __str__(self): + return self.name + + def __cmp__(self, other): + return cmp(self.name, other.name) + +#=== Defined Enums ======================================================================================== +# Defined as a list of dictionaries of (name, value) pairs. These enums supplement those defined by +# System.Reflection.Primitives. + +__enumSchema = [ + # AssemblyFlags - as defined in ECMA + { 'name': 'AssemblyFlags', + 'baseTypeName': 'uint', + 'flags': RecordDefFlags.Enum | RecordDefFlags.Flags, + 'members': [ + { 'name': 'PublicKey', 'value': 0x0001, 'comment': 'The assembly reference holds the full (unhashed) public key.' }, + { 'name': 'Retargetable', 'value': 0x0100, 'comment': 'The implementation of this assembly used at runtime is not expected to match the version seen at compile time.' }, + { 'name': 'DisableJITcompileOptimizer', 'value': 0x4000, 'comment': 'Reserved.' }, + { 'name': 'EnableJITcompileTracking', 'value': 0x8000, 'comment': 'Reserved.' }, + ], + }, + # AssemblyHashAlgorithm - as defined in ECMA + { 'name': 'AssemblyHashAlgorithm', + 'baseTypeName': 'uint', + 'flags': RecordDefFlags.Enum, + 'members': [ + { 'name': 'None', 'value': 0x0000 }, + { 'name': 'Reserved', 'value': 0x8003 }, + { 'name': 'SHA1', 'value': 0x8004 }, + ], + }, + # FixedArgumentAttributes - used to indicate if an argument for a custom attribute instantiation + # should be boxed. + { 'name': 'FixedArgumentAttributes', + 'baseTypeName': 'byte', + 'flags': RecordDefFlags.Enum | RecordDefFlags.Flags, + 'members': [ + { 'name': 'None', 'value': 0 }, + { 'name': 'Boxed', 'comment': 'Values should be boxed as Object' }, + ], + }, + # NamedArgumentMemberKind - used to disambiguate the referenced members of the named + # arguments to a custom attribute instance. + { 'name': 'NamedArgumentMemberKind', + 'baseTypeName': 'byte', + 'flags': RecordDefFlags.Enum, + 'members': [ + { 'name': 'Property', 'comment': 'Specifies the name of a property' }, + { 'name': 'Field', 'comment': 'Specifies the name of a field' }, + ] + }, + # GenericParameterKind - used to distinguish between generic type and generic method type parameters. + { 'name': 'GenericParameterKind', + 'baseTypeName': 'byte', + 'flags': RecordDefFlags.Enum, + 'members': [ + { 'name': 'GenericTypeParameter', 'comment': 'Represents a type parameter for a generic type.' }, + { 'name': 'GenericMethodParameter', 'comment': 'Represents a type parameter from a generic method.' }, + ] + }, +] + +# Create a list of RecordDef instances based on the contents of __enumSchema +enumSchema = [RecordDef(**enumDef) for enumDef in __enumSchema] + +#=== Record schema definition ============================================================================= + +#--- ConstantXXXValue, ConstantXXXArray, and corresponding Handle types ----------------------------------- +# Creates a set of record schema definitions (see format description in 'Metadata records' section below) +# that represent contant primitive type values. Adds concept of constant managed reference, which +# must always have a null value (thus the use of the NotPersisted flag). +__constantValueTypes = sorted([fName for (csName, fName) in primitiveTypes.iteritems()] + ['Reference', 'Handle']) +__constantValueRecordSchema = [('Constant' + fName + 'Value', None, RecordDefFlags(0), [('Value', csName, MemberDefFlags(0))]) \ + for (csName, fName) in primitiveTypes.iteritems()] + \ + [('ConstantReferenceValue', None, RecordDefFlags(0), [('Value', 'Object', MemberDefFlags.NotPersisted)])] + +# Creates a set of record schema definitions (see format description in 'Metadata records' section below) +# that represent contant arrays primitive type values. Adds concept of a constant array of handle values (currently used to store +# an array TypeDefOrRefOrSpec handles corresponding to System.Type arguments to the instantiation of a custom attribute, or to store +# custom initialized object[] arrays in custom attributes). +__constantValueArrayTypes = sorted([fName + 'Array' for (csName, fName) in primitiveTypes.iteritems()] + ['HandleArray']) +__constantArrayRecordSchema = [('Constant' + fName + 'Array', None, RecordDefFlags(0), [('Value', csName, MemberDefFlags.Array)]) \ + for (csName, fName) in primitiveTypes.iteritems()] + \ + [('ConstantHandleArray', None, RecordDefFlags(0), [('Value', 'Handle', MemberDefFlags.RecordRef | MemberDefFlags.List)])] + +# Combines constant value and array schema record definitions +__constantRecordSchema = sorted(__constantValueRecordSchema + __constantArrayRecordSchema, key = lambda x: x[0]) + +#--- Common tuple definitions ----------------------------------------------------------------------------- +TypeDefOrRef = ('TypeDefinition', 'TypeReference') +TypeDefOrRefOrSpec = TypeDefOrRef + ('TypeSpecification',) +TypeSig = ('TypeInstantiationSignature', 'SZArraySignature', 'ArraySignature', 'PointerSignature', 'ByReferenceSignature', 'TypeVariableSignature', 'MethodTypeVariableSignature') +TypeDefOrRefOrSpecOrConstant = TypeDefOrRefOrSpec + tuple(ct[0] for ct in __constantRecordSchema) + +#--- Metadata records ------------------------------------------------------------------------------------- +# The record schema is defined as a list of tuples, one for each record type. +# Record tuple format: (name, base type (not currently used), flags, [members]) +# Member tuple format: (name, type, flags) +# These are largely based on the definitions in ECMA335. + +__recordSchema = [ + ('TypeDefinition', None, RecordDefFlags.CustomCompare, [ + ('Flags', 'TypeAttributes', MemberDefFlags(0)), + ('BaseType', TypeDefOrRefOrSpec, MemberDefFlags.RecordRef), + ('NamespaceDefinition', 'NamespaceDefinition', MemberDefFlags.RecordRef | MemberDefFlags.Compare), + ('Name', 'ConstantStringValue', MemberDefFlags.RecordRef | MemberDefFlags.Child | MemberDefFlags.Compare), + ('Size', 'uint', MemberDefFlags(0)), + ('PackingSize', 'uint', MemberDefFlags(0)), + ('EnclosingType', 'TypeDefinition', MemberDefFlags.RecordRef | MemberDefFlags.Compare), + ('NestedTypes', 'TypeDefinition', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('Methods', 'Method', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('Fields', 'Field', MemberDefFlags.Map | MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('Properties', 'Property', MemberDefFlags.Map | MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('Events', 'Event', MemberDefFlags.Map | MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('GenericParameters', 'GenericParameter', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('Interfaces', TypeDefOrRefOrSpec, MemberDefFlags.List | MemberDefFlags.RecordRef), + ('CustomAttributes', 'CustomAttribute', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child), + ]), + ('TypeReference', None, RecordDefFlags(0), [ + ('ParentNamespaceOrType', ('NamespaceReference', 'TypeReference'), MemberDefFlags.RecordRef), + ('TypeName', 'ConstantStringValue', MemberDefFlags.RecordRef | MemberDefFlags.Child | MemberDefFlags.Name), + ('CustomAttributes', 'CustomAttribute', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child), + ]), + ('TypeSpecification', None, RecordDefFlags(0), [ + ('Signature', TypeDefOrRef + TypeSig, MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('CustomAttributes', 'CustomAttribute', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child), + ]), + ('ScopeDefinition', None, RecordDefFlags.CustomCompare, [ + ('Flags', 'AssemblyFlags', MemberDefFlags.Compare), + ('Name', 'ConstantStringValue', MemberDefFlags.RecordRef | MemberDefFlags.Child | MemberDefFlags.Compare), + ('HashAlgorithm', 'AssemblyHashAlgorithm', MemberDefFlags.Compare), + ('MajorVersion', 'ushort', MemberDefFlags.Compare), + ('MinorVersion', 'ushort', MemberDefFlags.Compare), + ('BuildNumber', 'ushort', MemberDefFlags.Compare), + ('RevisionNumber', 'ushort', MemberDefFlags.Compare), + ('PublicKey', 'byte', MemberDefFlags.Array | MemberDefFlags.Compare), + ('Culture', 'ConstantStringValue', MemberDefFlags.RecordRef | MemberDefFlags.Child | MemberDefFlags.Compare), + ('RootNamespaceDefinition', 'NamespaceDefinition', MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('CustomAttributes', 'CustomAttribute', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child), + ]), + ('ScopeReference', None, RecordDefFlags(0), [ + ('Flags', 'AssemblyFlags', MemberDefFlags(0)), + ('Name', 'ConstantStringValue', MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('MajorVersion', 'ushort', MemberDefFlags(0)), + ('MinorVersion', 'ushort', MemberDefFlags(0)), + ('BuildNumber', 'ushort', MemberDefFlags(0)), + ('RevisionNumber', 'ushort', MemberDefFlags(0)), + ('PublicKeyOrToken', 'byte', MemberDefFlags.Array), + ('Culture', 'ConstantStringValue', MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('CustomAttributes', 'CustomAttribute', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child), + ]), + ('NamespaceDefinition', None, RecordDefFlags.CustomCompare, [ + ('ParentScopeOrNamespace', ('NamespaceDefinition', 'ScopeDefinition'), MemberDefFlags.RecordRef | MemberDefFlags.Compare), + ('Name', 'ConstantStringValue', MemberDefFlags.RecordRef | MemberDefFlags.Child | MemberDefFlags.Compare), + ('TypeDefinitions', 'TypeDefinition', MemberDefFlags.Map | MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('TypeForwarders', 'TypeForwarder', MemberDefFlags.Map | MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('NamespaceDefinitions', 'NamespaceDefinition', MemberDefFlags.Map | MemberDefFlags.RecordRef | MemberDefFlags.Child), + ]), + ('NamespaceReference', None, RecordDefFlags(0), [ + ('ParentScopeOrNamespace', ('NamespaceReference', 'ScopeReference'), MemberDefFlags.RecordRef), + ('Name', 'ConstantStringValue', MemberDefFlags.RecordRef | MemberDefFlags.Child), + ]), + ('Method', None, RecordDefFlags(0), [ + ('RVA', 'uint', MemberDefFlags(0)), + ('Flags', 'MethodAttributes', MemberDefFlags(0)), + ('ImplFlags', 'MethodImplAttributes', MemberDefFlags(0)), + ('Name', 'ConstantStringValue', MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('Signature', 'MethodSignature', MemberDefFlags.RecordRef | MemberDefFlags.Child ), + ('Parameters', 'Parameter', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child | MemberDefFlags.EnumerateForHashCode), + ('GenericParameters', 'GenericParameter', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child | MemberDefFlags.EnumerateForHashCode), + ('MethodImpls', 'MethodImpl', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('CustomAttributes', 'CustomAttribute', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child), + ]), + ('MethodInstantiation', None, RecordDefFlags(0), [ + ('Method', ('Method', 'MemberReference'), MemberDefFlags.RecordRef), + ('Instantiation', 'MethodSignature', MemberDefFlags.RecordRef), + ]), + ('MemberReference', None, RecordDefFlags(0), [ + ('Parent', ('Method',) + TypeDefOrRefOrSpec, MemberDefFlags.RecordRef), + ('Name', 'ConstantStringValue', MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('Signature', ('MethodSignature', 'FieldSignature'), MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('CustomAttributes', 'CustomAttribute', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child), + ]), + ('Field', None, RecordDefFlags(0), [ + ('Flags', 'FieldAttributes', MemberDefFlags(0)), + ('Name', 'ConstantStringValue', MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('Signature', 'FieldSignature', MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('DefaultValue', TypeDefOrRefOrSpecOrConstant, MemberDefFlags.RecordRef), + ('Offset', 'uint', MemberDefFlags(0)), + ('CustomAttributes', 'CustomAttribute', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child | MemberDefFlags.EnumerateForHashCode), + ]), + ('Property', None, RecordDefFlags(0), [ + ('Flags', 'PropertyAttributes', MemberDefFlags(0)), + ('Name', 'ConstantStringValue', MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('Signature', 'PropertySignature', MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('MethodSemantics', 'MethodSemantics', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child | MemberDefFlags.EnumerateForHashCode), + ('DefaultValue', TypeDefOrRefOrSpecOrConstant, MemberDefFlags.RecordRef), + ('CustomAttributes', 'CustomAttribute', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child | MemberDefFlags.EnumerateForHashCode), + ]), + ('Event', None, RecordDefFlags(0), [ + ('Flags', 'EventAttributes', MemberDefFlags(0)), + ('Name', 'ConstantStringValue', MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('Type', TypeDefOrRefOrSpec, MemberDefFlags.RecordRef), + ('MethodSemantics', 'MethodSemantics', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child | MemberDefFlags.EnumerateForHashCode), + ('CustomAttributes', 'CustomAttribute', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child | MemberDefFlags.EnumerateForHashCode), + ]), + ('CustomAttribute', None, RecordDefFlags.ReentrantEquals, [ + ('Type', TypeDefOrRef, MemberDefFlags.RecordRef), + ('Constructor', ('Method', 'MemberReference'), MemberDefFlags.RecordRef), + ('FixedArguments', 'FixedArgument', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child | MemberDefFlags.EnumerateForHashCode), + ('NamedArguments', 'NamedArgument', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child | MemberDefFlags.EnumerateForHashCode), + ]), + ('FixedArgument', None, RecordDefFlags(0), [ + ('Flags', 'FixedArgumentAttributes', MemberDefFlags(0)), + ('Type', TypeDefOrRefOrSpec, MemberDefFlags.RecordRef), + ('Value', TypeDefOrRefOrSpecOrConstant, MemberDefFlags.RecordRef), + ]), + ('NamedArgument', None, RecordDefFlags(0), [ + ('Flags', 'NamedArgumentMemberKind', MemberDefFlags(0)), + ('Name', 'ConstantStringValue', MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('Value', 'FixedArgument', MemberDefFlags.RecordRef | MemberDefFlags.Child), + ]), + ('GenericParameter', None, RecordDefFlags(0), [ + ('Number', 'ushort', MemberDefFlags(0)), + ('Flags', 'GenericParameterAttributes', MemberDefFlags(0)), + ('Kind', 'GenericParameterKind', MemberDefFlags(0)), + ('Name', 'ConstantStringValue', MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('Constraints', TypeDefOrRefOrSpec, MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.EnumerateForHashCode), + ('CustomAttributes', 'CustomAttribute', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child), + ]), + ('MethodImpl', None, RecordDefFlags(0), [ + ('MethodDeclaration', ('Method', 'MemberReference'), MemberDefFlags.RecordRef), + ('CustomAttributes', 'CustomAttribute', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child | MemberDefFlags.EnumerateForHashCode), + ]), + ('Parameter', None, RecordDefFlags(0), [ + ('Flags', 'ParameterAttributes', MemberDefFlags(0)), + ('Sequence', 'ushort', MemberDefFlags(0)), + ('Name', 'ConstantStringValue', MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('DefaultValue', TypeDefOrRefOrSpecOrConstant, MemberDefFlags.RecordRef), + ('CustomAttributes', 'CustomAttribute', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child), + ]), + ('MethodSemantics', None, RecordDefFlags(0), [ + ('Attributes', 'MethodSemanticsAttributes', MemberDefFlags(0)), + ('Method', 'Method', MemberDefFlags.RecordRef), + ('CustomAttributes', 'CustomAttribute', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child | MemberDefFlags.EnumerateForHashCode), + ]), + ('TypeInstantiationSignature', None, RecordDefFlags(0), [ + ('GenericType', TypeDefOrRefOrSpec, MemberDefFlags.RecordRef), + ('GenericTypeArguments', TypeDefOrRefOrSpec, MemberDefFlags.List | MemberDefFlags.RecordRef), + ]), + ('SZArraySignature', None, RecordDefFlags(0), [ + ('ElementType', TypeDefOrRefOrSpec, MemberDefFlags.RecordRef), + ]), + ('ArraySignature', None, RecordDefFlags(0), [ + ('ElementType', TypeDefOrRefOrSpec, MemberDefFlags.RecordRef), + ('Rank', 'int', MemberDefFlags(0)), + ('Sizes', 'int', MemberDefFlags.Array), + ('LowerBounds', 'int', MemberDefFlags.Array), + ]), + ('ByReferenceSignature', None, RecordDefFlags(0), [ + ('Type', TypeDefOrRefOrSpec, MemberDefFlags.RecordRef), + ]), + ('PointerSignature', None, RecordDefFlags(0), [ + ('Type', TypeDefOrRefOrSpec, MemberDefFlags.RecordRef), + ]), + ('TypeVariableSignature', None, RecordDefFlags(0), [ + ('Number', 'int', MemberDefFlags(0)), + ]), + ('MethodTypeVariableSignature', None, RecordDefFlags(0), [ + ('Number', 'int', MemberDefFlags(0)), + ]), + ('FieldSignature', None, RecordDefFlags(0), [ + ('Type', TypeDefOrRefOrSpec, MemberDefFlags.RecordRef), + ('CustomModifiers', 'CustomModifier', MemberDefFlags.List | MemberDefFlags.RecordRef), + ]), + ('PropertySignature', None, RecordDefFlags(0), [ + ('CallingConvention', 'CallingConventions', MemberDefFlags(0)), + ('CustomModifiers', 'CustomModifier', MemberDefFlags.List | MemberDefFlags.RecordRef), + ('Type', TypeDefOrRefOrSpec, MemberDefFlags.RecordRef), + ('Parameters', 'ParameterTypeSignature', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.EnumerateForHashCode), + ]), + ('MethodSignature', None, RecordDefFlags(0), [ + ('CallingConvention', 'CallingConventions', MemberDefFlags(0)), + ('GenericParameterCount', 'int', MemberDefFlags(0)), + ('ReturnType', 'ReturnTypeSignature', MemberDefFlags.RecordRef), + ('Parameters', 'ParameterTypeSignature', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.EnumerateForHashCode), + ('VarArgParameters', 'ParameterTypeSignature', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.EnumerateForHashCode), + ]), + ('ReturnTypeSignature', None, RecordDefFlags(0), [ + ('CustomModifiers', 'CustomModifier', MemberDefFlags.List | MemberDefFlags.RecordRef), + ('Type', TypeDefOrRefOrSpec, MemberDefFlags.RecordRef), + ]), + ('ParameterTypeSignature', None, RecordDefFlags(0), [ + ('CustomModifiers', 'CustomModifier', MemberDefFlags.List | MemberDefFlags.RecordRef), + ('Type', TypeDefOrRefOrSpec, MemberDefFlags.RecordRef), + ]), + ('TypeForwarder', None, RecordDefFlags(0), [ + ('Scope', 'ScopeReference', MemberDefFlags.RecordRef), + ('Name', 'ConstantStringValue', MemberDefFlags.RecordRef | MemberDefFlags.Child | MemberDefFlags.Name), + ('NestedTypes', 'TypeForwarder', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child), + ('CustomAttributes', 'CustomAttribute', MemberDefFlags.List | MemberDefFlags.RecordRef | MemberDefFlags.Child), + ]), + ('CustomModifier', None, RecordDefFlags(0), [ + ('IsOptional', 'bool', MemberDefFlags(0)), + ('Type', TypeDefOrRefOrSpec, MemberDefFlags.RecordRef), + ]), + # ConstantXXXValue provided in __constantRecordSchema and appened to end of this list. +] + __constantRecordSchema + +# Ordered dictionary of schema records (as defined above) +recordSchema = odict([(rName, rMembers) for rName, rBase, rFlags, rMembers in __recordSchema]) + +# Ordered dictionary of RecordDef instances +recordDefs = odict([(rName, RecordDef(rName, rBase, rFlags, + [ { 'name': mName, 'typeName': mType, 'flags': mFlags } for mName,mType,mFlags in rMembers])) for rName, rBase, rFlags, rMembers in __recordSchema]) + +# Used to enable some custom actions for string records. +stringRecordTypes = set(['ConstantStringValue']) + +# Contains a list of records with corresponding Handle types (currently all of them). +handleSchema = [n for n in recordSchema.iterkeys()] + +# Print out some diagnostic info if script is directly invoked. +if __name__ == '__main__': + print '\nRecordFlags flag values:' + for n,v in RecordDefFlags.iterflags(): + print ' {} : 0x{:x}'.format(n,v) + + print '\nRecordFlags mask values:' + for n,v in RecordDefFlags.itermasks(): + print ' {} : 0x{:x}'.format(n,v) + + print '\nRecordMemberFlags flag values:' + for n,v in MemberDefFlags.iterflags(): + print ' {} : 0x{:x}'.format(n,v) + + print '\nRecordMemberFlags mask values:' + for n,v in MemberDefFlags.itermasks(): + print ' {} : 0x{:x}'.format(n,v) + + print '\nRecords:' + for k in recordSchema.iterkeys(): + print ' ' + k + + print '\nHandles:' + for k in handleSchema: + print ' ' + k diff --git a/src/Common/src/Internal/Metadata/NativeFormat/Script/odict.py b/src/Common/src/Internal/Metadata/NativeFormat/Script/odict.py new file mode 100644 index 000000000..5671b1fd9 --- /dev/null +++ b/src/Common/src/Internal/Metadata/NativeFormat/Script/odict.py @@ -0,0 +1,96 @@ +# Copyright (c) Microsoft. All rights reserved. +# Licensed under the MIT license. See LICENSE file in the project root for full license information. + +""" +Provides an ordered dictionary (odict) that can be used as a standard dict but will also +enumerate the values and keys in the order in which they were added. +""" + +def _isiterable(obj): + if type(obj) == str: + return False + try: + iter(obj) + except TypeError: + return False + return True + +class odict(dict): + def __ParseArg(self, arg): + if isinstance(arg, odict): + for k,v in arg.iteritems(): + self[k] = v + if isinstance(arg, dict): + for k in sorted(arg.iterkeys()): + self[k] = arg[k] + elif isinstance(arg, tuple) and len(arg) == 2: + k,v = arg + self[k] = v + elif _isiterable(arg): + for arg2 in arg: + self.__ParseArg(arg2) + else: + raise Exception('Unexpected argument {0}.'.format(arg)) + + def __init__(self, *args, **kv): + super(odict, self).__init__() + self.__keys = [] + for arg in args: + self.__ParseArg(arg) + + def __delitem__(self, key): + super(odict, self).__delitem__(key) + self.__keys.remove(key) + + def __setitem__(self, key, item): + super(odict, self).__setitem__(key, item) + if key not in self.__keys: self.__keys.append(key) + return self[key] + + def clear(self): + super(odict, self).clear() + self.__keys = [] + + def copy(self): + new_dict = odict(super(odict, self).copy()) + new_dict.__keys = self.__keys[:] + return new_dict + + def items(self): + return zip(self.keys(), self.values()) + + def iteritems(self): + return self.items() + + def keys(self): + return self.__keys + + def iterkeys(self): + return self.keys() + + def popitem(self): + try: + key = self.__keys[-1] + except IndexError: + raise KeyError('dictionary is empty') + + val = self[key] + del self[key] + + return (key, val) + + def setdefault(self, key, failobj = None): + val = super(odict, self).setdefault(key, failobj) + if key not in self.__keys: self.__keys.append(key) + return val + + def update(self, dict): + super(odict, self).update(dict) + for key in super(odict, self).keys(): + if key not in self.__keys: self.__keys.append(key) + + def values(self): + return map(self.get, self.__keys) + + def itervalues(self): + return self.values()
\ No newline at end of file diff --git a/src/ILCompiler.MetadataWriter/src/ILCompiler.MetadataWriter.targets b/src/ILCompiler.MetadataWriter/src/ILCompiler.MetadataWriter.targets new file mode 100644 index 000000000..dea32fa06 --- /dev/null +++ b/src/ILCompiler.MetadataWriter/src/ILCompiler.MetadataWriter.targets @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <NativeFormatCommonPath>$(MSBuildThisFileDirectory)..\..\Common\src\Internal\NativeFormat</NativeFormatCommonPath> + <MetadataCommonPath>$(MSBuildThisFileDirectory)..\..\Common\src\Internal\Metadata\NativeFormat</MetadataCommonPath> + <MetadataWriterPath>$(MSBuildThisFileDirectory)Internal\Metadata\NativeFormat\Writer</MetadataWriterPath> + </PropertyGroup> + <ItemGroup> + <Compile Include="$(NativeFormatCommonPath)\NativeFormat.cs" /> + <Compile Include="$(NativeFormatCommonPath)\NativeFormatReader.cs" /> + <Compile Include="$(NativeFormatCommonPath)\NativeFormatReader.String.cs" /> + <Compile Include="$(NativeFormatCommonPath)\NativeFormatWriter.cs" /> + <Compile Include="$(NativeFormatCommonPath)\NativeFormatWriter.Primitives.cs" /> + </ItemGroup> + <ItemGroup> + <Compile Include="$(MetadataCommonPath)\NativeFormatReaderCommonGen.cs" /> + <Compile Include="$(MetadataCommonPath)\MdBinaryReader.cs" /> + <Compile Include="$(MetadataCommonPath)\MdBinaryReaderGen.cs" /> + <Compile Include="$(MetadataCommonPath)\NativeMetadataReader.cs" /> + <Compile Include="$(MetadataCommonPath)\NativeFormatReaderGen.cs" /> + </ItemGroup> + <ItemGroup> + <Compile Include="$(MetadataWriterPath)\ConstantValues.cs" /> + <Compile Include="$(MetadataWriterPath)\MdBinaryWriter.cs" /> + <Compile Include="$(MetadataWriterPath)\MdBinaryWriterGen.cs" /> + <Compile Include="$(MetadataWriterPath)\NativeFormatWriterGen.cs" /> + <Compile Include="$(MetadataWriterPath)\NativeMetadataWriter.cs" /> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/ConstantValues.cs b/src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/ConstantValues.cs new file mode 100644 index 000000000..367d8c55f --- /dev/null +++ b/src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/ConstantValues.cs @@ -0,0 +1,246 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.IO; +using System.Linq; +using System.Text; +using System.Diagnostics; +using System.Threading.Tasks; +using System.Collections.Generic; + +using System.Reflection; + +namespace Internal.Metadata.NativeFormat.Writer +{ + public partial class ConstantBooleanValue + { + public override string ToString() + { + //return String.Format("ConstantBooleanValue : {0}", this.Value); + return String.Format("(Boolean){0}", this.Value); + } + } + + public partial class ConstantBooleanArray + { + public override string ToString() + { + //return "ConstantBooleanArray : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + return "(Boolean[]) {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + } + } + public partial class ConstantCharValue + { + public override string ToString() + { + //return String.Format("ConstantCharValue : {0}", this.Value); + + return String.Format("'{0}'", this.Value); + } + } + + public partial class ConstantCharArray + { + public override string ToString() + { + //return "ConstantCharArray : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + return "(Char[]) {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + } + } + public partial class ConstantStringValue + { + public override string ToString() + { + //return String.Format("ConstantStringValue : {0}", this.Value); + if (this.Value == null) return "null"; + else return String.Format("\"{0}\"", this.Value); + } + } + + public partial class ConstantStringArray + { + public override string ToString() + { + //return "ConstantStringArray : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + return "(String[]) {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + } + } + public partial class ConstantByteValue + { + public override string ToString() + { + //return String.Format("ConstantByteValue : {0}", this.Value); + return String.Format("(Byte){0}", this.Value); + } + } + + public partial class ConstantByteArray + { + public override string ToString() + { + //return "ConstantByteArray : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + return "(Byte[]) {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + } + } + public partial class ConstantSByteValue + { + public override string ToString() + { + //return String.Format("ConstantSByteValue : {0}", this.Value); + return String.Format("(SByte){0}", this.Value); + } + } + + public partial class ConstantSByteArray + { + public override string ToString() + { + //return "ConstantSByteArray : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + return "(SByte[]) {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + } + } + public partial class ConstantInt16Value + { + public override string ToString() + { + //return String.Format("ConstantInt16Value : {0}", this.Value); + return String.Format("(Int16){0}", this.Value); + } + } + + public partial class ConstantInt16Array + { + public override string ToString() + { + //return "ConstantInt16Array : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + return "(Int16[]) {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + } + } + public partial class ConstantUInt16Value + { + public override string ToString() + { + //return String.Format("ConstantUInt16Value : {0}", this.Value); + return String.Format("(UInt16){0}", this.Value); + } + } + + public partial class ConstantUInt16Array + { + public override string ToString() + { + //return "ConstantUInt16Array : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + return "(UInt16[]) {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + } + } + public partial class ConstantInt32Value + { + public override string ToString() + { + //return String.Format("ConstantInt32Value : {0}", this.Value); + return String.Format("(Int32){0}", this.Value); + } + } + + public partial class ConstantInt32Array + { + public override string ToString() + { + //return "ConstantInt32Array : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + return "(Int32[]) {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + } + } + public partial class ConstantUInt32Value + { + public override string ToString() + { + //return String.Format("ConstantUInt32Value : {0}", this.Value); + return String.Format("(UInt32){0}", this.Value); + } + } + + public partial class ConstantUInt32Array + { + public override string ToString() + { + //return "ConstantUInt32Array : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + return "(UInt32[]) {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + } + } + public partial class ConstantInt64Value + { + public override string ToString() + { + //return String.Format("ConstantInt64Value : {0}", this.Value); + return String.Format("(Int64){0}", this.Value); + } + } + + public partial class ConstantInt64Array + { + public override string ToString() + { + //return "ConstantInt64Array : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + return "(Int64[]) {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + } + } + public partial class ConstantUInt64Value + { + public override string ToString() + { + //return String.Format("ConstantUInt64Value : {0}", this.Value); + return String.Format("(UInt64){0}", this.Value); + } + } + + public partial class ConstantUInt64Array + { + public override string ToString() + { + //return "ConstantUInt64Array : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + return "(UInt64[]) {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + } + } + public partial class ConstantSingleValue + { + public override string ToString() + { + //return String.Format("ConstantSingleValue : {0}", this.Value); + return String.Format("(Single){0}", this.Value); + } + } + + public partial class ConstantSingleArray + { + public override string ToString() + { + //return "ConstantSingleArray : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + return "(Single[]) {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + } + } + public partial class ConstantDoubleValue + { + public override string ToString() + { + //return String.Format("ConstantDoubleValue : {0}", this.Value); + return String.Format("(Double){0}", this.Value); + } + } + + public partial class ConstantDoubleArray + { + public override string ToString() + { + //return "ConstantDoubleArray : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + return "(Double[]) {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}"; + } + } + public partial class ConstantReferenceValue + { + public override string ToString() + { + return "null"; + } + } +} diff --git a/src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/MdBinaryWriter.cs b/src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/MdBinaryWriter.cs new file mode 100644 index 000000000..9f1504f32 --- /dev/null +++ b/src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/MdBinaryWriter.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.IO; +using System.Linq; +using System.Collections.Generic; +using System.Reflection; +using System.Text; +using Internal.NativeFormat; +using Debug = System.Diagnostics.Debug; + +namespace Internal.Metadata.NativeFormat.Writer +{ + internal static partial class MdBinaryWriter + { + public static void Write(this NativeWriter writer, bool value) + { + writer.WriteUInt8((byte)(value ? 1 : 0)); + } + + public static void Write(this NativeWriter writer, byte value) + { + writer.WriteUInt8(value); + } + + public static void Write(this NativeWriter writer, sbyte value) + { + writer.WriteUInt8((byte)value); + } + + public static void Write(this NativeWriter writer, short value) + { + writer.WriteSigned(value); + } + + public static void Write(this NativeWriter writer, ushort value) + { + writer.WriteUnsigned(value); + } + + public static void Write(this NativeWriter writer, int value) + { + writer.WriteSigned(value); + } + + public static void Write(this NativeWriter writer, uint value) + { + writer.WriteUnsigned(value); + } + + public static void Write(this NativeWriter writer, ulong value) + { + writer.WriteUnsignedLong(value); + } + + public static void Write(this NativeWriter writer, long value) + { + writer.WriteSignedLong(value); + } + + public static void Write(this NativeWriter writer, string value) + { + Debug.Assert(value != null); + writer.WriteString(value); + } + + public static void Write(this NativeWriter writer, char value) + { + writer.WriteUnsigned((uint)value); + } + + public static void Write(this NativeWriter writer, float value) + { + writer.WriteFloat(value); + } + + public static void Write(this NativeWriter writer, double value) + { + writer.WriteDouble(value); + } + + public static void Write(this NativeWriter writer, MetadataRecord record) + { + if (record != null) + writer.WriteUnsigned((uint)record.HandleType | (uint)(record.HandleOffset << 8)); + else + writer.WriteUnsigned(0); + } + } +} diff --git a/src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/MdBinaryWriterGen.cs b/src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/MdBinaryWriterGen.cs new file mode 100644 index 000000000..5f8ccf0d7 --- /dev/null +++ b/src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/MdBinaryWriterGen.cs @@ -0,0 +1,1663 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +// NOTE: This is a generated file - do not manually edit! + +#pragma warning disable 649 + +using System; +using System.IO; +using System.Linq; +using System.Collections.Generic; +using System.Reflection; +using Internal.NativeFormat; +using Debug = System.Diagnostics.Debug; + +namespace Internal.Metadata.NativeFormat.Writer +{ + /// <summary> + /// MdBinaryWriter + /// </summary> + internal static partial class MdBinaryWriter + { + public static void Write(this NativeWriter writer, IEnumerable<bool> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (bool value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<char> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (char value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<string> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (string value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<byte> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (byte value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<sbyte> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (sbyte value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<short> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (short value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ushort> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ushort value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<int> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (int value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<uint> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (uint value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<long> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (long value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ulong> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ulong value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<float> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (float value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<double> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (double value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, AssemblyFlags value) + { + writer.WriteUnsigned((uint)value); + } // Write + + public static void Write(this NativeWriter writer, AssemblyHashAlgorithm value) + { + writer.WriteUnsigned((uint)value); + } // Write + + public static void Write(this NativeWriter writer, CallingConventions value) + { + writer.WriteUnsigned((uint)value); + } // Write + + public static void Write(this NativeWriter writer, EventAttributes value) + { + writer.WriteUnsigned((uint)value); + } // Write + + public static void Write(this NativeWriter writer, FieldAttributes value) + { + writer.WriteUnsigned((uint)value); + } // Write + + public static void Write(this NativeWriter writer, FixedArgumentAttributes value) + { + writer.WriteUnsigned((uint)value); + } // Write + + public static void Write(this NativeWriter writer, GenericParameterAttributes value) + { + writer.WriteUnsigned((uint)value); + } // Write + + public static void Write(this NativeWriter writer, GenericParameterKind value) + { + writer.WriteUnsigned((uint)value); + } // Write + + public static void Write(this NativeWriter writer, MethodAttributes value) + { + writer.WriteUnsigned((uint)value); + } // Write + + public static void Write(this NativeWriter writer, MethodImplAttributes value) + { + writer.WriteUnsigned((uint)value); + } // Write + + public static void Write(this NativeWriter writer, MethodSemanticsAttributes value) + { + writer.WriteUnsigned((uint)value); + } // Write + + public static void Write(this NativeWriter writer, NamedArgumentMemberKind value) + { + writer.WriteUnsigned((uint)value); + } // Write + + public static void Write(this NativeWriter writer, PInvokeAttributes value) + { + writer.WriteUnsigned((uint)value); + } // Write + + public static void Write(this NativeWriter writer, ParameterAttributes value) + { + writer.WriteUnsigned((uint)value); + } // Write + + public static void Write(this NativeWriter writer, PropertyAttributes value) + { + writer.WriteUnsigned((uint)value); + } // Write + + public static void Write(this NativeWriter writer, TypeAttributes value) + { + writer.WriteUnsigned((uint)value); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<MetadataRecord> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (MetadataRecord value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, TypeDefinition record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<TypeDefinition> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (TypeDefinition value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, TypeReference record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<TypeReference> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (TypeReference value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, TypeSpecification record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<TypeSpecification> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (TypeSpecification value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ScopeDefinition record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ScopeDefinition> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ScopeDefinition value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ScopeReference record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ScopeReference> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ScopeReference value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, NamespaceDefinition record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<NamespaceDefinition> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (NamespaceDefinition value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, NamespaceReference record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<NamespaceReference> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (NamespaceReference value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, Method record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<Method> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (Method value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, MethodInstantiation record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<MethodInstantiation> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (MethodInstantiation value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, MemberReference record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<MemberReference> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (MemberReference value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, Field record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<Field> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (Field value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, Property record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<Property> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (Property value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, Event record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<Event> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (Event value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, CustomAttribute record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<CustomAttribute> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (CustomAttribute value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, FixedArgument record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<FixedArgument> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (FixedArgument value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, NamedArgument record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<NamedArgument> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (NamedArgument value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, GenericParameter record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<GenericParameter> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (GenericParameter value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, MethodImpl record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<MethodImpl> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (MethodImpl value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, Parameter record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<Parameter> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (Parameter value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, MethodSemantics record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<MethodSemantics> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (MethodSemantics value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, TypeInstantiationSignature record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<TypeInstantiationSignature> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (TypeInstantiationSignature value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, SZArraySignature record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<SZArraySignature> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (SZArraySignature value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ArraySignature record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ArraySignature> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ArraySignature value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ByReferenceSignature record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ByReferenceSignature> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ByReferenceSignature value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, PointerSignature record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<PointerSignature> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (PointerSignature value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, TypeVariableSignature record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<TypeVariableSignature> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (TypeVariableSignature value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, MethodTypeVariableSignature record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<MethodTypeVariableSignature> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (MethodTypeVariableSignature value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, FieldSignature record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<FieldSignature> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (FieldSignature value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, PropertySignature record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<PropertySignature> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (PropertySignature value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, MethodSignature record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<MethodSignature> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (MethodSignature value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ReturnTypeSignature record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ReturnTypeSignature> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ReturnTypeSignature value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ParameterTypeSignature record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ParameterTypeSignature> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ParameterTypeSignature value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, TypeForwarder record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<TypeForwarder> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (TypeForwarder value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, CustomModifier record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<CustomModifier> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (CustomModifier value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantBooleanArray record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantBooleanArray> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantBooleanArray value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantBooleanValue record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantBooleanValue> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantBooleanValue value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantByteArray record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantByteArray> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantByteArray value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantByteValue record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantByteValue> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantByteValue value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantCharArray record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantCharArray> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantCharArray value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantCharValue record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantCharValue> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantCharValue value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantDoubleArray record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantDoubleArray> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantDoubleArray value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantDoubleValue record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantDoubleValue> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantDoubleValue value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantHandleArray record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantHandleArray> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantHandleArray value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantInt16Array record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantInt16Array> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantInt16Array value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantInt16Value record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantInt16Value> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantInt16Value value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantInt32Array record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantInt32Array> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantInt32Array value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantInt32Value record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantInt32Value> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantInt32Value value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantInt64Array record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantInt64Array> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantInt64Array value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantInt64Value record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantInt64Value> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantInt64Value value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantReferenceValue record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantReferenceValue> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantReferenceValue value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantSByteArray record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantSByteArray> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantSByteArray value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantSByteValue record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantSByteValue> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantSByteValue value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantSingleArray record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantSingleArray> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantSingleArray value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantSingleValue record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantSingleValue> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantSingleValue value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantStringArray record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantStringArray> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantStringArray value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantStringValue record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantStringValue> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantStringValue value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantUInt16Array record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantUInt16Array> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantUInt16Array value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantUInt16Value record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantUInt16Value> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantUInt16Value value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantUInt32Array record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantUInt32Array> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantUInt32Array value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantUInt32Value record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantUInt32Value> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantUInt32Value value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantUInt64Array record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantUInt64Array> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantUInt64Array value in values) + { + writer.Write(value); + } + } // Write + + public static void Write(this NativeWriter writer, ConstantUInt64Value record) + { + if (record != null) + writer.WriteUnsigned((uint)record.Handle.Offset); + else + writer.WriteUnsigned(0); + } // Write + + public static void Write(this NativeWriter writer, IEnumerable<ConstantUInt64Value> values) + { + if (values == null) + { + writer.WriteUnsigned(0); + return; + } + writer.WriteUnsigned((uint)values.Count()); + foreach (ConstantUInt64Value value in values) + { + writer.Write(value); + } + } // Write + } // MdBinaryWriter +} // Internal.Metadata.NativeFormat.Writer diff --git a/src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/NativeFormatWriterGen.cs b/src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/NativeFormatWriterGen.cs new file mode 100644 index 000000000..f51ce89a3 --- /dev/null +++ b/src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/NativeFormatWriterGen.cs @@ -0,0 +1,5051 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +// NOTE: This is a generated file - do not manually edit! + +#pragma warning disable 649 + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using System.Reflection; +using System.Threading; +using Internal.Metadata.NativeFormat.Writer; +using Internal.NativeFormat; +using HandleType = Internal.Metadata.NativeFormat.HandleType; +using Debug = System.Diagnostics.Debug; + +namespace Internal.Metadata.NativeFormat.Writer +{ + /// <summary> + /// ArraySignature + /// </summary> + public partial class ArraySignature : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ArraySignature; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + ElementType = visitor.Visit(this, ElementType); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ArraySignature; + if (other == null) return false; + if (!Object.Equals(ElementType, other.ElementType)) return false; + if (Rank != other.Rank) return false; + if (!Sizes.SequenceEqual(other.Sizes)) return false; + if (!LowerBounds.SequenceEqual(other.LowerBounds)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 1603870787; + hash = ((hash << 13) - (hash >> 19)) ^ (ElementType == null ? 0 : ElementType.GetHashCode()); + hash = ((hash << 13) - (hash >> 19)) ^ Rank.GetHashCode(); + if (Sizes != null) + { + for (int i = 0; i < Sizes.Length; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ Sizes[i].GetHashCode(); + } + } + if (LowerBounds != null) + { + for (int i = 0; i < LowerBounds.Length; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ LowerBounds[i].GetHashCode(); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + Debug.Assert(ElementType == null || + ElementType.HandleType == HandleType.TypeDefinition || + ElementType.HandleType == HandleType.TypeReference || + ElementType.HandleType == HandleType.TypeSpecification); + writer.Write(ElementType); + writer.Write(Rank); + writer.Write(Sizes); + writer.Write(LowerBounds); + } // Save + + internal static ArraySignatureHandle AsHandle(ArraySignature record) + { + if (record == null) + { + return new ArraySignatureHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ArraySignatureHandle Handle + { + get + { + return new ArraySignatureHandle(HandleOffset); + } + } // Handle + + public MetadataRecord ElementType; + public int Rank; + public int[] Sizes; + public int[] LowerBounds; + } // ArraySignature + + /// <summary> + /// ByReferenceSignature + /// </summary> + public partial class ByReferenceSignature : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ByReferenceSignature; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + Type = visitor.Visit(this, Type); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ByReferenceSignature; + if (other == null) return false; + if (!Object.Equals(Type, other.Type)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -695627658; + hash = ((hash << 13) - (hash >> 19)) ^ (Type == null ? 0 : Type.GetHashCode()); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + Debug.Assert(Type == null || + Type.HandleType == HandleType.TypeDefinition || + Type.HandleType == HandleType.TypeReference || + Type.HandleType == HandleType.TypeSpecification); + writer.Write(Type); + } // Save + + internal static ByReferenceSignatureHandle AsHandle(ByReferenceSignature record) + { + if (record == null) + { + return new ByReferenceSignatureHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ByReferenceSignatureHandle Handle + { + get + { + return new ByReferenceSignatureHandle(HandleOffset); + } + } // Handle + + public MetadataRecord Type; + } // ByReferenceSignature + + /// <summary> + /// ConstantBooleanArray + /// </summary> + public partial class ConstantBooleanArray : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantBooleanArray; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantBooleanArray; + if (other == null) return false; + if (!Value.SequenceEqual(other.Value)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 1799185487; + if (Value != null) + { + for (int i = 0; i < Value.Length; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ Value[i].GetHashCode(); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantBooleanArrayHandle AsHandle(ConstantBooleanArray record) + { + if (record == null) + { + return new ConstantBooleanArrayHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantBooleanArrayHandle Handle + { + get + { + return new ConstantBooleanArrayHandle(HandleOffset); + } + } // Handle + + public bool[] Value; + } // ConstantBooleanArray + + /// <summary> + /// ConstantBooleanValue + /// </summary> + public partial class ConstantBooleanValue : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantBooleanValue; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantBooleanValue; + if (other == null) return false; + if (Value != other.Value) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 842390402; + hash = ((hash << 13) - (hash >> 19)) ^ Value.GetHashCode(); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantBooleanValueHandle AsHandle(ConstantBooleanValue record) + { + if (record == null) + { + return new ConstantBooleanValueHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantBooleanValueHandle Handle + { + get + { + return new ConstantBooleanValueHandle(HandleOffset); + } + } // Handle + + public bool Value; + } // ConstantBooleanValue + + /// <summary> + /// ConstantByteArray + /// </summary> + public partial class ConstantByteArray : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantByteArray; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantByteArray; + if (other == null) return false; + if (!Value.SequenceEqual(other.Value)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -216020972; + if (Value != null) + { + for (int i = 0; i < Value.Length; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ Value[i].GetHashCode(); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantByteArrayHandle AsHandle(ConstantByteArray record) + { + if (record == null) + { + return new ConstantByteArrayHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantByteArrayHandle Handle + { + get + { + return new ConstantByteArrayHandle(HandleOffset); + } + } // Handle + + public byte[] Value; + } // ConstantByteArray + + /// <summary> + /// ConstantByteValue + /// </summary> + public partial class ConstantByteValue : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantByteValue; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantByteValue; + if (other == null) return false; + if (Value != other.Value) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 229129511; + hash = ((hash << 13) - (hash >> 19)) ^ Value.GetHashCode(); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantByteValueHandle AsHandle(ConstantByteValue record) + { + if (record == null) + { + return new ConstantByteValueHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantByteValueHandle Handle + { + get + { + return new ConstantByteValueHandle(HandleOffset); + } + } // Handle + + public byte Value; + } // ConstantByteValue + + /// <summary> + /// ConstantCharArray + /// </summary> + public partial class ConstantCharArray : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantCharArray; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantCharArray; + if (other == null) return false; + if (!Value.SequenceEqual(other.Value)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 306354450; + if (Value != null) + { + for (int i = 0; i < Value.Length; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ Value[i].GetHashCode(); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantCharArrayHandle AsHandle(ConstantCharArray record) + { + if (record == null) + { + return new ConstantCharArrayHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantCharArrayHandle Handle + { + get + { + return new ConstantCharArrayHandle(HandleOffset); + } + } // Handle + + public char[] Value; + } // ConstantCharArray + + /// <summary> + /// ConstantCharValue + /// </summary> + public partial class ConstantCharValue : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantCharValue; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantCharValue; + if (other == null) return false; + if (Value != other.Value) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -1395702369; + hash = ((hash << 13) - (hash >> 19)) ^ Value.GetHashCode(); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantCharValueHandle AsHandle(ConstantCharValue record) + { + if (record == null) + { + return new ConstantCharValueHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantCharValueHandle Handle + { + get + { + return new ConstantCharValueHandle(HandleOffset); + } + } // Handle + + public char Value; + } // ConstantCharValue + + /// <summary> + /// ConstantDoubleArray + /// </summary> + public partial class ConstantDoubleArray : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantDoubleArray; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantDoubleArray; + if (other == null) return false; + if (!Value.SequenceEqual(other.Value)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -1926817667; + if (Value != null) + { + for (int i = 0; i < Value.Length; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ Value[i].GetHashCode(); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantDoubleArrayHandle AsHandle(ConstantDoubleArray record) + { + if (record == null) + { + return new ConstantDoubleArrayHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantDoubleArrayHandle Handle + { + get + { + return new ConstantDoubleArrayHandle(HandleOffset); + } + } // Handle + + public double[] Value; + } // ConstantDoubleArray + + /// <summary> + /// ConstantDoubleValue + /// </summary> + public partial class ConstantDoubleValue : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantDoubleValue; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantDoubleValue; + if (other == null) return false; + if (Value != other.Value) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 1481871770; + hash = ((hash << 13) - (hash >> 19)) ^ Value.GetHashCode(); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantDoubleValueHandle AsHandle(ConstantDoubleValue record) + { + if (record == null) + { + return new ConstantDoubleValueHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantDoubleValueHandle Handle + { + get + { + return new ConstantDoubleValueHandle(HandleOffset); + } + } // Handle + + public double Value; + } // ConstantDoubleValue + + /// <summary> + /// ConstantHandleArray + /// </summary> + public partial class ConstantHandleArray : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantHandleArray; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + Value = Value.Select(value => visitor.Visit(this, value)).ToList(); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantHandleArray; + if (other == null) return false; + if (!Value.SequenceEqual(other.Value)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 245030796; + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantHandleArrayHandle AsHandle(ConstantHandleArray record) + { + if (record == null) + { + return new ConstantHandleArrayHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantHandleArrayHandle Handle + { + get + { + return new ConstantHandleArrayHandle(HandleOffset); + } + } // Handle + + public List<MetadataRecord> Value = new List<MetadataRecord>(); + } // ConstantHandleArray + + /// <summary> + /// ConstantInt16Array + /// </summary> + public partial class ConstantInt16Array : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantInt16Array; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantInt16Array; + if (other == null) return false; + if (!Value.SequenceEqual(other.Value)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 511421544; + if (Value != null) + { + for (int i = 0; i < Value.Length; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ Value[i].GetHashCode(); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantInt16ArrayHandle AsHandle(ConstantInt16Array record) + { + if (record == null) + { + return new ConstantInt16ArrayHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantInt16ArrayHandle Handle + { + get + { + return new ConstantInt16ArrayHandle(HandleOffset); + } + } // Handle + + public short[] Value; + } // ConstantInt16Array + + /// <summary> + /// ConstantInt16Value + /// </summary> + public partial class ConstantInt16Value : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantInt16Value; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantInt16Value; + if (other == null) return false; + if (Value != other.Value) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 981319805; + hash = ((hash << 13) - (hash >> 19)) ^ Value.GetHashCode(); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantInt16ValueHandle AsHandle(ConstantInt16Value record) + { + if (record == null) + { + return new ConstantInt16ValueHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantInt16ValueHandle Handle + { + get + { + return new ConstantInt16ValueHandle(HandleOffset); + } + } // Handle + + public short Value; + } // ConstantInt16Value + + /// <summary> + /// ConstantInt32Array + /// </summary> + public partial class ConstantInt32Array : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantInt32Array; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantInt32Array; + if (other == null) return false; + if (!Value.SequenceEqual(other.Value)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -1821266972; + if (Value != null) + { + for (int i = 0; i < Value.Length; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ Value[i].GetHashCode(); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantInt32ArrayHandle AsHandle(ConstantInt32Array record) + { + if (record == null) + { + return new ConstantInt32ArrayHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantInt32ArrayHandle Handle + { + get + { + return new ConstantInt32ArrayHandle(HandleOffset); + } + } // Handle + + public int[] Value; + } // ConstantInt32Array + + /// <summary> + /// ConstantInt32Value + /// </summary> + public partial class ConstantInt32Value : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantInt32Value; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantInt32Value; + if (other == null) return false; + if (Value != other.Value) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -586694639; + hash = ((hash << 13) - (hash >> 19)) ^ Value.GetHashCode(); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantInt32ValueHandle AsHandle(ConstantInt32Value record) + { + if (record == null) + { + return new ConstantInt32ValueHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantInt32ValueHandle Handle + { + get + { + return new ConstantInt32ValueHandle(HandleOffset); + } + } // Handle + + public int Value; + } // ConstantInt32Value + + /// <summary> + /// ConstantInt64Array + /// </summary> + public partial class ConstantInt64Array : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantInt64Array; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantInt64Array; + if (other == null) return false; + if (!Value.SequenceEqual(other.Value)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -769479382; + if (Value != null) + { + for (int i = 0; i < Value.Length; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ Value[i].GetHashCode(); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantInt64ArrayHandle AsHandle(ConstantInt64Array record) + { + if (record == null) + { + return new ConstantInt64ArrayHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantInt64ArrayHandle Handle + { + get + { + return new ConstantInt64ArrayHandle(HandleOffset); + } + } // Handle + + public long[] Value; + } // ConstantInt64Array + + /// <summary> + /// ConstantInt64Value + /// </summary> + public partial class ConstantInt64Value : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantInt64Value; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantInt64Value; + if (other == null) return false; + if (Value != other.Value) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 1994441023; + hash = ((hash << 13) - (hash >> 19)) ^ Value.GetHashCode(); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantInt64ValueHandle AsHandle(ConstantInt64Value record) + { + if (record == null) + { + return new ConstantInt64ValueHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantInt64ValueHandle Handle + { + get + { + return new ConstantInt64ValueHandle(HandleOffset); + } + } // Handle + + public long Value; + } // ConstantInt64Value + + /// <summary> + /// ConstantReferenceValue + /// </summary> + public partial class ConstantReferenceValue : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantReferenceValue; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantReferenceValue; + if (other == null) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -498183990; + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + + } // Save + + internal static ConstantReferenceValueHandle AsHandle(ConstantReferenceValue record) + { + if (record == null) + { + return new ConstantReferenceValueHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantReferenceValueHandle Handle + { + get + { + return new ConstantReferenceValueHandle(HandleOffset); + } + } // Handle + } // ConstantReferenceValue + + /// <summary> + /// ConstantSByteArray + /// </summary> + public partial class ConstantSByteArray : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantSByteArray; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantSByteArray; + if (other == null) return false; + if (!Value.SequenceEqual(other.Value)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -1904334730; + if (Value != null) + { + for (int i = 0; i < Value.Length; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ Value[i].GetHashCode(); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantSByteArrayHandle AsHandle(ConstantSByteArray record) + { + if (record == null) + { + return new ConstantSByteArrayHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantSByteArrayHandle Handle + { + get + { + return new ConstantSByteArrayHandle(HandleOffset); + } + } // Handle + + public sbyte[] Value; + } // ConstantSByteArray + + /// <summary> + /// ConstantSByteValue + /// </summary> + public partial class ConstantSByteValue : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantSByteValue; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantSByteValue; + if (other == null) return false; + if (Value != other.Value) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -1000778923; + hash = ((hash << 13) - (hash >> 19)) ^ Value.GetHashCode(); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantSByteValueHandle AsHandle(ConstantSByteValue record) + { + if (record == null) + { + return new ConstantSByteValueHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantSByteValueHandle Handle + { + get + { + return new ConstantSByteValueHandle(HandleOffset); + } + } // Handle + + public sbyte Value; + } // ConstantSByteValue + + /// <summary> + /// ConstantSingleArray + /// </summary> + public partial class ConstantSingleArray : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantSingleArray; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantSingleArray; + if (other == null) return false; + if (!Value.SequenceEqual(other.Value)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 212052597; + if (Value != null) + { + for (int i = 0; i < Value.Length; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ Value[i].GetHashCode(); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantSingleArrayHandle AsHandle(ConstantSingleArray record) + { + if (record == null) + { + return new ConstantSingleArrayHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantSingleArrayHandle Handle + { + get + { + return new ConstantSingleArrayHandle(HandleOffset); + } + } // Handle + + public float[] Value; + } // ConstantSingleArray + + /// <summary> + /// ConstantSingleValue + /// </summary> + public partial class ConstantSingleValue : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantSingleValue; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantSingleValue; + if (other == null) return false; + if (Value != other.Value) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -1786883192; + hash = ((hash << 13) - (hash >> 19)) ^ Value.GetHashCode(); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantSingleValueHandle AsHandle(ConstantSingleValue record) + { + if (record == null) + { + return new ConstantSingleValueHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantSingleValueHandle Handle + { + get + { + return new ConstantSingleValueHandle(HandleOffset); + } + } // Handle + + public float Value; + } // ConstantSingleValue + + /// <summary> + /// ConstantStringArray + /// </summary> + public partial class ConstantStringArray : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantStringArray; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantStringArray; + if (other == null) return false; + if (!Value.SequenceEqual(other.Value)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 270977183; + if (Value != null) + { + for (int i = 0; i < Value.Length; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ Value[i].GetHashCode(); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantStringArrayHandle AsHandle(ConstantStringArray record) + { + if (record == null) + { + return new ConstantStringArrayHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantStringArrayHandle Handle + { + get + { + return new ConstantStringArrayHandle(HandleOffset); + } + } // Handle + + public string[] Value; + } // ConstantStringArray + + /// <summary> + /// ConstantStringValue + /// </summary> + public partial class ConstantStringValue : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantStringValue; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantStringValue; + if (other == null) return false; + if (Value != other.Value) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 280549046; + hash = ((hash << 13) - (hash >> 19)) ^ (Value == null ? 0 : Value.GetHashCode()); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + if (Value == null) + return; + + + writer.Write(Value); + } // Save + + internal static ConstantStringValueHandle AsHandle(ConstantStringValue record) + { + if (record == null) + { + return new ConstantStringValueHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantStringValueHandle Handle + { + get + { + if (Value == null) + return new ConstantStringValueHandle(0); + else + return new ConstantStringValueHandle(HandleOffset); + } + } // Handle + + public string Value; + } // ConstantStringValue + + /// <summary> + /// ConstantUInt16Array + /// </summary> + public partial class ConstantUInt16Array : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantUInt16Array; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantUInt16Array; + if (other == null) return false; + if (!Value.SequenceEqual(other.Value)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -462047045; + if (Value != null) + { + for (int i = 0; i < Value.Length; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ Value[i].GetHashCode(); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantUInt16ArrayHandle AsHandle(ConstantUInt16Array record) + { + if (record == null) + { + return new ConstantUInt16ArrayHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantUInt16ArrayHandle Handle + { + get + { + return new ConstantUInt16ArrayHandle(HandleOffset); + } + } // Handle + + public ushort[] Value; + } // ConstantUInt16Array + + /// <summary> + /// ConstantUInt16Value + /// </summary> + public partial class ConstantUInt16Value : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantUInt16Value; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantUInt16Value; + if (other == null) return false; + if (Value != other.Value) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -1667604030; + hash = ((hash << 13) - (hash >> 19)) ^ Value.GetHashCode(); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantUInt16ValueHandle AsHandle(ConstantUInt16Value record) + { + if (record == null) + { + return new ConstantUInt16ValueHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantUInt16ValueHandle Handle + { + get + { + return new ConstantUInt16ValueHandle(HandleOffset); + } + } // Handle + + public ushort Value; + } // ConstantUInt16Value + + /// <summary> + /// ConstantUInt32Array + /// </summary> + public partial class ConstantUInt32Array : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantUInt32Array; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantUInt32Array; + if (other == null) return false; + if (!Value.SequenceEqual(other.Value)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -453396483; + if (Value != null) + { + for (int i = 0; i < Value.Length; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ Value[i].GetHashCode(); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantUInt32ArrayHandle AsHandle(ConstantUInt32Array record) + { + if (record == null) + { + return new ConstantUInt32ArrayHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantUInt32ArrayHandle Handle + { + get + { + return new ConstantUInt32ArrayHandle(HandleOffset); + } + } // Handle + + public uint[] Value; + } // ConstantUInt32Array + + /// <summary> + /// ConstantUInt32Value + /// </summary> + public partial class ConstantUInt32Value : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantUInt32Value; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantUInt32Value; + if (other == null) return false; + if (Value != other.Value) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -1659477760; + hash = ((hash << 13) - (hash >> 19)) ^ Value.GetHashCode(); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantUInt32ValueHandle AsHandle(ConstantUInt32Value record) + { + if (record == null) + { + return new ConstantUInt32ValueHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantUInt32ValueHandle Handle + { + get + { + return new ConstantUInt32ValueHandle(HandleOffset); + } + } // Handle + + public uint Value; + } // ConstantUInt32Value + + /// <summary> + /// ConstantUInt64Array + /// </summary> + public partial class ConstantUInt64Array : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantUInt64Array; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantUInt64Array; + if (other == null) return false; + if (!Value.SequenceEqual(other.Value)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -470567020; + if (Value != null) + { + for (int i = 0; i < Value.Length; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ Value[i].GetHashCode(); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantUInt64ArrayHandle AsHandle(ConstantUInt64Array record) + { + if (record == null) + { + return new ConstantUInt64ArrayHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantUInt64ArrayHandle Handle + { + get + { + return new ConstantUInt64ArrayHandle(HandleOffset); + } + } // Handle + + public ulong[] Value; + } // ConstantUInt64Array + + /// <summary> + /// ConstantUInt64Value + /// </summary> + public partial class ConstantUInt64Value : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ConstantUInt64Value; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ConstantUInt64Value; + if (other == null) return false; + if (Value != other.Value) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -1678745429; + hash = ((hash << 13) - (hash >> 19)) ^ Value.GetHashCode(); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Value); + } // Save + + internal static ConstantUInt64ValueHandle AsHandle(ConstantUInt64Value record) + { + if (record == null) + { + return new ConstantUInt64ValueHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ConstantUInt64ValueHandle Handle + { + get + { + return new ConstantUInt64ValueHandle(HandleOffset); + } + } // Handle + + public ulong Value; + } // ConstantUInt64Value + + /// <summary> + /// CustomAttribute + /// </summary> + public partial class CustomAttribute : MetadataRecord + { + public CustomAttribute() + { + _equalsReentrancyGuard = new ThreadLocal<ReentrancyGuardStack>(() => new ReentrancyGuardStack()); + } + + public override HandleType HandleType + { + get + { + return HandleType.CustomAttribute; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + FixedArguments = visitor.Visit(this, FixedArguments.AsEnumerable()); + NamedArguments = visitor.Visit(this, NamedArguments.AsEnumerable()); + Type = visitor.Visit(this, Type); + Constructor = visitor.Visit(this, Constructor); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as CustomAttribute; + if (other == null) return false; + if (_equalsReentrancyGuard.Value.Contains(other)) + return true; + _equalsReentrancyGuard.Value.Push(other); + try + { + if (!Object.Equals(Type, other.Type)) return false; + if (!Object.Equals(Constructor, other.Constructor)) return false; + if (!FixedArguments.SequenceEqual(other.FixedArguments)) return false; + if (!NamedArguments.SequenceEqual(other.NamedArguments)) return false; + } + finally + { + var popped = _equalsReentrancyGuard.Value.Pop(); + Debug.Assert(Object.ReferenceEquals(other, popped)); + } + return true; + } // Equals + + private ThreadLocal<ReentrancyGuardStack> _equalsReentrancyGuard; + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 1789737237; + hash = ((hash << 13) - (hash >> 19)) ^ (Type == null ? 0 : Type.GetHashCode()); + hash = ((hash << 13) - (hash >> 19)) ^ (Constructor == null ? 0 : Constructor.GetHashCode()); + if (FixedArguments != null) + { + for (int i = 0; i < FixedArguments.Count; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ (FixedArguments[i] == null ? 0 : FixedArguments[i].GetHashCode()); + } + } + if (NamedArguments != null) + { + for (int i = 0; i < NamedArguments.Count; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ (NamedArguments[i] == null ? 0 : NamedArguments[i].GetHashCode()); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + Debug.Assert(Type == null || + Type.HandleType == HandleType.TypeDefinition || + Type.HandleType == HandleType.TypeReference); + writer.Write(Type); + Debug.Assert(Constructor == null || + Constructor.HandleType == HandleType.Method || + Constructor.HandleType == HandleType.MemberReference); + writer.Write(Constructor); + writer.Write(FixedArguments); + writer.Write(NamedArguments); + } // Save + + internal static CustomAttributeHandle AsHandle(CustomAttribute record) + { + if (record == null) + { + return new CustomAttributeHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new CustomAttributeHandle Handle + { + get + { + return new CustomAttributeHandle(HandleOffset); + } + } // Handle + + public MetadataRecord Type; + public MetadataRecord Constructor; + public List<FixedArgument> FixedArguments = new List<FixedArgument>(); + public List<NamedArgument> NamedArguments = new List<NamedArgument>(); + } // CustomAttribute + + /// <summary> + /// CustomModifier + /// </summary> + public partial class CustomModifier : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.CustomModifier; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + Type = visitor.Visit(this, Type); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as CustomModifier; + if (other == null) return false; + if (IsOptional != other.IsOptional) return false; + if (!Object.Equals(Type, other.Type)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -227081198; + hash = ((hash << 13) - (hash >> 19)) ^ IsOptional.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ (Type == null ? 0 : Type.GetHashCode()); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(IsOptional); + Debug.Assert(Type == null || + Type.HandleType == HandleType.TypeDefinition || + Type.HandleType == HandleType.TypeReference || + Type.HandleType == HandleType.TypeSpecification); + writer.Write(Type); + } // Save + + internal static CustomModifierHandle AsHandle(CustomModifier record) + { + if (record == null) + { + return new CustomModifierHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new CustomModifierHandle Handle + { + get + { + return new CustomModifierHandle(HandleOffset); + } + } // Handle + + public bool IsOptional; + public MetadataRecord Type; + } // CustomModifier + + /// <summary> + /// Event + /// </summary> + public partial class Event : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.Event; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + Name = visitor.Visit(this, Name.AsSingleEnumerable()).FirstOrDefault(); + MethodSemantics = visitor.Visit(this, MethodSemantics.AsEnumerable()); + CustomAttributes = visitor.Visit(this, CustomAttributes.AsEnumerable()); + Type = visitor.Visit(this, Type); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as Event; + if (other == null) return false; + if (Flags != other.Flags) return false; + if (!Object.Equals(Name, other.Name)) return false; + if (!Object.Equals(Type, other.Type)) return false; + if (!MethodSemantics.SequenceEqual(other.MethodSemantics)) return false; + if (!CustomAttributes.SequenceEqual(other.CustomAttributes)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -1560445450; + hash = ((hash << 13) - (hash >> 19)) ^ Flags.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ (Name == null ? 0 : Name.GetHashCode()); + hash = ((hash << 13) - (hash >> 19)) ^ (Type == null ? 0 : Type.GetHashCode()); + if (MethodSemantics != null) + { + for (int i = 0; i < MethodSemantics.Count; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ (MethodSemantics[i] == null ? 0 : MethodSemantics[i].GetHashCode()); + } + } + if (CustomAttributes != null) + { + for (int i = 0; i < CustomAttributes.Count; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ (CustomAttributes[i] == null ? 0 : CustomAttributes[i].GetHashCode()); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Flags); + writer.Write(Name); + Debug.Assert(Type == null || + Type.HandleType == HandleType.TypeDefinition || + Type.HandleType == HandleType.TypeReference || + Type.HandleType == HandleType.TypeSpecification); + writer.Write(Type); + writer.Write(MethodSemantics); + writer.Write(CustomAttributes); + } // Save + + internal static EventHandle AsHandle(Event record) + { + if (record == null) + { + return new EventHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new EventHandle Handle + { + get + { + return new EventHandle(HandleOffset); + } + } // Handle + + public EventAttributes Flags; + public ConstantStringValue Name; + public MetadataRecord Type; + public List<MethodSemantics> MethodSemantics = new List<MethodSemantics>(); + public List<CustomAttribute> CustomAttributes = new List<CustomAttribute>(); + } // Event + + /// <summary> + /// Field + /// </summary> + public partial class Field : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.Field; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + Name = visitor.Visit(this, Name.AsSingleEnumerable()).FirstOrDefault(); + Signature = visitor.Visit(this, Signature.AsSingleEnumerable()).FirstOrDefault(); + CustomAttributes = visitor.Visit(this, CustomAttributes.AsEnumerable()); + DefaultValue = visitor.Visit(this, DefaultValue); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as Field; + if (other == null) return false; + if (Flags != other.Flags) return false; + if (!Object.Equals(Name, other.Name)) return false; + if (!Object.Equals(Signature, other.Signature)) return false; + if (!Object.Equals(DefaultValue, other.DefaultValue)) return false; + if (Offset != other.Offset) return false; + if (!CustomAttributes.SequenceEqual(other.CustomAttributes)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -1184596707; + hash = ((hash << 13) - (hash >> 19)) ^ Flags.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ (Name == null ? 0 : Name.GetHashCode()); + hash = ((hash << 13) - (hash >> 19)) ^ (Signature == null ? 0 : Signature.GetHashCode()); + hash = ((hash << 13) - (hash >> 19)) ^ (DefaultValue == null ? 0 : DefaultValue.GetHashCode()); + hash = ((hash << 13) - (hash >> 19)) ^ Offset.GetHashCode(); + if (CustomAttributes != null) + { + for (int i = 0; i < CustomAttributes.Count; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ (CustomAttributes[i] == null ? 0 : CustomAttributes[i].GetHashCode()); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Flags); + writer.Write(Name); + writer.Write(Signature); + Debug.Assert(DefaultValue == null || + DefaultValue.HandleType == HandleType.TypeDefinition || + DefaultValue.HandleType == HandleType.TypeReference || + DefaultValue.HandleType == HandleType.TypeSpecification || + DefaultValue.HandleType == HandleType.ConstantBooleanArray || + DefaultValue.HandleType == HandleType.ConstantBooleanValue || + DefaultValue.HandleType == HandleType.ConstantByteArray || + DefaultValue.HandleType == HandleType.ConstantByteValue || + DefaultValue.HandleType == HandleType.ConstantCharArray || + DefaultValue.HandleType == HandleType.ConstantCharValue || + DefaultValue.HandleType == HandleType.ConstantDoubleArray || + DefaultValue.HandleType == HandleType.ConstantDoubleValue || + DefaultValue.HandleType == HandleType.ConstantHandleArray || + DefaultValue.HandleType == HandleType.ConstantInt16Array || + DefaultValue.HandleType == HandleType.ConstantInt16Value || + DefaultValue.HandleType == HandleType.ConstantInt32Array || + DefaultValue.HandleType == HandleType.ConstantInt32Value || + DefaultValue.HandleType == HandleType.ConstantInt64Array || + DefaultValue.HandleType == HandleType.ConstantInt64Value || + DefaultValue.HandleType == HandleType.ConstantReferenceValue || + DefaultValue.HandleType == HandleType.ConstantSByteArray || + DefaultValue.HandleType == HandleType.ConstantSByteValue || + DefaultValue.HandleType == HandleType.ConstantSingleArray || + DefaultValue.HandleType == HandleType.ConstantSingleValue || + DefaultValue.HandleType == HandleType.ConstantStringArray || + DefaultValue.HandleType == HandleType.ConstantStringValue || + DefaultValue.HandleType == HandleType.ConstantUInt16Array || + DefaultValue.HandleType == HandleType.ConstantUInt16Value || + DefaultValue.HandleType == HandleType.ConstantUInt32Array || + DefaultValue.HandleType == HandleType.ConstantUInt32Value || + DefaultValue.HandleType == HandleType.ConstantUInt64Array || + DefaultValue.HandleType == HandleType.ConstantUInt64Value); + writer.Write(DefaultValue); + writer.Write(Offset); + writer.Write(CustomAttributes); + } // Save + + internal static FieldHandle AsHandle(Field record) + { + if (record == null) + { + return new FieldHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new FieldHandle Handle + { + get + { + return new FieldHandle(HandleOffset); + } + } // Handle + + public FieldAttributes Flags; + public ConstantStringValue Name; + public FieldSignature Signature; + public MetadataRecord DefaultValue; + public uint Offset; + public List<CustomAttribute> CustomAttributes = new List<CustomAttribute>(); + } // Field + + /// <summary> + /// FieldSignature + /// </summary> + public partial class FieldSignature : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.FieldSignature; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + Type = visitor.Visit(this, Type); + CustomModifiers = CustomModifiers.Select(value => visitor.Visit(this, value)).ToList(); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as FieldSignature; + if (other == null) return false; + if (!Object.Equals(Type, other.Type)) return false; + if (!CustomModifiers.SequenceEqual(other.CustomModifiers)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -964924677; + hash = ((hash << 13) - (hash >> 19)) ^ (Type == null ? 0 : Type.GetHashCode()); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + Debug.Assert(Type == null || + Type.HandleType == HandleType.TypeDefinition || + Type.HandleType == HandleType.TypeReference || + Type.HandleType == HandleType.TypeSpecification); + writer.Write(Type); + writer.Write(CustomModifiers); + } // Save + + internal static FieldSignatureHandle AsHandle(FieldSignature record) + { + if (record == null) + { + return new FieldSignatureHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new FieldSignatureHandle Handle + { + get + { + return new FieldSignatureHandle(HandleOffset); + } + } // Handle + + public MetadataRecord Type; + public List<CustomModifier> CustomModifiers = new List<CustomModifier>(); + } // FieldSignature + + /// <summary> + /// FixedArgument + /// </summary> + public partial class FixedArgument : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.FixedArgument; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + Type = visitor.Visit(this, Type); + Value = visitor.Visit(this, Value); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as FixedArgument; + if (other == null) return false; + if (Flags != other.Flags) return false; + if (!Object.Equals(Type, other.Type)) return false; + if (!Object.Equals(Value, other.Value)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -346484021; + hash = ((hash << 13) - (hash >> 19)) ^ Flags.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ (Type == null ? 0 : Type.GetHashCode()); + hash = ((hash << 13) - (hash >> 19)) ^ (Value == null ? 0 : Value.GetHashCode()); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Flags); + Debug.Assert(Type == null || + Type.HandleType == HandleType.TypeDefinition || + Type.HandleType == HandleType.TypeReference || + Type.HandleType == HandleType.TypeSpecification); + writer.Write(Type); + Debug.Assert(Value == null || + Value.HandleType == HandleType.TypeDefinition || + Value.HandleType == HandleType.TypeReference || + Value.HandleType == HandleType.TypeSpecification || + Value.HandleType == HandleType.ConstantBooleanArray || + Value.HandleType == HandleType.ConstantBooleanValue || + Value.HandleType == HandleType.ConstantByteArray || + Value.HandleType == HandleType.ConstantByteValue || + Value.HandleType == HandleType.ConstantCharArray || + Value.HandleType == HandleType.ConstantCharValue || + Value.HandleType == HandleType.ConstantDoubleArray || + Value.HandleType == HandleType.ConstantDoubleValue || + Value.HandleType == HandleType.ConstantHandleArray || + Value.HandleType == HandleType.ConstantInt16Array || + Value.HandleType == HandleType.ConstantInt16Value || + Value.HandleType == HandleType.ConstantInt32Array || + Value.HandleType == HandleType.ConstantInt32Value || + Value.HandleType == HandleType.ConstantInt64Array || + Value.HandleType == HandleType.ConstantInt64Value || + Value.HandleType == HandleType.ConstantReferenceValue || + Value.HandleType == HandleType.ConstantSByteArray || + Value.HandleType == HandleType.ConstantSByteValue || + Value.HandleType == HandleType.ConstantSingleArray || + Value.HandleType == HandleType.ConstantSingleValue || + Value.HandleType == HandleType.ConstantStringArray || + Value.HandleType == HandleType.ConstantStringValue || + Value.HandleType == HandleType.ConstantUInt16Array || + Value.HandleType == HandleType.ConstantUInt16Value || + Value.HandleType == HandleType.ConstantUInt32Array || + Value.HandleType == HandleType.ConstantUInt32Value || + Value.HandleType == HandleType.ConstantUInt64Array || + Value.HandleType == HandleType.ConstantUInt64Value); + writer.Write(Value); + } // Save + + internal static FixedArgumentHandle AsHandle(FixedArgument record) + { + if (record == null) + { + return new FixedArgumentHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new FixedArgumentHandle Handle + { + get + { + return new FixedArgumentHandle(HandleOffset); + } + } // Handle + + public FixedArgumentAttributes Flags; + public MetadataRecord Type; + public MetadataRecord Value; + } // FixedArgument + + /// <summary> + /// GenericParameter + /// </summary> + public partial class GenericParameter : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.GenericParameter; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + Name = visitor.Visit(this, Name.AsSingleEnumerable()).FirstOrDefault(); + CustomAttributes = visitor.Visit(this, CustomAttributes.AsEnumerable()); + Constraints = Constraints.Select(value => visitor.Visit(this, value)).ToList(); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as GenericParameter; + if (other == null) return false; + if (Number != other.Number) return false; + if (Flags != other.Flags) return false; + if (Kind != other.Kind) return false; + if (!Object.Equals(Name, other.Name)) return false; + if (!Constraints.SequenceEqual(other.Constraints)) return false; + if (!CustomAttributes.SequenceEqual(other.CustomAttributes)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 1752735177; + hash = ((hash << 13) - (hash >> 19)) ^ Number.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ Flags.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ Kind.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ (Name == null ? 0 : Name.GetHashCode()); + if (Constraints != null) + { + for (int i = 0; i < Constraints.Count; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ (Constraints[i] == null ? 0 : Constraints[i].GetHashCode()); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Number); + writer.Write(Flags); + writer.Write(Kind); + writer.Write(Name); + Debug.Assert(Constraints.TrueForAll(handle => handle == null || + handle.HandleType == HandleType.TypeDefinition || + handle.HandleType == HandleType.TypeReference || + handle.HandleType == HandleType.TypeSpecification)); + writer.Write(Constraints); + writer.Write(CustomAttributes); + } // Save + + internal static GenericParameterHandle AsHandle(GenericParameter record) + { + if (record == null) + { + return new GenericParameterHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new GenericParameterHandle Handle + { + get + { + return new GenericParameterHandle(HandleOffset); + } + } // Handle + + public ushort Number; + public GenericParameterAttributes Flags; + public GenericParameterKind Kind; + public ConstantStringValue Name; + public List<MetadataRecord> Constraints = new List<MetadataRecord>(); + public List<CustomAttribute> CustomAttributes = new List<CustomAttribute>(); + } // GenericParameter + + /// <summary> + /// MemberReference + /// </summary> + public partial class MemberReference : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.MemberReference; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + Name = visitor.Visit(this, Name.AsSingleEnumerable()).FirstOrDefault(); + Signature = visitor.Visit(this, Signature.AsSingleEnumerable()).FirstOrDefault(); + CustomAttributes = visitor.Visit(this, CustomAttributes.AsEnumerable()); + Parent = visitor.Visit(this, Parent); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as MemberReference; + if (other == null) return false; + if (!Object.Equals(Parent, other.Parent)) return false; + if (!Object.Equals(Name, other.Name)) return false; + if (!Object.Equals(Signature, other.Signature)) return false; + if (!CustomAttributes.SequenceEqual(other.CustomAttributes)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -2088053629; + hash = ((hash << 13) - (hash >> 19)) ^ (Parent == null ? 0 : Parent.GetHashCode()); + hash = ((hash << 13) - (hash >> 19)) ^ (Name == null ? 0 : Name.GetHashCode()); + hash = ((hash << 13) - (hash >> 19)) ^ (Signature == null ? 0 : Signature.GetHashCode()); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + Debug.Assert(Parent == null || + Parent.HandleType == HandleType.Method || + Parent.HandleType == HandleType.TypeDefinition || + Parent.HandleType == HandleType.TypeReference || + Parent.HandleType == HandleType.TypeSpecification); + writer.Write(Parent); + writer.Write(Name); + Debug.Assert(Signature == null || + Signature.HandleType == HandleType.MethodSignature || + Signature.HandleType == HandleType.FieldSignature); + writer.Write(Signature); + writer.Write(CustomAttributes); + } // Save + + internal static MemberReferenceHandle AsHandle(MemberReference record) + { + if (record == null) + { + return new MemberReferenceHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new MemberReferenceHandle Handle + { + get + { + return new MemberReferenceHandle(HandleOffset); + } + } // Handle + + public MetadataRecord Parent; + public ConstantStringValue Name; + public MetadataRecord Signature; + public List<CustomAttribute> CustomAttributes = new List<CustomAttribute>(); + } // MemberReference + + /// <summary> + /// MetadataWriter + /// </summary> + public partial class MetadataWriter + { + } // MetadataWriter + + /// <summary> + /// Method + /// </summary> + public partial class Method : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.Method; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + Name = visitor.Visit(this, Name.AsSingleEnumerable()).FirstOrDefault(); + Signature = visitor.Visit(this, Signature.AsSingleEnumerable()).FirstOrDefault(); + Parameters = visitor.Visit(this, Parameters.AsEnumerable()); + GenericParameters = visitor.Visit(this, GenericParameters.AsEnumerable()); + MethodImpls = visitor.Visit(this, MethodImpls.AsEnumerable()); + CustomAttributes = visitor.Visit(this, CustomAttributes.AsEnumerable()); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as Method; + if (other == null) return false; + if (RVA != other.RVA) return false; + if (Flags != other.Flags) return false; + if (ImplFlags != other.ImplFlags) return false; + if (!Object.Equals(Name, other.Name)) return false; + if (!Object.Equals(Signature, other.Signature)) return false; + if (!Parameters.SequenceEqual(other.Parameters)) return false; + if (!GenericParameters.SequenceEqual(other.GenericParameters)) return false; + if (!MethodImpls.SequenceEqual(other.MethodImpls)) return false; + if (!CustomAttributes.SequenceEqual(other.CustomAttributes)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 414302350; + hash = ((hash << 13) - (hash >> 19)) ^ RVA.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ Flags.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ ImplFlags.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ (Name == null ? 0 : Name.GetHashCode()); + hash = ((hash << 13) - (hash >> 19)) ^ (Signature == null ? 0 : Signature.GetHashCode()); + if (Parameters != null) + { + for (int i = 0; i < Parameters.Count; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ (Parameters[i] == null ? 0 : Parameters[i].GetHashCode()); + } + } + if (GenericParameters != null) + { + for (int i = 0; i < GenericParameters.Count; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ (GenericParameters[i] == null ? 0 : GenericParameters[i].GetHashCode()); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(RVA); + writer.Write(Flags); + writer.Write(ImplFlags); + writer.Write(Name); + writer.Write(Signature); + writer.Write(Parameters); + writer.Write(GenericParameters); + writer.Write(MethodImpls); + writer.Write(CustomAttributes); + } // Save + + internal static MethodHandle AsHandle(Method record) + { + if (record == null) + { + return new MethodHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new MethodHandle Handle + { + get + { + return new MethodHandle(HandleOffset); + } + } // Handle + + public uint RVA; + public MethodAttributes Flags; + public MethodImplAttributes ImplFlags; + public ConstantStringValue Name; + public MethodSignature Signature; + public List<Parameter> Parameters = new List<Parameter>(); + public List<GenericParameter> GenericParameters = new List<GenericParameter>(); + public List<MethodImpl> MethodImpls = new List<MethodImpl>(); + public List<CustomAttribute> CustomAttributes = new List<CustomAttribute>(); + } // Method + + /// <summary> + /// MethodImpl + /// </summary> + public partial class MethodImpl : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.MethodImpl; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + CustomAttributes = visitor.Visit(this, CustomAttributes.AsEnumerable()); + MethodDeclaration = visitor.Visit(this, MethodDeclaration); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as MethodImpl; + if (other == null) return false; + if (!Object.Equals(MethodDeclaration, other.MethodDeclaration)) return false; + if (!CustomAttributes.SequenceEqual(other.CustomAttributes)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -470854868; + hash = ((hash << 13) - (hash >> 19)) ^ (MethodDeclaration == null ? 0 : MethodDeclaration.GetHashCode()); + if (CustomAttributes != null) + { + for (int i = 0; i < CustomAttributes.Count; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ (CustomAttributes[i] == null ? 0 : CustomAttributes[i].GetHashCode()); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + Debug.Assert(MethodDeclaration == null || + MethodDeclaration.HandleType == HandleType.Method || + MethodDeclaration.HandleType == HandleType.MemberReference); + writer.Write(MethodDeclaration); + writer.Write(CustomAttributes); + } // Save + + internal static MethodImplHandle AsHandle(MethodImpl record) + { + if (record == null) + { + return new MethodImplHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new MethodImplHandle Handle + { + get + { + return new MethodImplHandle(HandleOffset); + } + } // Handle + + public MetadataRecord MethodDeclaration; + public List<CustomAttribute> CustomAttributes = new List<CustomAttribute>(); + } // MethodImpl + + /// <summary> + /// MethodInstantiation + /// </summary> + public partial class MethodInstantiation : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.MethodInstantiation; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + Method = visitor.Visit(this, Method); + Instantiation = visitor.Visit(this, Instantiation); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as MethodInstantiation; + if (other == null) return false; + if (!Object.Equals(Method, other.Method)) return false; + if (!Object.Equals(Instantiation, other.Instantiation)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -1994047112; + hash = ((hash << 13) - (hash >> 19)) ^ (Method == null ? 0 : Method.GetHashCode()); + hash = ((hash << 13) - (hash >> 19)) ^ (Instantiation == null ? 0 : Instantiation.GetHashCode()); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + Debug.Assert(Method == null || + Method.HandleType == HandleType.Method || + Method.HandleType == HandleType.MemberReference); + writer.Write(Method); + writer.Write(Instantiation); + } // Save + + internal static MethodInstantiationHandle AsHandle(MethodInstantiation record) + { + if (record == null) + { + return new MethodInstantiationHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new MethodInstantiationHandle Handle + { + get + { + return new MethodInstantiationHandle(HandleOffset); + } + } // Handle + + public MetadataRecord Method; + public MethodSignature Instantiation; + } // MethodInstantiation + + /// <summary> + /// MethodSemantics + /// </summary> + public partial class MethodSemantics : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.MethodSemantics; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + CustomAttributes = visitor.Visit(this, CustomAttributes.AsEnumerable()); + Method = visitor.Visit(this, Method); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as MethodSemantics; + if (other == null) return false; + if (Attributes != other.Attributes) return false; + if (!Object.Equals(Method, other.Method)) return false; + if (!CustomAttributes.SequenceEqual(other.CustomAttributes)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 849522319; + hash = ((hash << 13) - (hash >> 19)) ^ Attributes.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ (Method == null ? 0 : Method.GetHashCode()); + if (CustomAttributes != null) + { + for (int i = 0; i < CustomAttributes.Count; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ (CustomAttributes[i] == null ? 0 : CustomAttributes[i].GetHashCode()); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Attributes); + writer.Write(Method); + writer.Write(CustomAttributes); + } // Save + + internal static MethodSemanticsHandle AsHandle(MethodSemantics record) + { + if (record == null) + { + return new MethodSemanticsHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new MethodSemanticsHandle Handle + { + get + { + return new MethodSemanticsHandle(HandleOffset); + } + } // Handle + + public MethodSemanticsAttributes Attributes; + public Method Method; + public List<CustomAttribute> CustomAttributes = new List<CustomAttribute>(); + } // MethodSemantics + + /// <summary> + /// MethodSignature + /// </summary> + public partial class MethodSignature : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.MethodSignature; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + ReturnType = visitor.Visit(this, ReturnType); + Parameters = Parameters.Select(value => visitor.Visit(this, value)).ToList(); + VarArgParameters = VarArgParameters.Select(value => visitor.Visit(this, value)).ToList(); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as MethodSignature; + if (other == null) return false; + if (CallingConvention != other.CallingConvention) return false; + if (GenericParameterCount != other.GenericParameterCount) return false; + if (!Object.Equals(ReturnType, other.ReturnType)) return false; + if (!Parameters.SequenceEqual(other.Parameters)) return false; + if (!VarArgParameters.SequenceEqual(other.VarArgParameters)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -177286454; + hash = ((hash << 13) - (hash >> 19)) ^ CallingConvention.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ GenericParameterCount.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ (ReturnType == null ? 0 : ReturnType.GetHashCode()); + if (Parameters != null) + { + for (int i = 0; i < Parameters.Count; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ (Parameters[i] == null ? 0 : Parameters[i].GetHashCode()); + } + } + if (VarArgParameters != null) + { + for (int i = 0; i < VarArgParameters.Count; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ (VarArgParameters[i] == null ? 0 : VarArgParameters[i].GetHashCode()); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(CallingConvention); + writer.Write(GenericParameterCount); + writer.Write(ReturnType); + writer.Write(Parameters); + writer.Write(VarArgParameters); + } // Save + + internal static MethodSignatureHandle AsHandle(MethodSignature record) + { + if (record == null) + { + return new MethodSignatureHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new MethodSignatureHandle Handle + { + get + { + return new MethodSignatureHandle(HandleOffset); + } + } // Handle + + public CallingConventions CallingConvention; + public int GenericParameterCount; + public ReturnTypeSignature ReturnType; + public List<ParameterTypeSignature> Parameters = new List<ParameterTypeSignature>(); + public List<ParameterTypeSignature> VarArgParameters = new List<ParameterTypeSignature>(); + } // MethodSignature + + /// <summary> + /// MethodTypeVariableSignature + /// </summary> + public partial class MethodTypeVariableSignature : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.MethodTypeVariableSignature; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as MethodTypeVariableSignature; + if (other == null) return false; + if (Number != other.Number) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -581196591; + hash = ((hash << 13) - (hash >> 19)) ^ Number.GetHashCode(); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Number); + } // Save + + internal static MethodTypeVariableSignatureHandle AsHandle(MethodTypeVariableSignature record) + { + if (record == null) + { + return new MethodTypeVariableSignatureHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new MethodTypeVariableSignatureHandle Handle + { + get + { + return new MethodTypeVariableSignatureHandle(HandleOffset); + } + } // Handle + + public int Number; + } // MethodTypeVariableSignature + + /// <summary> + /// NamedArgument + /// </summary> + public partial class NamedArgument : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.NamedArgument; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + Name = visitor.Visit(this, Name.AsSingleEnumerable()).FirstOrDefault(); + Value = visitor.Visit(this, Value.AsSingleEnumerable()).FirstOrDefault(); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as NamedArgument; + if (other == null) return false; + if (Flags != other.Flags) return false; + if (!Object.Equals(Name, other.Name)) return false; + if (!Object.Equals(Value, other.Value)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 745864020; + hash = ((hash << 13) - (hash >> 19)) ^ Flags.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ (Name == null ? 0 : Name.GetHashCode()); + hash = ((hash << 13) - (hash >> 19)) ^ (Value == null ? 0 : Value.GetHashCode()); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Flags); + writer.Write(Name); + writer.Write(Value); + } // Save + + internal static NamedArgumentHandle AsHandle(NamedArgument record) + { + if (record == null) + { + return new NamedArgumentHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new NamedArgumentHandle Handle + { + get + { + return new NamedArgumentHandle(HandleOffset); + } + } // Handle + + public NamedArgumentMemberKind Flags; + public ConstantStringValue Name; + public FixedArgument Value; + } // NamedArgument + + /// <summary> + /// NamespaceDefinition + /// </summary> + public partial class NamespaceDefinition : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.NamespaceDefinition; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + Name = visitor.Visit(this, Name.AsSingleEnumerable()).FirstOrDefault(); + TypeDefinitions = visitor.Visit(this, TypeDefinitions.AsEnumerable()); + TypeForwarders = visitor.Visit(this, TypeForwarders.AsEnumerable()); + NamespaceDefinitions = visitor.Visit(this, NamespaceDefinitions.AsEnumerable()); + ParentScopeOrNamespace = visitor.Visit(this, ParentScopeOrNamespace); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as NamespaceDefinition; + if (other == null) return false; + if (!Object.Equals(ParentScopeOrNamespace, other.ParentScopeOrNamespace)) return false; + if (!Object.Equals(Name, other.Name)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -1498718221; + hash = ((hash << 13) - (hash >> 19)) ^ (ParentScopeOrNamespace == null ? 0 : ParentScopeOrNamespace.GetHashCode()); + hash = ((hash << 13) - (hash >> 19)) ^ (Name == null ? 0 : Name.GetHashCode()); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + Debug.Assert(ParentScopeOrNamespace == null || + ParentScopeOrNamespace.HandleType == HandleType.NamespaceDefinition || + ParentScopeOrNamespace.HandleType == HandleType.ScopeDefinition); + writer.Write(ParentScopeOrNamespace); + writer.Write(Name); + writer.Write(TypeDefinitions); + writer.Write(TypeForwarders); + writer.Write(NamespaceDefinitions); + } // Save + + internal static NamespaceDefinitionHandle AsHandle(NamespaceDefinition record) + { + if (record == null) + { + return new NamespaceDefinitionHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new NamespaceDefinitionHandle Handle + { + get + { + return new NamespaceDefinitionHandle(HandleOffset); + } + } // Handle + + public MetadataRecord ParentScopeOrNamespace; + public ConstantStringValue Name; + public List<TypeDefinition> TypeDefinitions = new List<TypeDefinition>(); + public List<TypeForwarder> TypeForwarders = new List<TypeForwarder>(); + public List<NamespaceDefinition> NamespaceDefinitions = new List<NamespaceDefinition>(); + } // NamespaceDefinition + + /// <summary> + /// NamespaceReference + /// </summary> + public partial class NamespaceReference : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.NamespaceReference; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + Name = visitor.Visit(this, Name.AsSingleEnumerable()).FirstOrDefault(); + ParentScopeOrNamespace = visitor.Visit(this, ParentScopeOrNamespace); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as NamespaceReference; + if (other == null) return false; + if (!Object.Equals(ParentScopeOrNamespace, other.ParentScopeOrNamespace)) return false; + if (!Object.Equals(Name, other.Name)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 895578098; + hash = ((hash << 13) - (hash >> 19)) ^ (ParentScopeOrNamespace == null ? 0 : ParentScopeOrNamespace.GetHashCode()); + hash = ((hash << 13) - (hash >> 19)) ^ (Name == null ? 0 : Name.GetHashCode()); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + Debug.Assert(ParentScopeOrNamespace == null || + ParentScopeOrNamespace.HandleType == HandleType.NamespaceReference || + ParentScopeOrNamespace.HandleType == HandleType.ScopeReference); + writer.Write(ParentScopeOrNamespace); + writer.Write(Name); + } // Save + + internal static NamespaceReferenceHandle AsHandle(NamespaceReference record) + { + if (record == null) + { + return new NamespaceReferenceHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new NamespaceReferenceHandle Handle + { + get + { + return new NamespaceReferenceHandle(HandleOffset); + } + } // Handle + + public MetadataRecord ParentScopeOrNamespace; + public ConstantStringValue Name; + } // NamespaceReference + + /// <summary> + /// Parameter + /// </summary> + public partial class Parameter : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.Parameter; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + Name = visitor.Visit(this, Name.AsSingleEnumerable()).FirstOrDefault(); + CustomAttributes = visitor.Visit(this, CustomAttributes.AsEnumerable()); + DefaultValue = visitor.Visit(this, DefaultValue); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as Parameter; + if (other == null) return false; + if (Flags != other.Flags) return false; + if (Sequence != other.Sequence) return false; + if (!Object.Equals(Name, other.Name)) return false; + if (!Object.Equals(DefaultValue, other.DefaultValue)) return false; + if (!CustomAttributes.SequenceEqual(other.CustomAttributes)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -929818086; + hash = ((hash << 13) - (hash >> 19)) ^ Flags.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ Sequence.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ (Name == null ? 0 : Name.GetHashCode()); + hash = ((hash << 13) - (hash >> 19)) ^ (DefaultValue == null ? 0 : DefaultValue.GetHashCode()); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Flags); + writer.Write(Sequence); + writer.Write(Name); + Debug.Assert(DefaultValue == null || + DefaultValue.HandleType == HandleType.TypeDefinition || + DefaultValue.HandleType == HandleType.TypeReference || + DefaultValue.HandleType == HandleType.TypeSpecification || + DefaultValue.HandleType == HandleType.ConstantBooleanArray || + DefaultValue.HandleType == HandleType.ConstantBooleanValue || + DefaultValue.HandleType == HandleType.ConstantByteArray || + DefaultValue.HandleType == HandleType.ConstantByteValue || + DefaultValue.HandleType == HandleType.ConstantCharArray || + DefaultValue.HandleType == HandleType.ConstantCharValue || + DefaultValue.HandleType == HandleType.ConstantDoubleArray || + DefaultValue.HandleType == HandleType.ConstantDoubleValue || + DefaultValue.HandleType == HandleType.ConstantHandleArray || + DefaultValue.HandleType == HandleType.ConstantInt16Array || + DefaultValue.HandleType == HandleType.ConstantInt16Value || + DefaultValue.HandleType == HandleType.ConstantInt32Array || + DefaultValue.HandleType == HandleType.ConstantInt32Value || + DefaultValue.HandleType == HandleType.ConstantInt64Array || + DefaultValue.HandleType == HandleType.ConstantInt64Value || + DefaultValue.HandleType == HandleType.ConstantReferenceValue || + DefaultValue.HandleType == HandleType.ConstantSByteArray || + DefaultValue.HandleType == HandleType.ConstantSByteValue || + DefaultValue.HandleType == HandleType.ConstantSingleArray || + DefaultValue.HandleType == HandleType.ConstantSingleValue || + DefaultValue.HandleType == HandleType.ConstantStringArray || + DefaultValue.HandleType == HandleType.ConstantStringValue || + DefaultValue.HandleType == HandleType.ConstantUInt16Array || + DefaultValue.HandleType == HandleType.ConstantUInt16Value || + DefaultValue.HandleType == HandleType.ConstantUInt32Array || + DefaultValue.HandleType == HandleType.ConstantUInt32Value || + DefaultValue.HandleType == HandleType.ConstantUInt64Array || + DefaultValue.HandleType == HandleType.ConstantUInt64Value); + writer.Write(DefaultValue); + writer.Write(CustomAttributes); + } // Save + + internal static ParameterHandle AsHandle(Parameter record) + { + if (record == null) + { + return new ParameterHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ParameterHandle Handle + { + get + { + return new ParameterHandle(HandleOffset); + } + } // Handle + + public ParameterAttributes Flags; + public ushort Sequence; + public ConstantStringValue Name; + public MetadataRecord DefaultValue; + public List<CustomAttribute> CustomAttributes = new List<CustomAttribute>(); + } // Parameter + + /// <summary> + /// ParameterTypeSignature + /// </summary> + public partial class ParameterTypeSignature : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ParameterTypeSignature; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + CustomModifiers = CustomModifiers.Select(value => visitor.Visit(this, value)).ToList(); + Type = visitor.Visit(this, Type); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ParameterTypeSignature; + if (other == null) return false; + if (!CustomModifiers.SequenceEqual(other.CustomModifiers)) return false; + if (!Object.Equals(Type, other.Type)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -898234212; + hash = ((hash << 13) - (hash >> 19)) ^ (Type == null ? 0 : Type.GetHashCode()); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(CustomModifiers); + Debug.Assert(Type == null || + Type.HandleType == HandleType.TypeDefinition || + Type.HandleType == HandleType.TypeReference || + Type.HandleType == HandleType.TypeSpecification); + writer.Write(Type); + } // Save + + internal static ParameterTypeSignatureHandle AsHandle(ParameterTypeSignature record) + { + if (record == null) + { + return new ParameterTypeSignatureHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ParameterTypeSignatureHandle Handle + { + get + { + return new ParameterTypeSignatureHandle(HandleOffset); + } + } // Handle + + public List<CustomModifier> CustomModifiers = new List<CustomModifier>(); + public MetadataRecord Type; + } // ParameterTypeSignature + + /// <summary> + /// PointerSignature + /// </summary> + public partial class PointerSignature : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.PointerSignature; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + Type = visitor.Visit(this, Type); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as PointerSignature; + if (other == null) return false; + if (!Object.Equals(Type, other.Type)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 335490965; + hash = ((hash << 13) - (hash >> 19)) ^ (Type == null ? 0 : Type.GetHashCode()); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + Debug.Assert(Type == null || + Type.HandleType == HandleType.TypeDefinition || + Type.HandleType == HandleType.TypeReference || + Type.HandleType == HandleType.TypeSpecification); + writer.Write(Type); + } // Save + + internal static PointerSignatureHandle AsHandle(PointerSignature record) + { + if (record == null) + { + return new PointerSignatureHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new PointerSignatureHandle Handle + { + get + { + return new PointerSignatureHandle(HandleOffset); + } + } // Handle + + public MetadataRecord Type; + } // PointerSignature + + /// <summary> + /// Property + /// </summary> + public partial class Property : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.Property; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + Name = visitor.Visit(this, Name.AsSingleEnumerable()).FirstOrDefault(); + Signature = visitor.Visit(this, Signature.AsSingleEnumerable()).FirstOrDefault(); + MethodSemantics = visitor.Visit(this, MethodSemantics.AsEnumerable()); + CustomAttributes = visitor.Visit(this, CustomAttributes.AsEnumerable()); + DefaultValue = visitor.Visit(this, DefaultValue); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as Property; + if (other == null) return false; + if (Flags != other.Flags) return false; + if (!Object.Equals(Name, other.Name)) return false; + if (!Object.Equals(Signature, other.Signature)) return false; + if (!MethodSemantics.SequenceEqual(other.MethodSemantics)) return false; + if (!Object.Equals(DefaultValue, other.DefaultValue)) return false; + if (!CustomAttributes.SequenceEqual(other.CustomAttributes)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -101394342; + hash = ((hash << 13) - (hash >> 19)) ^ Flags.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ (Name == null ? 0 : Name.GetHashCode()); + hash = ((hash << 13) - (hash >> 19)) ^ (Signature == null ? 0 : Signature.GetHashCode()); + if (MethodSemantics != null) + { + for (int i = 0; i < MethodSemantics.Count; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ (MethodSemantics[i] == null ? 0 : MethodSemantics[i].GetHashCode()); + } + } + hash = ((hash << 13) - (hash >> 19)) ^ (DefaultValue == null ? 0 : DefaultValue.GetHashCode()); + if (CustomAttributes != null) + { + for (int i = 0; i < CustomAttributes.Count; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ (CustomAttributes[i] == null ? 0 : CustomAttributes[i].GetHashCode()); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Flags); + writer.Write(Name); + writer.Write(Signature); + writer.Write(MethodSemantics); + Debug.Assert(DefaultValue == null || + DefaultValue.HandleType == HandleType.TypeDefinition || + DefaultValue.HandleType == HandleType.TypeReference || + DefaultValue.HandleType == HandleType.TypeSpecification || + DefaultValue.HandleType == HandleType.ConstantBooleanArray || + DefaultValue.HandleType == HandleType.ConstantBooleanValue || + DefaultValue.HandleType == HandleType.ConstantByteArray || + DefaultValue.HandleType == HandleType.ConstantByteValue || + DefaultValue.HandleType == HandleType.ConstantCharArray || + DefaultValue.HandleType == HandleType.ConstantCharValue || + DefaultValue.HandleType == HandleType.ConstantDoubleArray || + DefaultValue.HandleType == HandleType.ConstantDoubleValue || + DefaultValue.HandleType == HandleType.ConstantHandleArray || + DefaultValue.HandleType == HandleType.ConstantInt16Array || + DefaultValue.HandleType == HandleType.ConstantInt16Value || + DefaultValue.HandleType == HandleType.ConstantInt32Array || + DefaultValue.HandleType == HandleType.ConstantInt32Value || + DefaultValue.HandleType == HandleType.ConstantInt64Array || + DefaultValue.HandleType == HandleType.ConstantInt64Value || + DefaultValue.HandleType == HandleType.ConstantReferenceValue || + DefaultValue.HandleType == HandleType.ConstantSByteArray || + DefaultValue.HandleType == HandleType.ConstantSByteValue || + DefaultValue.HandleType == HandleType.ConstantSingleArray || + DefaultValue.HandleType == HandleType.ConstantSingleValue || + DefaultValue.HandleType == HandleType.ConstantStringArray || + DefaultValue.HandleType == HandleType.ConstantStringValue || + DefaultValue.HandleType == HandleType.ConstantUInt16Array || + DefaultValue.HandleType == HandleType.ConstantUInt16Value || + DefaultValue.HandleType == HandleType.ConstantUInt32Array || + DefaultValue.HandleType == HandleType.ConstantUInt32Value || + DefaultValue.HandleType == HandleType.ConstantUInt64Array || + DefaultValue.HandleType == HandleType.ConstantUInt64Value); + writer.Write(DefaultValue); + writer.Write(CustomAttributes); + } // Save + + internal static PropertyHandle AsHandle(Property record) + { + if (record == null) + { + return new PropertyHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new PropertyHandle Handle + { + get + { + return new PropertyHandle(HandleOffset); + } + } // Handle + + public PropertyAttributes Flags; + public ConstantStringValue Name; + public PropertySignature Signature; + public List<MethodSemantics> MethodSemantics = new List<MethodSemantics>(); + public MetadataRecord DefaultValue; + public List<CustomAttribute> CustomAttributes = new List<CustomAttribute>(); + } // Property + + /// <summary> + /// PropertySignature + /// </summary> + public partial class PropertySignature : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.PropertySignature; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + CustomModifiers = CustomModifiers.Select(value => visitor.Visit(this, value)).ToList(); + Type = visitor.Visit(this, Type); + Parameters = Parameters.Select(value => visitor.Visit(this, value)).ToList(); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as PropertySignature; + if (other == null) return false; + if (CallingConvention != other.CallingConvention) return false; + if (!CustomModifiers.SequenceEqual(other.CustomModifiers)) return false; + if (!Object.Equals(Type, other.Type)) return false; + if (!Parameters.SequenceEqual(other.Parameters)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -401451631; + hash = ((hash << 13) - (hash >> 19)) ^ CallingConvention.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ (Type == null ? 0 : Type.GetHashCode()); + if (Parameters != null) + { + for (int i = 0; i < Parameters.Count; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ (Parameters[i] == null ? 0 : Parameters[i].GetHashCode()); + } + } + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(CallingConvention); + writer.Write(CustomModifiers); + Debug.Assert(Type == null || + Type.HandleType == HandleType.TypeDefinition || + Type.HandleType == HandleType.TypeReference || + Type.HandleType == HandleType.TypeSpecification); + writer.Write(Type); + writer.Write(Parameters); + } // Save + + internal static PropertySignatureHandle AsHandle(PropertySignature record) + { + if (record == null) + { + return new PropertySignatureHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new PropertySignatureHandle Handle + { + get + { + return new PropertySignatureHandle(HandleOffset); + } + } // Handle + + public CallingConventions CallingConvention; + public List<CustomModifier> CustomModifiers = new List<CustomModifier>(); + public MetadataRecord Type; + public List<ParameterTypeSignature> Parameters = new List<ParameterTypeSignature>(); + } // PropertySignature + + /// <summary> + /// ReturnTypeSignature + /// </summary> + public partial class ReturnTypeSignature : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ReturnTypeSignature; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + CustomModifiers = CustomModifiers.Select(value => visitor.Visit(this, value)).ToList(); + Type = visitor.Visit(this, Type); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ReturnTypeSignature; + if (other == null) return false; + if (!CustomModifiers.SequenceEqual(other.CustomModifiers)) return false; + if (!Object.Equals(Type, other.Type)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 1808955079; + hash = ((hash << 13) - (hash >> 19)) ^ (Type == null ? 0 : Type.GetHashCode()); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(CustomModifiers); + Debug.Assert(Type == null || + Type.HandleType == HandleType.TypeDefinition || + Type.HandleType == HandleType.TypeReference || + Type.HandleType == HandleType.TypeSpecification); + writer.Write(Type); + } // Save + + internal static ReturnTypeSignatureHandle AsHandle(ReturnTypeSignature record) + { + if (record == null) + { + return new ReturnTypeSignatureHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ReturnTypeSignatureHandle Handle + { + get + { + return new ReturnTypeSignatureHandle(HandleOffset); + } + } // Handle + + public List<CustomModifier> CustomModifiers = new List<CustomModifier>(); + public MetadataRecord Type; + } // ReturnTypeSignature + + /// <summary> + /// SZArraySignature + /// </summary> + public partial class SZArraySignature : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.SZArraySignature; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + ElementType = visitor.Visit(this, ElementType); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as SZArraySignature; + if (other == null) return false; + if (!Object.Equals(ElementType, other.ElementType)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 1118159789; + hash = ((hash << 13) - (hash >> 19)) ^ (ElementType == null ? 0 : ElementType.GetHashCode()); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + Debug.Assert(ElementType == null || + ElementType.HandleType == HandleType.TypeDefinition || + ElementType.HandleType == HandleType.TypeReference || + ElementType.HandleType == HandleType.TypeSpecification); + writer.Write(ElementType); + } // Save + + internal static SZArraySignatureHandle AsHandle(SZArraySignature record) + { + if (record == null) + { + return new SZArraySignatureHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new SZArraySignatureHandle Handle + { + get + { + return new SZArraySignatureHandle(HandleOffset); + } + } // Handle + + public MetadataRecord ElementType; + } // SZArraySignature + + /// <summary> + /// ScopeDefinition + /// </summary> + public partial class ScopeDefinition : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ScopeDefinition; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + Name = visitor.Visit(this, Name.AsSingleEnumerable()).FirstOrDefault(); + Culture = visitor.Visit(this, Culture.AsSingleEnumerable()).FirstOrDefault(); + RootNamespaceDefinition = visitor.Visit(this, RootNamespaceDefinition.AsSingleEnumerable()).FirstOrDefault(); + CustomAttributes = visitor.Visit(this, CustomAttributes.AsEnumerable()); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ScopeDefinition; + if (other == null) return false; + if (Flags != other.Flags) return false; + if (!Object.Equals(Name, other.Name)) return false; + if (HashAlgorithm != other.HashAlgorithm) return false; + if (MajorVersion != other.MajorVersion) return false; + if (MinorVersion != other.MinorVersion) return false; + if (BuildNumber != other.BuildNumber) return false; + if (RevisionNumber != other.RevisionNumber) return false; + if (!PublicKey.SequenceEqual(other.PublicKey)) return false; + if (!Object.Equals(Culture, other.Culture)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 13322760; + hash = ((hash << 13) - (hash >> 19)) ^ Flags.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ (Name == null ? 0 : Name.GetHashCode()); + hash = ((hash << 13) - (hash >> 19)) ^ HashAlgorithm.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ MajorVersion.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ MinorVersion.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ BuildNumber.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ RevisionNumber.GetHashCode(); + if (PublicKey != null) + { + for (int i = 0; i < PublicKey.Length; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ PublicKey[i].GetHashCode(); + } + } + hash = ((hash << 13) - (hash >> 19)) ^ (Culture == null ? 0 : Culture.GetHashCode()); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Flags); + writer.Write(Name); + writer.Write(HashAlgorithm); + writer.Write(MajorVersion); + writer.Write(MinorVersion); + writer.Write(BuildNumber); + writer.Write(RevisionNumber); + writer.Write(PublicKey); + writer.Write(Culture); + writer.Write(RootNamespaceDefinition); + writer.Write(CustomAttributes); + } // Save + + internal static ScopeDefinitionHandle AsHandle(ScopeDefinition record) + { + if (record == null) + { + return new ScopeDefinitionHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ScopeDefinitionHandle Handle + { + get + { + return new ScopeDefinitionHandle(HandleOffset); + } + } // Handle + + public AssemblyFlags Flags; + public ConstantStringValue Name; + public AssemblyHashAlgorithm HashAlgorithm; + public ushort MajorVersion; + public ushort MinorVersion; + public ushort BuildNumber; + public ushort RevisionNumber; + public byte[] PublicKey; + public ConstantStringValue Culture; + public NamespaceDefinition RootNamespaceDefinition; + public List<CustomAttribute> CustomAttributes = new List<CustomAttribute>(); + } // ScopeDefinition + + /// <summary> + /// ScopeReference + /// </summary> + public partial class ScopeReference : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.ScopeReference; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + Name = visitor.Visit(this, Name.AsSingleEnumerable()).FirstOrDefault(); + Culture = visitor.Visit(this, Culture.AsSingleEnumerable()).FirstOrDefault(); + CustomAttributes = visitor.Visit(this, CustomAttributes.AsEnumerable()); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as ScopeReference; + if (other == null) return false; + if (Flags != other.Flags) return false; + if (!Object.Equals(Name, other.Name)) return false; + if (MajorVersion != other.MajorVersion) return false; + if (MinorVersion != other.MinorVersion) return false; + if (BuildNumber != other.BuildNumber) return false; + if (RevisionNumber != other.RevisionNumber) return false; + if (!PublicKeyOrToken.SequenceEqual(other.PublicKeyOrToken)) return false; + if (!Object.Equals(Culture, other.Culture)) return false; + if (!CustomAttributes.SequenceEqual(other.CustomAttributes)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -769863623; + hash = ((hash << 13) - (hash >> 19)) ^ Flags.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ (Name == null ? 0 : Name.GetHashCode()); + hash = ((hash << 13) - (hash >> 19)) ^ MajorVersion.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ MinorVersion.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ BuildNumber.GetHashCode(); + hash = ((hash << 13) - (hash >> 19)) ^ RevisionNumber.GetHashCode(); + if (PublicKeyOrToken != null) + { + for (int i = 0; i < PublicKeyOrToken.Length; i++) + { + hash = ((hash << 13) - (hash >> 19)) ^ PublicKeyOrToken[i].GetHashCode(); + } + } + hash = ((hash << 13) - (hash >> 19)) ^ (Culture == null ? 0 : Culture.GetHashCode()); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Flags); + writer.Write(Name); + writer.Write(MajorVersion); + writer.Write(MinorVersion); + writer.Write(BuildNumber); + writer.Write(RevisionNumber); + writer.Write(PublicKeyOrToken); + writer.Write(Culture); + writer.Write(CustomAttributes); + } // Save + + internal static ScopeReferenceHandle AsHandle(ScopeReference record) + { + if (record == null) + { + return new ScopeReferenceHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new ScopeReferenceHandle Handle + { + get + { + return new ScopeReferenceHandle(HandleOffset); + } + } // Handle + + public AssemblyFlags Flags; + public ConstantStringValue Name; + public ushort MajorVersion; + public ushort MinorVersion; + public ushort BuildNumber; + public ushort RevisionNumber; + public byte[] PublicKeyOrToken; + public ConstantStringValue Culture; + public List<CustomAttribute> CustomAttributes = new List<CustomAttribute>(); + } // ScopeReference + + /// <summary> + /// TypeDefinition + /// </summary> + public partial class TypeDefinition : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.TypeDefinition; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + Name = visitor.Visit(this, Name.AsSingleEnumerable()).FirstOrDefault(); + NestedTypes = visitor.Visit(this, NestedTypes.AsEnumerable()); + Methods = visitor.Visit(this, Methods.AsEnumerable()); + Fields = visitor.Visit(this, Fields.AsEnumerable()); + Properties = visitor.Visit(this, Properties.AsEnumerable()); + Events = visitor.Visit(this, Events.AsEnumerable()); + GenericParameters = visitor.Visit(this, GenericParameters.AsEnumerable()); + CustomAttributes = visitor.Visit(this, CustomAttributes.AsEnumerable()); + BaseType = visitor.Visit(this, BaseType); + NamespaceDefinition = visitor.Visit(this, NamespaceDefinition); + EnclosingType = visitor.Visit(this, EnclosingType); + Interfaces = Interfaces.Select(value => visitor.Visit(this, value)).ToList(); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as TypeDefinition; + if (other == null) return false; + if (!Object.Equals(NamespaceDefinition, other.NamespaceDefinition)) return false; + if (!Object.Equals(Name, other.Name)) return false; + if (!Object.Equals(EnclosingType, other.EnclosingType)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -967212031; + hash = ((hash << 13) - (hash >> 19)) ^ (NamespaceDefinition == null ? 0 : NamespaceDefinition.GetHashCode()); + hash = ((hash << 13) - (hash >> 19)) ^ (Name == null ? 0 : Name.GetHashCode()); + hash = ((hash << 13) - (hash >> 19)) ^ (EnclosingType == null ? 0 : EnclosingType.GetHashCode()); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Flags); + Debug.Assert(BaseType == null || + BaseType.HandleType == HandleType.TypeDefinition || + BaseType.HandleType == HandleType.TypeReference || + BaseType.HandleType == HandleType.TypeSpecification); + writer.Write(BaseType); + writer.Write(NamespaceDefinition); + writer.Write(Name); + writer.Write(Size); + writer.Write(PackingSize); + writer.Write(EnclosingType); + writer.Write(NestedTypes); + writer.Write(Methods); + writer.Write(Fields); + writer.Write(Properties); + writer.Write(Events); + writer.Write(GenericParameters); + Debug.Assert(Interfaces.TrueForAll(handle => handle == null || + handle.HandleType == HandleType.TypeDefinition || + handle.HandleType == HandleType.TypeReference || + handle.HandleType == HandleType.TypeSpecification)); + writer.Write(Interfaces); + writer.Write(CustomAttributes); + } // Save + + internal static TypeDefinitionHandle AsHandle(TypeDefinition record) + { + if (record == null) + { + return new TypeDefinitionHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new TypeDefinitionHandle Handle + { + get + { + return new TypeDefinitionHandle(HandleOffset); + } + } // Handle + + public TypeAttributes Flags; + public MetadataRecord BaseType; + public NamespaceDefinition NamespaceDefinition; + public ConstantStringValue Name; + public uint Size; + public uint PackingSize; + public TypeDefinition EnclosingType; + public List<TypeDefinition> NestedTypes = new List<TypeDefinition>(); + public List<Method> Methods = new List<Method>(); + public List<Field> Fields = new List<Field>(); + public List<Property> Properties = new List<Property>(); + public List<Event> Events = new List<Event>(); + public List<GenericParameter> GenericParameters = new List<GenericParameter>(); + public List<MetadataRecord> Interfaces = new List<MetadataRecord>(); + public List<CustomAttribute> CustomAttributes = new List<CustomAttribute>(); + } // TypeDefinition + + /// <summary> + /// TypeForwarder + /// </summary> + public partial class TypeForwarder : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.TypeForwarder; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + Name = visitor.Visit(this, Name.AsSingleEnumerable()).FirstOrDefault(); + NestedTypes = visitor.Visit(this, NestedTypes.AsEnumerable()); + CustomAttributes = visitor.Visit(this, CustomAttributes.AsEnumerable()); + Scope = visitor.Visit(this, Scope); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as TypeForwarder; + if (other == null) return false; + if (!Object.Equals(Scope, other.Scope)) return false; + if (!Object.Equals(Name, other.Name)) return false; + if (!NestedTypes.SequenceEqual(other.NestedTypes)) return false; + if (!CustomAttributes.SequenceEqual(other.CustomAttributes)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 690839467; + hash = ((hash << 13) - (hash >> 19)) ^ (Scope == null ? 0 : Scope.GetHashCode()); + hash = ((hash << 13) - (hash >> 19)) ^ (Name == null ? 0 : Name.GetHashCode()); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Scope); + writer.Write(Name); + writer.Write(NestedTypes); + writer.Write(CustomAttributes); + } // Save + + internal static TypeForwarderHandle AsHandle(TypeForwarder record) + { + if (record == null) + { + return new TypeForwarderHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new TypeForwarderHandle Handle + { + get + { + return new TypeForwarderHandle(HandleOffset); + } + } // Handle + + public ScopeReference Scope; + public ConstantStringValue Name; + public List<TypeForwarder> NestedTypes = new List<TypeForwarder>(); + public List<CustomAttribute> CustomAttributes = new List<CustomAttribute>(); + } // TypeForwarder + + /// <summary> + /// TypeInstantiationSignature + /// </summary> + public partial class TypeInstantiationSignature : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.TypeInstantiationSignature; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + GenericType = visitor.Visit(this, GenericType); + GenericTypeArguments = GenericTypeArguments.Select(value => visitor.Visit(this, value)).ToList(); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as TypeInstantiationSignature; + if (other == null) return false; + if (!Object.Equals(GenericType, other.GenericType)) return false; + if (!GenericTypeArguments.SequenceEqual(other.GenericTypeArguments)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -1724439320; + hash = ((hash << 13) - (hash >> 19)) ^ (GenericType == null ? 0 : GenericType.GetHashCode()); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + Debug.Assert(GenericType == null || + GenericType.HandleType == HandleType.TypeDefinition || + GenericType.HandleType == HandleType.TypeReference || + GenericType.HandleType == HandleType.TypeSpecification); + writer.Write(GenericType); + Debug.Assert(GenericTypeArguments.TrueForAll(handle => handle == null || + handle.HandleType == HandleType.TypeDefinition || + handle.HandleType == HandleType.TypeReference || + handle.HandleType == HandleType.TypeSpecification)); + writer.Write(GenericTypeArguments); + } // Save + + internal static TypeInstantiationSignatureHandle AsHandle(TypeInstantiationSignature record) + { + if (record == null) + { + return new TypeInstantiationSignatureHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new TypeInstantiationSignatureHandle Handle + { + get + { + return new TypeInstantiationSignatureHandle(HandleOffset); + } + } // Handle + + public MetadataRecord GenericType; + public List<MetadataRecord> GenericTypeArguments = new List<MetadataRecord>(); + } // TypeInstantiationSignature + + /// <summary> + /// TypeReference + /// </summary> + public partial class TypeReference : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.TypeReference; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + TypeName = visitor.Visit(this, TypeName.AsSingleEnumerable()).FirstOrDefault(); + CustomAttributes = visitor.Visit(this, CustomAttributes.AsEnumerable()); + ParentNamespaceOrType = visitor.Visit(this, ParentNamespaceOrType); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as TypeReference; + if (other == null) return false; + if (!Object.Equals(ParentNamespaceOrType, other.ParentNamespaceOrType)) return false; + if (!Object.Equals(TypeName, other.TypeName)) return false; + if (!CustomAttributes.SequenceEqual(other.CustomAttributes)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = -594854621; + hash = ((hash << 13) - (hash >> 19)) ^ (ParentNamespaceOrType == null ? 0 : ParentNamespaceOrType.GetHashCode()); + hash = ((hash << 13) - (hash >> 19)) ^ (TypeName == null ? 0 : TypeName.GetHashCode()); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + Debug.Assert(ParentNamespaceOrType == null || + ParentNamespaceOrType.HandleType == HandleType.NamespaceReference || + ParentNamespaceOrType.HandleType == HandleType.TypeReference); + writer.Write(ParentNamespaceOrType); + writer.Write(TypeName); + writer.Write(CustomAttributes); + } // Save + + internal static TypeReferenceHandle AsHandle(TypeReference record) + { + if (record == null) + { + return new TypeReferenceHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new TypeReferenceHandle Handle + { + get + { + return new TypeReferenceHandle(HandleOffset); + } + } // Handle + + public MetadataRecord ParentNamespaceOrType; + public ConstantStringValue TypeName; + public List<CustomAttribute> CustomAttributes = new List<CustomAttribute>(); + } // TypeReference + + /// <summary> + /// TypeSpecification + /// </summary> + public partial class TypeSpecification : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.TypeSpecification; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + Signature = visitor.Visit(this, Signature.AsSingleEnumerable()).FirstOrDefault(); + CustomAttributes = visitor.Visit(this, CustomAttributes.AsEnumerable()); + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as TypeSpecification; + if (other == null) return false; + if (!Object.Equals(Signature, other.Signature)) return false; + if (!CustomAttributes.SequenceEqual(other.CustomAttributes)) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 263768524; + hash = ((hash << 13) - (hash >> 19)) ^ (Signature == null ? 0 : Signature.GetHashCode()); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + Debug.Assert(Signature == null || + Signature.HandleType == HandleType.TypeDefinition || + Signature.HandleType == HandleType.TypeReference || + Signature.HandleType == HandleType.TypeInstantiationSignature || + Signature.HandleType == HandleType.SZArraySignature || + Signature.HandleType == HandleType.ArraySignature || + Signature.HandleType == HandleType.PointerSignature || + Signature.HandleType == HandleType.ByReferenceSignature || + Signature.HandleType == HandleType.TypeVariableSignature || + Signature.HandleType == HandleType.MethodTypeVariableSignature); + writer.Write(Signature); + writer.Write(CustomAttributes); + } // Save + + internal static TypeSpecificationHandle AsHandle(TypeSpecification record) + { + if (record == null) + { + return new TypeSpecificationHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new TypeSpecificationHandle Handle + { + get + { + return new TypeSpecificationHandle(HandleOffset); + } + } // Handle + + public MetadataRecord Signature; + public List<CustomAttribute> CustomAttributes = new List<CustomAttribute>(); + } // TypeSpecification + + /// <summary> + /// TypeVariableSignature + /// </summary> + public partial class TypeVariableSignature : MetadataRecord + { + public override HandleType HandleType + { + get + { + return HandleType.TypeVariableSignature; + } + } // HandleType + + internal override void Visit(IRecordVisitor visitor) + { + + } // Visit + + public override sealed bool Equals(Object obj) + { + if (Object.ReferenceEquals(this, obj)) return true; + var other = obj as TypeVariableSignature; + if (other == null) return false; + if (Number != other.Number) return false; + return true; + } // Equals + + public override sealed int GetHashCode() + { + if (_hash != 0) + return _hash; + EnterGetHashCode(); + int hash = 2086004915; + hash = ((hash << 13) - (hash >> 19)) ^ Number.GetHashCode(); + LeaveGetHashCode(); + _hash = hash; + return _hash; + } // GetHashCode + + internal override void Save(NativeWriter writer) + { + writer.Write(Number); + } // Save + + internal static TypeVariableSignatureHandle AsHandle(TypeVariableSignature record) + { + if (record == null) + { + return new TypeVariableSignatureHandle(0); + } + else + { + return record.Handle; + } + } // AsHandle + + internal new TypeVariableSignatureHandle Handle + { + get + { + return new TypeVariableSignatureHandle(HandleOffset); + } + } // Handle + + public int Number; + } // TypeVariableSignature +} // Internal.Metadata.NativeFormat.Writer diff --git a/src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/NativeMetadataWriter.cs b/src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/NativeMetadataWriter.cs new file mode 100644 index 000000000..7eb84b2bd --- /dev/null +++ b/src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/NativeMetadataWriter.cs @@ -0,0 +1,1111 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +#pragma warning disable 649 + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using System.Reflection; +using Debug = System.Diagnostics.Debug; +using ConditionalAttribute = System.Diagnostics.ConditionalAttribute; +using HandleType = Internal.Metadata.NativeFormat.HandleType; +using Internal.NativeFormat; + +namespace Internal.Metadata.NativeFormat.Writer +{ + using Graph = AdjacencyGraph; + internal class Edge + { + public MetadataRecord Source; + public MetadataRecord Target; + public Edge(MetadataRecord source, MetadataRecord target) + { + Source = source; + Target = target; + } + }; + internal class AdjacencyGraph + { + private HashSet<MetadataRecord> _vertices = new HashSet<MetadataRecord>(); + // private Dictionary<MetadataRecord, HashSet<Edge>> _edges = new Dictionary<MetadataRecord, HashSet<Edge>>(); + + public void AddVertex(MetadataRecord v) + { + _vertices.Add(v); + } + +#if false + public void AddEdge(Edge e) + { + HashSet<Edge> vedges; + if (!_edges.TryGetValue(e.Source, out vedges)) + { + vedges = new HashSet<Edge>(); + _edges.Add(e.Source, vedges); + } + vedges.Add(e); + } +#endif + + public bool ContainsVertex(MetadataRecord v) + { + return _vertices.Contains(v); + } + + public IEnumerable<MetadataRecord> Vertices + { get { return _vertices; } } + } + + internal partial interface IRecordVisitor + { + // Adds edge + DstT Visit<SrcT, DstT>(SrcT src, DstT dst) + where SrcT : MetadataRecord + where DstT : MetadataRecord; + + // Adds grouped edges + Dictionary<string, DstT> Visit<SrcT, DstT>(SrcT src, IEnumerable<KeyValuePair<string, DstT>> dst) + where SrcT : MetadataRecord + where DstT : MetadataRecord; + + // Adds grouped edges + List<DstT> Visit<SrcT, DstT>(SrcT src, IEnumerable<DstT> dst) + where SrcT : MetadataRecord + where DstT : MetadataRecord; + } + + internal class SourceVertex : MetadataRecord + { + public override HandleType HandleType + { + get { throw new NotImplementedException(); } + } + + internal override void Save(NativeWriter writer) + { + throw new NotImplementedException(); + } + + internal override void Visit(IRecordVisitor visitor) + { + throw new NotImplementedException(); + } + } + + internal abstract class RecordVisitorBase : IRecordVisitor + { +#if false + private class SequenceComparer<T> + : IEqualityComparer<IEnumerable<T>> + { + public bool Equals(IEnumerable<T> x, IEnumerable<T> y) + { + return + Object.ReferenceEquals(x, y) || + (x != null && + y != null && + x.GetType() == y.GetType() && + x.SequenceEqual(y)); + } + + public static int GetHashCode(T o) + { + if (o == null) + return 0; + return o.GetHashCode(); + } + + public int GetHashCode(IEnumerable<T> obj) + { + if (obj == null) + return 0; + return obj.Aggregate(0, (h, o) => h ^ GetHashCode(o)); + } + } + + Dictionary<IEnumerable<MetadataRecord>, object> _listPool = new Dictionary<IEnumerable<MetadataRecord>, object>(new SequenceComparer<MetadataRecord>()); + + private List<T> GetPooledArray<T>(List<T> rec) where T : MetadataRecord + { + if (rec == null || rec.Count() == 0) + return rec; + + object pooledRecord; + if (_listPool.TryGetValue(rec, out pooledRecord) && pooledRecord != rec) + { + if (rec.GetType().GetElementType() == typeof(MetadataRecord)) + _stats.ArraySizeSavings += rec.Count() * sizeof(int) - 3; + else + _stats.ArraySizeSavings += rec.Count() * 3 - 3; + Debug.Assert(rec.GetType() == pooledRecord.GetType()); + rec = (List<T>)pooledRecord; + } + else + { + _listPool[rec] = rec; + } + return rec; + } + + private struct Stats + { + public int ArraySizeSavings; + } + private Stats _stats = new Stats(); +#endif + + private Dictionary<MetadataRecord, MetadataRecord> _recordPool = new Dictionary<MetadataRecord, MetadataRecord>(); + + public RecordVisitorBase() + { + _graph.AddVertex(MetaSourceVertex); + } + + internal T MapToPooledRecord<T>(T rec) where T : MetadataRecord + { + return (T)_recordPool[rec]; + } + + private T GetPooledRecord<T>(T rec) where T : MetadataRecord + { + if (rec == null) + return rec; + + MetadataRecord pooledRecord; + if (_recordPool.TryGetValue(rec, out pooledRecord) && pooledRecord != rec) + { + Debug.Assert(rec.GetType() == pooledRecord.GetType()); + rec = (T)pooledRecord; + } + else + { + _recordPool[rec] = rec; + } + return rec; + } + + // Adds a Vertex + public T Visit<T>(T rec) + where T : MetadataRecord + { + rec = GetPooledRecord(rec); + + if (rec == null) + return rec; + + if (_graph.ContainsVertex(rec)) + return rec; + + _graph.AddVertex(rec); + _queue.Enqueue(rec); + + return rec; + } + + // Adds Edges + public Dictionary<string, DstT> Visit<SrcT, DstT>(SrcT src, IEnumerable<KeyValuePair<string, DstT>> dst) + where SrcT : MetadataRecord + where DstT : MetadataRecord + { + var res = new Dictionary<string, DstT>(); + + foreach (var kv in dst) + { + res.Add(kv.Key, Visit(src, kv.Value, true)); + } + + return res; + } + + public void Run(IEnumerable<MetadataRecord> records) + { + foreach (var rec in records) + { + Visit((MetadataRecord)null, rec); + } + + while (_queue.Count != 0) + { + _queue.Dequeue().Visit(this); + } + } + + // Adds Edges + public List<DstT> Visit<SrcT, DstT>(SrcT src, IEnumerable<DstT> dst) + where SrcT : MetadataRecord + where DstT : MetadataRecord + { +#if false + return GetPooledArray(dst.Select(d => Visit(src, d, true)).ToList()); +#else + return dst.Select(d => Visit(src, d, true)).ToList(); +#endif + } + + // Adds Edge + public DstT Visit<SrcT, DstT>(SrcT src, DstT dst) + where SrcT : MetadataRecord + where DstT : MetadataRecord + { + return Visit(src, dst, src == null); + } + + // Adds Edge + internal DstT Visit<SrcT, DstT>(SrcT src, DstT dst, bool isChild) + where SrcT : MetadataRecord + where DstT : MetadataRecord + { + var res = Visit(dst); + +#if false + if (res != null) + { + _graph.AddEdge(new Edge(src ?? MetaSourceVertex, res)); + } +#endif + + return res; + } + + protected Queue<MetadataRecord> _queue = new Queue<MetadataRecord>(); + protected Graph _graph = new Graph(); + + public Graph Graph { get { return _graph; } } + public readonly MetadataRecord MetaSourceVertex = new SourceVertex(); + } + + internal class RecordVisitor : RecordVisitorBase + { + } + + + internal partial class MetadataHeader : MetadataRecord + { + public const uint Signature = 0xDEADDFFD; + public List<ScopeDefinition> ScopeDefinitions = new List<ScopeDefinition>(); + + internal override void Save(NativeWriter writer) + { + writer.WriteUInt32(Signature); + writer.Write(ScopeDefinitions); + } + + public override HandleType HandleType + { + get { throw new NotImplementedException(); } + } + + internal override void Visit(IRecordVisitor visitor) + { + ScopeDefinitions = visitor.Visit(this, ScopeDefinitions.AsEnumerable()); + } + } + + public partial class MetadataWriter + { + internal MetadataHeader _metadataHeader = new MetadataHeader(); + + public List<TypeReference> UnreachableTypeReferences { get; private set; } + + public List<ScopeDefinition> ScopeDefinitions + { + get { return _metadataHeader.ScopeDefinitions; } + } + + private RecordVisitor _visitor = null; + + public MetadataWriter() + { + UnreachableTypeReferences = new List<TypeReference>(); + } + + public int GetRecordHandle(MetadataRecord rec) + { + var realRec = _visitor.MapToPooledRecord(rec); + + Debug.Assert(realRec.Handle.Offset != 0); + + return realRec.Handle._value; + } + + public void Write(Stream stream) + { + _visitor = new RecordVisitor(); + + _visitor.Run(ScopeDefinitions.AsEnumerable()); + _visitor.Run(UnreachableTypeReferences.AsEnumerable()); + + IEnumerable<MetadataRecord> records = _visitor.Graph.Vertices.Where(v => v != _visitor.MetaSourceVertex); + + var writer = new NativeWriter(); + + var section = writer.NewSection(); + + _metadataHeader.ScopeDefinitions = ScopeDefinitions; + section.Place(_metadataHeader); + + foreach (var rec in records) + { + section.Place(rec); + } + + writer.Save(stream); + + if (LogWriter != null) + { + // Create a CSV file, one line per meta-data record. + LogWriter.WriteLine("Handle, Kind, Name, Children"); + // needed to enumerate children of a meta-data record + var childVisitor = new WriteChildrenVisitor(LogWriter); + + foreach (var rec in records) + { + // First the metadata handle + LogWriter.Write(rec.Handle._value.ToString("x8")); + LogWriter.Write(", "); + + // Next the handle type + LogWriter.Write(rec.HandleType.ToString()); + LogWriter.Write(", "); + + // 3rd, the name, Quote the string if not already quoted + string asString = rec.ToString(false); + bool alreadyQuoted = asString.StartsWith("\"") && asString.EndsWith("\""); + if (!alreadyQuoted) + { + LogWriter.Write("\""); + asString = asString.Replace("\\", "\\\\").Replace("\"", "\\\""); // Quote " and \ + } + // TODO we assume that a quoted string is escaped properly + LogWriter.Write(asString); + + if (!alreadyQuoted) + LogWriter.Write("\""); + LogWriter.Write(", "); + + // Finally write out the handle IDs for my children + LogWriter.Write("\""); + childVisitor.Reset(); + rec.Visit(childVisitor); + LogWriter.Write("\""); + LogWriter.WriteLine(); + } + LogWriter.Flush(); + } + } + + // WriteChildrenVisitor is a helper class needed to write out the list of the + // handles (as space separated hex numbers) of all children of a given node + // to the 'logWriter' text stream. It simply implementes the IRecordVisitor + // interface to hook the callbacks needed for the MetadataRecord.Visit API. + // It is only used in the Write() method above. + private class WriteChildrenVisitor : IRecordVisitor + { + public WriteChildrenVisitor(TextWriter logWriter) + { + _logWriter = logWriter; + } + + // Resets the state back to what is was just after the constructor is called. + public void Reset() { _notFirst = false; } + + // All visits come to here for every child. Here we simply print the handle as hex. + public void Log(MetadataRecord rec) + { + if (rec == null) + return; + if (_notFirst) + _logWriter.Write(" "); + else + _notFirst = true; + _logWriter.Write(rec.Handle._value.ToString("x")); + } + + public DstT Visit<SrcT, DstT>(SrcT src, DstT dst) where SrcT : MetadataRecord where DstT : MetadataRecord + { + Log(dst); + return dst; + } + public Dictionary<string, DstT> Visit<SrcT, DstT>(SrcT src, IEnumerable<KeyValuePair<string, DstT>> dst) where SrcT : MetadataRecord where DstT : MetadataRecord + { + foreach (var keyValue in dst) + Log(keyValue.Value); + return dst as Dictionary<string, DstT>; + } + public List<DstT> Visit<SrcT, DstT>(SrcT src, IEnumerable<DstT> dst) where SrcT : MetadataRecord where DstT : MetadataRecord + { + foreach (var elem in dst) + Log(elem); + return dst.ToList(); + } + + private bool _notFirst; // The first child should not have a space before it. This tracks this + private TextWriter _logWriter; // Where we write output to + } + + public TextWriter LogWriter = null; + } + + internal class ReentrancyGuardStack + { + private MetadataRecord[] _array; + private int _size; + + public ReentrancyGuardStack() + { + // Start with a non-zero initial size. With a bit of luck this will prevent memory allocations + // when Push() is used. + _array = new MetadataRecord[8]; + _size = 0; + } + + public bool Contains(MetadataRecord item) + { + int count = _size; + while (count-- > 0) + { + // Important: we use ReferenceEquals because this method will be called from Equals() + // on 'record'. This is also why we can't use System.Collections.Generic.Stack. + if (Object.ReferenceEquals(item, _array[count])) + return true; + } + return false; + } + + public MetadataRecord Pop() + { + if (_size == 0) + throw new InvalidOperationException(); + MetadataRecord record = _array[--_size]; + _array[_size] = null; + return record; + } + + public void Push(MetadataRecord item) + { + if (_size == _array.Length) + Array.Resize(ref _array, 2 * _array.Length); + _array[_size++] = item; + } + } + + public abstract class MetadataRecord : Vertex + { + protected int _hash = 0; + + // debug-only guard against reentrancy in GetHashCode() + private bool _gettingHashCode = false; + + [Conditional("DEBUG")] + protected void EnterGetHashCode() + { + Debug.Assert(!_gettingHashCode); + _gettingHashCode = true; + } + + [Conditional("DEBUG")] + protected void LeaveGetHashCode() + { + Debug.Assert(_gettingHashCode); + _gettingHashCode = false; + } + + public abstract HandleType HandleType { get; } + + internal int HandleOffset + { + get + { + return _offset & 0x00FFFFFF; + } + } + + internal Handle Handle + { + get + { + return new Handle(HandleType, HandleOffset); + } + } + + internal abstract void Visit(IRecordVisitor visitor); + + public override string ToString() + { + return "[@TODO:" + this.GetType().ToString() + "]"; + } + + public virtual string ToString(bool includeHandleValue) + { + return ToString(); + } + + protected static string ToString<T>(IEnumerable<T> arr, string sep = ", ", bool includeHandleValue = false) where T : MetadataRecord + { + return String.Join(sep, arr.Select(v => v.ToString(includeHandleValue))); + } + } + + public interface ICustomAttributeMetadataRecord + { + IList<CustomAttribute> GetCustomAttributes(); + } + + public abstract partial class Blob : MetadataRecord + { + } + + /// <summary> + /// Supplements generated class with convenient coversion operators + /// </summary> + public partial class ConstantStringValue + { + public static explicit operator string (ConstantStringValue value) + { + if (value == null) + return null; + else + return value.Value; + } + + public static explicit operator ConstantStringValue(string value) + { + return new ConstantStringValue() { Value = value }; + } + } + + public partial class ScopeDefinition + { + public override string ToString() + { + return ToString(true); + } + public override string ToString(bool includeHandleValue) + { + return Name.ToString() + (includeHandleValue ? String.Format(" ({0:x})", Handle._value) : ""); + } + } + + public partial class ScopeReference + { + public override string ToString() + { + return ToString(true); + } + public override string ToString(bool includeHandleValue) + { + return Name.ToString() + (includeHandleValue ? String.Format(" ({0:x})", Handle._value) : ""); + } + } + + public partial class NamespaceDefinition + { + public override string ToString() + { + return ToString(true); + } + + public override string ToString(bool includeHandleValue) + { + string str; + + if (Name != null && !String.IsNullOrEmpty(Name.Value)) + { + str = Name.Value; + } + else + { + str = string.Empty; + } + + if (includeHandleValue) + str += String.Format("({0})", Handle.ToString()); + + if (this.ParentScopeOrNamespace != null) + { + var pns = this.ParentScopeOrNamespace as NamespaceDefinition; + if (pns != null) + { + if (!String.IsNullOrEmpty(pns.ToString(false))) + str = pns.ToString(false) + '.' + str; + } + } + return str; + } + } + + public partial class NamespaceReference + { + public override string ToString() + { + return ToString(true); + } + public override string ToString(bool includeHandleValue) + { + string str; + + if (Name != null && !String.IsNullOrEmpty(Name.Value)) + { + str = Name.Value; + } + else + { + str = string.Empty; + } + + if (includeHandleValue) + str += String.Format("({0})", Handle.ToString()); + + if (this.ParentScopeOrNamespace != null) + { + var pns = this.ParentScopeOrNamespace as NamespaceReference; + if (pns != null) + { + if (!String.IsNullOrEmpty(pns.ToString(false))) + str = pns.ToString(false) + '.' + str; + } + else + { + //str = ParentScopeOrNamespace.ToString() + " : " + str; + } + } + return str; + } + } + + public partial class TypeDefinition + { + public override string ToString() + { + return ToString(false); + } + public override string ToString(bool includeHandleValue) + { + string str = null; + if (this.EnclosingType != null) + { + str = this.EnclosingType.ToString(false) + "+" + Name.Value; + if (includeHandleValue) + str += String.Format(" ({0:x})", Handle._value); + return str; + } + else if (this.NamespaceDefinition != null && this.NamespaceDefinition.Name != null) + { + str = this.NamespaceDefinition.ToString(false) + "." + Name.Value; + if (includeHandleValue) + str += String.Format(" ({0:x})", Handle._value); + return str; + } + str = Name.Value + String.Format(" ({0:x})", Handle._value); + if (includeHandleValue) + str += String.Format(" ({0:x})", Handle._value); + return str; + } + } + + public partial class TypeReference + { + public override string ToString() + { + return ToString(false); + } + public override string ToString(bool includeHandleValue) + { + String s = ""; + if (ParentNamespaceOrType is NamespaceReference) + s += ParentNamespaceOrType.ToString(false) + "."; + if (ParentNamespaceOrType is TypeReference) + s += ParentNamespaceOrType.ToString(false) + "+"; + s += TypeName.Value; + if (includeHandleValue) + s += String.Format(" ({0:x})", Handle._value); + return s; + } + } + + public partial class TypeForwarder + { + public override string ToString() + { + return this.Name.Value + " -> " + this.Scope.Name.Value; + } + } + + public partial class GenericParameter + { + public override string ToString() + { + return Kind.FlagsToString() + " " + Name.Value + "(" + Number.ToString() + ")"; + } + } + + public partial class Field + { + public override string ToString() + { + return Name.Value; + } + } + + public partial class Method + { + public override string ToString() + { + return Signature.ToString(Name.Value); + } + } + + public partial class Property + { + public override string ToString() + { + return Name.Value; + } + } + + public partial class Event + { + public override string ToString() + { + return Name.Value; + } + } + + public partial class SZArraySignature + { + public override string ToString() + { + return ElementType.ToString() + "[]"; + } + } + + public partial class ArraySignature + { + public override string ToString() + { + return ElementType.ToString() + "[" + new String(',', Rank - 1) + "]"; + } + } + + public partial class TypeSpecification + { + public override string ToString() + { + return Signature.ToString(); + } + } + + public partial class TypeInstantiationSignature + { + public override string ToString() + { + return this.GenericType.ToString() + "<" + String.Join(", ", this.GenericTypeArguments.Select(ga => ga.ToString()).ToArray()) + ">"; + } + } + + public partial class MethodImpl + { + public override string ToString() + { + return this.MethodDeclaration.ToString(); + } + } + + public partial class ParameterTypeSignature + { + public override string ToString() + { + return Type.ToString(); + } + } + + public partial class ByReferenceSignature + { + public override string ToString() + { + return "ref " + Type.ToString(); + } + } + + public partial class ReturnTypeSignature + { + public override string ToString() + { + return Type.ToString(); + } + } + + public partial class CustomAttribute + { + public override string ToString() + { + string str = Type.ToString(false) + "..ctor"; + str += "(" + String.Join(", ", FixedArguments.Select(fa => fa.ToString()).Concat(NamedArguments.Select(na => na.ToString())).ToArray()) + ")"; + str += "(type: " + Type.Handle.ToString() + ", ctor: " + Constructor.Handle.ToString(); + return str; + } + } + + public partial class FixedArgument + { + private static bool IsConstantArray(MetadataRecord rec) + { + switch (rec.HandleType) + { + case HandleType.ConstantBooleanArray: + case HandleType.ConstantCharArray: + case HandleType.ConstantStringArray: + case HandleType.ConstantByteArray: + case HandleType.ConstantSByteArray: + case HandleType.ConstantInt16Array: + case HandleType.ConstantUInt16Array: + case HandleType.ConstantInt32Array: + case HandleType.ConstantUInt32Array: + case HandleType.ConstantInt64Array: + case HandleType.ConstantUInt64Array: + case HandleType.ConstantSingleArray: + case HandleType.ConstantDoubleArray: + return true; + default: + return false; + } + } + public override string ToString() + { + return Flags.FlagsToString() + + (Type != null ? " (" + Type.ToString() + ")" : "") + + (Value != null ? " " + Value.ToString() : ""); + } + } + + public partial class NamedArgument + { + public override string ToString() + { + return Name + " = " + Value.ToString(); + } + } + + public partial class MemberReference + { + public override string ToString() + { + return Parent.ToString() + "." + Name.Value; + } + } + + public partial class MethodSemantics + { + public override string ToString() + { + string str = Enum.GetName(typeof(MethodSemanticsAttributes), Attributes); + return str + " : " + Method.ToString(); + } + } + + public partial class MethodSignature + { + public override string ToString() + { + return ToString(" "); + } + public string ToString(string name) + { + return String.Join(" ", new string[] { + CallingConvention.FlagsToString(), + ReturnType.ToString(false), + name + + (GenericParameterCount == 0 ? "" : "`" + GenericParameterCount.ToString()) + + "(" + String.Join(", ", Parameters.Select(p => p.ToString(false)).Concat(VarArgParameters.Select(p => p.ToString(false)))) + ")"}.Where(e => !String.IsNullOrWhiteSpace(e))); + } + } + + public partial class PropertySignature + { + public override string ToString() + { + return String.Join(" ", Enum.GetName(typeof(CallingConventions), CallingConvention), + ToString(CustomModifiers, " "), Type.ToString()) + "(" + ToString(Parameters) + ")"; + } + } + + public partial class FieldSignature + { + public override string ToString() + { + return ToString(CustomModifiers, " ") + Type.ToString(); + } + } + + public partial class CustomModifier + { + public override string ToString() + { + return "[" + (IsOptional ? "opt : " : "req : ") + Type.ToString() + "]"; + } + } + + public partial class TypeVariableSignature + { + public override string ToString() + { + return "!" + Number; + } + } + + public partial class MethodTypeVariableSignature + { + public override string ToString() + { + return "!!" + Number; + } + } + + public partial class Parameter + { + public override string ToString() + { + string flags = Flags.FlagsToString(); + return String.Format("{0}{1} (Seq:{2}) {3}", + flags, + Name.ToString(), + Sequence, + (DefaultValue == null ? "" : " = " + DefaultValue.ToString())); + } + } + + public partial class PointerSignature + { + public override string ToString() + { + return Type.ToString() + "*"; + } + } + + public static class EnumHelpers + { + public static string FlagsToString<T>(this T value) where T : IConvertible + { + if (!(value is Enum)) + throw new ArgumentException(); + + var eType = value.GetType(); + var flags = ((T[])Enum.GetValues(eType)).Where( + eVal => (((IConvertible)eVal).ToInt32(null) != 0) && ((((IConvertible)value).ToInt32(null) & ((IConvertible)eVal).ToInt32(null)) == ((IConvertible)eVal).ToInt32(null))); + if (flags.Count() == 0) + return ""; + else + return "[" + String.Join(" | ", flags.Select(eVal => Enum.GetName(eType, eVal))) + "] "; + } + } + + public static class ListExtensions + { + public static T FirstOrDefault<T>(this List<T> list) + { + if (list.Count != 0) + return list[0]; + return default(T); + } + public static T First<T>(this List<T> list) where T : class + { + if (list.Count != 0) + return list[0]; + return null; + } + } + + public static partial class DictionaryExtensions + { + internal static T FirstOrDefault<T>(this Dictionary<string, T> dict) + { + if (dict.Count != 0) + foreach (var value in dict.Values) + return value; + return default(T); + } + internal static T First<T>(this Dictionary<string, T> dict) where T : class + { + if (dict.Count != 0) + foreach (var value in dict.Values) + return value; + return null; + } + + internal static IEnumerable<T> AsSingleEnumerable<T>(this T value) + { + yield return value; + } + } + + public static partial class SignatureHelpers + { + public static SZArraySignature AsSZArray(this MetadataRecord record) + { + return new SZArraySignature() { ElementType = record }; + } + } + + // SequenceEquals on IEnumerable is painfully slow and allocates memory. + public static class SequenceExtensions + { + public static bool SequenceEqual<T>(this List<T> first, List<T> second) + { + return first.SequenceEqual(second, null); + } + + public static bool SequenceEqual<T>(this List<T> first, List<T> second, IEqualityComparer<T> comparer) + { + if (first.Count != second.Count) + { + return false; + } + + if (comparer == null) + { + comparer = EqualityComparer<T>.Default; + } + + for (int i = 0; i < first.Count; i++) + { + if (!comparer.Equals(first[i], second[i])) + { + return false; + } + } + + return true; + } + + public static bool SequenceEqual<T>(this T[] first, T[] second) + { + return first.SequenceEqual(second, null); + } + + public static bool SequenceEqual<T>(this T[] first, T[] second, IEqualityComparer<T> comparer) + { + if (first.Length != second.Length) + { + return false; + } + + if (comparer == null) + { + comparer = EqualityComparer<T>.Default; + } + + for (int i = 0; i < first.Length; i++) + { + if (!comparer.Equals(first[i], second[i])) + { + return false; + } + } + + return true; + } + } +} + diff --git a/src/System.Private.Reflection.Metadata/src/System.Private.Reflection.Metadata.csproj b/src/System.Private.Reflection.Metadata/src/System.Private.Reflection.Metadata.csproj new file mode 100644 index 000000000..00b7ac84f --- /dev/null +++ b/src/System.Private.Reflection.Metadata/src/System.Private.Reflection.Metadata.csproj @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>System.Private.Reflection.Metadata</AssemblyName> + <OutputType>Library</OutputType> + <ProjectGuid>{45A617DF-FEC7-59C8-FD0D-BD27938DC940}</ProjectGuid> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <CLSCompliant>false</CLSCompliant> + </PropertyGroup> + <!-- Default configurations to help VS understand the options --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> + <PlatformTarget>x86</PlatformTarget> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> + <PlatformTarget>x86</PlatformTarget> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|amd64' "> + <PlatformTarget>x64</PlatformTarget> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|amd64' "> + <PlatformTarget>x64</PlatformTarget> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|arm' "> + <PlatformTarget>arm</PlatformTarget> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|arm' "> + <PlatformTarget>arm</PlatformTarget> + </PropertyGroup> + + <ItemGroup> + <ProjectReference Include="..\..\System.Private.CoreLib\src\System.Private.CoreLib.csproj" /> + <ProjectReference Include="..\..\AotPackageReference\AotPackageReference.depproj"> + <ReferenceOutputAssembly>false</ReferenceOutputAssembly> + </ProjectReference> + + <ReferencePath Include="$(AotPackageReferencePath)\System.Reflection.Primitives.dll" /> + <ReferencePath Include="$(AotPackageReferencePath)\System.Runtime.dll" /> + <ReferencePath Include="$(AotPackageReferencePath)\System.Runtime.Extensions.dll" /> + </ItemGroup> + + <PropertyGroup> + <NativeFormatCommonPath>..\..\Common\src\Internal\NativeFormat</NativeFormatCommonPath> + <MetadataCommonPath>..\..\Common\src\Internal\Metadata\NativeFormat</MetadataCommonPath> + </PropertyGroup> + <ItemGroup> + <Compile Include="$(NativeFormatCommonPath)\NativeFormat.cs" /> + <Compile Include="$(NativeFormatCommonPath)\NativeFormatReader.cs" /> + <Compile Include="$(NativeFormatCommonPath)\NativeFormatReader.String.cs" /> + </ItemGroup> + <ItemGroup> + <Compile Include="$(MetadataCommonPath)\NativeFormatReaderCommonGen.cs" /> + <Compile Include="$(MetadataCommonPath)\MdBinaryReader.cs" /> + <Compile Include="$(MetadataCommonPath)\MdBinaryReaderGen.cs" /> + <Compile Include="$(MetadataCommonPath)\NativeMetadataReader.cs" /> + <Compile Include="$(MetadataCommonPath)\NativeFormatReaderGen.cs" /> + </ItemGroup> + + <PropertyGroup> + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> + <TargetPlatformIdentifier>Portable</TargetPlatformIdentifier> + <TargetFrameworkIdentifier>.NETPortable</TargetFrameworkIdentifier> + <TargetFrameworkProfile>Profile7</TargetFrameworkProfile> + <TargetFrameworkMonikerDisplayName>.NET Portable Subset</TargetFrameworkMonikerDisplayName> + <ImplicitlyExpandTargetFramework>false</ImplicitlyExpandTargetFramework> + </PropertyGroup> + + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> |