Imported Upstream version 5.4.0.167

Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-08-21 15:34:15 +00:00
parent e49d6f06c0
commit 536cd135cc
12856 changed files with 563812 additions and 223249 deletions

View File

@@ -8,11 +8,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Reflection.Metadata.
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Reflection.Metadata", "src\System.Reflection.Metadata.csproj", "{F3E433C8-352F-4944-BF7F-765CE435370D}"
ProjectSection(ProjectDependencies) = postProject
{69B25962-B4C2-4295-8809-5653CD03FC75} = {69B25962-B4C2-4295-8809-5653CD03FC75}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Reflection.Metadata", "ref\System.Reflection.Metadata.csproj", "{69B25962-B4C2-4295-8809-5653CD03FC75}"
EndProject
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
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{2E666815-2EDB-464B-9DF6-380BF4789AD4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -27,6 +34,10 @@ Global
{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
{69B25962-B4C2-4295-8809-5653CD03FC75}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
{69B25962-B4C2-4295-8809-5653CD03FC75}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
{69B25962-B4C2-4295-8809-5653CD03FC75}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU
{69B25962-B4C2-4295-8809-5653CD03FC75}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -34,5 +45,6 @@ Global
GlobalSection(NestedProjects) = preSolution
{7061832A-E8CF-4AB6-A8DC-44D2F5A43A13} = {1A2F9F4A-A032-433E-B914-ADD5992BB178}
{F3E433C8-352F-4944-BF7F-765CE435370D} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD}
{69B25962-B4C2-4295-8809-5653CD03FC75} = {2E666815-2EDB-464B-9DF6-380BF4789AD4}
EndGlobalSection
EndGlobal

View File

@@ -2,8 +2,9 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\dir.props" />
<PropertyGroup>
<PackageVersion>1.5.0</PackageVersion>
<AssemblyVersion>1.4.2.0</AssemblyVersion>
<PackageVersion>1.6.0</PackageVersion>
<AssemblyVersion>1.4.3.0</AssemblyVersion>
<AssemblyKey>MSFT</AssemblyKey>
<IsNETCoreApp>true</IsNETCoreApp>
<IsUAP>true</IsUAP>
</PropertyGroup>

View File

@@ -13,6 +13,8 @@
<TargetFramework>portable-net45+win8</TargetFramework>
<Version>1.1.37</Version>
</FilePackageDependency>
<InboxOnTargetFramework Include="netcoreapp2.0" />
<InboxOnTargetFramework Include="uap10.1" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PackageConfigurations>
netstandard1.1;
netstandard;
</PackageConfigurations>
<BuildConfigurations>
$(PackageConfigurations);
netcoreapp;
uap-Windows_NT;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1 @@
d421ee938b951e8fc13b1f093c52ec399c682a2d

View File

@@ -0,0 +1,34 @@
<?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" />
<PropertyGroup>
<ProjectGuid>{69B25962-B4C2-4295-8809-5653CD03FC75}</ProjectGuid>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CLSCompliant>false</CLSCompliant>
</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-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="System.Reflection.Metadata.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp' Or '$(TargetGroup)' == 'uap'">
<ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" />
<ProjectReference Include="..\..\System.Collections.Immutable\ref\System.Collections.Immutable.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netstandard1.1'">
<Reference Include="System.IO" />
<Reference Include="System.Reflection.Primitives" />
<Reference Include="System.Runtime" />
<Reference Include="System.Text.Encoding" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netstandard' Or '$(TargetGroup)' == 'netstandard1.1'">
<ProjectReference Include="..\..\System.Collections.Immutable\ref\System.Collections.Immutable.csproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -29,7 +29,9 @@ The associated .pdb file may not exist at the path indicated by Path field. If i
If the containing PE/COFF file is deterministic the Guid field above and DateTimeStamp field of the directory entry are calculated deterministically based solely on the content of the associated .pdb file. Otherwise the value of Guid is random and the value of DateTimeStamp indicates the time and date that the debug data was created.
*Version Major=any, Minor=0x504d* of the data format has the same structure as above. The Age shall be 1. The format of the associated .pdb file is Portable PDB. The Major version specified in the entry indicates the version of the Portable PDB format. Together 16B of the Guid concatenated with 4B of the TimeDateStamp field of the entry form a PDB ID that should be used to match the PE/COFF image with the associated PDB (instead of Guid and Age). Matching PDB ID is stored in the #Pdb stream of the .pdb file.
*Version Major=any, Minor=0x504d* of the data format has the same structure as above. The Age shall be 1. The format of the .pdb file that this PE/COFF file was built with is Portable PDB. The Major version specified in the entry indicates the version of the Portable PDB format. Together 16B of the Guid concatenated with 4B of the TimeDateStamp field of the entry form a PDB ID that should be used to match the PE/COFF image with the associated PDB (instead of Guid and Age). Matching PDB ID is stored in the #Pdb stream of the .pdb file.
> A matching PDB may be found whose format is different than the format of the PDB the PE/COFF file was built with. This may happen when the original PDB file is [converted](http://github.com/dotnet/symreader-converter) to the other format without updating the PE/COFF file. This scenario is fully supported. A tool looking for the associated PDB shall determine the actual format of the found PDB based on the signature at the start of the PDB file. The tool may use the version in CodeView entry as a hint to prefer the original format over the converted one if both are available.
### Deterministic Debug Directory Entry (type 16)

View File

@@ -232,12 +232,12 @@ There shall be no duplicate rows in the LocalVariable table, based upon owner an
There shall be no duplicate rows in the LocalVariable table, based upon owner and _Name_.
#####<a name="LocalVariableAttributes"></a>LocalVariableAttributes
##### <a name="LocalVariableAttributes"></a>LocalVariableAttributes
| flag | value | description |
|:------|:------|:------------|
| DebuggerHidden | 0x0001 | Variable shouldnt appear in the list of variables displayed by the debugger |
###<a name="LocalConstantTable"></a>LocalConstant Table: 0x34
### <a name="LocalConstantTable"></a>LocalConstant Table: 0x34
The LocalConstant table has the following columns:
@@ -248,7 +248,7 @@ Conceptually, every row in the LocalConstant table is owned by one, and only one
There shall be no duplicate rows in the LocalConstant table, based upon owner and _Name_.
####<a name="LocalConstantSig"></a>LocalConstantSig Blob
#### <a name="LocalConstantSig"></a>LocalConstantSig Blob
The structure of the blob is
@@ -302,13 +302,13 @@ The encoding of the _GeneralValue_ is determined based upon the type expressed b
| System | Decimal | sign (highest bit), scale (bits 0..7), low (uint32), mid (uint32), high (uint32) |
| System | DateTime | int64: ticks |
###<a name="ImportScopeTable"></a>ImportScope Table: 0x35
### <a name="ImportScopeTable"></a>ImportScope Table: 0x35
The ImportScope table has the following columns:
* Parent (ImportScope row id or nil)
* Imports (Blob index, encoding: [Imports blob](#ImportsBlob))
####<a name="ImportsBlob"></a>Imports Blob
#### <a name="ImportsBlob"></a>Imports Blob
Imports blob represents all imports declared by an import scope.
Imports blob has the following structure:

View File

@@ -1,9 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
<PackageConfigurations>
netstandard1.1;
netstandard;
</PackageConfigurations>
<BuildConfigurations>
$(PackageConfigurations);
netcoreapp;
uap-Windows_NT;
</BuildConfigurations>

View File

@@ -10,6 +10,7 @@
<DefaultLanguage>en-US</DefaultLanguage>
<NoWarn>1591</NoWarn>
<CLSCompliant>false</CLSCompliant>
<DefineConstants Condition="'$(TargetGroup)' == 'netstandard1.1'">NETSTANDARD11</DefineConstants>
<PackageTargetFramework Condition="'$(TargetGroup)' == 'netstandard1.1'">netstandard1.1;portable-net45+win8</PackageTargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Debug|AnyCPU'" />
@@ -21,6 +22,9 @@
<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\PinnedObject.cs" />
<Compile Include="System\Reflection\Internal\Utilities\CriticalDisposableObject.cs" Condition="'$(TargetGroup)' != 'netstandard1.1'" />
<Compile Include="System\Reflection\Internal\Utilities\CriticalDisposableObject.netstandard1.1.cs" Condition="'$(TargetGroup)' == 'netstandard1.1'" />
<Compile Include="System\Reflection\Internal\Utilities\ExceptionUtilities.cs" />
<Compile Include="System\Reflection\Internal\Utilities\PathUtilities.cs" />
<Compile Include="System\Reflection\Metadata\Ecma335\Encoding\FunctionPointerAttributes.cs" />
@@ -96,14 +100,17 @@
<Compile Include="System\Reflection\Internal\Utilities\BitArithmetic.cs" />
<Compile Include="System\Reflection\Internal\Utilities\StringUtils.cs" />
<Compile Include="System\Reflection\Internal\Utilities\EmptyArray.cs" />
<Compile Include="System\Reflection\Internal\Utilities\EncodingHelper.cs" />
<Compile Include="System\Reflection\Internal\Utilities\FileStreamReadLightUp.cs" />
<Compile Include="System\Reflection\Internal\Utilities\EncodingHelper.cs" Condition="'$(TargetGroup)' != 'netcoreapp'" />
<Compile Include="System\Reflection\Internal\Utilities\EncodingHelper.netcoreapp.cs" Condition="'$(TargetGroup)' == 'netcoreapp'" />
<Compile Include="System\Reflection\Internal\Utilities\FileStreamReadLightUp.cs" Condition="'$(TargetGroup)' != 'netstandard1.1'" />
<Compile Include="System\Reflection\Internal\Utilities\FileStreamReadLightUp.netstandard1.1.cs" Condition="'$(TargetGroup)' == 'netstandard1.1'" />
<Compile Include="System\Reflection\Internal\Utilities\Hash.cs" />
<Compile Include="System\Reflection\Internal\Utilities\ImmutableByteArrayInterop.cs" />
<Compile Include="System\Reflection\Internal\Utilities\ImmutableMemoryStream.cs" />
<Compile Include="System\Reflection\Internal\Utilities\LightUpHelper.cs" />
<Compile Include="System\Reflection\Internal\Utilities\LightUpHelper.cs" Condition="'$(TargetGroup)' != 'netcoreapp'" />
<Compile Include="System\Reflection\Internal\Utilities\MemoryBlock.cs" />
<Compile Include="System\Reflection\Internal\Utilities\MemoryMapLightUp.cs" />
<Compile Include="System\Reflection\Internal\Utilities\MemoryMapLightUp.cs" Condition="'$(TargetGroup)' != 'netstandard1.1'" />
<Compile Include="System\Reflection\Internal\Utilities\MemoryMapLightUp.netstandard1.1.cs" Condition="'$(TargetGroup)' == 'netstandard1.1'" />
<Compile Include="System\Reflection\Internal\Utilities\PooledStringBuilder.cs" />
<Compile Include="System\Reflection\Internal\Utilities\ObjectPool`1.cs" />
<Compile Include="System\Reflection\Internal\Utilities\ReadOnlyUnmanagedMemoryStream.cs" />
@@ -257,6 +264,8 @@
<Reference Include="System.Text.Encoding" />
<Reference Include="System.Text.Encoding.Extensions" />
<Reference Include="System.Threading" />
<Reference Include="System.IO.MemoryMappedFiles" Condition="'$(TargetGroup)' != 'netstandard1.1'" />
<Reference Include="System.Buffers" Condition="'$(TargetGroup)' == 'netcoreapp'" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -44,18 +44,11 @@ namespace System.Reflection.Internal
/// Disposes the block.
/// </summary>
/// <remarks>
/// The operation is idempotent, but must not be called concurrently with any other operations on the block
/// or with another call to Dispose.
/// The operation is idempotent, but must not be called concurrently with any other operations on the block.
///
/// Using the block after dispose is an error in our code and therefore no effort is made to throw a tidy
/// ObjectDisposedException and null ref or AV is possible.
/// </remarks>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected abstract void Dispose(bool disposing);
public abstract void Dispose();
}
}

View File

@@ -23,9 +23,8 @@ namespace System.Reflection.Internal
_start = start;
}
protected override void Dispose(bool disposing)
public override void Dispose()
{
Debug.Assert(disposing);
_provider = null;
}

View File

@@ -5,8 +5,6 @@
using System.Collections.Immutable;
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
namespace System.Reflection.Internal
@@ -14,7 +12,7 @@ namespace System.Reflection.Internal
internal sealed class ByteArrayMemoryProvider : MemoryBlockProvider
{
private readonly ImmutableArray<byte> _array;
private StrongBox<GCHandle> _pinned;
private PinnedObject _pinned;
public ByteArrayMemoryProvider(ImmutableArray<byte> array)
{
@@ -22,15 +20,10 @@ namespace System.Reflection.Internal
_array = array;
}
~ByteArrayMemoryProvider()
protected override void Dispose(bool disposing)
{
Dispose(disposing: false);
}
protected override void Dispose(bool disposing)
{
_pinned?.Value.Free();
_pinned = null;
Debug.Assert(disposing);
Interlocked.Exchange(ref _pinned, null)?.Dispose();
}
public override int Size => _array.Length;
@@ -53,17 +46,16 @@ namespace System.Reflection.Internal
{
if (_pinned == null)
{
var newPinned = new StrongBox<GCHandle>(
GCHandle.Alloc(ImmutableByteArrayInterop.DangerousGetUnderlyingArray(_array), GCHandleType.Pinned));
var newPinned = new PinnedObject(ImmutableByteArrayInterop.DangerousGetUnderlyingArray(_array));
if (Interlocked.CompareExchange(ref _pinned, newPinned, null) != null)
{
// another thread has already allocated the handle:
newPinned.Value.Free();
newPinned.Dispose();
}
}
return (byte*)_pinned.Value.AddrOfPinnedObject();
return _pinned.Pointer;
}
}
}

