Convert to netcoreapp2.0 (#338)

* Converted samples and test projects to run on netcoreapp2.0
This commit is contained in:
BrennanConroy 2017-03-25 09:37:39 -07:00 committed by David Fowler
parent 430b8a3686
commit 6130003193
22 changed files with 91 additions and 58 deletions

View File

@ -9,6 +9,7 @@
<MoqVersion>4.7.1</MoqVersion> <MoqVersion>4.7.1</MoqVersion>
<NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion> <NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion>
<RedisVersion>1.1.605</RedisVersion> <RedisVersion>1.1.605</RedisVersion>
<RuntimeFrameworkVersion>2.0.0-*</RuntimeFrameworkVersion>
<TestSdkVersion>15.0.0</TestSdkVersion> <TestSdkVersion>15.0.0</TestSdkVersion>
<XunitVersion>2.2.0</XunitVersion> <XunitVersion>2.2.0</XunitVersion>
</PropertyGroup> </PropertyGroup>

View File

@ -3,7 +3,7 @@
<Import Project="..\..\build\common.props" /> <Import Project="..\..\build\common.props" />
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework> <TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -3,7 +3,7 @@
<Import Project="..\..\build\dependencies.props" /> <Import Project="..\..\build\dependencies.props" />
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework> <TargetFramework>netcoreapp2.0</TargetFramework>
<UserSecretsId>aspnet-ChatSample-f11cf018-e0a8-49fa-b749-4c0eb5c9150b</UserSecretsId> <UserSecretsId>aspnet-ChatSample-f11cf018-e0a8-49fa-b749-4c0eb5c9150b</UserSecretsId>
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8</PackageTargetFallback> <PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8</PackageTargetFallback>
<!-- Don't create a NuGet package --> <!-- Don't create a NuGet package -->

View File

@ -3,7 +3,7 @@
<Import Project="..\..\build\dependencies.props" /> <Import Project="..\..\build\dependencies.props" />
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework> <TargetFramework>netcoreapp2.0</TargetFramework>
<!-- Don't create a NuGet package --> <!-- Don't create a NuGet package -->
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
</PropertyGroup> </PropertyGroup>

View File

@ -3,7 +3,7 @@
<Import Project="..\..\build\dependencies.props" /> <Import Project="..\..\build\dependencies.props" />
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework> <TargetFramework>netcoreapp2.0</TargetFramework>
<!-- Don't create a NuGet package --> <!-- Don't create a NuGet package -->
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
</PropertyGroup> </PropertyGroup>

View File

@ -3,8 +3,8 @@
<Import Project="..\..\build\dependencies.props" /> <Import Project="..\..\build\dependencies.props" />
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netcoreapp1.1;net46</TargetFrameworks> <TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">$(PackageTargetFallback);portable-net45+win8+wp8+wpa81</PackageTargetFallback> <PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">$(PackageTargetFallback);portable-net45+win8+wp8+wpa81</PackageTargetFallback>
<!-- Don't create a NuGet package --> <!-- Don't create a NuGet package -->
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
</PropertyGroup> </PropertyGroup>

View File

@ -3,7 +3,7 @@
<Import Project="..\..\build\dependencies.props" /> <Import Project="..\..\build\dependencies.props" />
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework> <TargetFramework>netcoreapp2.0</TargetFramework>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<!-- Don't create a NuGet package --> <!-- Don't create a NuGet package -->
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>

View File

@ -20,19 +20,28 @@ namespace Microsoft.AspNetCore.Sockets.Internal.Formatters
{ {
if (_state.Length == null) if (_state.Length == null)
{ {
var length = buffer.TryReadBytes(sizeof(long))?.ToSingleSpan(); var lengthBuffer = buffer.TryReadBytes(sizeof(long));
if (length == null || length.Value.Length < sizeof(long))
if (lengthBuffer == null)
{ {
message = default(Message); message = default(Message);
return false; return false;
} }
var longLength = length.Value.ReadBigEndian<long>(); var length = lengthBuffer.Value.ToSingleSpan();
if (length.Length < sizeof(long))
{
message = default(Message);
return false;
}
var longLength = length.ReadBigEndian<long>();
if (longLength > Int32.MaxValue) if (longLength > Int32.MaxValue)
{ {
throw new FormatException("Messages over 2GB in size are not supported"); throw new FormatException("Messages over 2GB in size are not supported");
} }
buffer.Advance(length.Value.Length); buffer.Advance(length.Length);
_state.Length = (int)longLength; _state.Length = (int)longLength;
} }

View File

@ -11,8 +11,8 @@ namespace Microsoft.AspNetCore.Sockets.Internal.Formatters
{ {
public static class ServerSentEventsMessageFormatter public static class ServerSentEventsMessageFormatter
{ {
private static readonly Span<byte> DataPrefix = new byte[] { (byte)'d', (byte)'a', (byte)'t', (byte)'a', (byte)':', (byte)' ' }; private static readonly byte[] DataPrefix = new byte[] { (byte)'d', (byte)'a', (byte)'t', (byte)'a', (byte)':', (byte)' ' };
private static readonly Span<byte> Newline = new byte[] { (byte)'\r', (byte)'\n' }; private static readonly byte[] Newline = new byte[] { (byte)'\r', (byte)'\n' };
private const byte LineFeed = (byte)'\n'; private const byte LineFeed = (byte)'\n';
private const char TextTypeFlag = 'T'; private const char TextTypeFlag = 'T';

View File

@ -86,17 +86,20 @@ namespace Microsoft.AspNetCore.Sockets.Internal.Formatters
private bool TryReadLength(ref BytesReader buffer) private bool TryReadLength(ref BytesReader buffer)
{ {
// Read until the first ':' to find the length // Read until the first ':' to find the length
var lengthSpan = buffer.ReadBytesUntil((byte)TextMessageFormatter.FieldDelimiter)?.ToSingleSpan(); var lengthBuffer = buffer.ReadBytesUntil((byte)TextMessageFormatter.FieldDelimiter);
if (lengthSpan == null)
if (lengthBuffer == null)
{ {
// Insufficient data // Insufficient data
return false; return false;
} }
var lengthSpan = lengthBuffer.Value.ToSingleSpan();
// Parse the length // Parse the length
if (!PrimitiveParser.TryParseInt32(lengthSpan.Value, out var length, out var consumedByLength, encoder: TextEncoder.Utf8) || consumedByLength < lengthSpan.Value.Length) if (!PrimitiveParser.TryParseInt32(lengthSpan, out var length, out var consumedByLength, encoder: TextEncoder.Utf8) || consumedByLength < lengthSpan.Length)
{ {
if (TextEncoder.Utf8.TryDecode(lengthSpan.Value, out var lengthString, out _)) if (TextEncoder.Utf8.TryDecode(lengthSpan, out var lengthString, out _))
{ {
throw new FormatException($"Invalid length: '{lengthString}'"); throw new FormatException($"Invalid length: '{lengthString}'");
} }

View File

@ -583,8 +583,10 @@ namespace Microsoft.Extensions.WebSockets.Internal
return closeResult; return closeResult;
} }
private static void PingPayloadWriter(WritableBuffer output, Span<byte> maskingKey, int payloadLength, DateTime timestamp) private static unsafe void PingPayloadWriter(WritableBuffer output, uint maskingKeyValue, int payloadLength, DateTime timestamp)
{ {
var maskingKey = new Span<byte>(&maskingKeyValue, sizeof(uint));
var payload = output.Buffer.Slice(0, payloadLength); var payload = output.Buffer.Slice(0, payloadLength);
// TODO: Don't put this string on the heap? Is there a way to do that without re-implementing ToString? // TODO: Don't put this string on the heap? Is there a way to do that without re-implementing ToString?
@ -612,8 +614,10 @@ namespace Microsoft.Extensions.WebSockets.Internal
output.Advance(payloadLength); output.Advance(payloadLength);
} }
private static void CloseResultPayloadWriter(WritableBuffer output, Span<byte> maskingKey, int payloadLength, WebSocketCloseResult result) private static unsafe void CloseResultPayloadWriter(WritableBuffer output, uint maskingKeyValue, int payloadLength, WebSocketCloseResult result)
{ {
var maskingKey = new Span<byte>(&maskingKeyValue, sizeof(uint));
// Write the close payload out // Write the close payload out
var payload = output.Buffer.Slice(0, payloadLength).Span; var payload = output.Buffer.Slice(0, payloadLength).Span;
result.WriteTo(ref output); result.WriteTo(ref output);
@ -624,8 +628,10 @@ namespace Microsoft.Extensions.WebSockets.Internal
} }
} }
private static void AppendPayloadWriter(WritableBuffer output, Span<byte> maskingKey, int payloadLength, ReadableBuffer payload) private static unsafe void AppendPayloadWriter(WritableBuffer output, uint maskingKeyValue, int payloadLength, ReadableBuffer payload)
{ {
var maskingKey = new Span<byte>(&maskingKeyValue, sizeof(uint));
if (maskingKey.Length > 0) if (maskingKey.Length > 0)
{ {
// Mask the payload in it's own buffer // Mask the payload in it's own buffer
@ -635,7 +641,7 @@ namespace Microsoft.Extensions.WebSockets.Internal
output.Append(payload); output.Append(payload);
} }
private Task SendCoreAsync<T>(bool fin, WebSocketOpcode opcode, int payloadAllocLength, int payloadLength, Action<WritableBuffer, Span<byte>, int, T> payloadWriter, T payload, CancellationToken cancellationToken) private Task SendCoreAsync<T>(bool fin, WebSocketOpcode opcode, int payloadAllocLength, int payloadLength, Action<WritableBuffer, uint, int, T> payloadWriter, T payload, CancellationToken cancellationToken)
{ {
if (_sendLock.Wait(0)) if (_sendLock.Wait(0))
{ {
@ -647,13 +653,13 @@ namespace Microsoft.Extensions.WebSockets.Internal
} }
} }
private async Task SendCoreWaitForLockAsync<T>(bool fin, WebSocketOpcode opcode, int payloadAllocLength, int payloadLength, Action<WritableBuffer, Span<byte>, int, T> payloadWriter, T payload, CancellationToken cancellationToken) private async Task SendCoreWaitForLockAsync<T>(bool fin, WebSocketOpcode opcode, int payloadAllocLength, int payloadLength, Action<WritableBuffer, uint, int, T> payloadWriter, T payload, CancellationToken cancellationToken)
{ {
await _sendLock.WaitAsync(cancellationToken); await _sendLock.WaitAsync(cancellationToken);
await SendCoreLockAcquiredAsync(fin, opcode, payloadAllocLength, payloadLength, payloadWriter, payload, cancellationToken); await SendCoreLockAcquiredAsync(fin, opcode, payloadAllocLength, payloadLength, payloadWriter, payload, cancellationToken);
} }
private async Task SendCoreLockAcquiredAsync<T>(bool fin, WebSocketOpcode opcode, int payloadAllocLength, int payloadLength, Action<WritableBuffer, Span<byte>, int, T> payloadWriter, T payload, CancellationToken cancellationToken) private async Task SendCoreLockAcquiredAsync<T>(bool fin, WebSocketOpcode opcode, int payloadAllocLength, int payloadLength, Action<WritableBuffer, uint, int, T> payloadWriter, T payload, CancellationToken cancellationToken)
{ {
try try
{ {
@ -679,17 +685,7 @@ namespace Microsoft.Extensions.WebSockets.Internal
// Write the length and mask flag // Write the length and mask flag
WritePayloadLength(payloadLength, buffer); WritePayloadLength(payloadLength, buffer);
var maskingKey = Span<byte>.Empty; WritePayload(ref buffer, payloadLength, payloadWriter, payload);
if (_maskingKeyBuffer != null)
{
// Get a span of the output buffer for the masking key, write it there, then advance the write head.
maskingKey = buffer.Buffer.Slice(0, 4).Span;
WriteMaskingKey(maskingKey);
buffer.Advance(4);
}
// Write the payload
payloadWriter(buffer, maskingKey, payloadLength, payload);
// Flush. // Flush.
await buffer.FlushAsync(); await buffer.FlushAsync();
@ -701,6 +697,28 @@ namespace Microsoft.Extensions.WebSockets.Internal
} }
} }
private void WritePayload<T>(ref WritableBuffer buffer, int payloadLength, Action<WritableBuffer, uint, int, T> payloadWriter, T payload)
{
var maskingKey = Span<byte>.Empty;
var keySize = sizeof(uint);
if (_maskingKeyBuffer != null)
{
// Get a span of the output buffer for the masking key, write it there, then advance the write head.
maskingKey = buffer.Buffer.Slice(0, keySize).Span;
WriteMaskingKey(maskingKey);
buffer.Advance(keySize);
// Write the payload
payloadWriter(buffer, maskingKey.Read<uint>(), payloadLength, payload);
}
else
{
// Write the payload un-masked
payloadWriter(buffer, 0, payloadLength, payload);
}
}
private int CalculateAllocSize(int payloadAllocLength, int payloadLength) private int CalculateAllocSize(int payloadAllocLength, int payloadLength)
{ {
var allocSize = 2; var allocSize = 2;

View File

@ -3,8 +3,8 @@
<Import Project="..\..\build\common.props" /> <Import Project="..\..\build\common.props" />
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netcoreapp1.1;net46</TargetFrameworks> <TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp1.1</TargetFrameworks> <TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.0</TargetFrameworks>
<!-- TODO remove when https://github.com/Microsoft/vstest/issues/428 is resolved --> <!-- TODO remove when https://github.com/Microsoft/vstest/issues/428 is resolved -->
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>

View File

@ -3,8 +3,8 @@
<Import Project="..\..\build\common.props" /> <Import Project="..\..\build\common.props" />
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netcoreapp1.1;net46</TargetFrameworks> <TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp1.1</TargetFrameworks> <TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.0</TargetFrameworks>
<!-- TODO remove when https://github.com/Microsoft/vstest/issues/428 is resolved --> <!-- TODO remove when https://github.com/Microsoft/vstest/issues/428 is resolved -->
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>

View File

@ -4,7 +4,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp1.1</TargetFrameworks> <TargetFrameworks>netcoreapp2.0</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -3,8 +3,8 @@
<Import Project="..\..\build\common.props" /> <Import Project="..\..\build\common.props" />
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netcoreapp1.1;net46</TargetFrameworks> <TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp1.1</TargetFrameworks> <TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.0</TargetFrameworks>
<!-- TODO remove when https://github.com/Microsoft/vstest/issues/428 is resolved --> <!-- TODO remove when https://github.com/Microsoft/vstest/issues/428 is resolved -->
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
@ -37,7 +37,7 @@
<PackageReference Include="xunit" Version="$(XunitVersion)" /> <PackageReference Include="xunit" Version="$(XunitVersion)" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.1' "> <ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
<PackageReference Include="System.Net.WebSockets.Client" Version="$(CoreFxVersion)" /> <PackageReference Include="System.Net.WebSockets.Client" Version="$(CoreFxVersion)" />
</ItemGroup> </ItemGroup>

View File

@ -3,8 +3,8 @@
<Import Project="..\..\build\common.props" /> <Import Project="..\..\build\common.props" />
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netcoreapp1.1;net46</TargetFrameworks> <TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp1.1</TargetFrameworks> <TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.0</TargetFrameworks>
<!-- TODO remove when https://github.com/Microsoft/vstest/issues/428 is resolved --> <!-- TODO remove when https://github.com/Microsoft/vstest/issues/428 is resolved -->
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>

View File

@ -3,8 +3,8 @@
<Import Project="..\..\build\common.props" /> <Import Project="..\..\build\common.props" />
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netcoreapp1.1;net46</TargetFrameworks> <TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp1.1</TargetFrameworks> <TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.0</TargetFrameworks>
<!-- TODO remove when https://github.com/Microsoft/vstest/issues/428 is resolved --> <!-- TODO remove when https://github.com/Microsoft/vstest/issues/428 is resolved -->
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>

View File

@ -100,7 +100,7 @@ namespace Microsoft.AspNetCore.WebSockets.Internal.ConformanceTest.Autobahn
{ {
ApplicationBaseUriHint = baseUrl, ApplicationBaseUriHint = baseUrl,
ApplicationType = ApplicationType.Portable, ApplicationType = ApplicationType.Portable,
TargetFramework = "netcoreapp1.1", TargetFramework = "netcoreapp2.0",
EnvironmentName = "Development" EnvironmentName = "Development"
}; };
@ -111,7 +111,7 @@ namespace Microsoft.AspNetCore.WebSockets.Internal.ConformanceTest.Autobahn
#if NET46 #if NET46
System.Net.ServicePointManager.ServerCertificateValidationCallback = (_, __, ___, ____) => true; System.Net.ServicePointManager.ServerCertificateValidationCallback = (_, __, ___, ____) => true;
var client = new HttpClient(); var client = new HttpClient();
#else #elif NETCOREAPP2_0
var handler = new HttpClientHandler(); var handler = new HttpClientHandler();
if (ssl) if (ssl)
{ {
@ -121,6 +121,8 @@ namespace Microsoft.AspNetCore.WebSockets.Internal.ConformanceTest.Autobahn
handler.ServerCertificateCustomValidationCallback = (_, __, ___, ____) => true; handler.ServerCertificateCustomValidationCallback = (_, __, ___, ____) => true;
} }
var client = new HttpClient(handler); var client = new HttpClient(handler);
#else
#error Target framework needs to be updated
#endif #endif
// Make sure the server works // Make sure the server works

View File

@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\build\common.props" /> <Import Project="..\..\build\common.props" />
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netcoreapp1.1;net46</TargetFrameworks> <TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp1.1</TargetFrameworks> <TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.0</TargetFrameworks>
<!-- TODO remove when https://github.com/Microsoft/vstest/issues/428 is resolved --> <!-- TODO remove when https://github.com/Microsoft/vstest/issues/428 is resolved -->
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
@ -21,7 +21,7 @@
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" /> <PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" />
<PackageReference Include="xunit" Version="$(XunitVersion)" /> <PackageReference Include="xunit" Version="$(XunitVersion)" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.1' "> <ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
<PackageReference Include="System.Diagnostics.FileVersionInfo" Version="$(CoreFxVersion)" /> <PackageReference Include="System.Diagnostics.FileVersionInfo" Version="$(CoreFxVersion)" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -3,8 +3,8 @@
<Import Project="..\..\build\common.props" /> <Import Project="..\..\build\common.props" />
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netcoreapp1.1;net46</TargetFrameworks> <TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp1.1</TargetFrameworks> <TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.0</TargetFrameworks>
<!-- TODO remove when https://github.com/Microsoft/vstest/issues/428 is resolved --> <!-- TODO remove when https://github.com/Microsoft/vstest/issues/428 is resolved -->
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>

View File

@ -143,15 +143,15 @@ namespace Microsoft.Extensions.WebSockets.Internal.Tests
Assert.Equal(0x85, data[1]); Assert.Equal(0x85, data[1]);
// We don't know the mask, so we have to read it in order to verify this frame // We don't know the mask, so we have to read it in order to verify this frame
var mask = data.Slice(2, 4); var mask = new byte[] { data[2], data[3], data[4], data[5] };
var actualPayload = data.Slice(6); var actualPayload = new byte[data.Length - 6];
// Unmask the payload // Unmask the payload
for (int i = 0; i < actualPayload.Length; i++) for (int i = 0; i < actualPayload.Length; i++)
{ {
actualPayload[i] = (byte)(mask[i % 4] ^ actualPayload[i]); actualPayload[i] = (byte)(mask[i % 4] ^ data[i + 6]);
} }
Assert.Equal(new byte[] { 0x0A, 0x0B, 0x0C, 0x0D, 0x0E }, actualPayload.ToArray()); Assert.Equal(new byte[] { 0x0A, 0x0B, 0x0C, 0x0D, 0x0E }, actualPayload);
} }
[Theory] [Theory]

View File

@ -3,7 +3,7 @@
<Import Project="..\..\build\common.props" /> <Import Project="..\..\build\common.props" />
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework> <TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>