mcintyre321/oneof

Easy to use F#-like ~discriminated~ unions for C# with exhaustive compile time matching

View on GitHub ↗Jump to charts ↓

Summary Information

Updated 1 hour ago
Type:Library / SDKCategory(s):Core & Utility LibrariesLanguages & Runtimes
Added to GitGenius on September 17th, 2026
Created on January 12th, 2016
Open Issues & Pull Requests: 68 (+0)
GitHub issues: Enabled
Number of forks: 164
Total Stargazers: 4,055 (+0)
Total Subscribers: 52 (+0)

Repository Insights (GitGenius)

Median issue/PR response: 2.2 days
Mean response time: 93.4 days
90th percentile: 179.4 days
Tracked items: 24

Most active contributors

Sign in to see contributor activity.

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 23
New in 7 days: 0
Closed in 7 days: 0
Avg open age: 708 days
Stale 30+ days: 22
Stale 90+ days: 20

Recent activity

Opened in 7 days: 0
Closed in 7 days: 0
Comments in 7 days: 0
Events in 7 days: 0

Top labels

No label distribution available yet.

Most active issues this week

Sign in to see which issues are moving.

Detailed Description

OneOf is a C# library that provides F#-style discriminated unions using a custom generic type that holds a single value from a specified set of types.

The library solves the problem of expressing multiple possible return types from a method while maintaining type safety and forcing callers to handle all cases. Instead of using exception-based control flow, custom result base types, or non-descriptive return types, OneOf lets you declare exactly which types a method might return. The approach uses a generic OneOf type parameterized with all possible result types, and callers use a Match method that requires a handler function for each possible type, making it impossible to forget a case.

Developers should choose this tool when they want method signatures that accurately document all possible outcomes and need compile-time guarantees that every case is handled. It works well as a return type when a method can produce different results, as a parameter type to avoid creating multiple overloads, and as an Option type by combining it with utility types like None, Some, or Maybe. The library distinguishes itself from switch statements and if-based control flow by requiring exhaustive matching with no fallback handler, which means adding a new possible return type forces all calling code to be updated rather than silently falling through to a default case.

The project maintains active engagement with its user base through issue responses and accepts pull requests for improvements. Development includes regular updates to the codebase and ongoing refinement of the matching and type-picking APIs based on user feedback.