Skip to content

Commit f44dfa2

Browse files
committed
Update README
1 parent 47ceafa commit f44dfa2

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

README.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@
55

66
A .NET source generator for creating
77
* Simple value objects wrapping other type(s), without the hassle of manual `Equals`/`GetHashCode`
8-
* Value objects wrapping math primitives
9-
* I.e. `[WrapperValueObject(typeof(int))] readonly partial struct MeterLength { }` - the type is implicitly castable to `int`, and you can create your own math operations
8+
* Value objects wrapping math primitives and other types
9+
* I.e. `[WrapperValueObject(typeof(int))] readonly partial struct MeterLength { }` - the type is implicitly castable to `int`
10+
* Math and comparison operator overloads are automatically generated
11+
* `ToString` is generated with formatting options similar to those on the primitive type, i.e. `ToString(string? format, IFormatProvider? provider)` for math types
1012
* Strongly typed ID's
11-
* Similar to F# `type ProductId = ProductId of Guid`, here it becomes `[WrapperValueObject] readonly partial struct ProductId { }`
13+
* Similar to F# `type ProductId = ProductId of Guid`, here it becomes `[WrapperValueObject] readonly partial struct ProductId { }` with a `New()` function similar to `Guid.NewGuid()`
14+
15+
The generator targets .NET Standard 2.0 and has been tested with `netcoreapp3.1` and `net5.0` target frameworks.
16+
The library is alpha quality.
1217

1318
Note that record type feature for structs is planned for C# 10, in which cases some of the
1419
use cases this library supports will be easier to achieve without this libray.
@@ -30,10 +35,12 @@ Or install via CLI
3035
dotnet add package WrapperValueObject.Generator --version 0.0.1-alpha05
3136
```
3237

38+
This package is a build time dependency only.
39+
3340
## Usage
3441

3542
1. Use the attribute to specify the underlying type.
36-
2. Declare the struct or class with the `partial` keyword. (and does not support nested types)
43+
2. Declare the struct or class with the `partial` keyword.
3744

3845
### Strongly typed ID
3946

@@ -125,6 +132,16 @@ Debug.Assert(match.Result.HomeGoals == 2);
125132
Debug.Assert(match.Result.AwayGoals == 1);
126133
```
127134

135+
## Limitations
136+
137+
* Need .NET 5 SDK (I think) due to source generators
138+
* Does not support nested types
139+
* Limited configuration options in terms of what code is generated
140+
141+
## Related projects and inspiration
142+
143+
* [StronglyTypedId](https://github.com/andrewlock/StronglyTypedId) by @andrewlock
144+
128145
## TODO/under consideration
129146

130147
Further development on this PoC was prompted by this discussion: https://github.com/ironcev/awesome-roslyn/issues/17

0 commit comments

Comments
 (0)