Skip to content

Clean.Architecture.Web/Program.cs configuration over all clean up #821

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

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

TadehB7
Copy link
Contributor

@TadehB7 TadehB7 commented Sep 16, 2024

This pull request contains Clean.Architecture.Web/Program.cs configuration over all clean up:

  • The Program.cs file is kept minimal and focuses on high-level configurations.
  • Extension methods allow you to offload dependency injection setup to the relevant layers (Application, Infrastructure).
  • By following this pattern, your code adheres to Clean Architecture principles, where the separation of concerns is clear, and each layer is responsible for its own configuration and services.

This cleanup should make your Program.cs file more maintainable and aligned with Clean Architecture.

@ardalis
Copy link
Owner

ardalis commented Sep 26, 2024

Looks great, thanks! Any interest in doing the same for the /sample folder project?

@ardalis ardalis merged commit 84ab0e4 into ardalis:main Sep 26, 2024
2 checks passed
Comment on lines +47 to +51
catch (Exception ex)
{
var logger = services.GetRequiredService<ILogger<Program>>();
logger.LogError(ex, "An error occurred seeding the DB. {exceptionMessage}", ex.Message);
}

Check notice

Code scanning / CodeQL

Generic catch clause Note

Generic catch clause.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants