Skip to content

Commit 8999fce

Browse files
committed
Update core dependencies
This also removes testing on .NET Core 3.1, which is out of support. Signed-off-by: Jon Skeet <[email protected]>
1 parent 1fe92ab commit 8999fce

File tree

11 files changed

+26
-33
lines changed

11 files changed

+26
-33
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ jobs:
1717
- name: Check out our repo
1818
uses: actions/checkout@v3
1919

20-
# We need the .NET Core 3.1 runtime for testing
21-
- name: Setup .NET Core 3.1
22-
uses: actions/setup-dotnet@v3
23-
with:
24-
dotnet-version: 3.1.x
25-
2620
# Build with .NET 6.0 SDK
2721
- name: Setup .NET 6.0
2822
uses: actions/setup-dotnet@v3

.github/workflows/nuget.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ jobs:
1515
- name: Check out our repo
1616
uses: actions/checkout@v3
1717

18-
# We need the .NET Core 3.1 runtime for testing
19-
- name: Setup .NET Core 3.1
20-
uses: actions/setup-dotnet@v3
21-
with:
22-
dotnet-version: 3.1.x
23-
2418
# Build with .NET 6.0 SDK
2519
- name: Setup .NET 6.0
2620
uses: actions/setup-dotnet@v3
@@ -37,4 +31,3 @@ jobs:
3731
run: |
3832
dotnet pack -c Release -p:ContinuousIntegrationBuild=true -o $PWD/nuget
3933
for file in nuget/*.nupkg; do dotnet nuget push -s https://api.nuget.org/v3/index.json -k ${{secrets.NUGET_API_KEY}} $file; done
40-

samples/CloudNative.CloudEvents.AspNetCoreSample/CloudNative.CloudEvents.AspNetCoreSample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
4+
<TargetFrameworks>net6.0</TargetFrameworks>
55
</PropertyGroup>
66

77
<ItemGroup>

samples/HttpSend/HttpSend.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<TargetFramework>net6.0</TargetFramework>
66
</PropertyGroup>
77

88
<ItemGroup>

src/CloudNative.CloudEvents/CloudNative.CloudEvents.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="System.Memory" Version="4.5.4" />
12+
<PackageReference Include="System.Memory" Version="4.5.5" />
1313
<!-- Source-only package with nullable reference annotations. -->
14-
<PackageReference Include="Nullable" Version="1.3.0" PrivateAssets="All" />
14+
<PackageReference Include="Nullable" Version="1.3.1" PrivateAssets="All" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

test/CloudNative.CloudEvents.IntegrationTests/CloudNative.CloudEvents.IntegrationTests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.0.0" />
9-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2" />
8+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.14" />
9+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
1010
<PackageReference Include="xunit" Version="2.4.2" />
1111
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
1212
</ItemGroup>

test/CloudNative.CloudEvents.UnitTests/CloudNative.CloudEvents.UnitTests.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
5-
<LangVersion>8.0</LangVersion>
4+
<TargetFramework>net6.0</TargetFramework>
65
<Nullable>enable</Nullable>
76
</PropertyGroup>
87

98
<ItemGroup>
109
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
11-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
1211
<PackageReference Include="xunit" Version="2.4.2" />
1312
<PackageReference Include="xunit.runner.console" Version="2.4.2">
1413
<PrivateAssets>all</PrivateAssets>

test/CloudNative.CloudEvents.UnitTests/DocumentationSamples.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using System.IO;
1414
using System.Linq;
1515
using System.Net.Http;
16+
using System.Net.Http.Headers;
1617
using System.Threading.Tasks;
1718
using Xunit;
1819

@@ -160,12 +161,15 @@ private static async Task<HttpRequest> ConvertHttpRequestMessage(HttpRequestMess
160161
{
161162
request.Headers[header.Key] = header.Value.Single();
162163
}
163-
foreach (var header in message.Content.Headers)
164+
if (message.Content?.Headers is HttpContentHeaders contentHeaders)
164165
{
165-
request.Headers[header.Key] = header.Value.Single();
166+
foreach (var header in contentHeaders)
167+
{
168+
request.Headers[header.Key] = header.Value.Single();
169+
}
166170
}
167171

168-
var contentBytes = await message.Content.ReadAsByteArrayAsync();
172+
var contentBytes = await (message.Content?.ReadAsByteArrayAsync() ?? Task.FromResult(Array.Empty<byte>()));
169173
request.Body = new MemoryStream(contentBytes);
170174
return request;
171175
}

test/CloudNative.CloudEvents.UnitTests/Http/HttpListenerExtensionsTest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public async Task CopyToHttpListenerResponseAsync_BinaryMode()
196196
async context => await cloudEvent.CopyToHttpListenerResponseAsync(context.Response, ContentMode.Binary, formatter));
197197
response.EnsureSuccessStatusCode();
198198
var content = response.Content;
199-
Assert.Equal("text/plain", content.Headers.ContentType.MediaType);
199+
Assert.Equal("text/plain", content.Headers.ContentType!.MediaType);
200200
Assert.Equal("plain text", await content.ReadAsStringAsync());
201201
Assert.Equal("1.0", response.Headers.GetValues("ce-specversion").Single());
202202
Assert.Equal(cloudEvent.Type, response.Headers.GetValues("ce-type").Single());
@@ -229,7 +229,7 @@ public async Task CopyToListenerResponseAsync_NonBinaryDataButNoDataContentType_
229229
var response = await GetResponseAsync(
230230
async context => await cloudEvent.CopyToHttpListenerResponseAsync(context.Response, ContentMode.Binary, formatter));
231231
var content = response.Content;
232-
Assert.Equal("application/json", content.Headers.ContentType.MediaType);
232+
Assert.Equal("application/json", content.Headers.ContentType!.MediaType);
233233
Assert.Equal("\"plain text\"", await content.ReadAsStringAsync());
234234
}
235235

@@ -255,7 +255,7 @@ public async Task CopyToHttpListenerResponseAsync_StructuredMode()
255255
async context => await cloudEvent.CopyToHttpListenerResponseAsync(context.Response, ContentMode.Structured, formatter));
256256
response.EnsureSuccessStatusCode();
257257
var content = response.Content;
258-
Assert.Equal(MimeUtilities.MediaType + "+json", content.Headers.ContentType.MediaType);
258+
Assert.Equal(MimeUtilities.MediaType + "+json", content.Headers.ContentType!.MediaType);
259259
var bytes = await content.ReadAsByteArrayAsync();
260260

261261
var parsed = new JsonEventFormatter().DecodeStructuredModeMessage(bytes, MimeUtilities.ToContentType(content.Headers.ContentType), extensionAttributes: null);
@@ -284,7 +284,7 @@ public async Task CopyToHttpListenerResponseAsync_Batch()
284284

285285
response.EnsureSuccessStatusCode();
286286
var content = response.Content;
287-
Assert.Equal(MimeUtilities.BatchMediaType + "+json", content.Headers.ContentType.MediaType);
287+
Assert.Equal(MimeUtilities.BatchMediaType + "+json", content.Headers.ContentType!.MediaType);
288288
var bytes = await content.ReadAsByteArrayAsync();
289289
var parsedBatch = new JsonEventFormatter().DecodeBatchModeMessage(bytes, MimeUtilities.ToContentType(content.Headers.ContentType), extensionAttributes: null);
290290
AssertBatchesEqual(batch, parsedBatch);
@@ -299,7 +299,7 @@ private async Task<T> SendRequestAsync<T>(HttpRequestMessage request, Func<HttpL
299299
var guid = Guid.NewGuid().ToString();
300300
request.Headers.Add(TestContextHeader, guid);
301301

302-
T result = default;
302+
T result = default!;
303303
bool executed = false;
304304

305305
PendingRequests[guid] = async context =>

test/CloudNative.CloudEvents.UnitTests/Http/HttpTestBase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ private async Task ProcessRequestsAsync()
8484

8585
private async Task HandleContext(HttpListenerContext requestContext)
8686
{
87-
var ctxHeaderValue = requestContext.Request.Headers[TestContextHeader];
87+
var ctxHeaderValue = requestContext.Request.Headers[TestContextHeader]
88+
?? throw new InvalidOperationException("Test context header was missing");
8889

8990
if (PendingRequests.TryRemove(ctxHeaderValue, out var pending))
9091
{

0 commit comments

Comments
 (0)