Skip to content

Commit 3896783

Browse files
authored
Dev (#14)
* - update several dependency injection extension methods - add endpoint tests - add test step to github release workflow - bump version * - update deps to latest
1 parent 85702f7 commit 3896783

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1675
-15
lines changed

.github/workflows/release.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ env:
99
ENDPOINTSPROJECTNAME: "ModEndpoints"
1010
REMOTESERVICESCOREPROJECTNAME: "ModEndpoints.RemoteServices.Core"
1111
REMOTESERVICESPROJECTNAME: "ModEndpoints.RemoteServices"
12+
13+
ENDPOINTSTESTPROJECTNAME: "ModEndpoints.Tests"
1214

1315
jobs:
1416
build:
@@ -39,6 +41,11 @@ jobs:
3941
- name: Build
4042
run: dotnet build ${{ env.ENDPOINTSPROJECTNAME }} --configuration Release --no-restore
4143
working-directory: src
44+
45+
- name: Test
46+
run: dotnet test ${{ env.ENDPOINTSTESTPROJECTNAME }} --no-restore --verbosity normal
47+
working-directory: tests
48+
4249
- name: Package nuget remote services core
4350
run: dotnet pack ${{ env.REMOTESERVICESCOREPROJECTNAME }} --configuration Release --no-build -o:package
4451
working-directory: src

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1919
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
2020

21-
<Version>0.6.4</Version>
21+
<Version>0.6.5</Version>
2222
</PropertyGroup>
2323
</Project>

ModEndpoints.sln

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShowcaseWebApi.FeatureContr
3838
EndProject
3939
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceEndpointClient", "samples\ServiceEndpointClient\ServiceEndpointClient.csproj", "{286D2D88-E9F9-EB56-64BA-76C95D7ED0D8}"
4040
EndProject
41+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
42+
EndProject
43+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModEndpoints.TestServer", "tests\ModEndpoints.TestServer\ModEndpoints.TestServer.csproj", "{338C85BC-44D4-D6DA-437B-EE2BC45F041A}"
44+
EndProject
45+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModEndpoints.Tests", "tests\ModEndpoints.Tests\ModEndpoints.Tests.csproj", "{31B5E39A-9973-1BFE-42E6-485AE83C4910}"
46+
EndProject
4147
Global
4248
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4349
Debug|Any CPU = Debug|Any CPU
@@ -76,6 +82,14 @@ Global
7682
{286D2D88-E9F9-EB56-64BA-76C95D7ED0D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
7783
{286D2D88-E9F9-EB56-64BA-76C95D7ED0D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
7884
{286D2D88-E9F9-EB56-64BA-76C95D7ED0D8}.Release|Any CPU.Build.0 = Release|Any CPU
85+
{338C85BC-44D4-D6DA-437B-EE2BC45F041A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
86+
{338C85BC-44D4-D6DA-437B-EE2BC45F041A}.Debug|Any CPU.Build.0 = Debug|Any CPU
87+
{338C85BC-44D4-D6DA-437B-EE2BC45F041A}.Release|Any CPU.ActiveCfg = Release|Any CPU
88+
{338C85BC-44D4-D6DA-437B-EE2BC45F041A}.Release|Any CPU.Build.0 = Release|Any CPU
89+
{31B5E39A-9973-1BFE-42E6-485AE83C4910}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
90+
{31B5E39A-9973-1BFE-42E6-485AE83C4910}.Debug|Any CPU.Build.0 = Debug|Any CPU
91+
{31B5E39A-9973-1BFE-42E6-485AE83C4910}.Release|Any CPU.ActiveCfg = Release|Any CPU
92+
{31B5E39A-9973-1BFE-42E6-485AE83C4910}.Release|Any CPU.Build.0 = Release|Any CPU
7993
EndGlobalSection
8094
GlobalSection(SolutionProperties) = preSolution
8195
HideSolutionNode = FALSE
@@ -90,6 +104,8 @@ Global
90104
{3CDE6A69-09BA-4714-8DCD-D934BA27EBEB} = {04A4BF42-A7C5-4D83-A137-90D6C3E68A00}
91105
{DE3AA974-14C3-402F-93F4-A4A5D3DC0131} = {74B81852-D3A9-49BA-A62F-A653FBB36665}
92106
{286D2D88-E9F9-EB56-64BA-76C95D7ED0D8} = {74B81852-D3A9-49BA-A62F-A653FBB36665}
107+
{338C85BC-44D4-D6DA-437B-EE2BC45F041A} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
108+
{31B5E39A-9973-1BFE-42E6-485AE83C4910} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
93109
EndGlobalSection
94110
GlobalSection(ExtensibilityGlobals) = postSolution
95111
SolutionGuid = {8AD0451A-6029-4173-B7C5-737D09139323}

samples/ServiceEndpointClient/ServiceEndpointClient.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
10-
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="9.0.2" />
9+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.4" />
10+
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="9.0.4" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

samples/ShowcaseWebApi/ShowcaseWebApi.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.2" />
9-
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />
8+
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.4" />
9+
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.1.1" />
1010
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.11.0" />
1111
<PackageReference Include="Asp.Versioning.Http" Version="8.1.0" />
1212
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />

src/ModEndpoints.Core/DependencyInjectionExtensions.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ public static class DependencyInjectionExtensions
1111
{
1212
public static IServiceCollection AddModEndpointsCoreFromAssemblyContaining<T>(
1313
this IServiceCollection services,
14-
Assembly assembly,
1514
ServiceLifetime lifetime = ServiceLifetime.Transient)
1615
{
1716
return services.AddModEndpointsCoreFromAssembly(typeof(T).Assembly, lifetime);
@@ -39,7 +38,7 @@ private static IServiceCollection AddRouteGroupsCoreFromAssembly(
3938
.Where(type => type is { IsAbstract: false, IsInterface: false } &&
4039
type.IsAssignableTo(typeof(IRouteGroupConfigurator)) &&
4140
type != typeof(RootRouteGroup) &&
42-
!type.GetCustomAttributes(typeof(DoNotRegisterAttribute)).Any())
41+
!type.GetCustomAttributes<DoNotRegisterAttribute>().Any())
4342
.Select(type => ServiceDescriptor.DescribeKeyed(typeof(IRouteGroupConfigurator), type, type, lifetime))
4443
.ToArray();
4544

@@ -48,7 +47,7 @@ private static IServiceCollection AddRouteGroupsCoreFromAssembly(
4847
return services;
4948
}
5049

51-
public static IServiceCollection AddEndpointsCoreFromAssembly(
50+
private static IServiceCollection AddEndpointsCoreFromAssembly(
5251
this IServiceCollection services,
5352
Assembly assembly,
5453
ServiceLifetime lifetime)
@@ -57,7 +56,7 @@ public static IServiceCollection AddEndpointsCoreFromAssembly(
5756
.DefinedTypes
5857
.Where(type => type is { IsAbstract: false, IsInterface: false } &&
5958
type.IsAssignableTo(typeof(IEndpointConfigurator)) &&
60-
!type.GetCustomAttributes(typeof(DoNotRegisterAttribute)).Any());
59+
!type.GetCustomAttributes<DoNotRegisterAttribute>().Any());
6160

6261
CheckServiceEndpointRegistrations(endpointTypes);
6362

src/ModEndpoints.Core/ModEndpoints.Core.csproj

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

2323
<ItemGroup>
2424
<PackageReference Include="FluentValidation" Version="11.11.0" />
25-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.2" />
25+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.4" />
2626
</ItemGroup>
2727

2828
<ItemGroup>

src/ModEndpoints.RemoteServices/DependencyInjectionExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public static IServiceCollection AddRemoteServicesWithNewClient(
165165
.DefinedTypes
166166
.Where(type => type is { IsAbstract: false, IsInterface: false } &&
167167
type.IsAssignableTo(typeof(IServiceRequestMarker)) &&
168-
!type.GetCustomAttributes(typeof(DoNotRegisterAttribute)).Any());
168+
!type.GetCustomAttributes<DoNotRegisterAttribute>().Any());
169169

170170
if (requestFilterPredicate is not null)
171171
{
@@ -209,7 +209,7 @@ public static IServiceCollection AddRemoteServicesToExistingClient(
209209
.DefinedTypes
210210
.Where(type => type is { IsAbstract: false, IsInterface: false } &&
211211
type.IsAssignableTo(typeof(IServiceRequestMarker)) &&
212-
!type.GetCustomAttributes(typeof(DoNotRegisterAttribute)).Any());
212+
!type.GetCustomAttributes<DoNotRegisterAttribute>().Any());
213213

214214
if (requestFilterPredicate is not null)
215215
{
@@ -232,7 +232,7 @@ private static IServiceCollection AddRemoteServiceWithNewClientInternal(
232232
Action<IServiceProvider, HttpClient> configureClient,
233233
Action<IHttpClientBuilder>? configureClientBuilder)
234234
{
235-
if (requestType.GetCustomAttributes(typeof(DoNotRegisterAttribute)).Any())
235+
if (requestType.GetCustomAttributes<DoNotRegisterAttribute>().Any())
236236
{
237237
throw new InvalidOperationException(string.Format(RequestTypeFlaggedAsDoNotRegister, requestType));
238238
}
@@ -257,7 +257,7 @@ private static IServiceCollection AddRemoteServiceToExistingClientInternal(
257257
Type requestType,
258258
string clientName)
259259
{
260-
if (requestType.GetCustomAttributes(typeof(DoNotRegisterAttribute)).Any())
260+
if (requestType.GetCustomAttributes<DoNotRegisterAttribute>().Any())
261261
{
262262
throw new InvalidOperationException(string.Format(RequestTypeFlaggedAsDoNotRegister, requestType));
263263
}

src/ModEndpoints.RemoteServices/ModEndpoints.RemoteServices.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</ItemGroup>
2222

2323
<ItemGroup>
24-
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.2" />
24+
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.4" />
2525
<PackageReference Include="ModResults" Version="1.0.0" />
2626
</ItemGroup>
2727

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using ModEndpoints.Core;
2+
3+
namespace ModEndpoints.TestServer.Features.Books.Configuration;
4+
5+
[MapToGroup<FeaturesRouteGroup>()]
6+
internal class BooksRouteGroup : RouteGroupConfigurator
7+
{
8+
protected override void Configure(
9+
IServiceProvider serviceProvider,
10+
IRouteGroupConfigurator? parentRouteGroup)
11+
{
12+
MapGroup("/books");
13+
}
14+
}

0 commit comments

Comments
 (0)