Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ardalis committed Dec 18, 2023
2 parents 6a500fa + b76ca33 commit 4ee1967
Show file tree
Hide file tree
Showing 98 changed files with 236 additions and 74,249 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.100-rc.2.23502.2'
dotnet-version: '8.0.100'
- name: Build with dotnet
run: dotnet build --configuration Release
- name: Test with dotnet
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/src/Clean.Architecture.Web/bin/Debug/net7.0/Clean.Architecture.Web.dll",
"program": "${workspaceFolder}/src/Clean.Architecture.Web/bin/Debug/net8.0/Clean.Architecture.Web.dll",
"args": [],
"cwd": "${workspaceFolder}/src/Clean.Architecture.Web",
"stopAtEntry": false,
Expand Down
7 changes: 3 additions & 4 deletions CleanArchitecture.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
<metadata>
<id>Ardalis.CleanArchitecture.Template</id>
<title>ASP.NET Core Clean Architecture Solution</title>
<version>9.0.0-preview</version>
<version>9.0.1</version>
<authors>Steve Smith</authors>
<description>
The Clean Architecture Solution Template popularized by Steve @ardalis Smith. Provides a great starting point for modern and/or DDD solutions built with .NET 7 and C# 11.
The Clean Architecture Solution Template popularized by Steve @ardalis Smith. Provides a great starting point for modern and/or DDD solutions built with .NET 8 and C# 12.
Features zero tight coupling to database or data access technology.
</description>
<language>en-US</language>
<license type="expression">MIT</license>
<projectUrl>https://github.com/ardalis/CleanArchitecture</projectUrl>
<releaseNotes>
Major changes included in this release!
* Updated to dotnet 8
Minor updates to dependencies. Fixed Releases on GitHub.
</releaseNotes>
<packageTypes>
<packageType name="Template" />
Expand Down
2 changes: 2 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup>
<NoWarn>1591</NoWarn> <!-- Remove this to turn on warnings for missing XML Comments -->
Expand Down
46 changes: 21 additions & 25 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,44 +1,40 @@
<Project>
<ItemGroup>
<PackageVersion Include="Ardalis.GuardClauses" Version="4.1.1" />
<PackageVersion Include="Ardalis.GuardClauses" Version="4.2.0" />
<PackageVersion Include="Ardalis.HttpClientTestExtensions" Version="4.2.0" />
<PackageVersion Include="Ardalis.ListStartupServices" Version="1.1.4" />
<PackageVersion Include="Ardalis.Result" Version="7.2.0" />
<PackageVersion Include="Ardalis.Result.AspNetCore" Version="7.2.0" />
<PackageVersion Include="Ardalis.SharedKernel" Version="1.3.0" />
<PackageVersion Include="Ardalis.SharedKernel" Version="1.4.0" />
<PackageVersion Include="Ardalis.SmartEnum" Version="7.0.0" />
<PackageVersion Include="Ardalis.Specification" Version="7.0.0" />
<PackageVersion Include="Ardalis.Specification.EntityFrameworkCore" Version="7.0.0" />
<PackageVersion Include="Ardalis.Specification" Version="8.0.0" />
<PackageVersion Include="Ardalis.Specification.EntityFrameworkCore" Version="8.0.0" />
<PackageVersion Include="Autofac" Version="7.1.0" />
<PackageVersion Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="FastEndpoints" Version="5.19.0" />
<PackageVersion Include="FastEndpoints" Version="5.20.1" />
<PackageVersion Include="FastEndpoints.ApiExplorer" Version="2.2.0" />
<PackageVersion Include="FastEndpoints.Swagger" Version="5.19.0" />
<PackageVersion Include="FastEndpoints.Swagger" Version="5.20.1" />
<PackageVersion Include="FastEndpoints.Swagger.Swashbuckle" Version="2.2.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="MailKit" Version="4.2.0" />
<PackageVersion Include="MediatR" Version="12.1.1" />
<PackageVersion Include="MediatR.Extensions.Autofac.DependencyInjection" Version="11.2.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.0-rc.2.23480.2" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.0-rc.2.23480.2" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.0-rc.2.23480.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.0-rc.2.23480.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0-rc.2.23480.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0-rc.2.23480.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0-rc.2.23480.1" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0-rc.2.23479.6" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageVersion Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.0-rc.2.23509.1" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="MailKit" Version="4.3.0" />
<PackageVersion Include="MediatR" Version="12.2.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.0" />
<PackageVersion Include="NSubstitute" Version="5.1.0" />
<PackageVersion Include="ReportGenerator" Version="5.1.26" />
<PackageVersion Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageVersion Include="Serilog.Sinks.ApplicationInsights" Version="4.0.1-dev-00040" />
<PackageVersion Include="ReportGenerator" Version="5.2.0" />
<PackageVersion Include="Serilog.AspNetCore" Version="8.0.0" />
<PackageVersion Include="SQLite" Version="3.13.0" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageVersion Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
<PackageVersion Include="xunit" Version="2.6.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.3" />
<PackageVersion Include="xunit" Version="2.6.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.5" />
</ItemGroup>
</Project>
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ Or if you're feeling really generous, we now support GitHub sponsorships - see t

