Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

THRIFT-5726 package upgrades and consolidation/improvement of build targets checks #2833

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.4" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.6" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@

<ItemGroup>
<PackageReference Include="CompareNETObjects" Version="4.79.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
<PackageReference Include="System.ServiceModel.Primitives" Version="4.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="System.ServiceModel.Primitives" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Thrift\Thrift.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.ServiceModel.Primitives" Version="4.10.0" />
<PackageReference Include="System.ServiceModel.Primitives" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

<ItemGroup>
<PackageReference Include="CompareNETObjects" Version="4.79.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="NSubstitute" Version="5.0.0" />
</ItemGroup>

Expand Down
24 changes: 12 additions & 12 deletions lib/netstd/Thrift/Protocol/TJSONProtocol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,11 @@ private async ValueTask<byte[]> ReadJsonStringAsync(bool skipContext, Cancellati
// escaped?
if (ch != TJSONProtocolConstants.EscSequences[0])
{
#if NETSTANDARD2_0
await buffer.WriteAsync(new[] {ch}, 0, 1, cancellationToken);
#else
#if NET5_0_OR_GREATER
var wbuf = new[] { ch };
await buffer.WriteAsync(wbuf.AsMemory(0, 1), cancellationToken);
#else
await buffer.WriteAsync(new[] { ch }, 0, 1, cancellationToken);
#endif
continue;
}
Expand All @@ -454,11 +454,11 @@ private async ValueTask<byte[]> ReadJsonStringAsync(bool skipContext, Cancellati
throw new TProtocolException(TProtocolException.INVALID_DATA, "Expected control char");
}
ch = TJSONProtocolConstants.EscapeCharValues[off];
#if NETSTANDARD2_0
await buffer.WriteAsync(new[] {ch}, 0, 1, cancellationToken);
#else
#if NET5_0_OR_GREATER
var wbuf = new[] { ch };
await buffer.WriteAsync( wbuf.AsMemory(0, 1), cancellationToken);
#else
await buffer.WriteAsync(new[] { ch }, 0, 1, cancellationToken);
#endif
continue;
}
Expand Down Expand Up @@ -488,20 +488,20 @@ private async ValueTask<byte[]> ReadJsonStringAsync(bool skipContext, Cancellati

codeunits.Add((char) wch);
var tmp = Utf8Encoding.GetBytes(codeunits.ToArray());
#if NETSTANDARD2_0
await buffer.WriteAsync(tmp, 0, tmp.Length, cancellationToken);
#else
#if NET5_0_OR_GREATER
await buffer.WriteAsync(tmp.AsMemory(0, tmp.Length), cancellationToken);
#else
await buffer.WriteAsync(tmp, 0, tmp.Length, cancellationToken);
#endif
codeunits.Clear();
}
else
{
var tmp = Utf8Encoding.GetBytes(new[] { (char)wch });
#if NETSTANDARD2_0
await buffer.WriteAsync(tmp, 0, tmp.Length, cancellationToken);
#else
#if NET5_0_OR_GREATER
await buffer.WriteAsync(tmp.AsMemory( 0, tmp.Length), cancellationToken);
#else
await buffer.WriteAsync(tmp, 0, tmp.Length, cancellationToken);
#endif
}
}
Expand Down
14 changes: 12 additions & 2 deletions lib/netstd/Thrift/Thrift.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,36 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" Condition="'$(TargetFramework.StartsWith(`netstandard2.`))' == 'true'" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="System.IO.Pipes" Version="[4.3,)" />
<PackageReference Include="System.IO.Pipes.AccessControl" Version="5.0.0" />
<PackageReference Include="System.IO.Pipes.AccessControl" Version="5.0.0" Condition="'$(TargetFramework.StartsWith(`netstandard2.`))' == 'true'" />
<PackageReference Include="System.Net.Http.WinHttpHandler" Version="7.0.0" />
<PackageReference Include="System.Net.NameResolution" Version="[4.3,)" />
<PackageReference Include="System.Net.Requests" Version="[4.3,)" />
<PackageReference Include="System.Net.Security" Version="4.3.2" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
</ItemGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" Condition="'$(TargetFramework.StartsWith(`netstandard2.`))' == 'false'" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" />
</ItemGroup>

<ItemGroup>
<None Include="..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.AspNetCore.Components.Web">
<Version>7.0.9</Version>
</PackageReference>
</ItemGroup>

