UnlimitedSharp.GenericInference
1.0.0
dotnet add package UnlimitedSharp.GenericInference --version 1.0.0
NuGet\Install-Package UnlimitedSharp.GenericInference -Version 1.0.0
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="UnlimitedSharp.GenericInference" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add UnlimitedSharp.GenericInference --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: UnlimitedSharp.GenericInference, 1.0.0"
#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.
// Install UnlimitedSharp.GenericInference as a Cake Addin #addin nuget:?package=UnlimitedSharp.GenericInference&version=1.0.0 // Install UnlimitedSharp.GenericInference as a Cake Tool #tool nuget:?package=UnlimitedSharp.GenericInference&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
This packages enables the inference of generic type parameters from the constraints of other type parameters, as well as inference from deconstruction variables. Just install the package and the following code, otherwise invalid, magically starts compiling and working as expected:
static class Example
{
static void Deconstruct<T1, T2>(this object[] args, out T1 var1, out T2 var2)
{
var1 = (T1)args[0];
var2 = (T2)args[1];
}
static void Constrain<T, U>(T t) where T : IEnumerable<U>
{
foreach (var u in t)
Console.WriteLine(u);
}
static void Test()
{
object[] args = { "1", 2 };
(string first, int second) = args; //inferred Deconstruct<string, int>
var list = new List<int>();
Constrain(list); //inferred Constrain<List<int>, int>
}
}
There are no supported framework assets in this package.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 120 | 9/27/2024 |