Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build-and-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ jobs:
steps:
- name: Install Dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: 9.x
- name: Check-out
uses: actions/checkout@master
- name: Building (Release)
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/test-and-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: test-and-report.yml
on:
pull_request:
push:
branches:
- 'main'
paths:
- 'samples/**'
- 'src/**'
Expand All @@ -15,15 +17,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check-out
uses: actions/checkout@master
uses: actions/checkout@v4
- name: Install Dotnet
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.x
9.x
- name: Install ReportGenerator
run: dotnet tool install dotnet-reportgenerator-globaltool --tool-path tools
- name: Test
run: dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=lcov
- name: Generate Coverage Report
run: tools/reportgenerator "-reports:tests/**/coverage.info" "-targetdir:./coverage/" -reporttypes:lcov
run: tools/reportgenerator "-reports:tests/**/coverage.*.info" "-targetdir:./coverage/" -reporttypes:lcov
- name: Upload to Coveralls
uses: coverallsapp/github-action@master
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
[Bb]in/
[Tt]est[Rr]esults/
nupkgs/
.idea/
.editorconfig
45 changes: 33 additions & 12 deletions Panner.AspNetCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Panner.AspNetCore", "src\Pa
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Panner.AspNetCore.Tests", "tests\Panner.AspNetCore.Tests\Panner.AspNetCore.Tests.csproj", "{2FA57751-5D7A-430D-89F8-CB06B75937FA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCore3_1", "samples\AspNetCore3_1\AspNetCore3_1.csproj", "{FC10AD84-66D7-4C98-9A3B-620D6ACC1357}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApiNet9MinimalFluent", "samples\WebApiNet9MinimalFluent\WebApiNet9MinimalFluent.csproj", "{84F94171-2814-4993-9BC6-43D7F9535027}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet5_0", "samples\AspNet5_0\AspNet5_0.csproj", "{00CBFE9C-C93E-4DC9-BDE5-87A10E170CF5}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApiNet9ControllersFluent", "samples\WebApiNet9ControllersFluent\WebApiNet9ControllersFluent.csproj", "{D7BE4E4E-38E0-4DCC-A8CB-7D9CE22994DB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAPINet8MinimalFluent", "samples\WebAPINet8MinimalFluent\WebAPINet8MinimalFluent.csproj", "{39BD3C99-BBB1-48BA-B015-92C30A8813CC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApi8ControllersFluent", "samples\WebApi8ControllersFluent\WebApi8ControllersFluent.csproj", "{8580601A-A694-4656-B72C-B56C3BEBF81B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastEndpointsNet9", "sample\FastEndpoints\Source\FastEndpointsNet9.csproj", "{D155BED8-7ABE-4EA4-8C75-3E3CFFDCDF5C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -27,21 +33,36 @@ Global
{2FA57751-5D7A-430D-89F8-CB06B75937FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2FA57751-5D7A-430D-89F8-CB06B75937FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2FA57751-5D7A-430D-89F8-CB06B75937FA}.Release|Any CPU.Build.0 = Release|Any CPU
{FC10AD84-66D7-4C98-9A3B-620D6ACC1357}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FC10AD84-66D7-4C98-9A3B-620D6ACC1357}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC10AD84-66D7-4C98-9A3B-620D6ACC1357}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC10AD84-66D7-4C98-9A3B-620D6ACC1357}.Release|Any CPU.Build.0 = Release|Any CPU
{00CBFE9C-C93E-4DC9-BDE5-87A10E170CF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00CBFE9C-C93E-4DC9-BDE5-87A10E170CF5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00CBFE9C-C93E-4DC9-BDE5-87A10E170CF5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00CBFE9C-C93E-4DC9-BDE5-87A10E170CF5}.Release|Any CPU.Build.0 = Release|Any CPU
{84F94171-2814-4993-9BC6-43D7F9535027}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{84F94171-2814-4993-9BC6-43D7F9535027}.Debug|Any CPU.Build.0 = Debug|Any CPU
{84F94171-2814-4993-9BC6-43D7F9535027}.Release|Any CPU.ActiveCfg = Release|Any CPU
{84F94171-2814-4993-9BC6-43D7F9535027}.Release|Any CPU.Build.0 = Release|Any CPU
{D7BE4E4E-38E0-4DCC-A8CB-7D9CE22994DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D7BE4E4E-38E0-4DCC-A8CB-7D9CE22994DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D7BE4E4E-38E0-4DCC-A8CB-7D9CE22994DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D7BE4E4E-38E0-4DCC-A8CB-7D9CE22994DB}.Release|Any CPU.Build.0 = Release|Any CPU
{39BD3C99-BBB1-48BA-B015-92C30A8813CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{39BD3C99-BBB1-48BA-B015-92C30A8813CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{39BD3C99-BBB1-48BA-B015-92C30A8813CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{39BD3C99-BBB1-48BA-B015-92C30A8813CC}.Release|Any CPU.Build.0 = Release|Any CPU
{8580601A-A694-4656-B72C-B56C3BEBF81B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8580601A-A694-4656-B72C-B56C3BEBF81B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8580601A-A694-4656-B72C-B56C3BEBF81B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8580601A-A694-4656-B72C-B56C3BEBF81B}.Release|Any CPU.Build.0 = Release|Any CPU
{D155BED8-7ABE-4EA4-8C75-3E3CFFDCDF5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D155BED8-7ABE-4EA4-8C75-3E3CFFDCDF5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D155BED8-7ABE-4EA4-8C75-3E3CFFDCDF5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D155BED8-7ABE-4EA4-8C75-3E3CFFDCDF5C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{FC10AD84-66D7-4C98-9A3B-620D6ACC1357} = {D40300B7-1803-48CB-8F7D-6A96AB75F666}
{00CBFE9C-C93E-4DC9-BDE5-87A10E170CF5} = {D40300B7-1803-48CB-8F7D-6A96AB75F666}
{84F94171-2814-4993-9BC6-43D7F9535027} = {D40300B7-1803-48CB-8F7D-6A96AB75F666}
{D7BE4E4E-38E0-4DCC-A8CB-7D9CE22994DB} = {D40300B7-1803-48CB-8F7D-6A96AB75F666}
{39BD3C99-BBB1-48BA-B015-92C30A8813CC} = {D40300B7-1803-48CB-8F7D-6A96AB75F666}
{8580601A-A694-4656-B72C-B56C3BEBF81B} = {D40300B7-1803-48CB-8F7D-6A96AB75F666}
{D155BED8-7ABE-4EA4-8C75-3E3CFFDCDF5C} = {D40300B7-1803-48CB-8F7D-6A96AB75F666}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D12812E7-06E1-4FFB-A601-D656FE2A0075}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Panner.AspNetCore.Samples.AspNet5_0.EFModel
namespace Panner.AspNetCore.Samples.FastEndpointsNet9.EFModel
{
using Microsoft.EntityFrameworkCore;
using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Panner.AspNetCore.Samples.AspNetCore3_1.EFModel
namespace Panner.AspNetCore.Samples.FastEndpointsNet9.EFModel
{
using System;

Expand Down
27 changes: 27 additions & 0 deletions sample/FastEndpoints/Source/FastEndpointsNet9.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
<NoWarn>CS1591;CA2016</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>Panner.AspNetCore.Samples.FastEndpointsNet9</AssemblyName>
<RootNamespace>Panner.AspNetCore.Samples.FastEndpointsNet9</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FastEndpoints" Version="6.0.0" />
<PackageReference Include="FastEndpoints.Generator" Version="6.0.0" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<PackageReference Include="FastEndpoints.Security" Version="6.0.0" />
<PackageReference Include="FastEndpoints.Swagger" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.6" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Panner.AspNetCore.csproj" />
</ItemGroup>

</Project>
41 changes: 41 additions & 0 deletions sample/FastEndpoints/Source/Features/Posts/Endpoint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Microsoft.EntityFrameworkCore;
using Panner;
using Panner.AspNetCore.Samples.FastEndpointsNet9.EFModel;
using Views = Panner.AspNetCore.Samples.FastEndpointsNet9.Views;
using Panner.AspNetCore.Samples.FastEndpointsNet9.PannerExtensions;

namespace Posts;

sealed class Endpoint : Endpoint<Request, IEnumerable<Views.Post>>
{
private readonly BlogContext _context;

public Endpoint(BlogContext context)
{
_context = context;
}

public override void Configure()
{
Get("/posts");
AllowAnonymous();
}

public override async Task HandleAsync(Request r, CancellationToken c)
{
_context.Database.EnsureCreated();
var result = await _context.Posts
.Apply(r.Filters ?? Array.Empty<IFilterParticle<Post>>())
.Apply(r.Sorts ?? Array.Empty<ISortParticle<Post>>())
.Select(x => new Views.Post
{
Id = x.Id,
Title = x.Title,
Content = x.Content,
Creation = x.CreatedOn
})
.ToArrayAsync(c);

await SendAsync(result, cancellation: c);
}
}
16 changes: 16 additions & 0 deletions sample/FastEndpoints/Source/Features/Posts/Request.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Microsoft.AspNetCore.Mvc;

using Panner;
using Panner.AspNetCore.Samples.FastEndpointsNet9.EFModel;
using FastEndpoints;

namespace Posts;

sealed class Request
{
[FastEndpoints.FromQuery]
public IReadOnlyCollection<ISortParticle<Post>>? Sorts { get; set; }

[FastEndpoints.FromQuery]
public IReadOnlyCollection<IFilterParticle<Post>>? Filters { get; set; }
}
18 changes: 18 additions & 0 deletions sample/FastEndpoints/Source/Features/SayHello/Endpoint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace SayHello;

sealed class Endpoint : Endpoint<Request, Response>
{
public override void Configure()
{
Post("/api/hello");
AllowAnonymous();
}

public override async Task HandleAsync(Request r, CancellationToken c)
{
await SendAsync(new()
{
Message = $"Hello {r.FirstName} {r.LastName}..."
});
}
}
18 changes: 18 additions & 0 deletions sample/FastEndpoints/Source/Features/SayHello/Request.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using FluentValidation;

namespace SayHello;

sealed class Request
{
public string FirstName { get; set; }
public string LastName { get; set; }

internal sealed class Validator : Validator<Request>
{
public Validator()
{
RuleFor(x => x.FirstName).MinimumLength(3);
RuleFor(x => x.LastName).MinimumLength(5);
}
}
}
6 changes: 6 additions & 0 deletions sample/FastEndpoints/Source/Features/SayHello/Response.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace SayHello;

sealed class Response
{
public string Message { get; set; }
}
9 changes: 9 additions & 0 deletions sample/FastEndpoints/Source/Meta.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
global using FastEndpoints;
global using FastEndpoints.Security;
global using FastEndpoints.Swagger;
global using FastEndpoints;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Tests")]

public partial class Program;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Panner.AspNetCore.Samples.AspNet5_0.PannerExtensions
namespace Panner.AspNetCore.Samples.FastEndpointsNet9.PannerExtensions
{
using global::Panner.AspNetCore.Samples.AspNet5_0.EFModel;
using global::Panner.AspNetCore.Samples.FastEndpointsNet9.EFModel;
using global::Panner.Builders;

public static partial class PEntityBuilderExtensions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Panner.AspNetCore.Samples.AspNetCore3_1.PannerExtensions
namespace Panner.AspNetCore.Samples.FastEndpointsNet9.PannerExtensions
{
using global::Panner.AspNetCore.Samples.AspNetCore3_1.EFModel;
using global::Panner.AspNetCore.Samples.FastEndpointsNet9.EFModel;
using System.Linq;

public class SortPostByPopularityParticle : ISortParticle<Post>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Panner.AspNetCore.Samples.AspNetCore3_1.EFModel;
using Panner.AspNetCore.Samples.FastEndpointsNet9.EFModel;

namespace Panner.AspNetCore.Samples.AspNetCore3_1.PannerExtensions
namespace Panner.AspNetCore.Samples.FastEndpointsNet9.PannerExtensions
{
public class SortPostsByPopularityParticleGenerator : ISortParticleGenerator<Post>
{
Expand Down
44 changes: 44 additions & 0 deletions sample/FastEndpoints/Source/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Microsoft.EntityFrameworkCore;
using Panner.AspNetCore;
using Panner.AspNetCore.Samples.FastEndpointsNet9;
using Panner.AspNetCore.Samples.FastEndpointsNet9.EFModel;
using Panner.AspNetCore.Samples.FastEndpointsNet9.PannerExtensions;
using Views = Panner.AspNetCore.Samples.FastEndpointsNet9.Views;
using Panner.Builders;

var bld = WebApplication.CreateBuilder(args);

bld.Services
.AddAuthenticationJwtBearer(s => s.SigningKey = bld.Configuration["Auth:JwtKey"])
.AddAuthorization()
.AddFastEndpoints(o => o.SourceGeneratorDiscoveredTypes = DiscoveredTypes.All)
.SwaggerDocument();

bld.Services.UsePanner(c =>
{
c.Entity<Post>()
.IsSortableByPopularity()
.Property(x => x.Id, o => o
.IsSortableAs(nameof(Views.Post.Id))
.IsFilterableAs(nameof(Views.Post.Id))
)
.Property(x => x.Title, o => o
.IsSortableAs(nameof(Views.Post.Title))
)
.Property(x => x.CreatedOn, o => o
.IsSortableAs(nameof(Views.Post.Creation))
.IsFilterableAs(nameof(Views.Post.Creation))
);
});

bld.Services.AddDbContext<BlogContext>(o => o.UseInMemoryDatabase("BlogDb"));

var app = bld.Build();
app.UseAuthentication()
.UseAuthorization()
.UseFastEndpoints(c =>
{
c.Errors.UseProblemDetails();
})
.UseSwaggerGen();
app.Run();
14 changes: 14 additions & 0 deletions sample/FastEndpoints/Source/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Panner.AspNetCore.Samples.AspNetCore3_1.Views
namespace Panner.AspNetCore.Samples.FastEndpointsNet9.Views
{
using System;

Expand Down
11 changes: 11 additions & 0 deletions sample/FastEndpoints/Source/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"Auth": {
"JwtKey": "a long secret string used to sign jwts. usually set via matching environment variable."
}
}
3 changes: 3 additions & 0 deletions sample/FastEndpoints/Source/appsettings.Testing.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{

}
8 changes: 8 additions & 0 deletions sample/FastEndpoints/Source/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
Loading
Loading