<Target Name="SetTFMAssemblyAttributesPath" BeforeTargets="GenerateTargetFrameworkMonikerAttribute">
<PropertyGroup>
Expand Down
18 changes: 9 additions & 9 deletions lib/netstd/Thrift/Transport/Client/THttpTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ public override async ValueTask<int> ReadAsync(byte[] buffer, int offset, int le

try
{
#if NETSTANDARD2_0
var ret = await _inputStream.ReadAsync(buffer, offset, length, cancellationToken);
#else
#if NET5_0_OR_GREATER
var ret = await _inputStream.ReadAsync(new Memory<byte>(buffer, offset, length), cancellationToken);
#else
var ret = await _inputStream.ReadAsync(buffer, offset, length, cancellationToken);
#endif
if (ret == -1)
{
Expand All @@ -173,10 +173,10 @@ public override async Task WriteAsync(byte[] buffer, int offset, int length, Can
{
cancellationToken.ThrowIfCancellationRequested();

#if NETSTANDARD2_0
await _outputStream.WriteAsync(buffer, offset, length, cancellationToken);
#else
#if NET5_0_OR_GREATER
await _outputStream.WriteAsync(buffer.AsMemory(offset, length), cancellationToken);
#else
await _outputStream.WriteAsync(buffer, offset, length, cancellationToken);
#endif
}

Expand Down Expand Up @@ -245,10 +245,10 @@ public override async Task FlushAsync(CancellationToken cancellationToken)
var response = (await _httpClient.PostAsync(_uri, contentStream, cancellationToken)).EnsureSuccessStatusCode();

_inputStream?.Dispose();
#if NETSTANDARD2_0 || NETSTANDARD2_1
_inputStream = await response.Content.ReadAsStreamAsync();
#else
#if NET5_0_OR_GREATER
_inputStream = await response.Content.ReadAsStreamAsync(cancellationToken);
#else
_inputStream = await response.Content.ReadAsStreamAsync();
#endif
if (_inputStream.CanSeek)
{
Expand Down
12 changes: 6 additions & 6 deletions lib/netstd/Thrift/Transport/Client/TNamedPipeTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ public override async ValueTask<int> ReadAsync(byte[] buffer, int offset, int le
}

CheckReadBytesAvailable(length);
#if NETSTANDARD2_0
var numRead = await PipeStream.ReadAsync(buffer, offset, length, cancellationToken);
#else
#if NET5_0_OR_GREATER
var numRead = await PipeStream.ReadAsync(new Memory<byte>(buffer, offset, length), cancellationToken);
#else
var numRead = await PipeStream.ReadAsync(buffer, offset, length, cancellationToken);
#endif
CountConsumedMessageBytes(numRead);
return numRead;
Expand All @@ -98,10 +98,10 @@ public override async Task WriteAsync(byte[] buffer, int offset, int length, Can
var nBytes = Math.Min(15 * 4096, length); // 16 would exceed the limit
while (nBytes > 0)
{
#if NETSTANDARD2_0
await PipeStream.WriteAsync(buffer, offset, nBytes, cancellationToken);
#else
#if NET5_0_OR_GREATER
await PipeStream.WriteAsync(buffer.AsMemory(offset, nBytes), cancellationToken);
#else
await PipeStream.WriteAsync(buffer, offset, nBytes, cancellationToken);
#endif
offset += nBytes;
length -= nBytes;
Expand Down
12 changes: 6 additions & 6 deletions lib/netstd/Thrift/Transport/Client/TStreamTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ public override async ValueTask<int> ReadAsync(byte[] buffer, int offset, int le
"Cannot read from null inputstream");
}

#if NETSTANDARD2_0
return await InputStream.ReadAsync(buffer, offset, length, cancellationToken);
#else
#if NET5_0_OR_GREATER
return await InputStream.ReadAsync(new Memory<byte>(buffer, offset, length), cancellationToken);
#else
return await InputStream.ReadAsync(buffer, offset, length, cancellationToken);
#endif
}

Expand All @@ -96,10 +96,10 @@ public override async Task WriteAsync(byte[] buffer, int offset, int length, Can
"Cannot write to null outputstream");
}

#if NETSTANDARD2_0
await OutputStream.WriteAsync(buffer, offset, length, cancellationToken);
#else
#if NET5_0_OR_GREATER
await OutputStream.WriteAsync(buffer.AsMemory(offset, length), cancellationToken);
#else
await OutputStream.WriteAsync(buffer, offset, length, cancellationToken);
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,10 @@ public override async ValueTask<int> ReadAsync(byte[] buffer, int offset, int le
}

CheckReadBytesAvailable(length);
#if NETSTANDARD2_0
var numBytes = await PipeStream.ReadAsync(buffer, offset, length, cancellationToken);
#else
#if NET5_0_OR_GREATER
var numBytes = await PipeStream.ReadAsync(buffer.AsMemory(offset, length), cancellationToken);
#else
var numBytes = await PipeStream.ReadAsync(buffer, offset, length, cancellationToken);
#endif
CountConsumedMessageBytes(numBytes);
return numBytes;
Expand Down
2 changes: 1 addition & 1 deletion test/netstd/Client/Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<ItemGroup>
<PackageReference Include="System.Net.Http.WinHttpHandler" Version="7.0.0" />
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="[4.3,)" />
<PackageReference Include="System.ServiceModel.Primitives" Version="4.10.0" />
<PackageReference Include="System.ServiceModel.Primitives" Version="6.0.0" />
<PackageReference Include="System.Threading" Version="[4.3,)" />
</ItemGroup>

Expand Down
3 changes: 1 addition & 2 deletions test/netstd/Server/Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@

<ItemGroup>
<PackageReference Include="System.IO.Pipes" Version="4.3.0" />
<PackageReference Include="System.IO.Pipes.AccessControl" Version="5.0.0" />
<PackageReference Include="System.Net.Http.WinHttpHandler" Version="7.0.0" />
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="[4.3,)" />
<PackageReference Include="System.ServiceModel.Primitives" Version="4.10.0" />
<PackageReference Include="System.ServiceModel.Primitives" Version="6.0.0" />
<PackageReference Include="System.Threading" Version="[4.3,)" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion tutorial/netstd/Interfaces/Interfaces.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.ServiceModel.Primitives" Version="4.10.0" />
<PackageReference Include="System.ServiceModel.Primitives" Version="6.0.0" />
</ItemGroup>

<Target Name="PreBuild" BeforeTargets="_GenerateRestoreProjectSpec;Restore;Compile">
Expand Down
9 changes: 4 additions & 5 deletions tutorial/netstd/Server/Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@
<ProjectReference Include="../../../lib/netstd/Thrift/Thrift.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.2.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="7.0.0" />
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.AspNetCore.Components.Web">
<Version>7.0.9</Version>
</PackageReference>
</ItemGroup>
</Project>