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

add sealed for handlers & cleanup in minimal api #202

Merged
merged 4 commits into from
Aug 8, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Atc.CodeGeneration.CSharp/Content/AccessModifiers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public enum AccessModifiers
[Description("public static class")]
PublicStaticClass,

[Description("public sealed class")]
PublicSealedClass,

[Description("public record")]
PublicRecord,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static ClassParameters Create(
@namespace,
openApiOperation.ExtractDocumentationTagsForHandler(),
Attributes: null,
AccessModifiers.PublicClass,
AccessModifiers.PublicSealedClass,
ClassTypeName: $"{operationName}{ContentGeneratorConstants.Handler}",
GenericTypeName: null,
InheritedClassTypeName: $"I{operationName}{ContentGeneratorConstants.Handler}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,47 +213,10 @@ public void GenerateServiceCollectionExtensions()
AlwaysBreakDownParameters: true,
UseExpressionBody: false,
Content: """
services.ConfigureOptions(configuration);
services.DefineHandlersAndServices();
return services;
""");

var methodConfigureOptions = new MethodParameters(
DocumentationTags: null,
Attributes: null,
AccessModifiers.PublicStatic,
ReturnGenericTypeName: null,
ReturnTypeName: "void",
Name: "ConfigureOptions",
Parameters:
[
new(
Attributes: null,
GenericTypeName: null,
IsGenericListType: false,
TypeName: "this IServiceCollection",
IsNullableType: false,
IsReferenceType: false,
Name: "services",
DefaultValue: null),
new(
Attributes: null,
GenericTypeName: null,
IsGenericListType: false,
TypeName: "IConfiguration",
IsNullableType: false,
IsReferenceType: false,
Name: "configuration",
DefaultValue: null),
],
AlwaysBreakDownParameters: true,
UseExpressionBody: false,
Content: """
services.Configure<ServiceOptions>(options => configuration.GetRequiredSection(nameof(ServiceOptions)).Bind(options));
services.Configure<EnvironmentOptions>(options => configuration.GetRequiredSection(nameof(EnvironmentOptions)).Bind(options));
services.Configure<NamingOptions>(options => configuration.GetRequiredSection(nameof(NamingOptions)).Bind(options));
""");

