Community Post: C# 15 union types and closed hierarchies - #26207
Merged
Merged
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
|
Images automagically compressed by Calibre's image-actions ✨ Compression reduced images by 73.4%, saving 660.4 KB.
|
Contributor
|
Images automagically compressed by Calibre's image-actions ✨ Compression reduced images by 5.4%, saving 8.6 KB.
3 images did not require optimisation. |
fahrigedik
approved these changes
Sep 23, 2026
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Unresolved review findings include a critical architectural issue and an ambiguity in the reusable generic result example.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (3)
What changed in this PR
This PR adds a Community Article on C# 15 union types, closed hierarchies, and ABP integration.
Changes:
- Explains exhaustive state and result modeling.
- Covers JSON serialization, caching, and versioning.
- Provides API, generic-result, and migration guidance.
| File | Review summary |
|---|---|
docs/en/Community-Articles/2026-09-23-csharp-15-union-types-and-closed-hierarchies/post.md |
Open findings cover a critical layering issue, generic-result conversion ambiguity, sample reproducibility, and closed-hierarchy wording. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| Placing an order has four *expected* outcomes, and only one of them is a success. Running out of stock isn't exceptional in an online shop; it happens every day, and the caller must handle it. That's a perfect fit for the `PlaceOrderResult` union we declared earlier. The domain service returns cases directly, and the implicit conversion works even through `Task<PlaceOrderResult>`: | ||
|
|
||
| ```csharp | ||
| public async Task<PlaceOrderResult> PlaceAsync(PlaceOrderInput input, CancellationToken cancellationToken = default) |
Comment on lines
+483
to
+485
| public static implicit operator Result<T>(T value) => new Success<T>(value); | ||
|
|
||
| public static implicit operator Result<T>(Error error) => new Failure<T>(error); |
| dotnet add test/OrderDemo.Tests package Microsoft.Extensions.TimeProvider.Testing | ||
| ``` | ||
|
|
||
| Then add the code from this article: the domain types, `Order`, `OrderPlacementService`, the in-memory stores, the API's `Program.cs` and DTOs, and the `Directory.Build.props` from the migration section. The API also needs `public partial class Program;` at the end of `Program.cs`, so that `WebApplicationFactory<Program>` can find it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



No description provided.