awesome-repositories.com
Blog
MCP
awesome-repositories.com

Discover the best open-source repositories with AI-powered search.

ExploreCurated searchesOpen-source alternativesSelf-hosted softwareBlogSitemap
ProjectMCP serverAboutHow we rankPress
LegalPrivacyTerms
© 2026 Bringes Technology SRL·VAT RO45896025·hello@awesome-repositories.com
mcintyre321 avatar

mcintyre321/OneOf

0
View on GitHub↗
4,048 stars·164 forks·C#·MIT·8 views

OneOf

OneOf is a C# discriminated union library and source generator that provides functional sum types. It serves as a strongly typed polymorphism tool, allowing developers to define method parameters and return values that can be exactly one of several specific types.

The project implements functional programming patterns to replace generic base classes with type-safe unions. It utilizes a source generator to automatically produce the boilerplate code required to manage these union type hierarchies during compilation.

The library provides mechanisms for pattern matching and union value extraction, featuring compile-time exhaustiveness enforcement to ensure every possible type case is handled in switch expressions. It supports reusable union type definitions and polymorphic API design through multi-type return signatures and parameter support.

Features

  • Discriminated Unions - Provides a library for implementing tagged sum types (discriminated unions) in C# with safe runtime switching.
  • C# Source Code Generators - Utilizes C# source generators to automatically produce the class hierarchies and metadata required for union types.
  • Exhaustiveness Analysis - Analyzes switch expressions to ensure every member of a union is handled, triggering a compiler error for missing cases.
  • Union State Matching - Provides mechanisms to execute specific handler functions based on the active variant of a union type.
  • Exhaustive Pattern Matches - Enforces that all variants of a union are handled in pattern matches, providing warnings or errors for incomplete cases.
  • Container Value Matching - Allows the extraction of values from multi-type containers using structural matching and switch blocks.
  • Type-Safe Discriminated Unions - Implements discriminated unions in C# to ensure every possible type is handled at compile time during pattern matching.
  • Union Types - Provides a utility to generate C# union types that can represent any one of several specified member types.
  • Closed Class Hierarchies - Implements closed class hierarchies via source generation to restrict the possible types within a union.
  • Strongly Typed Polymorphism - Provides a mechanism for defining method parameters and return values that can be exactly one of several specific types.
  • Sum Type Wrappers - Wraps multiple potential types in a single object that preserves type safety while allowing polymorphic value retrieval.
  • Sum Type Return Values - Provides the capability to return a value that can be any one of several predefined specific types.
  • Sum Type Returns - Enables functions to return one of several distinct types, replacing generic base classes with strongly typed signatures.
  • Functional Programming Patterns - Brings F#-style algebraic data types and functional programming paradigms into the imperative C# environment.
  • Union Type Parameters - Allows methods to accept one of several different types as a parameter, reducing the need for multiple method overloads.
  • Polymorphic API Signatures - Enables method signatures that accept or return one of several specific types without relying on generic base classes.
  • Algorithms and Data Structures - Provides discriminated unions with compile-time exhaustive matching.

Star history

Star history chart for mcintyre321/oneofStar history chart for mcintyre321/oneof

How this analysis was created: This summary and feature list are AI-generated from collected project material and can contain mistakes. Stars, license and language are imported from GitHub. Inclusion does not mean that we have tested or audited this project. Check the source documentation for any feature you depend on. Learn more on our About page.

AI search

Explore more awesome repositories

Describe what you need in plain English — the AI ranks thousands of curated open-source projects by relevance.

Start searching with AI

Projects sharing features with OneOf

These projects share indexed features with OneOf. Shared tags can include platform or build tooling; verify the primary use case before treating a result as a replacement.
  • microsoft/typescript-handbookmicrosoft avatar

    microsoft/TypeScript-Handbook

    4,855View on GitHub↗

    This project is a comprehensive guide and educational resource for the TypeScript language. It covers the fundamental principles of the language, including its structural type system, static type analysis, and the process of transpiling typed source files into JavaScript. The material details how to model complex data and reusable type logic using generics, conditional types, and mapped types. It also explains the use of declaration files to provide type safety for external JavaScript libraries and the integration of type checking into existing JavaScript projects via JSDoc annotations. The

    JavaScriptdocumentationlearntypescript
    View on GitHub↗4,855
  • gibbok/typescript-bookgibbok avatar

    gibbok/typescript-book

    10,317View on GitHub↗

    The Concise TypeScript Book: A Concise Guide to Effective Development in TypeScript. Free and Open Source.

    JavaScriptbookfreejavascript
    View on GitHub↗10,317
  • error-or/error-orerror-or avatar

    error-or/error-or

    2,058View on GitHub↗

    Error-or is a library that implements the result pattern to replace exception-based control flow with structured data. It provides a discriminated union implementation that encapsulates either a successful value or an error state within a single type, ensuring that operation outcomes are treated as first-class values. The library enables functional error handling by providing a fluent interface for chaining sequential operations. This monadic pipeline composition allows developers to define dependent operations that automatically short-circuit and return an error if any individual step in the

    C#
    View on GitHub↗2,058
  • microsoft/typespecmicrosoft avatar

    microsoft/typespec

    5,781View on GitHub↗

    TypeSpec is a language for defining cloud API shapes and generating OpenAPI, JSON Schema, and client/server code from a single source of truth. It functions as a protocol-agnostic API designer that models REST, gRPC, and other API protocols using a unified, extensible syntax, with a decorator-based metadata system for attaching metadata, validation rules, and lifecycle visibility to API models and operations. The compiler produces OpenAPI 3.0 specifications and other artifacts, and the tool supports declaring API versions and tracking changes to models, properties, and operations across releas

    Javajson-schemaopenapi3protobuf
    View on GitHub↗5,781
Compare all 30 related projects→

Frequently asked questions

What does mcintyre321/oneof do?

OneOf is a C# discriminated union library and source generator that provides functional sum types. It serves as a strongly typed polymorphism tool, allowing developers to define method parameters and return values that can be exactly one of several specific types.

What are the main features of mcintyre321/oneof?

The main features of mcintyre321/oneof are: Discriminated Unions, C# Source Code Generators, Exhaustiveness Analysis, Union State Matching, Exhaustive Pattern Matches, Container Value Matching, Type-Safe Discriminated Unions, Union Types.

Which projects share features with mcintyre321/oneof?

Projects with overlapping indexed features include: microsoft/typescript-handbook — This project is a comprehensive guide and educational resource for the TypeScript language. It covers the fundamental… error-or/error-or — Error-or is a library that implements the result pattern to replace exception-based control flow with structured data.… gibbok/typescript-book — The Concise TypeScript Book: A Concise Guide to Effective Development in TypeScript. Free and Open Source. microsoft/typespec — TypeSpec is a language for defining cloud API shapes and generating OpenAPI, JSON Schema, and client/server code from… odin-lang/odin — Odin is a compiled, statically typed systems programming language designed for high-performance software development.… typescript-cheatsheets/react — This project is a collection of technical reference guides and cheatsheets for implementing static typing patterns…