Skip to content

Commit 6e3669b

Browse files
committed
updated docs
1 parent 1095172 commit 6e3669b

3 files changed

Lines changed: 23 additions & 10 deletions

File tree

.github/copilot-instructions.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ The repository is organized as follows:
3838
- `Thinktecture.Runtime.Extensions.EntityFrameworkCore7`: Provides integration with Entity Framework Core 7.
3939
- `Thinktecture.Runtime.Extensions.EntityFrameworkCore8`: Provides integration with Entity Framework Core 8.
4040
- `Thinktecture.Runtime.Extensions.EntityFrameworkCore9`: Provides integration with Entity Framework Core 9.
41+
- `Thinktecture.Runtime.Extensions.EntityFrameworkCore10`: Provides integration with Entity Framework Core 10.
4142
- `Thinktecture.Runtime.Extensions.AspNetCore`: Provides extensions for ASP.NET Core, primarily for model binding of Smart Enums, Value Objects, and Discriminated Unions.
4243
- `Thinktecture.Runtime.Extensions.Swashbuckle`: Provides extensions for Swashbuckle (OpenAPI).
4344
- **`test/`**: Contains unit tests, with a structure that mirrors the `src/` directory.
@@ -62,16 +63,19 @@ The repository is organized as follows:
6263
## Core Feature Details
6364

6465
### Value Objects (`[ValueObject]`, `[ComplexValueObject]`)
66+
6567
- **Simple vs. Complex**: The library distinguishes between simple (keyed) value objects that wrap a single value, and complex value objects that compose multiple properties.
6668
- **Validation**: Prefer implementing the static partial method `ValidateFactoryArguments` for validation logic. This allows for returning a `ValidationError` and is used by factory methods (`Create`, `TryCreate`, `Validate`). Avoid `ValidateConstructorArguments` as it can only throw exceptions, which integrates poorly with frameworks.
6769
- **Customization**: Pay attention to attributes like `[KeyMemberEqualityComparer]` for custom equality logic (especially for strings) and `[ObjectFactory]` for custom serialization/parsing behavior.
6870

6971
### Smart Enums (`[SmartEnum]`)
72+
7073
- **Keyed vs. Keyless**: Smart Enums can have a key (e.g., `[SmartEnum<string>]`) or be keyless (`[SmartEnum]`).
7174
- **Rich Behavior**: They are not just constants; they can have properties, methods, and item-specific behavior (often implemented via inheritance or delegates using `[UseDelegateFromConstructor]`).
7275
- **Pattern Matching**: Use the generated `Switch` and `Map` methods for exhaustive, type-safe pattern matching.
7376

7477
### Discriminated Unions (`[Union]`)
78+
7579
- **Ad-hoc vs. Regular**: The library supports simple, ad-hoc unions (`[Union<T1, T2>]`) for combining a few types, and regular, inheritance-based unions for modeling more complex domain hierarchies.
7680
- **Serialization**: Ad-hoc unions do not serialize to polymorphic JSON by default. For custom serialization (e.g., to a string), use the `[ObjectFactory<T>]` attribute. Regular unions can be persisted in EF Core using TPH and serialized to polymorphic JSON using `[JsonDerivedType]`.
7781
- **Pattern Matching**: Like Smart Enums, use the generated `Switch` and `Map` methods for exhaustive matching.
@@ -116,9 +120,10 @@ When making changes, please ensure that:
116120
- You preview your changes to ensure they render correctly before submitting a pull request.
117121

118122
## Framework Integration Notes
123+
119124
- **JSON/MessagePack Serialization**: There are two ways to enable serialization for the library types:
120-
1. **Project Reference**: Add a reference to the corresponding integration package (e.g., `Thinktecture.Runtime.Extensions.Json`) in the project where the type is defined. This automatically adds the necessary converter attributes. This is the preferred approach.
121-
2. **Manual Registration**: Register the converter factory (e.g., `ThinktectureJsonConverterFactory`) in your application's `Startup.cs` or `Program.cs`.
125+
1. **Project Reference**: Add a reference to the corresponding integration package (e.g., `Thinktecture.Runtime.Extensions.Json`) in the project where the type is defined. This automatically adds the necessary converter attributes. This is the preferred approach.
126+
2. **Manual Registration**: Register the converter factory (e.g., `ThinktectureJsonConverterFactory`) in your application's `Startup.cs` or `Program.cs`.
122127
- **Entity Framework Core**: Use the `.UseThinktectureValueConverters()` extension method on `DbContextOptionsBuilder` to automatically configure value converters for all supported types in your model. For regular Discriminated Unions, you may need to configure the discriminator manually.
123128
- **ASP.NET Core Model Binding**: For types to be bindable from the request path, query, or body, they often rely on the `IParsable<T>` interface, which the source generator implements. For string-based keys or custom parsing logic, the `[ObjectFactory<string>]` attribute is essential.
124129