View File

@@ -2,9 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Immutable;
using System.Diagnostics;
namespace System.Reflection.Internal
{
/// <summary>
@@ -25,9 +22,8 @@ namespace System.Reflection.Internal
_size = size;
}
protected override void Dispose(bool disposing)
public override void Dispose()
{
Debug.Assert(disposing);
_buffer = null;
_size = 0;
}

View File

@@ -2,49 +2,73 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Immutable;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
namespace System.Reflection.Internal
{
internal unsafe sealed class MemoryMappedFileBlock : AbstractMemoryBlock
{
private readonly int _size;
private IDisposable _accessor; // MemoryMappedViewAccessor
private byte* _pointer;
private SafeBuffer _safeBuffer;
internal unsafe MemoryMappedFileBlock(IDisposable accessor, SafeBuffer safeBuffer, byte* pointer, int size)
private sealed class DisposableData : CriticalDisposableObject
{
_accessor = accessor;
_safeBuffer = safeBuffer;
_pointer = pointer;
private IDisposable _accessor; // MemoryMappedViewAccessor
private SafeBuffer _safeBuffer;
private byte* _pointer;
public DisposableData(IDisposable accessor, SafeBuffer safeBuffer, long offset)
{
// Make sure the current thread isn't aborted in between acquiring the pointer and assigning the fields.
#if !NETSTANDARD11
RuntimeHelpers.PrepareConstrainedRegions();
#endif
try
{
}
finally
{
byte* basePointer = null;
safeBuffer.AcquirePointer(ref basePointer);
_accessor = accessor;
_safeBuffer = safeBuffer;
_pointer = basePointer + offset;
}
}
protected override void Release()
{
// Make sure the current thread isn't aborted in between zeroing the references and releasing/disposing.
// Safe buffer only frees the underlying resource if its ref count drops to zero, so we have to make sure it does.
#if !NETSTANDARD11
RuntimeHelpers.PrepareConstrainedRegions();
#endif
try
{
}
finally
{
Interlocked.Exchange(ref _safeBuffer, null)?.ReleasePointer();
Interlocked.Exchange(ref _accessor, null)?.Dispose();
}
_pointer = null;
}
public byte* Pointer => _pointer;
}
private readonly DisposableData _data;
private readonly int _size;
internal unsafe MemoryMappedFileBlock(IDisposable accessor, SafeBuffer safeBuffer, long offset, int size)
{
_data = new DisposableData(accessor, safeBuffer, offset);
_size = size;
}
~MemoryMappedFileBlock()
{
Dispose(false);
}
protected override void Dispose(bool disposing)
{
if (_safeBuffer != null)
{
_safeBuffer.ReleasePointer();
_safeBuffer = null;
}
if (_accessor != null)
{
_accessor.Dispose();
_accessor = null;
}
_pointer = null;
}
public override byte* Pointer => _pointer;
public override void Dispose() => _data.Dispose();
public override byte* Pointer => _data.Pointer;
public override int Size => _size;
}
}