## Versions

The main branch is now using .NET 7. If you need a previous version use one of these tagged commits:
The main branch is now using .NET 8. If you need a previous version use one of these tagged commits:

- [7.0](https://github.com/ardalis/CleanArchitecture/releases/tag/v8)
- [6.0](https://github.com/ardalis/CleanArchitecture/releases/tag/dotnet-6)
- [5.0](https://github.com/ardalis/CleanArchitecture/releases/tag/dotnet-core-5)
- [3.1](https://github.com/ardalis/CleanArchitecture/tree/dotnet-core-3.1)
Expand Down Expand Up @@ -136,7 +137,10 @@ Example:

Thanks [@dahlsailrunner](https://github.com/dahlsailrunner) for your help getting this working!

> **Known Issue**: Don't include hyphens in the name. See [#201](https://github.com/ardalis/CleanArchitecture/issues/201).
**Known Issues**:

- Don't include hyphens in the name. See [#201](https://github.com/ardalis/CleanArchitecture/issues/201).
- Don't use 'Ardalis' as your namespace (conflicts with dependencies).

## Using the GitHub Repository

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.100",
"version": "8.0.100",
"rollForward": "latestMajor"
}
}
2 changes: 1 addition & 1 deletion sample/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<NoWarn>1591</NoWarn> <!-- Remove this to turn on warnings for missing XML Comments -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public class ToDoItem : EntityBase
public string Description { get; set; } = string.Empty;
public int? ContributorId { get; private set; } // tasks don't have anyone assigned when first created
public bool IsDone { get; private set; }
// TODO: Move Priority to ToDoItem from Project

public void MarkComplete()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace NimblePros.SampleToDo.Infrastructure;
public class AutofacInfrastructureModule : Module
{
private readonly bool _isDevelopment = false;
private readonly List<Assembly> _assemblies = new List<Assembly>();
private readonly List<Assembly> _assemblies = [];

public AutofacInfrastructureModule(bool isDevelopment, Assembly? callingAssembly = null)
{
Expand Down Expand Up @@ -102,7 +102,7 @@ private void RegisterMediatR(ContainerBuilder builder)
foreach (var mediatrOpenType in mediatrOpenTypes)
{
builder
.RegisterAssemblyTypes(_assemblies.ToArray())
.RegisterAssemblyTypes([.. _assemblies])
.AsClosedTypesOf(mediatrOpenType)
.AsImplementedInterfaces();
}
Expand All @@ -111,9 +111,14 @@ private void RegisterMediatR(ContainerBuilder builder)
private void RegisterDevelopmentOnlyDependencies(ContainerBuilder builder)
{
// NOTE: Add any development only services here
builder.RegisterType<FakeEmailSender>().As<IEmailSender>()
//builder.RegisterType<FakeEmailSender>().As<IEmailSender>()
// .InstancePerLifetimeScope();

// NOTE: Add any production only (real) services here
builder.RegisterType<SmtpEmailSender>().As<IEmailSender>()
.InstancePerLifetimeScope();


builder.RegisterType<FakeListContributorsQueryService>()
.As<IListContributorsQueryService>()
.InstancePerLifetimeScope();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@

namespace NimblePros.SampleToDo.Infrastructure.Data.Queries;

public class ListProjectsShallowQueryService : IListProjectsShallowQueryService
public class ListProjectsShallowQueryService(AppDbContext db) :
IListProjectsShallowQueryService
{
private readonly AppDbContext _db;

public ListProjectsShallowQueryService(AppDbContext db)
{
_db = db;
}
private readonly AppDbContext _db = db;

public async Task<IEnumerable<ProjectDTO>> ListAsync()
{
var result = await _db.Projects.FromSqlRaw("SELECT Id, Name, Status FROM Projects") // don't fetch other big columns
var result = await _db.Projects.FromSqlRaw("SELECT Id, Name FROM Projects") // don't fetch other big columns
.Select(x => new ProjectDTO(x.Id, x.Name, x.Status.ToString()))
.ToListAsync();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@

namespace NimblePros.SampleToDo.UseCases.Projects.ListShallow;

public class ListProjectsShallowHandler : IQueryHandler<ListProjectsShallowQuery, Result<IEnumerable<ProjectDTO>>>
public class ListProjectsShallowHandler(IListProjectsShallowQueryService query)
: IQueryHandler<ListProjectsShallowQuery, Result<IEnumerable<ProjectDTO>>>
{
private readonly IListProjectsShallowQueryService _query;

public ListProjectsShallowHandler(IListProjectsShallowQueryService query)
{
_query = query;
}
private readonly IListProjectsShallowQueryService _query = query;

public async Task<Result<IEnumerable<ProjectDTO>>> Handle(ListProjectsShallowQuery request, CancellationToken cancellationToken)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace NimblePros.SampleToDo.Web.ProjectEndpoints;

/// <summary>
/// Mark an item as complete
/// </summary>
public class MarkItemComplete : Endpoint<MarkItemCompleteRequest>
{
private readonly IMediator _mediator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:57679/"
"applicationUrl": "http://localhost:57678/"
}
}
}
72 changes: 72 additions & 0 deletions sample/src/NimblePros.SampleToDo.Web/api.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# For more info on HTTP files go to https://aka.ms/vs/httpfile
@hostname=localhost
@port=57678

// List all contributors
GET http://{{hostname}}:{{port}}/Contributors

###

// Get a specific contributor
@id_to_get=1
GET http://{{hostname}}:{{port}}/Contributors/{{id_to_get}}

###

// Add a new contributor
POST http://{{hostname}}:{{port}}/Contributors
Content-Type: application/json

{
"name": "John Doe"
}

###

// Update a contributor
@id_to_update=1
PUT http://{{hostname}}:{{port}}/Contributors/{{id_to_update}}
Content-Type: application/json

{
"id": {{id_to_update}},
"name": "ardalis2"
}

###

// Delete a contributor
@id_to_delete=1
DELETE http://{{hostname}}:{{port}}/Contributors/{{id_to_delete}}

###

// List all Projects
GET http://{{hostname}}:{{port}}/Projects

###

// Get a specific project
@id_to_get=1
GET http://{{hostname}}:{{port}}/Projects/{{id_to_get}}

###

// Create a new project
POST http://{{hostname}}:{{port}}/Projects
Content-Type: application/json

{
"name": "New Project"
}

###

// Mark an item as complete
@project_id=1
@item_id=2
POST http://{{hostname}}:{{port}}/Projects/{{project_id}}/ToDoItems/{{item_id}}
Content-Type: application/json

{
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<Sdk Name="Microsoft.Build.CentralPackageVersions" Version="2.1.3" />

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<Sdk Name="Microsoft.Build.CentralPackageVersions" Version="2.1.3" />

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<Sdk Name="Microsoft.Build.CentralPackageVersions" Version="2.1.3" />

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
5 changes: 0 additions & 5 deletions src/Clean.Architecture.Core/Clean.Architecture.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Sdk Name="Microsoft.Build.CentralPackageVersions" Version="2.1.3" />

<PropertyGroup>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ardalis.GuardClauses" />
<PackageReference Include="Ardalis.Result" />
Expand Down
Loading

0 comments on commit 4ee1967

Please sign in to comment.