Skip to content

Commit 31e083f

Browse files
committed
Add Brotli C# sources to corefx-bugfix
1 parent 45e51e4 commit 31e083f

29 files changed

+2126
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using System.Runtime.InteropServices;
7+
8+
namespace Microsoft.Win32.SafeHandles
9+
{
10+
internal sealed class SafeBrotliEncoderHandle : SafeHandle
11+
{
12+
public SafeBrotliEncoderHandle() : base(IntPtr.Zero, true) { }
13+
14+
protected override bool ReleaseHandle()
15+
{
16+
Interop.Brotli.BrotliEncoderDestroyInstance(handle);
17+
return true;
18+
}
19+
20+
public override bool IsInvalid => handle == IntPtr.Zero;
21+
}
22+
23+
internal sealed class SafeBrotliDecoderHandle : SafeHandle
24+
{
25+
public SafeBrotliDecoderHandle() : base(IntPtr.Zero, true) { }
26+
27+
protected override bool ReleaseHandle()
28+
{
29+
Interop.Brotli.BrotliDecoderDestroyInstance(handle);
30+
return true;
31+
}
32+
33+
public override bool IsInvalid => handle == IntPtr.Zero;
34+
}
35+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
# Visual Studio 14
3+
VisualStudioVersion = 14.0.25420.1
4+
MinimumVisualStudioVersion = 10.0.40219.1
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO.Compression.Brotli.Tests", "tests\System.IO.Compression.Brotli.Tests.csproj", "{BC2E1649-291D-412E-9529-EDDA94FA7AD6}"
6+
ProjectSection(ProjectDependencies) = postProject
7+
{5471BFE8-8071-466F-838E-5ADAA779E742} = {5471BFE8-8071-466F-838E-5ADAA779E742}
8+
EndProjectSection
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO.Compression.Brotli.Performance.Tests", "tests\Performance\System.IO.Compression.Brotli.Performance.Tests.csproj", "{1341F8C8-637A-49A1-BE0F-13867A634929}"
11+
ProjectSection(ProjectDependencies) = postProject
12+
{5471BFE8-8071-466F-838E-5ADAA779E742} = {5471BFE8-8071-466F-838E-5ADAA779E742}
13+
EndProjectSection
14+
EndProject
15+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO.Compression.Brotli", "src\System.IO.Compression.Brotli.csproj", "{5471BFE8-8071-466F-838E-5ADAA779E742}"
16+
ProjectSection(ProjectDependencies) = postProject
17+
{4ADD9456-A929-4254-B8A2-16FC628ABFDA} = {4ADD9456-A929-4254-B8A2-16FC628ABFDA}
18+
EndProjectSection
19+
EndProject
20+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO.Compression.Brotli", "ref\System.IO.Compression.Brotli.csproj", "{4ADD9456-A929-4254-B8A2-16FC628ABFDA}"
21+
EndProject
22+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{1A2F9F4A-A032-433E-B914-ADD5992BB178}"
23+
EndProject
24+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E107E9C1-E893-4E87-987E-04EF0DCEAEFD}"
25+
EndProject
26+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{2E666815-2EDB-464B-9DF6-380BF4789AD4}"
27+
EndProject
28+
Global
29+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
30+
Debug|Any CPU = Debug|Any CPU
31+
Release|Any CPU = Release|Any CPU
32+
EndGlobalSection
33+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
34+
{BC2E1649-291D-412E-9529-EDDA94FA7AD6}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
35+
{BC2E1649-291D-412E-9529-EDDA94FA7AD6}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
36+
{BC2E1649-291D-412E-9529-EDDA94FA7AD6}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
37+
{BC2E1649-291D-412E-9529-EDDA94FA7AD6}.Release|Any CPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
38+
{1341F8C8-637A-49A1-BE0F-13867A634929}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
39+
{1341F8C8-637A-49A1-BE0F-13867A634929}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
40+
{1341F8C8-637A-49A1-BE0F-13867A634929}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
41+
{1341F8C8-637A-49A1-BE0F-13867A634929}.Release|Any CPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
42+
{5471BFE8-8071-466F-838E-5ADAA779E742}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
43+
{5471BFE8-8071-466F-838E-5ADAA779E742}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
44+
{5471BFE8-8071-466F-838E-5ADAA779E742}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
45+
{5471BFE8-8071-466F-838E-5ADAA779E742}.Release|Any CPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
46+
{4ADD9456-A929-4254-B8A2-16FC628ABFDA}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
47+
{4ADD9456-A929-4254-B8A2-16FC628ABFDA}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
48+
{4ADD9456-A929-4254-B8A2-16FC628ABFDA}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU
49+
{4ADD9456-A929-4254-B8A2-16FC628ABFDA}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU
50+
EndGlobalSection
51+
GlobalSection(SolutionProperties) = preSolution
52+
HideSolutionNode = FALSE
53+
EndGlobalSection
54+
GlobalSection(NestedProjects) = preSolution
55+
{BC2E1649-291D-412E-9529-EDDA94FA7AD6} = {1A2F9F4A-A032-433E-B914-ADD5992BB178}
56+
{1341F8C8-637A-49A1-BE0F-13867A634929} = {1A2F9F4A-A032-433E-B914-ADD5992BB178}
57+
{5471BFE8-8071-466F-838E-5ADAA779E742} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD}
58+
{4ADD9456-A929-4254-B8A2-16FC628ABFDA} = {2E666815-2EDB-464B-9DF6-380BF4789AD4}
59+
EndGlobalSection
60+
EndGlobal
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\dir.props" />
4+
<PropertyGroup>
5+
<AssemblyVersion>4.2.1.0</AssemblyVersion>
6+
<AssemblyKey>ECMA</AssemblyKey>
7+
<IsNETCoreApp>true</IsNETCoreApp>
8+
<IsUAP>true</IsUAP>
9+
</PropertyGroup>
10+
</Project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<BuildConfigurations>
5+
netcoreapp;
6+
</BuildConfigurations>
7+
</PropertyGroup>
8+
</Project>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
// ------------------------------------------------------------------------------
5+
// Changes to this file must follow the http://aka.ms/api-review process.
6+
// ------------------------------------------------------------------------------
7+
8+
namespace System.IO.Compression
9+
{
10+
public partial struct BrotliDecoder : System.IDisposable
11+
{
12+
public System.Buffers.OperationStatus Decompress(System.ReadOnlySpan<byte> source, System.Span<byte> destination, out int bytesConsumed, out int bytesWritten) { bytesConsumed = default(int); bytesWritten = default(int); throw null; }
13+
public static bool TryDecompress(System.ReadOnlySpan<byte> source, System.Span<byte> destination, out int bytesWritten) { bytesWritten = default(int); throw null; }
14+
public void Dispose() { }
15+
}
16+
public partial struct BrotliEncoder : System.IDisposable
17+
{
18+
public BrotliEncoder(int quality, int window) { }
19+
public System.Buffers.OperationStatus Compress(System.ReadOnlySpan<byte> source, System.Span<byte> destination, out int bytesConsumed, out int bytesWritten, bool isFinalBlock) { bytesConsumed = default(int); bytesWritten = default(int); throw null; }
20+
public System.Buffers.OperationStatus Flush(System.Span<byte> destination, out int bytesWritten) { bytesWritten = default(int); throw null; }
21+
public void Dispose() { }
22+
public static bool TryCompress(System.ReadOnlySpan<byte> source, System.Span<byte> destination, out int bytesWritten) { bytesWritten = default(int); throw null; }
23+
public static bool TryCompress(System.ReadOnlySpan<byte> source, System.Span<byte> destination, out int bytesWritten, int quality, int window) { bytesWritten = default(int); throw null; }
24+
public static int GetMaxCompressedLength(int inputSize) { throw null; }
25+
}
26+
public sealed partial class BrotliStream : System.IO.Stream
27+
{
28+
public BrotliStream(System.IO.Stream stream, System.IO.Compression.CompressionLevel compressionLevel) { }
29+
public BrotliStream(System.IO.Stream stream, System.IO.Compression.CompressionLevel compressionLevel, bool leaveOpen) { }
30+
public BrotliStream(System.IO.Stream stream, System.IO.Compression.CompressionMode mode) { }
31+
public BrotliStream(System.IO.Stream stream, System.IO.Compression.CompressionMode mode, bool leaveOpen) { }
32+
public System.IO.Stream BaseStream { get { throw null; } }
33+
public override bool CanRead { get { throw null; } }
34+
public override bool CanSeek { get { throw null; } }
35+
public override bool CanWrite { get { throw null; } }
36+
public override long Length { get { throw null; } }
37+
public override long Position { get { throw null; } set { } }
38+
protected override void Dispose(bool disposing) { }
39+
public override void Flush() { }
40+
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState) { throw null; }
41+
public override int EndRead(IAsyncResult asyncResult) { throw null; }
42+
public override int Read(byte[] buffer, int offset, int count) { throw null; }
43+
public override System.Threading.Tasks.Task<int> ReadAsync(byte[] buffer, int offset, int count, System.Threading.CancellationToken cancellationToken) { throw null; }
44+
public override long Seek(long offset, System.IO.SeekOrigin origin) { throw null; }
45+
public override void SetLength(long value) { }
46+
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState) { throw null; }
47+
public override void EndWrite(IAsyncResult asyncResult) { }
48+
public override void Write(byte[] buffer, int offset, int count) { }
49+
public override System.Threading.Tasks.Task WriteAsync(byte[] buffer, int offset, int count, System.Threading.CancellationToken cancellationToken) { throw null; }
50+
}
51+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
4+
<PropertyGroup>
5+
<ProjectGuid>{4ADD9456-A929-4254-B8A2-16FC628ABFDA}</ProjectGuid>
6+
</PropertyGroup>
7+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Debug|AnyCPU'" />
8+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Release|AnyCPU'" />
9+
<ItemGroup>
10+
<Compile Include="System.IO.Compression.Brotli.cs" />
11+
</ItemGroup>
12+
<ItemGroup>
13+
<ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" />
14+
<ProjectReference Include="..\..\System.Memory\ref\System.Memory.csproj" />
15+
<ProjectReference Include="..\..\System.IO\ref\System.IO.csproj" />
16+
<ProjectReference Include="..\..\System.IO.Compression\ref\System.IO.Compression.csproj" />
17+
<ProjectReference Include="..\..\System.Text.Encoding\ref\System.Text.Encoding.csproj" />
18+
<ProjectReference Include="..\..\System.Threading.Tasks\ref\System.Threading.Tasks.csproj" />
19+
</ItemGroup>
20+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
21+
</Project>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<BuildConfigurations>
5+
netcoreapp-Unix;
6+
netcoreapp-Windows_NT;
7+
</BuildConfigurations>
8+
</PropertyGroup>
9+
</Project>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using System.Runtime.InteropServices;
7+
using Microsoft.Win32.SafeHandles;
8+
using size_t = System.IntPtr;
9+
10+
internal static partial class Interop
11+
{
12+
internal static partial class Brotli
13+
{
14+
[DllImport(Libraries.CompressionNative)]
15+
internal static extern SafeBrotliDecoderHandle BrotliDecoderCreateInstance(IntPtr allocFunc, IntPtr freeFunc, IntPtr opaque);
16+
17+
[DllImport(Libraries.CompressionNative)]
18+
internal static extern unsafe int BrotliDecoderDecompressStream(
19+
SafeBrotliDecoderHandle state, ref size_t availableIn, byte** nextIn,
20+
ref size_t availableOut, byte** nextOut, out size_t totalOut);
21+
22+
[DllImport(Libraries.CompressionNative)]
23+
internal static extern unsafe bool BrotliDecoderDecompress(size_t availableInput, byte* inBytes, ref size_t availableOutput, byte* outBytes);
24+
25+
[DllImport(Libraries.CompressionNative)]
26+
internal static extern void BrotliDecoderDestroyInstance(IntPtr state);
27+
28+
[DllImport(Libraries.CompressionNative)]
29+
internal static extern bool BrotliDecoderIsFinished(SafeBrotliDecoderHandle state);
30+
}
31+
}
32+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using System.Runtime.InteropServices;
7+
using System.IO.Compression;
8+
using Microsoft.Win32.SafeHandles;
9+
using size_t = System.IntPtr;
10+
11+
internal static partial class Interop
12+
{
13+
internal static partial class Brotli
14+
{
15+
[DllImport(Libraries.CompressionNative)]
16+
internal static extern SafeBrotliEncoderHandle BrotliEncoderCreateInstance(IntPtr allocFunc, IntPtr freeFunc, IntPtr opaque);
17+
18+
[DllImport(Libraries.CompressionNative)]
19+
internal static extern bool BrotliEncoderSetParameter(SafeBrotliEncoderHandle state, BrotliEncoderParameter parameter, UInt32 value);
20+
21+
[DllImport(Libraries.CompressionNative)]
22+
internal static extern unsafe bool BrotliEncoderCompressStream(
23+
SafeBrotliEncoderHandle state, BrotliEncoderOperation op, ref size_t availableIn,
24+
byte** nextIn, ref size_t availableOut, byte** nextOut, out size_t totalOut);
25+
26+
[DllImport(Libraries.CompressionNative)]
27+
internal static extern bool BrotliEncoderHasMoreOutput(SafeBrotliEncoderHandle state);
28+
29+
[DllImport(Libraries.CompressionNative)]
30+
internal static extern void BrotliEncoderDestroyInstance(IntPtr state);
31+
32+
[DllImport(Libraries.CompressionNative)]
33+
internal static extern unsafe bool BrotliEncoderCompress(int quality, int window, int v, size_t availableInput, byte* inBytes, ref size_t availableOutput, byte* outBytes);
34+
}
35+
}
36+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!-- Not a bug. clrcompression.dll is a native components that ship as part of the package. -->
2+
clrcompression.dll!BrotliDecoderCreateInstance
3+
clrcompression.dll!BrotliDecoderDecompress
4+
clrcompression.dll!BrotliDecoderDecompressStream
5+
clrcompression.dll!BrotliDecoderDestroyInstance
6+
clrcompression.dll!BrotliDecoderErrorString
7+
clrcompression.dll!BrotliDecoderGetErrorCode
8+
clrcompression.dll!BrotliDecoderHasMoreOutput
9+
clrcompression.dll!BrotliDecoderIsFinished
10+
clrcompression.dll!BrotliDecoderIsUsed
11+
clrcompression.dll!BrotliDecoderSetParameter
12+
clrcompression.dll!BrotliDecoderTakeOutput
13+
clrcompression.dll!BrotliDecoderVersion
14+
clrcompression.dll!BrotliEncoderCompress
15+
clrcompression.dll!BrotliEncoderCompressStream
16+
clrcompression.dll!BrotliEncoderCreateInstance
17+
clrcompression.dll!BrotliEncoderDestroyInstance
18+
clrcompression.dll!BrotliEncoderHasMoreOutput
19+
clrcompression.dll!BrotliEncoderIsFinished
20+
clrcompression.dll!BrotliEncoderMaxCompressedSize
21+
clrcompression.dll!BrotliEncoderSetParameter
22+
clrcompression.dll!BrotliEncoderTakeOutput
23+
clrcompression.dll!BrotliEncoderVersion

0 commit comments

Comments
 (0)