Skip to content

Commit 6760ed6

Browse files
committed
- .NET 9.0 Support
- Sequential batch processing (via @MitchKuijpers on #767) - Removing .NET 6 and 7 as out of dupport - Moving .NET Framework to 4.8.
1 parent 013bc06 commit 6760ed6

29 files changed

Lines changed: 167 additions & 262 deletions

File tree

src/Directory.Build.props

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
<IsSampleProject Condition="$(MSBuildProjectName.ToLower().Contains('.samples.'))">true</IsSampleProject>
88
<IsTemplateProject Condition="$(MSBuildProjectName.ToLower().Contains('.templates.'))">true</IsTemplateProject>
99
<IsTemplatePackageProject Condition="$(MSBuildProjectName.ToLower().Contains('.templates.package'))">true</IsTemplatePackageProject>
10-
<IsNetCore Condition=" '$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net7.0' OR '$(TargetFramework)' == 'net8.0' ">true</IsNetCore>
10+
<IsNetCore Condition=" '$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net8.0' OR '$(TargetFramework)' == 'net9.0' ">true</IsNetCore>
1111
<IsPrimaryProject Condition=" '$(IsBenchmarkProject)' != 'true' And '$(IsTestProject)' != 'true' And '$(IsTestAssetProject)' != 'true' And '$(IsSampleProject)' != 'true' ">true</IsPrimaryProject>
12+
<IncludeReadmeFile Condition="Exists('$(MSBuildProjectDirectory)\readme.md')">true</IncludeReadmeFile>
1213

1314
<IncludeSource>false</IncludeSource>
1415
<IncludeSymbols>true</IncludeSymbols>
@@ -39,6 +40,7 @@
3940
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
4041
<NeutralLanguage>en-US</NeutralLanguage>
4142
<PackageLicenseExpression>MIT</PackageLicenseExpression>
43+
<PackageReadmeFile Condition="$(IncludeReadmeFile) == 'true'">readme.md</PackageReadmeFile>
4244
<!--
4345
Suppress a warning about upcoming deprecation of PackageLicenseUrl. When embedding licenses are supported,
4446
replace PackageLicenseUrl with PackageLicenseExpression.
@@ -96,25 +98,25 @@
9698
</PropertyGroup>
9799

98100
<PropertyGroup>
99-
<StandardTestTfms>net472</StandardTestTfms>
101+
<StandardTestTfms>net48</StandardTestTfms>
100102
</PropertyGroup>
101103

102104
<ItemGroup Condition=" $(IsTestProject) != 'true' and $(IsSampleProject) != 'true'">
103105
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.*" PrivateAssets="All" />
104106

105-
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
106-
<_Parameter1>$(AssemblyName.Replace("Microsoft.Restier.", "Microsoft.Restier.Tests.")), $(StrongNamePublicKey)</_Parameter1>
107-
</AssemblyAttribute>
107+
<InternalsVisibleTo Include="$(AssemblyName.Replace('Microsoft.Restier.', 'Microsoft.Restier.Tests.')), $(StrongNamePublicKey)" />
108108
</ItemGroup>
109109

110110
<ItemGroup Condition=" $(IsTestProject) == 'true' and $(IsSampleProject) != 'true'">
111+
<PackageReference Include="coverlet.collector" Version="6.*" />
111112
<PackageReference Include="FluentAssertions" Version="6.*" PrivateAssets="All" />
112-
<PackageReference Include="FluentAssertions.Analyzers" Version="0.17.*" PrivateAssets="All" />
113+
<PackageReference Include="FluentAssertions.Analyzers" Version="0.*" PrivateAssets="All" />
113114
<PackageReference Include="MSTest" Version="3.*" />
114115
</ItemGroup>
115116

116117
<ItemGroup>
117118
<None Include="$(MSBuildThisFileDirectory)dotnet-logo.png" Pack="true" PackagePath="\" Condition="'$(IsTestProject)' != 'true'" />
119+
<None Include="readme.md" Pack="true" PackagePath="\" Condition="$(IncludeReadmeFile) == 'true'" />
118120
</ItemGroup>
119121

120122
</Project>

src/Microsoft.Restier.AspNet/Batch/RestierBatchChangeSetRequestItem.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ public override async Task<ODataBatchResponseItem> SendRequestAsync(
9595
// - the ChangeSet is submitted
9696
// - the responses are created and
9797
// - the controller actions have returned
98-
await Task.WhenAll(responseTasks).ConfigureAwait(false);
98+
99+
// RWM: Process these in series for now, but I want this to be much smarter.
100+
responseTasks.ForEach(async request => await request.ConfigureAwait(false));
99101

100102
var responses = new List<HttpResponseMessage>();
101103
try
@@ -122,30 +124,24 @@ public override async Task<ODataBatchResponseItem> SendRequestAsync(
122124
throw;
123125
}
124126

125-
return new ChangeSetResponseItem(responses);
127+
return await Task.FromResult(new ChangeSetResponseItem(responses));
126128
}
127129

128130
/// <summary>
129131
/// Asynchronously submits a <see cref="ChangeSet"/>.
130132
/// </summary>
131133
/// <param name="changeSet">The change set to submit.</param>
132134
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
133-
#pragma warning disable CA1822 // Do not declare static members on generic types
134135
internal async Task SubmitChangeSet(ChangeSet changeSet)
135-
#pragma warning restore CA1822 // Do not declare static members on generic types
136-
137136
{
138-
var submitResults = await api.SubmitAsync(changeSet).ConfigureAwait(false);
137+
_ = await api.SubmitAsync(changeSet).ConfigureAwait(false);
139138
}
140139

141140
private static void DisposeResponses(IEnumerable<HttpResponseMessage> responses)
142141
{
143142
foreach (var response in responses)
144143
{
145-
if (response is not null)
146-
{
147-
response.Dispose();
148-
}
144+
response?.Dispose();
149145
}
150146
}
151147

src/Microsoft.Restier.AspNet/Batch/RestierBatchHandler.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616

1717
namespace Microsoft.Restier.AspNet.Batch
1818
{
19+
1920
/// <summary>
2021
/// Default implementation of <see cref="ODataBatchHandler"/> in RESTier.
2122
/// </summary>
2223
public class RestierBatchHandler : DefaultODataBatchHandler
2324
{
25+
2426
/// <summary>
2527
/// Initializes a new instance of the <see cref="RestierBatchHandler" /> class.
2628
/// </summary>
@@ -36,8 +38,10 @@ public RestierBatchHandler(HttpServer httpServer)
3638
/// <param name="request">The HTTP request that contains the batch requests.</param>
3739
/// <param name="cancellationToken">The cancellation token.</param>
3840
/// <returns>The task object that represents this asynchronous operation.</returns>
39-
public override async Task<IList<ODataBatchRequestItem>> ParseBatchRequestsAsync(HttpRequestMessage request, CancellationToken cancellationToken)
41+
public async override Task<IList<ODataBatchRequestItem>> ParseBatchRequestsAsync(HttpRequestMessage request, CancellationToken cancellationToken)
4042
{
43+
// TODO: RWM: I want to get a LOT smarter about batch processing and separate dependent requests from independent requests.
44+
// That way independent requests can be processed in parallel.
4145
Ensure.NotNull(request, nameof(request));
4246

4347
var requestContainer = request.CreateRequestContainer(ODataRouteName);
@@ -88,4 +92,5 @@ public override async Task<IList<ODataBatchRequestItem>> ParseBatchRequestsAsync
8892
protected virtual RestierBatchChangeSetRequestItem CreateRestierBatchChangeSetRequestItem(ApiBase api, IList<HttpRequestMessage> changeSetRequests) =>
8993
new RestierBatchChangeSetRequestItem(api, changeSetRequests);
9094
}
95+
9196
}

src/Microsoft.Restier.AspNet/Microsoft.Restier.AspNet.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<AssemblyName>Microsoft.Restier.AspNet</AssemblyName>
55
<RootNamespace>Microsoft.Restier.AspNet</RootNamespace>
6-
<TargetFrameworks>net472</TargetFrameworks>
6+
<TargetFrameworks>net48</TargetFrameworks>
77
<DocumentationFile>$(DocumentationFile)\$(AssemblyName).xml</DocumentationFile>
88
</PropertyGroup>
99

src/Microsoft.Restier.AspNetCore.Swagger/Microsoft.Restier.AspNetCore.Swagger.csproj

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

33
<PropertyGroup>
4-
<TargetFrameworks>net8.0;net7.0;net6.0;</TargetFrameworks>
4+
<TargetFrameworks>net9.0;net8.0;</TargetFrameworks>
55
<StrongNamePublicKey>$(StrongNamePublicKey)</StrongNamePublicKey>
66
<DocumentationFile>$(DocumentationFile)\$(AssemblyName).xml</DocumentationFile>
77
<PackageReadmeFile>README.md</PackageReadmeFile>
@@ -18,10 +18,4 @@
1818
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="[6.*, 7.0.0)" />
1919
</ItemGroup>
2020

21-
<ItemGroup>
22-
<None Include="README.md" Pack="true" PackagePath="">
23-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
24-
</None>
25-
</ItemGroup>
26-
2721
</Project>

src/Microsoft.Restier.AspNetCore/Batch/RestierBatchChangeSetRequestItem.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public RestierBatchChangeSetRequestItem(ApiBase api, IEnumerable<HttpContext> co
4242
/// </summary>
4343
/// <param name="handler">The handler for processing a message.</param>
4444
/// <returns>The task object that contains the batch response.</returns>
45-
public override async Task<ODataBatchResponseItem> SendRequestAsync(RequestDelegate handler)
45+
public async override Task<ODataBatchResponseItem> SendRequestAsync(RequestDelegate handler)
4646
{
4747
Ensure.NotNull(handler, nameof(handler));
4848

@@ -94,7 +94,9 @@ public override async Task<ODataBatchResponseItem> SendRequestAsync(RequestDeleg
9494
// - the ChangeSet is submitted
9595
// - the responses are created and
9696
// - the controller actions have returned
97-
await Task.WhenAll(responseTasks).ConfigureAwait(false);
97+
98+
// RWM: Process these in series for now, but I want this to be much smarter.
99+
responseTasks.ForEach(async request => await request.ConfigureAwait(false));
98100

99101
var returnContexts = new List<HttpContext>();
100102

@@ -113,7 +115,7 @@ public override async Task<ODataBatchResponseItem> SendRequestAsync(RequestDeleg
113115
}
114116
}
115117

116-
return new ChangeSetResponseItem(returnContexts);
118+
return await Task.FromResult(new ChangeSetResponseItem(returnContexts));
117119
}
118120

119121
/// <summary>

src/Microsoft.Restier.AspNetCore/Microsoft.Restier.AspNetCore.csproj

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<AssemblyName>Microsoft.Restier.AspNetCore</AssemblyName>
55
<RootNamespace>Microsoft.Restier.AspNetCore</RootNamespace>
6-
<TargetFrameworks>net6.0;net7.0;net8.0;</TargetFrameworks>
6+
<TargetFrameworks>net8.0;net9.0;</TargetFrameworks>
77
<StrongNamePublicKey>$(StrongNamePublicKey)</StrongNamePublicKey>
88
<DocumentationFile>$(DocumentationFile)\$(AssemblyName).xml</DocumentationFile>
99
</PropertyGroup>
@@ -52,15 +52,8 @@
5252
<Import Project="..\Microsoft.Restier.AspNet.Shared\Microsoft.Restier.AspNet.Shared.projitems" Label="Shared" />
5353

5454
<ItemGroup>
55-
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
56-
<_Parameter1>Microsoft.Restier.Tests.AspNetCorePlusEF6, $(StrongNamePublicKey)</_Parameter1>
57-
</AssemblyAttribute>
58-
</ItemGroup>
59-
60-
<ItemGroup>
61-
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
62-
<_Parameter1>Microsoft.Restier.Breakdance, $(StrongNamePublicKey)</_Parameter1>
63-
</AssemblyAttribute>
55+
<InternalsVisibleTo Include="Microsoft.Restier.Tests.AspNetCorePlusEF6, $(StrongNamePublicKey)" />
56+
<InternalsVisibleTo Include="Microsoft.Restier.Breakdance, $(StrongNamePublicKey)" />
6457
</ItemGroup>
6558

6659
</Project>

src/Microsoft.Restier.Breakdance/Microsoft.Restier.Breakdance.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<AssemblyName>Microsoft.Restier.Breakdance</AssemblyName>
55
<RootNamespace>Microsoft.Restier.Breakdance</RootNamespace>
6-
<TargetFrameworks>net472;net6.0;net7.0;net8.0;</TargetFrameworks>
6+
<TargetFrameworks>net48;net8.0;net9.0;</TargetFrameworks>
77
<DocumentationFile>$(DocumentationFile)\$(AssemblyName).xml</DocumentationFile>
88
</PropertyGroup>
99

@@ -31,21 +31,21 @@
3131
</PropertyGroup>
3232

3333
<ItemGroup>
34-
<PackageReference Include="EasyAF.Core" Version="[2.*-*, 3.0.0)" />
35-
<PackageReference Include="EasyAF.Http" Version="[2.*-*, 3.0.0)" />
34+
<PackageReference Include="EasyAF.Core" Version="[3.*, 4.0.0)" />
35+
<PackageReference Include="EasyAF.Http" Version="[3.*, 4.0.0)" />
3636
</ItemGroup>
3737

3838
<ItemGroup Condition="'$(IsNetCore)' != 'true'">
39-
<PackageReference Include="Breakdance.WebApi" Version="[6.*, 7.0.0)" />
40-
<PackageReference Include="EasyAF.Http.NewtonsoftJson" Version="[2.*-*, 3.0.0)" />
39+
<PackageReference Include="Breakdance.WebApi" Version="[7.*, 8.0.0)" />
40+
<PackageReference Include="EasyAF.Http.NewtonsoftJson" Version="[3.*, 4.0.0)" />
4141
<PackageReference Include="Microsoft.AspNet.OData" Version="[7.*, 8.0.0)" />
4242

4343
<ProjectReference Include="..\Microsoft.Restier.AspNet\Microsoft.Restier.AspNet.csproj" />
4444
</ItemGroup>
4545

4646
<ItemGroup Condition="'$(IsNetCore)' == 'true'">
47-
<PackageReference Include="Breakdance.AspNetCore" Version="[6.*, 7.0.0)"/>
48-
<PackageReference Include="EasyAF.Http.SystemTextJson" Version="[2.*-*, 3.0.0)" />
47+
<PackageReference Include="Breakdance.AspNetCore" Version="[7.*, 8.0.0)"/>
48+
<PackageReference Include="EasyAF.Http.SystemTextJson" Version="[3.*, 4.0.0)" />
4949

5050
<ProjectReference Include="..\Microsoft.Restier.AspNetCore\Microsoft.Restier.AspNetCore.csproj" />
5151
</ItemGroup>
Lines changed: 19 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net472;netstandard2.1;net6.0;net7.0;net8.0</TargetFrameworks>
4+
<TargetFrameworks>net48;netstandard2.1;net8.0;net9.0;</TargetFrameworks>
55
<StrongNamePublicKey>$(StrongNamePublicKey)</StrongNamePublicKey>
66
<DocumentationFile>$(DocumentationFile)\$(AssemblyName).xml</DocumentationFile>
77
</PropertyGroup>
@@ -24,27 +24,23 @@
2424
<PackageReference Include="Microsoft.OData.Core" Version="[7.*, 8.0.0)" />
2525
<PackageReference Include="Microsoft.OData.Edm" Version="[7.*, 8.0.0)" />
2626
<PackageReference Include="Newtonsoft.Json" Version="[13.0.1, 15.0.0)" />
27-
<PackageReference Include="System.ComponentModel.Annotations" Version="[5.*, 9.0.0)" />
27+
<PackageReference Include="System.ComponentModel.Annotations" Version="[5.*, 10.0.0)" />
2828
</ItemGroup>
2929

30-
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
31-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="[8.*-*, 9.0.0)" />
32-
</ItemGroup>
33-
34-
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
35-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="[7.*, 9.0.0)" />
30+
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
31+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="[9.*, 10.0.0)" />
3632
</ItemGroup>
3733

38-
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
39-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="[6.*, 9.0.0)" />
34+
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
35+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="[8.*, 10.0.0)" />
4036
</ItemGroup>
4137

42-
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1' OR '$(TargetFramework)' == 'net472'">
43-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="[6.*, 9.0.0)" />
38+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1' OR '$(TargetFramework)' == 'net48'">
39+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="[8.*, 10.0.0)" />
4440
</ItemGroup>
4541

4642
<ItemGroup>
47-
<Reference Include="System.Net.Http" Condition=" '$(TargetFramework)' == 'net472' " />
43+
<Reference Include="System.Net.Http" Condition=" '$(TargetFramework)' == 'net48' " />
4844
</ItemGroup>
4945

5046
<ItemGroup>
@@ -64,36 +60,16 @@
6460
</ItemGroup>
6561

6662
<ItemGroup>
67-
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
68-
<_Parameter1>Microsoft.Restier.AspNet, $(StrongNamePublicKey)</_Parameter1>
69-
</AssemblyAttribute>
70-
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
71-
<_Parameter1>Microsoft.Restier.AspNetCore, $(StrongNamePublicKey)</_Parameter1>
72-
</AssemblyAttribute>
73-
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
74-
<_Parameter1>Microsoft.Restier.AspNetCore.Swagger, $(StrongNamePublicKey)</_Parameter1>
75-
</AssemblyAttribute>
76-
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
77-
<_Parameter1>Microsoft.Restier.EntityFramework, $(StrongNamePublicKey)</_Parameter1>
78-
</AssemblyAttribute>
79-
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
80-
<_Parameter1>Microsoft.Restier.EntityFrameworkCore, $(StrongNamePublicKey)</_Parameter1>
81-
</AssemblyAttribute>
82-
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
83-
<_Parameter1>Microsoft.Restier.Tests.EntityFramework, $(StrongNamePublicKey)</_Parameter1>
84-
</AssemblyAttribute>
85-
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
86-
<_Parameter1>Microsoft.Restier.Tests.AspNet, $(StrongNamePublicKey)</_Parameter1>
87-
</AssemblyAttribute>
88-
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
89-
<_Parameter1>Microsoft.Restier.Tests.AspNetCore, $(StrongNamePublicKey)</_Parameter1>
90-
</AssemblyAttribute>
91-
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
92-
<_Parameter1>Microsoft.Restier.Tests.AspNetCorePlusEF6, $(StrongNamePublicKey)</_Parameter1>
93-
</AssemblyAttribute>
94-
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
95-
<_Parameter1>Microsoft.Restier.Tests.Shared, $(StrongNamePublicKey)</_Parameter1>
96-
</AssemblyAttribute>
63+
<InternalsVisibleTo Include="Microsoft.Restier.AspNet, $(StrongNamePublicKey)" />
64+
<InternalsVisibleTo Include="Microsoft.Restier.AspNetCore, $(StrongNamePublicKey)" />
65+
<InternalsVisibleTo Include="Microsoft.Restier.AspNetCore.Swagger, $(StrongNamePublicKey)" />
66+
<InternalsVisibleTo Include="Microsoft.Restier.EntityFramework, $(StrongNamePublicKey)" />
67+
<InternalsVisibleTo Include="Microsoft.Restier.EntityFrameworkCore, $(StrongNamePublicKey)" />
68+
<InternalsVisibleTo Include="Microsoft.Restier.Tests.EntityFramework, $(StrongNamePublicKey)" />
69+
<InternalsVisibleTo Include="Microsoft.Restier.Tests.AspNet, $(StrongNamePublicKey)" />
70+
<InternalsVisibleTo Include="Microsoft.Restier.Tests.AspNetCore, $(StrongNamePublicKey)" />
71+
<InternalsVisibleTo Include="Microsoft.Restier.Tests.AspNetCorePlusEF6, $(StrongNamePublicKey)" />
72+
<InternalsVisibleTo Include="Microsoft.Restier.Tests.Shared, $(StrongNamePublicKey)" />
9773
</ItemGroup>
9874

9975
</Project>

src/Microsoft.Restier.Core/Submit/DefaultSubmitHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ public async Task<SubmitResult> SubmitAsync(SubmitContext context, CancellationT
9090

9191
await PerformPersist(context, cancellationToken).ConfigureAwait(false);
9292

93-
#if NET472
94-
while(context.ChangeSet.Entries.TryDequeue(out _));
93+
#if NET48
94+
while (context.ChangeSet.Entries.TryDequeue(out _))
9595
#else
9696
context.ChangeSet.Entries.Clear();
9797
#endif

0 commit comments

Comments
 (0)