View File

@@ -2,8 +2,9 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Immutable;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
namespace System.Reflection.Internal
{
@@ -13,29 +14,60 @@ namespace System.Reflection.Internal
/// <remarks>
/// Owns the native memory resource.
/// </remarks>
internal unsafe sealed class NativeHeapMemoryBlock : AbstractMemoryBlock
internal sealed class NativeHeapMemoryBlock : AbstractMemoryBlock
{
private byte* _pointer;
private unsafe sealed class DisposableData : CriticalDisposableObject
{
private IntPtr _pointer;
public DisposableData(int size)
{
// make sure the current thread isn't aborted in between allocating and storing the pointer
#if !NETSTANDARD11
RuntimeHelpers.PrepareConstrainedRegions();
#endif
try
{
}
finally
{
_pointer = Marshal.AllocHGlobal(size);
}
}
protected override void Release()
{
// make sure the current thread isn't aborted in between zeroing the pointer and freeing the memory
#if !NETSTANDARD11
RuntimeHelpers.PrepareConstrainedRegions();
#endif
try
{
}
finally
{
IntPtr ptr = Interlocked.Exchange(ref _pointer, IntPtr.Zero);
if (ptr != IntPtr.Zero)
{
Marshal.FreeHGlobal(ptr);
}
}
}
public byte* Pointer => (byte*)_pointer;
}
private readonly DisposableData _data;
private readonly int _size;
internal NativeHeapMemoryBlock(int size)
{
_pointer = (byte*)Marshal.AllocHGlobal(size);
_data = new DisposableData(size);
_size = size;
}
~NativeHeapMemoryBlock()
{
Dispose(false);
}
protected override void Dispose(bool disposing)
{
Marshal.FreeHGlobal((IntPtr)_pointer);
_pointer = null;
}
public override byte* Pointer => _pointer;
public override void Dispose() => _data.Dispose();
public unsafe override byte* Pointer => _data.Pointer;
public override int Size => _size;
}
}