@@ -128,17 +133,18 @@ When making changes, please ensure that:
128133

129134
When adding support for a new library (e.g., a new serializer, ORM, or web framework), follow these steps:
130135

131-
1. **Create a new source project**: Add a new `.csproj` file under the `src/` directory (e.g., `src/Thinktecture.Runtime.Extensions.NewIntegration`).
132-
2. **Create a new test project**: Add a corresponding test project under the `test/` directory (e.g., `test/Thinktecture.Runtime.Extensions.NewIntegration.Tests`).
133-
3. **Add projects to the solution**: Use `dotnet sln add` to include both the new source and test projects in the main solution file.
134-
4. **Add dependencies**:
136+
1. **Create a new source project**: Add a new `.csproj` file under the `src/` directory (e.g., `src/Thinktecture.Runtime.Extensions.NewIntegration`).
137+
2. **Create a new test project**: Add a corresponding test project under the `test/` directory (e.g., `test/Thinktecture.Runtime.Extensions.NewIntegration.Tests`).
138+
3. **Add projects to the solution**: Use `dotnet sln add` to include both the new source and test projects in the main solution file.
139+
4. **Add dependencies**:
135140
- The new source project should reference the core `Thinktecture.Runtime.Extensions` project.
136141
- Add a package reference for the library you are integrating with. Manage the version in the `Directory.Packages.props` file.
137-
5. **Implement the integration logic**: Write the necessary code, such as custom converters, providers, or extension methods.
138-
6. **Write comprehensive tests**: Add unit tests in the test project to ensure the integration works correctly and handles edge cases.
139-
7. **Update the documentation**: Modify the existing documentation for Value Objects (`Value-Objects.md`), Smart Enums (`Smart-Enums.md`), and/or Discriminated Unions (`Discriminated-Unions.md`) in the `docs/` directory to include information about the new integration. Avoid creating a new documentation file for the integration itself.
142+
5. **Implement the integration logic**: Write the necessary code, such as custom converters, providers, or extension methods.
143+
6. **Write comprehensive tests**: Add unit tests in the test project to ensure the integration works correctly and handles edge cases.
144+
7. **Update the documentation**: Modify the existing documentation for Value Objects (`Value-Objects.md`), Smart Enums (`Smart-Enums.md`), and/or Discriminated Unions (`Discriminated-Unions.md`) in the `docs/` directory to include information about the new integration. Avoid creating a new documentation file for the integration itself.
140145

141146
### Common Use Cases
147+
142148
When implementing new features, consider these common patterns from the documentation:
143149

