v0.6

v0.6.0

.NET Upgrade

DO now supports .NET 8! Below you can find a task list to upgrade your projects.

- [ ] Upgrade .NET and C# versions
  - [ ] in projects
  - [ ] in docker files
  - [ ] in GitHub workflows
- [ ] Upgrade DO version
- [ ] Syntax improvements
  - [ ] Use primary constructors
  - [ ] Use collection expressions
- [ ] Use `[FromKeyedServices]` and `[FromServices]` in controllers

Upgrade .NET and C# versions

  • Upgrade the project's C# language to 12.
  • Framework version upgrade to net8.0 in the projects.
  • Framework and sdk version upgrade to 8 in Dockerfile.
  • Upgrade dotnet version 8 in Github actions.

Syntax improvements

Primary constructors

Use primary constructor, when there is a dependency that needs to be injected at the constructor without any logic or when the base class constructor is called. Parameter names start with underscore.

public class Entity(IEntityContext<Entity> _context)
{
  ...
}
Collection expressions

Use new and simplified collection expressions, where possible.

Visit Collection expression for more details.

[FromServices] in controllers

Instead of using constructor injection, use [FromServices] attribute to inject dependencies in controllers.

public Entity Get([FromServices] IQueryContext<Entity> entityQuery) { }

Improvements

  • ExceptionHandling now uses Microsoft.AspNetCore.Diagnostics.IExceptionHandling
    • ExceptionHandling feature now adds StatusCodePages middleware.
  • Exceptions now return ProblemDetails as response
  • ISystem is replaced with TimeProvider.System
    • Mocker, TheSystem extension is renamed to TheTime
    • Use FakeTimeProvider for tests by mocking TheTime
  • Internal Server Error response included extra details in message, removed
    • Extra details can be reached from the logs
  • HandledException is now abstract
    • Added optional ExtraDetails collection property to HandledException

Library Upgrades

PackageOld VersionNew Version
Microsoft.AspNetCore.Mvc.NewtonsoftJson7.0.138.0.0
Microsoft.Extensions.Configuration.Abstractions7.0.08.0.0
Microsoft.Extensions.Configuration.Binder7.0.08.0.0
Microsoft.Extensions.Logging.Abstractions7.0.08.0.0
Microsoft.NET.Test.Sdk7.0.08.0.0
Microsoft.Extensions.TimeProvider.Testingnew8.0.0
Moq4.20.694.20.70
NHibernate5.4.65.5.0
NUnit3.14.04.0.1
StyleCop.Analyzers.Unstable1.2.0.5071.2.0.556