View File

@@ -4,7 +4,6 @@
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
namespace System.Reflection.Internal
@@ -52,18 +51,12 @@ namespace System.Reflection.Internal
protected override void Dispose(bool disposing)
{
Debug.Assert(disposing);
if (!_leaveOpen && _stream != null)
if (!_leaveOpen)
{
_stream.Dispose();
_stream = null;
Interlocked.Exchange(ref _stream, null)?.Dispose();
}
if (_lazyMemoryMap != null)
{
_lazyMemoryMap.Dispose();
_lazyMemoryMap = null;
}
Interlocked.Exchange(ref _lazyMemoryMap, null)?.Dispose();
}
public override int Size
@@ -162,15 +155,13 @@ namespace System.Reflection.Internal
return false;
}
SafeBuffer safeBuffer;
byte* pointer = MemoryMapLightUp.AcquirePointer(accessor, out safeBuffer);
if (pointer == null)
if (!MemoryMapLightUp.TryGetSafeBufferAndPointerOffset(accessor, out var safeBuffer, out long offset))
{
block = null;
return false;
}
block = new MemoryMappedFileBlock(accessor, safeBuffer, pointer, size);
block = new MemoryMappedFileBlock(accessor, safeBuffer, offset, size);
return true;
}
}

View File

@@ -339,7 +339,7 @@ namespace System.Reflection
// ECMA-335 II.24.2.4:
// This final byte holds the value 1 if and only if any UTF16 character within
// the string has any bit set in its top byte, or its low byte is any of the following:
// 0x01<EFBFBD>0x08, 0x0E<EFBFBD>0x1F, 0x27, 0x2D, 0x7F. Otherwise, it holds 0.
// 0x01-0x08, 0x0E-0x1F, 0x27, 0x2D, 0x7F. Otherwise, it holds 0.
// The 1 signifies Unicode characters that require handling beyond that normally provided for 8-bit encoding sets.
foreach (char ch in str)

