Overloader 1.0.1
See the version list below for details.
dotnet add package Overloader --version 1.0.1
NuGet\Install-Package Overloader -Version 1.0.1
<PackageReference Include="Overloader" Version="1.0.1"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Overloader --version 1.0.1
#r "nuget: Overloader, 1.0.1"
// Install Overloader as a Cake Addin #addin nuget:?package=Overloader&version=1.0.1 // Install Overloader as a Cake Tool #tool nuget:?package=Overloader&version=1.0.1
<h1 align="center">Overloader</h1>
Overloader is the open-source source generator that provide unsafe generics. The main target of this project helps to write unsafe generics which don't have any common based interface or type. Also, create method parameters overloads that helps improve developer experience.
Installation
NuGet: dotnet add package overloader
Specific types on generics
Uncompilable code
public static class GenericMath
{
public static T Square<T>(T val) where T : double, float => val * val;
}
Solution
[Overload(typeof(float), "D", "F")]
public static class GenericMathD
{
public static double Square([T] double val) => val * val;
}
Generated part
[Overload(typeof(float), "D", "F")]
public static partial class GenericMathF
{
public static double Square([T] float val) => val * val;
}
P.S. GenericMath provided in preview versions of .net try to resolve this problem, but we can't restrict needed types.
Parameter overload creation to avoid additional struct/class allocation
User template
[Formatter(typeof(Vector2<>),
new object[] {"T"},
new object[]
{
"X", "T",
"Y", "T"
})]
[Overload(typeof(float), "2D", "2F")]
public static partial class Vector2DExtension
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: T]
public static ref Vector2<double> Sum([Integrity][T] this ref Vector2<double> vec1, [T] in Vector2<double> vec2)
{
vec1.X += vec2.X;
vec1.Y += vec2.Y;
return ref vec1;
}
}
Generated part
[Overload(typeof(float), "2D", "2F")]
public static partial class Vector2FExtension
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: T]
public static ref Overloader.Examples.Vector2<float> Sum([Integrity][T] this ref Overloader.Examples.Vector2<float> vec1, [T] float vec2X, float vec2Y)
{
vec1.X += vec2X;
vec1.Y += vec2Y;
return ref vec1;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: T]
public static ref Overloader.Examples.Vector2<float> Sum([Integrity][T] this ref Overloader.Examples.Vector2<float> vec1, [T] in Overloader.Examples.Vector2<float> vec2)
{
vec1.X += vec2.X;
vec1.Y += vec2.Y;
return ref vec1;
}
}
License
Overloader is licensed under the MIT license.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.CodeAnalysis.CSharp (>= 4.2.0)
- Microsoft.CodeAnalysis.CSharp.Workspaces (>= 4.2.0)
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 |
---|---|---|
3.0.3 | 155 | 7/2/2024 |
3.0.2 | 256 | 11/24/2023 |
3.0.1 | 205 | 10/21/2023 |
3.0.0 | 187 | 9/7/2023 |
2.2.3 | 194 | 7/30/2023 |
2.2.2 | 200 | 7/23/2023 |
2.2.1 | 177 | 7/22/2023 |
2.2.0 | 213 | 7/1/2023 |
2.1.9 | 198 | 6/24/2023 |
2.1.8 | 188 | 6/18/2023 |
2.1.7 | 178 | 6/16/2023 |
2.1.6 | 195 | 5/20/2023 |
2.1.5 | 186 | 5/20/2023 |
2.1.4 | 282 | 3/25/2023 |
2.1.3 | 421 | 11/22/2022 |
2.1.2 | 408 | 11/22/2022 |
2.1.1 | 370 | 11/15/2022 |
2.1.0 | 363 | 11/15/2022 |
2.0.9 | 427 | 11/13/2022 |
2.0.8 | 395 | 11/13/2022 |
2.0.7 | 412 | 11/13/2022 |
2.0.6 | 421 | 11/6/2022 |
2.0.5 | 420 | 11/6/2022 |
2.0.4 | 431 | 11/6/2022 |
2.0.3 | 403 | 10/27/2022 |
2.0.2 | 455 | 10/25/2022 |
2.0.1 | 508 | 10/25/2022 |
2.0.0 | 511 | 10/18/2022 |
1.1.3 | 480 | 9/19/2022 |
1.1.2 | 488 | 9/18/2022 |
1.1.1 | 523 | 9/18/2022 |
1.1.0 | 483 | 9/17/2022 |
1.0.9 | 480 | 9/5/2022 |
1.0.8 | 484 | 9/4/2022 |
1.0.7 | 453 | 9/4/2022 |
1.0.6 | 468 | 8/29/2022 |
1.0.5 | 468 | 8/29/2022 |
1.0.4 | 464 | 8/28/2022 |
1.0.3 | 443 | 8/24/2022 |
1.0.2 | 472 | 8/19/2022 |
1.0.1 | 471 | 8/19/2022 |
1.0.0 | 526 | 8/19/2022 |