Cranks.SeedWork.Domain
0.1.0-alpha.333
See the version list below for details.
dotnet add package Cranks.SeedWork.Domain --version 0.1.0-alpha.333
NuGet\Install-Package Cranks.SeedWork.Domain -Version 0.1.0-alpha.333
<PackageReference Include="Cranks.SeedWork.Domain" Version="0.1.0-alpha.333" />
paket add Cranks.SeedWork.Domain --version 0.1.0-alpha.333
#r "nuget: Cranks.SeedWork.Domain, 0.1.0-alpha.333"
// Install Cranks.SeedWork.Domain as a Cake Addin #addin nuget:?package=Cranks.SeedWork.Domain&version=0.1.0-alpha.333&prerelease // Install Cranks.SeedWork.Domain as a Cake Tool #tool nuget:?package=Cranks.SeedWork.Domain&version=0.1.0-alpha.333&prerelease
Cranks.SeedWork
This library is intendended to provide a usefull set of base classes and support to write your own applications based on the Domain Driven Design principle. It is intended to be primarily used in new applications, so it targets .NET 6.0 right now, and future version will most probably bump that even further, so it can make use of modern language features.
It uses source generators to simplify a lot of the boilerplate you would have to normally write.
Packages
Cranks.SeedWork.Domain
The only available package and still in a very early alpha phase. It provides support to write value objects and smart enums
Usage
Domain
ValueObjects
Define a value object like this
[ValueObject] // Without this, no source generation or analyzers are used.
public partial record Money(decimal Value) : ValueObject<Money>;
When there is only a single parameter in the primary constructor, the provided source generators automatically generate cast operators from and to the type of parameter type. If the type is IComparable, it also generates automatic forwards to the IComparable implementation of the parameter type as well as comparison operators.
Value objects can also have multiple values
[ValueObject] // Without this, no source generation or analyzers are used.
public partial record Address(string street, string zipcode, string city) : ValueObject<Address>;
For value objects with more than one parameter, there is currently no automatic code generation.
SmartEnums
Smart enums are extended enumeration classes which provide more functionality then the base enum
types of C#. They can be defined like this.
[SmartEnum]
public sealed partial record AddressType(string Key)
: SmartEnum<string>(Key) // the base class needs to know the key type of the enumeration
{
public static readonly AddressType Unknown = new("unknown"); // Enum instances need to be public static readonly
public static readonly AddressType Private = new("private"); // it's recommended not to use nameof here, since it will limit you from renaming the enums
public static readonly AddressType Business = new("business");
}
you can use it like
var private = AddressType.Private;
var allAdressTypes = AddressType.AllValues; // AllValues returns all enum instances
// TryGet and Get work similar to Parse/TryParse
var tryget = AddressType.TryGet("business", out var found) ? found : null;
var get = AddressType.Get("invalid value"), // throws
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Cranks.Targets.AnalyzerReference (>= 1.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.2.0-alpha.4 | 119 | 10/16/2022 |
0.2.0-alpha.1 | 115 | 10/15/2022 |
0.1.0 | 1,215 | 10/13/2022 |
0.1.0-alpha.333 | 102 | 10/13/2022 |
0.1.0-alpha.254 | 105 | 10/8/2022 |
0.1.0-alpha.185 | 105 | 10/8/2022 |
0.1.0-alpha.118 | 101 | 10/5/2022 |
0.1.0-alpha.55 | 101 | 10/4/2022 |
0.1.0-alpha.54 | 103 | 10/4/2022 |