var methodDefineHandlersAndServices = new MethodParameters(
DocumentationTags: null,
Attributes: null,
Expand Down Expand Up @@ -293,7 +256,6 @@ public void GenerateServiceCollectionExtensions()
Methods:
[
methodConfigureDomainServices,
methodConfigureOptions,
methodDefineHandlersAndServices,
],
GenerateToStringMethod: false);
Expand All @@ -319,8 +281,6 @@ public void MaintainGlobalUsings(
{
"System.CodeDom.Compiler",
"System.Diagnostics.CodeAnalysis",
"Atc.Azure.Options",
"Atc.Azure.Options.Environment",
"Microsoft.Extensions.Configuration",
"Microsoft.Extensions.DependencyInjection",
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static ClassParameters Create(
@namespace,
openApiOperation.ExtractDocumentationTagsForHandler(),
Attributes: null,
AccessModifiers.PublicClass,
AccessModifiers.PublicSealedClass,
ClassTypeName: $"{operationName}{ContentGeneratorConstants.Handler}",
GenericTypeName: null,
InheritedClassTypeName: $"I{operationName}{ContentGeneratorConstants.Handler}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Set name of account.
/// Operation: SetAccountName.
/// </summary>
public class SetAccountNameHandler : ISetAccountNameHandler
public sealed class SetAccountNameHandler : ISetAccountNameHandler
{
public Task<SetAccountNameResult> ExecuteAsync(
SetAccountNameParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Update name of account.
/// Operation: UpdateAccountName.
/// </summary>
public class UpdateAccountNameHandler : IUpdateAccountNameHandler
public sealed class UpdateAccountNameHandler : IUpdateAccountNameHandler
{
public Task<UpdateAccountNameResult> ExecuteAsync(
UpdateAccountNameParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Get addresses by postal code.
/// Operation: GetAddressesByPostalCodes.
/// </summary>
public class GetAddressesByPostalCodesHandler : IGetAddressesByPostalCodesHandler
public sealed class GetAddressesByPostalCodesHandler : IGetAddressesByPostalCodesHandler
{
public Task<GetAddressesByPostalCodesResult> ExecuteAsync(
GetAddressesByPostalCodesParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Get EventArgs By Id.
/// Operation: GetEventArgById.
/// </summary>
public class GetEventArgByIdHandler : IGetEventArgByIdHandler
public sealed class GetEventArgByIdHandler : IGetEventArgByIdHandler
{
public Task<GetEventArgByIdResult> ExecuteAsync(
GetEventArgByIdParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Get EventArgs List.
/// Operation: GetEventArgs.
/// </summary>
public class GetEventArgsHandler : IGetEventArgsHandler
public sealed class GetEventArgsHandler : IGetEventArgsHandler
{
public Task<GetEventArgsResult> ExecuteAsync(
CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Get File By Id.
/// Operation: GetFileById.
/// </summary>
public class GetFileByIdHandler : IGetFileByIdHandler
public sealed class GetFileByIdHandler : IGetFileByIdHandler
{
public Task<GetFileByIdResult> ExecuteAsync(
GetFileByIdParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Upload multi files as form data.
/// Operation: UploadMultiFilesAsFormData.
/// </summary>
public class UploadMultiFilesAsFormDataHandler : IUploadMultiFilesAsFormDataHandler
public sealed class UploadMultiFilesAsFormDataHandler : IUploadMultiFilesAsFormDataHandler
{
public Task<UploadMultiFilesAsFormDataResult> ExecuteAsync(
UploadMultiFilesAsFormDataParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Upload a file as OctetStream.
/// Operation: UploadSingleFileAsFormData.
/// </summary>
public class UploadSingleFileAsFormDataHandler : IUploadSingleFileAsFormDataHandler
public sealed class UploadSingleFileAsFormDataHandler : IUploadSingleFileAsFormDataHandler
{
public Task<UploadSingleFileAsFormDataResult> ExecuteAsync(
UploadSingleFileAsFormDataParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Upload a file as FormData.
/// Operation: UploadSingleObjectWithFileAsFormData.
/// </summary>
public class UploadSingleObjectWithFileAsFormDataHandler : IUploadSingleObjectWithFileAsFormDataHandler
public sealed class UploadSingleObjectWithFileAsFormDataHandler : IUploadSingleObjectWithFileAsFormDataHandler
{
public Task<UploadSingleObjectWithFileAsFormDataResult> ExecuteAsync(
UploadSingleObjectWithFileAsFormDataParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Upload files as FormData.
/// Operation: UploadSingleObjectWithFilesAsFormData.
/// </summary>
public class UploadSingleObjectWithFilesAsFormDataHandler : IUploadSingleObjectWithFilesAsFormDataHandler
public sealed class UploadSingleObjectWithFilesAsFormDataHandler : IUploadSingleObjectWithFilesAsFormDataHandler
{
public Task<UploadSingleObjectWithFilesAsFormDataResult> ExecuteAsync(
UploadSingleObjectWithFilesAsFormDataParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Create a new item.
/// Operation: CreateItem.
/// </summary>
public class CreateItemHandler : ICreateItemHandler
public sealed class CreateItemHandler : ICreateItemHandler
{
public Task<CreateItemResult> ExecuteAsync(
CreateItemParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Updates an item.
/// Operation: UpdateItem.
/// </summary>
public class UpdateItemHandler : IUpdateItemHandler
public sealed class UpdateItemHandler : IUpdateItemHandler
{
public Task<UpdateItemResult> ExecuteAsync(
UpdateItemParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Get order by id.
/// Operation: GetOrderById.
/// </summary>
public class GetOrderByIdHandler : IGetOrderByIdHandler
public sealed class GetOrderByIdHandler : IGetOrderByIdHandler
{
public Task<GetOrderByIdResult> ExecuteAsync(
GetOrderByIdParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Get orders.
/// Operation: GetOrders.
/// </summary>
public class GetOrdersHandler : IGetOrdersHandler
public sealed class GetOrdersHandler : IGetOrdersHandler
{
public Task<GetOrdersResult> ExecuteAsync(
GetOrdersParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Update part of order by id.
/// Operation: PatchOrdersId.
/// </summary>
public class PatchOrdersIdHandler : IPatchOrdersIdHandler
public sealed class PatchOrdersIdHandler : IPatchOrdersIdHandler
{
public Task<PatchOrdersIdResult> ExecuteAsync(
PatchOrdersIdParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Your GET endpoint.
/// Operation: GetRouteWithDash.
/// </summary>
public class GetRouteWithDashHandler : IGetRouteWithDashHandler
public sealed class GetRouteWithDashHandler : IGetRouteWithDashHandler
{
public Task<GetRouteWithDashResult> ExecuteAsync(
CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Returns tasks.
/// Operation: GetTasks.
/// </summary>
public class GetTasksHandler : IGetTasksHandler
public sealed class GetTasksHandler : IGetTasksHandler
{
public Task<GetTasksResult> ExecuteAsync(
CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Delete user by id.
/// Operation: DeleteUserById.
/// </summary>
public class DeleteUserByIdHandler : IDeleteUserByIdHandler
public sealed class DeleteUserByIdHandler : IDeleteUserByIdHandler
{
public Task<DeleteUserByIdResult> ExecuteAsync(
DeleteUserByIdParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Get user by email.
/// Operation: GetUserByEmail.
/// </summary>
public class GetUserByEmailHandler : IGetUserByEmailHandler
public sealed class GetUserByEmailHandler : IGetUserByEmailHandler
{
public Task<GetUserByEmailResult> ExecuteAsync(
GetUserByEmailParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Get user by id.
/// Operation: GetUserById.
/// </summary>
public class GetUserByIdHandler : IGetUserByIdHandler
public sealed class GetUserByIdHandler : IGetUserByIdHandler
{
public Task<GetUserByIdResult> ExecuteAsync(
GetUserByIdParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Get all users.
/// Operation: GetUsers.
/// </summary>
public class GetUsersHandler : IGetUsersHandler
public sealed class GetUsersHandler : IGetUsersHandler
{
public Task<GetUsersResult> ExecuteAsync(
CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Create a new user.
/// Operation: PostUser.
/// </summary>
public class PostUserHandler : IPostUserHandler
public sealed class PostUserHandler : IPostUserHandler
{
public Task<PostUserResult> ExecuteAsync(
PostUserParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Update gender on a user.
/// Operation: UpdateMyTestGender.
/// </summary>
public class UpdateMyTestGenderHandler : IUpdateMyTestGenderHandler
public sealed class UpdateMyTestGenderHandler : IUpdateMyTestGenderHandler
{
public Task<UpdateMyTestGenderResult> ExecuteAsync(
UpdateMyTestGenderParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Update user by id.
/// Operation: UpdateUserById.
/// </summary>
public class UpdateUserByIdHandler : IUpdateUserByIdHandler
public sealed class UpdateUserByIdHandler : IUpdateUserByIdHandler
{
public Task<UpdateUserByIdResult> ExecuteAsync(
UpdateUserByIdParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Set name of account.
/// Operation: SetAccountName.
/// </summary>
public class SetAccountNameHandler : ISetAccountNameHandler
public sealed class SetAccountNameHandler : ISetAccountNameHandler
{
public Task<SetAccountNameResult> ExecuteAsync(
SetAccountNameParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Update name of account.
/// Operation: UpdateAccountName.
/// </summary>
public class UpdateAccountNameHandler : IUpdateAccountNameHandler
public sealed class UpdateAccountNameHandler : IUpdateAccountNameHandler
{
public Task<UpdateAccountNameResult> ExecuteAsync(
UpdateAccountNameParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Get addresses by postal code.
/// Operation: GetAddressesByPostalCodes.
/// </summary>
public class GetAddressesByPostalCodesHandler : IGetAddressesByPostalCodesHandler
public sealed class GetAddressesByPostalCodesHandler : IGetAddressesByPostalCodesHandler
{
public Task<GetAddressesByPostalCodesResult> ExecuteAsync(
GetAddressesByPostalCodesParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Get EventArgs By Id.
/// Operation: GetEventArgById.
/// </summary>
public class GetEventArgByIdHandler : IGetEventArgByIdHandler
public sealed class GetEventArgByIdHandler : IGetEventArgByIdHandler
{
public Task<GetEventArgByIdResult> ExecuteAsync(
GetEventArgByIdParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Get EventArgs List.
/// Operation: GetEventArgs.
/// </summary>
public class GetEventArgsHandler : IGetEventArgsHandler
public sealed class GetEventArgsHandler : IGetEventArgsHandler
{
public Task<GetEventArgsResult> ExecuteAsync(
CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Get File By Id.
/// Operation: GetFileById.
/// </summary>
public class GetFileByIdHandler : IGetFileByIdHandler
public sealed class GetFileByIdHandler : IGetFileByIdHandler
{
public Task<GetFileByIdResult> ExecuteAsync(
GetFileByIdParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Upload multi files as form data.
/// Operation: UploadMultiFilesAsFormData.
/// </summary>
public class UploadMultiFilesAsFormDataHandler : IUploadMultiFilesAsFormDataHandler
public sealed class UploadMultiFilesAsFormDataHandler : IUploadMultiFilesAsFormDataHandler
{
public Task<UploadMultiFilesAsFormDataResult> ExecuteAsync(
UploadMultiFilesAsFormDataParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Upload a file as OctetStream.
/// Operation: UploadSingleFileAsFormData.
/// </summary>
public class UploadSingleFileAsFormDataHandler : IUploadSingleFileAsFormDataHandler
public sealed class UploadSingleFileAsFormDataHandler : IUploadSingleFileAsFormDataHandler
{
public Task<UploadSingleFileAsFormDataResult> ExecuteAsync(
UploadSingleFileAsFormDataParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Upload a file as FormData.
/// Operation: UploadSingleObjectWithFileAsFormData.
/// </summary>
public class UploadSingleObjectWithFileAsFormDataHandler : IUploadSingleObjectWithFileAsFormDataHandler
public sealed class UploadSingleObjectWithFileAsFormDataHandler : IUploadSingleObjectWithFileAsFormDataHandler
{
public Task<UploadSingleObjectWithFileAsFormDataResult> ExecuteAsync(
UploadSingleObjectWithFileAsFormDataParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Description: Upload files as FormData.
/// Operation: UploadSingleObjectWithFilesAsFormData.
/// </summary>
public class UploadSingleObjectWithFilesAsFormDataHandler : IUploadSingleObjectWithFilesAsFormDataHandler
public sealed class UploadSingleObjectWithFilesAsFormDataHandler : IUploadSingleObjectWithFilesAsFormDataHandler
{
public Task<UploadSingleObjectWithFilesAsFormDataResult> ExecuteAsync(
UploadSingleObjectWithFilesAsFormDataParameters parameters,
Expand Down
Loading
Loading