144150
- **Value Objects**:

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
[![Thinktecture.Runtime.Extensions.EntityFrameworkCore7](https://img.shields.io/nuget/v/Thinktecture.Runtime.Extensions.EntityFrameworkCore7.svg?maxAge=60&label=Thinktecture.Runtime.Extensions.EntityFrameworkCore7)](https://www.nuget.org/packages/Thinktecture.Runtime.Extensions.EntityFrameworkCore7/)
77
[![Thinktecture.Runtime.Extensions.EntityFrameworkCore8](https://img.shields.io/nuget/v/Thinktecture.Runtime.Extensions.EntityFrameworkCore8.svg?maxAge=60&label=Thinktecture.Runtime.Extensions.EntityFrameworkCore8)](https://www.nuget.org/packages/Thinktecture.Runtime.Extensions.EntityFrameworkCore8/)
88
[![Thinktecture.Runtime.Extensions.EntityFrameworkCore9](https://img.shields.io/nuget/v/Thinktecture.Runtime.Extensions.EntityFrameworkCore9.svg?maxAge=60&label=Thinktecture.Runtime.Extensions.EntityFrameworkCore9)](https://www.nuget.org/packages/Thinktecture.Runtime.Extensions.EntityFrameworkCore9/)
9+
[![Thinktecture.Runtime.Extensions.EntityFrameworkCore10](https://img.shields.io/nuget/v/Thinktecture.Runtime.Extensions.EntityFrameworkCore10.svg?maxAge=60&label=Thinktecture.Runtime.Extensions.EntityFrameworkCore10)](https://www.nuget.org/packages/Thinktecture.Runtime.Extensions.EntityFrameworkCore10/)
910
[![Thinktecture.Runtime.Extensions.Json](https://img.shields.io/nuget/v/Thinktecture.Runtime.Extensions.Json.svg?maxAge=60&label=Thinktecture.Runtime.Extensions.Json)](https://www.nuget.org/packages/Thinktecture.Runtime.Extensions.Json/)
1011
[![Thinktecture.Runtime.Extensions.Newtonsoft.Json](https://img.shields.io/nuget/v/Thinktecture.Runtime.Extensions.Newtonsoft.Json.svg?maxAge=60&label=Thinktecture.Runtime.Extensions.Newtonsoft.Json)](https://www.nuget.org/packages/Thinktecture.Runtime.Extensions.Newtonsoft.Json/)
1112
[![Thinktecture.Runtime.Extensions.MessagePack](https://img.shields.io/nuget/v/Thinktecture.Runtime.Extensions.MessagePack.svg?maxAge=60&label=Thinktecture.Runtime.Extensions.MessagePack)](https://www.nuget.org/packages/Thinktecture.Runtime.Extensions.MessagePack/)
@@ -27,18 +28,21 @@ This library provides some interfaces, classes, [Roslyn Source Generators](https
2728
See [wiki](https://github.com/PawelGerr/Thinktecture.Runtime.Extensions/wiki) for more documentation.
2829

2930
**Value Objects articles**:
31+
3032
* [Value Objects: Solving Primitive Obsession in .NET](https://www.thinktecture.com/en/net/value-objects-solving-primitive-obsession-in-net/)
3133
* [Handling Complexity: Introducing Complex Value Objects in .NET](https://www.thinktecture.com/en/net/handling-complexity-introducing-complex-value-objects-in-dotnet/)
3234
* [Value Objects in .NET: Integration with Frameworks and Libraries](https://www.thinktecture.com/en/net/value-objects-in-net-integration-with-frameworks-and-libraries/)
3335
* [Value Objects in .NET: Enhancing Business Semantics](https://www.thinktecture.com/en/net/value-objects-in-dotnet-enhancing-business-semantics/)
3436
* [Advanced Value Object Patterns in .NET](https://www.thinktecture.com/en/net/advanced-value-object-patterns-in-net/)
3537

3638
**Smart Enums articles**:
39+
3740
* [Smart Enums: Beyond Traditional Enumerations in .NET](https://www.thinktecture.com/en/net/smart-enums-beyond-traditional-enumerations-in-dotnet/)
3841
* [Smart Enums: Adding Domain Logic to Enumerations in .NET](https://www.thinktecture.com/en/net/smart-enums-adding-domain-logic-to-enumerations-in-dotnet/)
3942
* [Smart Enums in .NET: Integration with Frameworks and Libraries](https://www.thinktecture.com/en/net/smart-enums-in-net-integration-with-frameworks-and-libraries/)
4043

4144
**Discriminated Unions articles**:
45+
4246
* [Discriminated Unions: Representation of Alternative Types in .NET](https://www.thinktecture.com/en/net/discriminated-unions-representation-of-alternative-types-in-dotnet/)
4347
* [Pattern Matching with Discriminated Unions in .NET](https://www.thinktecture.com/en/net/pattern-matching-with-discriminated-unions-in-net/)
4448
* [Discriminated Unions in .NET: Modeling States and Variants](https://www.thinktecture.com/en/net/discriminated-unions-in-net-modeling-states-and-variants/)
@@ -85,6 +89,7 @@ Discriminated Unions:
8589

8690
Smart Enums provide a powerful alternative to traditional C# enums, offering type-safety, extensibility, and rich behavior.
8791
Unlike regular C# enums which are limited to numeric values and lack extensibility, Smart Enums can:
92+
8893
* Use any type as the underlying type (e.g., strings, integers) or none at all
8994
* Include additional fields, properties and behavior
9095
* Use polymorphism to define custom behavior for each value
@@ -110,6 +115,7 @@ Some of the Key Features are:
110115
Roslyn Analyzers and CodeFixes help the developers to implement the Smart Enums correctly
111116

112117
Provides support for:
118+
113119
* JSON (System.Text.Json and Newtonsoft)
114120
* Minimal Api Parameter Binding and ASP.NET Core Model Binding
115121
* Entity Framework Core
@@ -354,6 +360,7 @@ Value objects help solve several common problems in software development:
354360
```
355361

356362
Key Features:
363+
357364
* Two types of value objects:
358365
* Simple value objects (wrapper around a single value with validation)
359366
* Complex value objects (multiple properties representing a single concept)

docs

Submodule docs updated from ed21b8a to aed6863

0 commit comments

Comments
 (0)