View File

@@ -0,0 +1,23 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Runtime.ConstrainedExecution;
namespace System.Reflection.Internal
{
internal abstract class CriticalDisposableObject : CriticalFinalizerObject, IDisposable
{
protected abstract void Release();
public void Dispose()
{
Release();
GC.SuppressFinalize(this);
}
~CriticalDisposableObject()
{
Release();
}
}
}

View File

@@ -0,0 +1,40 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Runtime.InteropServices;
namespace System.Reflection.Internal
{
// HACK: CriticalFinalizerObject is not available in netstandard 1.x
// Use CriticalHandle instead -- we don't actually use the handle,
// just the fact that CriticalHandle derives from CriticalFinalizerObject to ensure critical finalizer.
internal abstract class CriticalDisposableObject : CriticalHandle
{
public CriticalDisposableObject()
: base(IntPtr.Zero)
{
}
public sealed override bool IsInvalid => true;
protected sealed override bool ReleaseHandle() =>
throw ExceptionUtilities.Unreachable;
protected new void SetHandle(IntPtr handle) =>
throw ExceptionUtilities.Unreachable;
protected sealed override void Dispose(bool disposing)
{
// do not call base dispose
Release();
if (disposing)
{
GC.SuppressFinalize(this);
}
}
protected abstract void Release();
}
}

Some files were not shown because too many files have changed in this diff Show More