You've already forked linux-packaging-mono
Imported Upstream version 5.2.0.175
Former-commit-id: bb0468d0f257ff100aa895eb5fe583fb5dfbf900
This commit is contained in:
parent
4bdbaf4a88
commit
966bba02bb
@@ -9,27 +9,30 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Reflection.Metadata.
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Reflection.Metadata", "src\System.Reflection.Metadata.csproj", "{F3E433C8-352F-4944-BF7F-765CE435370D}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{5C5F1FFD-CC57-4DFF-9CAF-0A2852323AD6}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
..\.nuget\packages.Windows_NT.config = ..\.nuget\packages.Windows_NT.config
|
||||
EndProjectSection
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{1A2F9F4A-A032-433E-B914-ADD5992BB178}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E107E9C1-E893-4E87-987E-04EF0DCEAEFD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
DebugNETCoreAppnetstandard1.1netstandard1.5|AnyCPU = DebugNETCoreAppnetstandard1.1netstandard1.5|AnyCPU
|
||||
ReleaseNETCoreAppnetstandard1.1netstandard1.5|AnyCPU = ReleaseNETCoreAppnetstandard1.1netstandard1.5|AnyCPU
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{7061832A-E8CF-4AB6-A8DC-44D2F5A43A13}.DebugNETCoreAppnetstandard1.1netstandard1.5|AnyCPU.ActiveCfg = netstandard1.5-Debug|Any CPU
|
||||
{7061832A-E8CF-4AB6-A8DC-44D2F5A43A13}.DebugNETCoreAppnetstandard1.1netstandard1.5|AnyCPU.Build.0 = netstandard1.5-Debug|Any CPU
|
||||
{7061832A-E8CF-4AB6-A8DC-44D2F5A43A13}.ReleaseNETCoreAppnetstandard1.1netstandard1.5|AnyCPU.ActiveCfg = netstandard1.5-Release|Any CPU
|
||||
{7061832A-E8CF-4AB6-A8DC-44D2F5A43A13}.ReleaseNETCoreAppnetstandard1.1netstandard1.5|AnyCPU.Build.0 = netstandard1.5-Release|Any CPU
|
||||
{F3E433C8-352F-4944-BF7F-765CE435370D}.DebugNETCoreAppnetstandard1.1netstandard1.5|AnyCPU.ActiveCfg = netstandard1.1-Debug|Any CPU
|
||||
{F3E433C8-352F-4944-BF7F-765CE435370D}.DebugNETCoreAppnetstandard1.1netstandard1.5|AnyCPU.Build.0 = netstandard1.1-Debug|Any CPU
|
||||
{F3E433C8-352F-4944-BF7F-765CE435370D}.ReleaseNETCoreAppnetstandard1.1netstandard1.5|AnyCPU.ActiveCfg = netstandard1.1-Release|Any CPU
|
||||
{F3E433C8-352F-4944-BF7F-765CE435370D}.ReleaseNETCoreAppnetstandard1.1netstandard1.5|AnyCPU.Build.0 = netstandard1.1-Release|Any CPU
|
||||
{7061832A-E8CF-4AB6-A8DC-44D2F5A43A13}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
|
||||
{7061832A-E8CF-4AB6-A8DC-44D2F5A43A13}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
|
||||
{7061832A-E8CF-4AB6-A8DC-44D2F5A43A13}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU
|
||||
{7061832A-E8CF-4AB6-A8DC-44D2F5A43A13}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU
|
||||
{F3E433C8-352F-4944-BF7F-765CE435370D}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
|
||||
{F3E433C8-352F-4944-BF7F-765CE435370D}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
|
||||
{F3E433C8-352F-4944-BF7F-765CE435370D}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU
|
||||
{F3E433C8-352F-4944-BF7F-765CE435370D}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{7061832A-E8CF-4AB6-A8DC-44D2F5A43A13} = {1A2F9F4A-A032-433E-B914-ADD5992BB178}
|
||||
{F3E433C8-352F-4944-BF7F-765CE435370D} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@@ -5,5 +5,6 @@
|
||||
<PackageVersion>1.5.0</PackageVersion>
|
||||
<AssemblyVersion>1.4.2.0</AssemblyVersion>
|
||||
<IsNETCoreApp>true</IsNETCoreApp>
|
||||
<IsUAP>true</IsUAP>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
<ItemGroup>
|
||||
<Project Include="System.Reflection.Metadata.pkgproj" />
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.traversal.targets))\dir.traversal.targets" />
|
||||
</Project>
|
||||
@@ -9,10 +9,10 @@
|
||||
<ProjectReference Include="..\src\System.Reflection.Metadata.csproj">
|
||||
<SupportedFramework>net45;netcore45;netcoreapp1.0;wpa81;$(AllXamarinFrameworks)</SupportedFramework>
|
||||
</ProjectReference>
|
||||
<Dependency Include="System.Collections.Immutable">
|
||||
<FilePackageDependency Include="System.Collections.Immutable">
|
||||
<TargetFramework>portable-net45+win8</TargetFramework>
|
||||
<Version>1.1.37</Version>
|
||||
</Dependency>
|
||||
</FilePackageDependency>
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
@@ -1,4 +1,4 @@
|
||||
#PE/COFF Specification Addendum
|
||||
# PE/COFF Specification Addendum
|
||||
|
||||
## Deterministic PE/COFF File
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#Portable PDB v1.0: Format Specification
|
||||
# Portable PDB v1.0: Format Specification
|
||||
|
||||
## Portable PDB
|
||||
The Portable PDB (Program Database) format describes an encoding of debugging information produced by compilers of Common Language Infrastructure (CLI) languages and consumed by debuggers and other tools. The format is based on the ECMA-335 Partition II metadata standard. It extends its schema while using the same physical table and stream layouts and encodings. The schema of the debugging metadata is complementary to the ECMA-335 metadata schema, therefore, the debugging metadata can (but doesn’t need to) be stored in the same metadata section of the PE/COFF file as the type system metadata.
|
||||
@@ -133,7 +133,7 @@ _Sequence points blob_ has the following structure:
|
||||
Blob ::= header SequencePointRecord (SequencePointRecord | document-record)*
|
||||
SequencePointRecord ::= sequence-point-record | hidden-sequence-point-record
|
||||
|
||||
#####header
|
||||
##### header
|
||||
| component | value stored | integer representation |
|
||||
|:-----------------|:------------------------------|:-----------------------|
|
||||
| _LocalSignature_ | StandAloneSig table row id | unsigned compressed |
|
||||
@@ -143,7 +143,7 @@ _LocalSignature_ stores the row id of the local signature of the method. This in
|
||||
|
||||
_InitialDocument_ is only present if the _Document_ field of the _MethodDebugInformation_ table is nil (i.e. the method body spans multiple documents).
|
||||
|
||||
#####sequence-point-record
|
||||
##### sequence-point-record
|
||||
| component | value stored | integer representation |
|
||||
|:---------------|:-----------------------------------------------------|:--------------------------------------------|
|
||||
| _δILOffset_ | _ILOffset_ if this is the first sequence point | unsigned compressed |
|
||||
@@ -156,7 +156,7 @@ _InitialDocument_ is only present if the _Document_ field of the _MethodDebugInf
|
||||
| _δStartColumn_ | _StartColumn_ if this is the first non-hidden sequence point | unsigned compressed |
|
||||
| | _StartColumn_ - _PreviousNonHidden_._StartColumn_ otherwise | signed compressed |
|
||||
|
||||
#####hidden-sequence-point-record
|
||||
##### hidden-sequence-point-record
|
||||
| component | value stored | integer representation |
|
||||
|:-------------|:-------------------------------------------------------|:--------------------------------|
|
||||
| _δILOffset_ | _ILOffset_ if this is the first sequence point | unsigned compressed |
|
||||
@@ -164,7 +164,7 @@ _InitialDocument_ is only present if the _Document_ field of the _MethodDebugInf
|
||||
| _ΔLine_ | 0 | unsigned compressed |
|
||||
| _ΔColumn_ | 0 | unsigned compressed |
|
||||
|
||||
#####document-record
|
||||
##### document-record
|
||||
| component | value stored | integer representation |
|
||||
|:-------------|:-----------------------------------|:-------------------------------|
|
||||
| _δILOffset_ | 0 | unsigned compressed |
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
<PropertyGroup>
|
||||
<BuildConfigurations>
|
||||
netstandard1.1;
|
||||
netstandard;
|
||||
netcoreapp;
|
||||
uap;
|
||||
uap-Windows_NT;
|
||||
</BuildConfigurations>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -1,64 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
@@ -186,9 +127,6 @@
|
||||
<data name="MetadataTableNotSorted" xml:space="preserve">
|
||||
<value>Metadata table {0} not sorted.</value>
|
||||
</data>
|
||||
<data name="AssemblyTableInvalidNumberOfRows" xml:space="preserve">
|
||||
<value>Invalid number of rows of Assembly table: {0}.</value>
|
||||
</data>
|
||||
<data name="ModuleTableInvalidNumberOfRows" xml:space="preserve">
|
||||
<value>Invalid number of rows of Module table: {0}.</value>
|
||||
</data>
|
||||
@@ -246,9 +184,6 @@
|
||||
<data name="WinMDMissingMscorlibRef" xml:space="preserve">
|
||||
<value>Missing mscorlib reference in AssemblyRef table.</value>
|
||||
</data>
|
||||
<data name="UnableToReadMetadataFile" xml:space="preserve">
|
||||
<value>Unable to read metadata file.</value>
|
||||
</data>
|
||||
<data name="UnexpectedStreamEnd" xml:space="preserve">
|
||||
<value>Unexpected stream end.</value>
|
||||
</data>
|
||||
@@ -258,9 +193,6 @@
|
||||
<data name="CantGetOffsetForVirtualHeapHandle" xml:space="preserve">
|
||||
<value>Can't get a heap offset for a virtual heap handle</value>
|
||||
</data>
|
||||
<data name="InvalidSectionName" xml:space="preserve">
|
||||
<value>Invalid section name</value>
|
||||
</data>
|
||||
<data name="InvalidNumberOfSections" xml:space="preserve">
|
||||
<value>Invalid number of sections in declared in PE header.</value>
|
||||
</data>
|
||||
@@ -291,15 +223,9 @@
|
||||
<data name="StreamTooLarge" xml:space="preserve">
|
||||
<value>Stream length minus starting position is too large to hold a PEImage.</value>
|
||||
</data>
|
||||
<data name="NegativeByteCountOrOffset" xml:space="preserve">
|
||||
<value>Negative byte count or offset.</value>
|
||||
</data>
|
||||
<data name="ImageTooSmallOrContainsInvalidOffsetOrCount" xml:space="preserve">
|
||||
<value>Image is either too small or contains an invalid byte offset or count.</value>
|
||||
</data>
|
||||
<data name="LitteEndianArchitectureRequired" xml:space="preserve">
|
||||
<value>Little-endian architecture required.</value>
|
||||
</data>
|
||||
<data name="MetadataStringDecoderEncodingMustBeUtf8" xml:space="preserve">
|
||||
<value>The MetadataStringDecoder instance used to instantiate the Metadata reader must have a UTF8 encoding.</value>
|
||||
</data>
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{F3E433C8-352F-4944-BF7F-765CE435370D}</ProjectGuid>
|
||||
<AssemblyName>System.Reflection.Metadata</AssemblyName>
|
||||
<DocumentationFile>$(OutputPath)System.Reflection.Metadata.xml</DocumentationFile>
|
||||
<DocumentationFile>$(OutputPath)$(MSBuildProjectName).xml</DocumentationFile>
|
||||
<RootNamespace>System.Reflection.Metadata</RootNamespace>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
@@ -15,10 +14,12 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard1.1-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard1.1-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Release|AnyCPU'" />
|
||||
<ItemGroup>
|
||||
<Compile Include="System\Reflection\Internal\Utilities\ExceptionUtilities.cs" />
|
||||
<Compile Include="System\Reflection\Internal\Utilities\PathUtilities.cs" />
|
||||
@@ -73,6 +74,7 @@
|
||||
<Compile Include="System\Reflection\PortableExecutable\ManagedTextSection.cs" />
|
||||
<Compile Include="System\Reflection\PortableExecutable\PEBuilder.cs" />
|
||||
<Compile Include="System\Reflection\PortableExecutable\DebugDirectory\DebugDirectoryBuilder.cs" />
|
||||
<Compile Include="System\Reflection\PortableExecutable\DebugDirectory\DebugDirectoryBuilder.EmbeddedPortablePdb.cs" />
|
||||
<Compile Include="System\Reflection\PortableExecutable\PEDirectoriesBuilder.cs" />
|
||||
<Compile Include="System\Reflection\PortableExecutable\PEHeaderBuilder.cs" />
|
||||
<Compile Include="System\Reflection\PortableExecutable\ResourceSectionBuilder.cs" />
|
||||
@@ -232,6 +234,7 @@
|
||||
<Compile Include="System\Reflection\PortableExecutable\PEHeaders.cs" />
|
||||
<Compile Include="System\Reflection\PortableExecutable\PEMemoryBlock.cs" />
|
||||
<Compile Include="System\Reflection\PortableExecutable\PEReader.cs" />
|
||||
<Compile Include="System\Reflection\PortableExecutable\PEReader.EmbeddedPortablePdb.cs" />
|
||||
<Compile Include="System\Reflection\PortableExecutable\PEStreamOptions.cs" />
|
||||
<Compile Include="System\Reflection\PortableExecutable\SectionHeader.cs" />
|
||||
<Compile Include="System\Reflection\Throw.cs" />
|
||||
|
||||
@@ -47,19 +47,12 @@ namespace System.Reflection
|
||||
|
||||
public static void WriteDouble(this byte[] buffer, int start, double value)
|
||||
{
|
||||
fixed (byte* ptr = &buffer[start])
|
||||
{
|
||||
*(long*)ptr = *(long*)&value;
|
||||
}
|
||||
WriteUInt64(buffer, start, *(ulong*)&value);
|
||||
}
|
||||
|
||||
public static void WriteSingle(this byte[] buffer, int start, float value)
|
||||
{
|
||||
|
||||
fixed (byte* ptr = &buffer[start])
|
||||
{
|
||||
*(int*)ptr = *(int*)&value;
|
||||
}
|
||||
WriteUInt32(buffer, start, *(uint*)&value);
|
||||
}
|
||||
|
||||
public static void WriteByte(this byte[] buffer, int start, byte value)
|
||||
@@ -72,7 +65,11 @@ namespace System.Reflection
|
||||
{
|
||||
fixed (byte* ptr = &buffer[start])
|
||||
{
|
||||
*(ushort*)ptr = value;
|
||||
unchecked
|
||||
{
|
||||
ptr[0] = (byte)value;
|
||||
ptr[1] = (byte)(value >> 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,16 +103,20 @@ namespace System.Reflection
|
||||
{
|
||||
fixed (byte* ptr = &buffer[start])
|
||||
{
|
||||
*(uint*)ptr = value;
|
||||
unchecked
|
||||
{
|
||||
ptr[0] = (byte)value;
|
||||
ptr[1] = (byte)(value >> 8);
|
||||
ptr[2] = (byte)(value >> 16);
|
||||
ptr[3] = (byte)(value >> 24);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteUInt64(this byte[] buffer, int start, ulong value)
|
||||
{
|
||||
fixed (byte* ptr = &buffer[start])
|
||||
{
|
||||
*(ulong*)ptr = value;
|
||||
}
|
||||
WriteUInt32(buffer, start, unchecked((uint)value));
|
||||
WriteUInt32(buffer, start + 4, unchecked((uint)(value >> 32)));
|
||||
}
|
||||
|
||||
public const int SizeOfSerializedDecimal = sizeof(byte) + 3 * sizeof(uint);
|
||||
@@ -127,28 +128,45 @@ namespace System.Reflection
|
||||
uint low, mid, high;
|
||||
value.GetBits(out isNegative, out scale, out low, out mid, out high);
|
||||
|
||||
fixed (byte* ptr = &buffer[start])
|
||||
{
|
||||
*ptr = (byte)(scale | (isNegative ? 0x80 : 0x00));
|
||||
*(uint*)(ptr + 1) = low;
|
||||
*(uint*)(ptr + 5) = mid;
|
||||
*(uint*)(ptr + 9) = high;
|
||||
}
|
||||
WriteByte(buffer, start, (byte)(scale | (isNegative ? 0x80 : 0x00)));
|
||||
WriteUInt32(buffer, start + 1, low);
|
||||
WriteUInt32(buffer, start + 5, mid);
|
||||
WriteUInt32(buffer, start + 9, high);
|
||||
}
|
||||
|
||||
public const int SizeOfGuid = 16;
|
||||
|
||||
public static void WriteGuid(this byte[] buffer, int start, Guid value)
|
||||
{
|
||||
fixed (byte* ptr = &buffer[start])
|
||||
fixed (byte* dst = &buffer[start])
|
||||
{
|
||||
int* dst = (int*)ptr;
|
||||
int* src = (int*)&value;
|
||||
byte* src = (byte*)&value;
|
||||
|
||||
dst[0] = src[0];
|
||||
dst[1] = src[1];
|
||||
dst[2] = src[2];
|
||||
dst[3] = src[3];
|
||||
uint a = *(uint*)(src + 0);
|
||||
unchecked
|
||||
{
|
||||
dst[0] = (byte)a;
|
||||
dst[1] = (byte)(a >> 8);
|
||||
dst[2] = (byte)(a >> 16);
|
||||
dst[3] = (byte)(a >> 24);
|
||||
|
||||
ushort b = *(ushort*)(src + 4);
|
||||
dst[4] = (byte)b;
|
||||
dst[5] = (byte)(b >> 8);
|
||||
|
||||
ushort c = *(ushort*)(src + 6);
|
||||
dst[6] = (byte)c;
|
||||
dst[7] = (byte)(c >> 8);
|
||||
}
|
||||
|
||||
dst[8] = src[8];
|
||||
dst[9] = src[9];
|
||||
dst[10] = src[10];
|
||||
dst[11] = src[11];
|
||||
dst[12] = src[12];
|
||||
dst[13] = src[13];
|
||||
dst[14] = src[14];
|
||||
dst[15] = src[15];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace System.Reflection.Internal
|
||||
Marshal.Copy((IntPtr)bytes, buffer, prefix.Length, byteCount);
|
||||
|
||||
string result;
|
||||
fixed (byte* prefixedBytes = buffer)
|
||||
fixed (byte* prefixedBytes = &buffer[0])
|
||||
{
|
||||
result = utf8Decoder.GetString(prefixedBytes, prefixedByteCount);
|
||||
}
|
||||
|
||||
@@ -3,40 +3,71 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
namespace System.Reflection.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// Replacements for System.Linq to avoid an unnecessary dependency.
|
||||
/// Parameter and return types strengthened to actual internal usage as an optimization.
|
||||
/// </summary>
|
||||
internal static class EnumerableExtensions
|
||||
{
|
||||
private class ComparisonComparer<T> : Comparer<T>
|
||||
public static T FirstOrDefault<T>(this ImmutableArray<T> collection, Func<T, bool> predicate)
|
||||
{
|
||||
private readonly Comparison<T> _compare;
|
||||
|
||||
public ComparisonComparer(Comparison<T> compare)
|
||||
foreach (var item in collection)
|
||||
{
|
||||
_compare = compare;
|
||||
if (predicate(item))
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
public override int Compare(T x, T y)
|
||||
return default(T);
|
||||
}
|
||||
|
||||
// used only in debugger display so we needn't get fancy with optimizations.
|
||||
public static IEnumerable<TResult> Select<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> selector)
|
||||
{
|
||||
foreach (var item in source)
|
||||
{
|
||||
return _compare(x, y);
|
||||
yield return selector(item);
|
||||
}
|
||||
}
|
||||
|
||||
private static class Functions<T>
|
||||
public static T Last<T>(this ImmutableArray<T>.Builder source)
|
||||
{
|
||||
public static readonly Func<T, T> Identity = t => t;
|
||||
return source[source.Count - 1];
|
||||
}
|
||||
|
||||
public static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> source, IComparer<T> comparer)
|
||||
public static IEnumerable<T> OrderBy<T>(this List<T> source, Comparison<T> comparison)
|
||||
{
|
||||
return source.OrderBy(Functions<T>.Identity, comparer);
|
||||
}
|
||||
// Produce an iterator that represents a stable sort of source.
|
||||
// Implement by creating an int array that represents the initial ordering of elements in
|
||||
// the source list, then sort those integers with a sort function that sorts by the values
|
||||
// in source, but for cases where the values are equivalent, sort by initial index in
|
||||
// the source array
|
||||
int[] map = new int[source.Count];
|
||||
for (int i = 0; i < map.Length; i++)
|
||||
map[i] = i;
|
||||
|
||||
public static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> source, Comparison<T> compare)
|
||||
{
|
||||
return source.OrderBy(new ComparisonComparer<T>(compare));
|
||||
Array.Sort(map, (int left, int right) =>
|
||||
{
|
||||
if (left == right)
|
||||
return 0;
|
||||
|
||||
int result = comparison(source[left], source[right]);
|
||||
if (result == 0)
|
||||
{
|
||||
return left - right;
|
||||
}
|
||||
return result;
|
||||
});
|
||||
|
||||
foreach (int index in map)
|
||||
{
|
||||
yield return source[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,12 +35,6 @@ namespace System.Reflection.Internal
|
||||
throw new ArgumentNullException(nameof(buffer));
|
||||
}
|
||||
|
||||
// the reader performs little-endian specific operations
|
||||
if (!BitConverter.IsLittleEndian)
|
||||
{
|
||||
Throw.LitteEndianArchitectureRequired();
|
||||
}
|
||||
|
||||
return new MemoryBlock(buffer, length);
|
||||
}
|
||||
|
||||
@@ -129,10 +123,16 @@ namespace System.Reflection.Internal
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal uint PeekUInt32(int offset)
|
||||
{
|
||||
CheckBounds(offset, sizeof(uint));
|
||||
return *(uint*)(Pointer + offset);
|
||||
|
||||
unchecked
|
||||
{
|
||||
byte* ptr = Pointer + offset;
|
||||
return (uint)(ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -184,10 +184,16 @@ namespace System.Reflection.Internal
|
||||
return BlobReader.InvalidCompressedInteger;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal ushort PeekUInt16(int offset)
|
||||
{
|
||||
CheckBounds(offset, sizeof(ushort));
|
||||
return *(ushort*)(Pointer + offset);
|
||||
|
||||
unchecked
|
||||
{
|
||||
byte* ptr = Pointer + offset;
|
||||
return (ushort)(ptr[0] | (ptr[1] << 8));
|
||||
}
|
||||
}
|
||||
|
||||
// When reference has tag bits.
|
||||
@@ -242,15 +248,39 @@ namespace System.Reflection.Internal
|
||||
internal Guid PeekGuid(int offset)
|
||||
{
|
||||
CheckBounds(offset, sizeof(Guid));
|
||||
return *(Guid*)(Pointer + offset);
|
||||
|
||||
byte* ptr = Pointer + offset;
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
return *(Guid*)ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
return new Guid(
|
||||
(int)(ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24)),
|
||||
(short)(ptr[4] | (ptr[5] << 8)),
|
||||
(short)(ptr[6] | (ptr[7] << 8)),
|
||||
ptr[8], ptr[9], ptr[10], ptr[11], ptr[12], ptr[13], ptr[14], ptr[15]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal string PeekUtf16(int offset, int byteCount)
|
||||
{
|
||||
CheckBounds(offset, byteCount);
|
||||
|
||||
// doesn't allocate a new string if byteCount == 0
|
||||
return new string((char*)(Pointer + offset), 0, byteCount / sizeof(char));
|
||||
byte* ptr = Pointer + offset;
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
// doesn't allocate a new string if byteCount == 0
|
||||
return new string((char*)ptr, 0, byteCount / sizeof(char));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Encoding.Unicode.GetString(ptr, byteCount);
|
||||
}
|
||||
}
|
||||
|
||||
internal string PeekUtf8(int offset, int byteCount)
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.ExceptionServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection.Internal;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace System.Reflection.Metadata
|
||||
{
|
||||
@@ -60,12 +60,6 @@ namespace System.Reflection.Metadata
|
||||
Throw.ArgumentOutOfRange(nameof(capacity));
|
||||
}
|
||||
|
||||
// the writer assumes little-endian architecture:
|
||||
if (!BitConverter.IsLittleEndian)
|
||||
{
|
||||
Throw.LitteEndianArchitectureRequired();
|
||||
}
|
||||
|
||||
_nextOrPrevious = this;
|
||||
_buffer = new byte[Math.Max(MinChunkSize, capacity)];
|
||||
}
|
||||
@@ -774,7 +768,7 @@ namespace System.Reflection.Metadata
|
||||
return;
|
||||
}
|
||||
|
||||
fixed (byte* ptr = buffer)
|
||||
fixed (byte* ptr = &buffer[0])
|
||||
{
|
||||
WriteBytesUnchecked(ptr + start, byteCount);
|
||||
}
|
||||
@@ -954,9 +948,20 @@ namespace System.Reflection.Metadata
|
||||
return;
|
||||
}
|
||||
|
||||
fixed (char* ptr = value)
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
WriteBytesUnchecked((byte*)ptr, value.Length * sizeof(char));
|
||||
fixed (char* ptr = &value[0])
|
||||
{
|
||||
WriteBytesUnchecked((byte*)ptr, value.Length * sizeof(char));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] bytes = Encoding.Unicode.GetBytes(value);
|
||||
fixed (byte* ptr = &bytes[0])
|
||||
{
|
||||
WriteBytesUnchecked((byte*)ptr, bytes.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -977,9 +982,20 @@ namespace System.Reflection.Metadata
|
||||
Throw.InvalidOperationBuilderAlreadyLinked();
|
||||
}
|
||||
|
||||
fixed (char* ptr = value)
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
WriteBytesUnchecked((byte*)ptr, value.Length * sizeof(char));
|
||||
fixed (char* ptr = value)
|
||||
{
|
||||
WriteBytesUnchecked((byte*)ptr, value.Length * sizeof(char));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] bytes = Encoding.Unicode.GetBytes(value);
|
||||
fixed (byte* ptr = bytes)
|
||||
{
|
||||
WriteBytesUnchecked((byte*)ptr, bytes.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace System.Reflection.Metadata
|
||||
throw new ArgumentException(SR.Format(SR.UnexpectedArrayLength, Size), nameof(id));
|
||||
}
|
||||
|
||||
fixed (byte* ptr = id)
|
||||
fixed (byte* ptr = &id[0])
|
||||
{
|
||||
var reader = new BlobReader(ptr, id.Length);
|
||||
Guid = reader.ReadGuid();
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace System.Reflection.Metadata
|
||||
|
||||
internal BlobReader(MemoryBlock block)
|
||||
{
|
||||
Debug.Assert(BitConverter.IsLittleEndian && block.Length >= 0 && (block.Pointer != null || block.Length == 0));
|
||||
Debug.Assert(block.Length >= 0 && (block.Pointer != null || block.Length == 0));
|
||||
_block = block;
|
||||
_currentPointer = block.Pointer;
|
||||
_endPointer = block.Pointer + block.Length;
|
||||
@@ -242,37 +242,63 @@ namespace System.Reflection.Metadata
|
||||
|
||||
public char ReadChar()
|
||||
{
|
||||
return *(char*)GetCurrentPointerAndAdvance(sizeof(char));
|
||||
unchecked
|
||||
{
|
||||
byte* ptr = GetCurrentPointerAndAdvance(sizeof(char));
|
||||
return (char)(ptr[0] + (ptr[1] << 8));
|
||||
}
|
||||
}
|
||||
|
||||
public short ReadInt16()
|
||||
{
|
||||
return *(short*)GetCurrentPointerAndAdvance(sizeof(short));
|
||||
unchecked
|
||||
{
|
||||
byte* ptr = GetCurrentPointerAndAdvance(sizeof(short));
|
||||
return (short)(ptr[0] + (ptr[1] << 8));
|
||||
}
|
||||
}
|
||||
|
||||
public ushort ReadUInt16()
|
||||
{
|
||||
return *(ushort*)GetCurrentPointerAndAdvance(sizeof(ushort));
|
||||
unchecked
|
||||
{
|
||||
byte* ptr = GetCurrentPointerAndAdvance(sizeof(ushort));
|
||||
return (ushort)(ptr[0] + (ptr[1] << 8));
|
||||
}
|
||||
}
|
||||
|
||||
public int ReadInt32()
|
||||
{
|
||||
return *(int*)GetCurrentPointerAndAdvance(sizeof(int));
|
||||
unchecked
|
||||
{
|
||||
byte* ptr = GetCurrentPointerAndAdvance(sizeof(int));
|
||||
return (int)(ptr[0] + (ptr[1] << 8) + (ptr[2] << 16) + (ptr[3] << 24));
|
||||
}
|
||||
}
|
||||
|
||||
public uint ReadUInt32()
|
||||
{
|
||||
return *(uint*)GetCurrentPointerAndAdvance(sizeof(uint));
|
||||
unchecked
|
||||
{
|
||||
byte* ptr = GetCurrentPointerAndAdvance(sizeof(uint));
|
||||
return (uint)(ptr[0] + (ptr[1] << 8) + (ptr[2] << 16) + (ptr[3] << 24));
|
||||
}
|
||||
}
|
||||
|
||||
public long ReadInt64()
|
||||
{
|
||||
return *(long*)GetCurrentPointerAndAdvance(sizeof(long));
|
||||
unchecked
|
||||
{
|
||||
byte* ptr = GetCurrentPointerAndAdvance(sizeof(long));
|
||||
uint lo = (uint)(ptr[0] + (ptr[1] << 8) + (ptr[2] << 16) + (ptr[3] << 24));
|
||||
uint hi = (uint)(ptr[4] + (ptr[5] << 8) + (ptr[6] << 16) + (ptr[7] << 24));
|
||||
return (long)(lo + ((ulong)hi << 32));
|
||||
}
|
||||
}
|
||||
|
||||
public ulong ReadUInt64()
|
||||
{
|
||||
return *(ulong*)GetCurrentPointerAndAdvance(sizeof(ulong));
|
||||
return unchecked((ulong)ReadInt64());
|
||||
}
|
||||
|
||||
public float ReadSingle()
|
||||
@@ -290,7 +316,22 @@ namespace System.Reflection.Metadata
|
||||
public Guid ReadGuid()
|
||||
{
|
||||
const int size = 16;
|
||||
return *(Guid*)GetCurrentPointerAndAdvance(size);
|
||||
byte * ptr = GetCurrentPointerAndAdvance(size);
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
return *(Guid*)ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
return new Guid(
|
||||
(int)(ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24)),
|
||||
(short)(ptr[4] | (ptr[5] << 8)),
|
||||
(short)(ptr[6] | (ptr[7] << 8)),
|
||||
ptr[8], ptr[9], ptr[10], ptr[11], ptr[12], ptr[13], ptr[14], ptr[15]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -312,12 +353,15 @@ namespace System.Reflection.Metadata
|
||||
throw new BadImageFormatException(SR.ValueTooLarge);
|
||||
}
|
||||
|
||||
return new decimal(
|
||||
*(int*)(ptr + 1),
|
||||
*(int*)(ptr + 5),
|
||||
*(int*)(ptr + 9),
|
||||
isNegative: (*ptr & 0x80) != 0,
|
||||
scale: scale);
|
||||
unchecked
|
||||
{
|
||||
return new decimal(
|
||||
(int)(ptr[1] | (ptr[2] << 8) | (ptr[3] << 16) | (ptr[4] << 24)),
|
||||
(int)(ptr[5] | (ptr[6] << 8) | (ptr[7] << 16) | (ptr[8] << 24)),
|
||||
(int)(ptr[9] | (ptr[10] << 8) | (ptr[11] << 16) | (ptr[12] << 24)),
|
||||
isNegative: (*ptr & 0x80) != 0,
|
||||
scale: scale);
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime ReadDateTime()
|
||||
|
||||
@@ -38,8 +38,6 @@ namespace System.Reflection.Metadata
|
||||
|
||||
public BlobWriter(byte[] buffer, int start, int count)
|
||||
{
|
||||
// the writer assumes little-endian architecture:
|
||||
Debug.Assert(BitConverter.IsLittleEndian);
|
||||
Debug.Assert(buffer != null);
|
||||
Debug.Assert(count >= 0);
|
||||
Debug.Assert(count <= buffer.Length - start);
|
||||
@@ -231,7 +229,7 @@ namespace System.Reflection.Metadata
|
||||
return;
|
||||
}
|
||||
|
||||
fixed (byte* ptr = buffer)
|
||||
fixed (byte* ptr = &buffer[0])
|
||||
{
|
||||
WriteBytes(ptr + start, byteCount);
|
||||
}
|
||||
@@ -384,7 +382,7 @@ namespace System.Reflection.Metadata
|
||||
return;
|
||||
}
|
||||
|
||||
fixed (char* ptr = value)
|
||||
fixed (char* ptr = &value[0])
|
||||
{
|
||||
WriteBytesUnchecked((byte*)ptr, value.Length * sizeof(char));
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection.Internal;
|
||||
|
||||
namespace System.Reflection.Metadata.Ecma335
|
||||
{
|
||||
|
||||
@@ -1 +1 @@
|
||||
25f6195c35a1330cac25c84beadbdc78c6ad52a2
|
||||
161cec5c59c4881faa640b4c15e500dd63cc0042
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user