VOOZH about

URL: https://www.nuget.org/packages/AnyOf/

⇱ NuGet Gallery | AnyOf 0.5.0.1




AnyOf 0.5.0.1

Prefix Reserved
dotnet add package AnyOf --version 0.5.0.1
 
 
NuGet\Install-Package AnyOf -Version 0.5.0.1
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AnyOf" Version="0.5.0.1" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AnyOf" Version="0.5.0.1" />
 
Directory.Packages.props
<PackageReference Include="AnyOf" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AnyOf --version 0.5.0.1
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AnyOf, 0.5.0.1"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AnyOf@0.5.0.1
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AnyOf&version=0.5.0.1
 
Install as a Cake Addin
#tool nuget:?package=AnyOf&version=0.5.0.1
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

AnyOf

Use the AnyOf<First, TSecond, ...> type to handle multiple defined types as input parameters for methods.

This project uses code generation to generate up to 10 AnyOf-types:

  • AnyOf<TFirst, TSecond>
  • AnyOf<TFirst, TSecond, TThird>
  • AnyOf<TFirst, TSecond, TThird, TFourth>
  • ...

Usage

using System;
using AnyOfTypes;

namespace ConsoleAppConsumer
{
 internal class Program
 {
 private static void Main(string[] args)
 {
 Console.WriteLine(ReturnSomething().CurrentValue);

 X(42);
 X("test");
 }

 // This method returns an string, int or bool in a random way.
 private static AnyOf<string, int, bool> ReturnSomething()
 {
 return new Random().Next(3) switch
 {
 1 => "test",
 2 => 42,
 _ => true,
 };
 }

 // This method accepts only an int and a string.
 private static void X(AnyOf<int, string> value)
 {
 Console.WriteLine("ToString " + value.ToString());
 Console.WriteLine("CurrentValue " + value.CurrentValue);
 Console.WriteLine("IsUndefined " + value.IsUndefined);
 Console.WriteLine("IsFirst " + value.IsFirst);
 Console.WriteLine("IsSecond " + value.IsSecond);

 switch (value.CurrentType)
 {
 case AnyOfType.First:
 Console.WriteLine("AnyOfType = First with value " + value.First);
 break;

 case AnyOfType.Second:
 Console.WriteLine("AnyOfType = Second with value " + value.Second);
 break;

 default:
 Console.WriteLine("???");
 break;
 }
 }
 }
}

Sponsors

Entity Framework Extensions and Dapper Plus are major sponsors and proud to contribute to the development of AnyOf, AnyOf.Newtonsoft.Json and AnyOf.System.Text.Json.

👁 Entity Framework Extensions

👁 Dapper Plus

Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 is compatible.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 is compatible.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 was computed.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp1.0 netcoreapp1.0 was computed.  netcoreapp1.1 netcoreapp1.1 was computed.  netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard1.0 netstandard1.0 is compatible.  netstandard1.1 netstandard1.1 was computed.  netstandard1.2 netstandard1.2 was computed.  netstandard1.3 netstandard1.3 was computed.  netstandard1.4 netstandard1.4 was computed.  netstandard1.5 netstandard1.5 was computed.  netstandard1.6 netstandard1.6 was computed.  netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 is compatible. 
.NET Framework net45 net45 is compatible.  net451 net451 was computed.  net452 net452 was computed.  net46 net46 was computed.  net461 net461 was computed.  net462 net462 was computed.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen30 tizen30 was computed.  tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Universal Windows Platform uap uap was computed.  uap10.0 uap10.0 was computed. 
Windows Phone wp8 wp8 was computed.  wp81 wp81 was computed.  wpa81 wpa81 was computed. 
Windows Store netcore netcore was computed.  netcore45 netcore45 was computed.  netcore451 netcore451 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (10)

Showing the top 5 NuGet packages that depend on AnyOf:

Package Downloads
WireMock.Net.Shared

Shared interfaces, models, enumerations and types.

WireMock.Org.RestClient

A WireMock.org RestClient using RestEase to access the admin interface.

Tingle.EventBus.Transports.Azure.Abstractions

Shared EventBus transport components for Azure.

Tingle.Extensions.Http.Authentication

Authentication handlers for use with HttpClient and Microsoft.Extensions.Http such as Shared Key, API Key and OAuth

CSharp.SourceGenerators.Extensions

Some extensions for a ISourceGenerator and IIncrementalGenerator which can be used to execute a SourceGenerator manually which makes unit-testing easy.

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on AnyOf:

Repository Stars
wiremock/WireMock.Net
WireMock.Net is a flexible product for stubbing and mocking web HTTP responses using advanced request matching and response templating. Based on WireMock Java, but extended and different functionality. Full documentation can be found at https://wiremock.org/dotnet/.
Reloaded-Project/Reloaded-II
Universal .NET Core Powered Modding Framework for any Native Game X86, X64.
StefH/FluentBuilder
A project which uses Source Generation to create a FluentBuilder for a specified model or DTO
Version Downloads Last Updated
0.5.0.1 1,865,843 6/13/2025
0.5.0 90,042 11/24/2024
0.4.0 12,471,843 7/19/2024
0.3.0 19,447,532 1/21/2022
0.2.0 1,249,365 10/11/2021
0.1.0 649 9/21/2021
0.0.23 629 9/15/2021
0.0.22 636 9/15/2021
0.0.21 651 9/14/2021
0.0.20 631 8/26/2021
0.0.19 924 8/26/2021
0.0.18 956 8/15/2021
0.0.17 619 8/10/2021
0.0.16 654 8/8/2021
0.0.15 613 8/7/2021
0.0.13 832 7/25/2021
0.0.12 673 7/8/2021
0.0.11 654 7/5/2021
0.0.10 772 7/4/2021
Loading failed

# 0.5.0 (24 November 2024)
- #23 Fix AnyOfJsonConverter (string and string list) [bug]
- #22 Null pointer in AnyOfJsonConverter.cs [bug]

The full release notes can be found here: https://github.com/StefH/AnyOf/blob/main/ReleaseNotes.md