{"id":13629499,"url":"https://github.com/emptycoder/Overloader","last_synced_at":"2025-04-17T09:34:14.846Z","repository":{"id":61923926,"uuid":"509921190","full_name":"emptycoder/Overloader","owner":"emptycoder","description":"Generator for method overloads.","archived":false,"fork":false,"pushed_at":"2023-11-26T10:58:23.000Z","size":563,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-26T17:13:53.122Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emptycoder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-03T04:23:58.000Z","updated_at":"2024-06-02T18:36:48.581Z","dependencies_parsed_at":"2024-06-02T18:36:47.427Z","dependency_job_id":"97c0f190-3ac9-4735-8fa5-76b713bbcfb0","html_url":"https://github.com/emptycoder/Overloader","commit_stats":{"total_commits":103,"total_committers":1,"mean_commits":103.0,"dds":0.0,"last_synced_commit":"9edbf9c11a760ad3a99008a8b295a33cdc6a7dbb"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emptycoder%2FOverloader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emptycoder%2FOverloader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emptycoder%2FOverloader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emptycoder%2FOverloader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emptycoder","download_url":"https://codeload.github.com/emptycoder/Overloader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249331826,"owners_count":21252647,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T22:01:12.193Z","updated_at":"2025-04-17T09:34:14.640Z","avatar_url":"https://github.com/emptycoder.png","language":"C#","funding_links":[],"categories":["Contributors Welcome for those"],"sub_categories":["1. [ThisAssembly](https://ignatandrei.github.io/RSCG_Examples/v2/docs/ThisAssembly) , in the [EnhancementProject](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#enhancementproject) category"],"readme":"\u003ch1 align=\"center\"\u003eOverloader\u003c/h1\u003e\n\nOverloader is open-source generator for method overloads.\nSupport of xml documentation for overloads.\n\n# Installation\n[NuGet](https://www.nuget.org/packages/Overloader/): `dotnet add package overloader`\n\n# Specific types on generics\n## Uncompilable code\n```csharp\npublic static class GenericMath\n{\n\tpublic static T Square\u003cT\u003e(T val) where T : double, float =\u003e val * val;\n}\n```\n\n## Solution\n```csharp\n[TSpecify(typeof(double))]\n[Overload(typeof(float), \"D\", \"F\")]\npublic static class GenericMathD\n{\n\tpublic static double Square([T] double val) =\u003e val * val;\n}\n```\n\n## Generated part\n```csharp\npublic static partial class GenericMathF\n{\n\tpublic static double Square(float val) =\u003e val * val;\n}\n```\n\n# Parameter overload creation to avoid additional struct/class allocation\n## User template\n```csharp\n[assembly: Formatter(\n\t\"Vector2\",\n\ttypeof(Vector2\u003c\u003e),\n\tnew object[] {\"T\"},\n\tnew object[]\n\t{\n\t\t\"X\", \"T\",\n\t\t\"Y\", \"T\"\n\t})]\n[TSpecify(typeof(double), \"Vector2\")]\n[Overload(typeof(float), \"2D\", \"2F\")]\npublic static partial class Vector2DExtension\n{\n\t[MethodImpl(MethodImplOptions.AggressiveInlining)]\n\t[return: T]\n\tpublic static ref Vector2\u003cdouble\u003e Sum([Integrity][T] this ref Vector2\u003cdouble\u003e vec1, [T] in Vector2\u003cdouble\u003e vec2)\n\t{\n\t\tvec1.X += vec2.X;\n\t\tvec1.Y += vec2.Y;\n\n\t\treturn ref vec1;\n\t}\n}\n```\n\n## Generated part\n```csharp\npublic static partial class Vector2FExtension\n{\n\t[MethodImpl(MethodImplOptions.AggressiveInlining)]\n\tpublic static ref Vector2\u003cfloat\u003e Sum(this ref Vector2\u003cfloat\u003e vec1, float vec2X, float vec2Y)\n\t{\n\t\tvec1.X += vec2X;\n\t\tvec1.Y += vec2Y;\n\t\treturn ref vec1;\n\t}\n\n\t[MethodImpl(MethodImplOptions.AggressiveInlining)]\n\tpublic static ref Vector2\u003cfloat\u003e Sum(this ref Vector2\u003cfloat\u003e vec1, in Vector2\u003cfloat\u003e vec2)\n\t{\n\t\tvec1.X += vec2.X;\n\t\tvec1.Y += vec2.Y;\n\t\treturn ref vec1;\n\t}\n}\n```\n\n# Parameter overload creation with cast\n## User template\n```csharp\n[assembly: Formatter(\n\t\"Vector2S\",\n\ttypeof(Vector2\u003c\u003e),\n\tnew object[] {\"T\"},\n\tnew object[]\n\t{\n\t\tnameof(Vector2\u003cshort\u003e.X), \"T\",\n\t\tnameof(Vector2\u003cshort\u003e.Y), \"T\"\n\t},\n\tnew object[]\n\t{\n\t\ttypeof(Vector2\u003cushort\u003e),\n\t\t\"(short) ${Var0}.X, (short) ${Var0}.Y\"\n\t})]\n\n[assembly: Formatter(\n\t\"Vector2US\",\n\ttypeof(Vector2\u003c\u003e),\n\tnew object[] {\"T\"},\n\tnew object[]\n\t{\n\t\tnameof(Vector2\u003cushort\u003e.X), \"T\",\n\t\tnameof(Vector2\u003cushort\u003e.Y), \"T\"\n\t},\n\tnew object[]\n\t{\n\t\ttypeof(Vector2\u003cshort\u003e),\n\t\t\"(ushort) ${Var0}.X, (ushort) ${Var0}.Y\"\n\t})]\n\n[TSpecify(typeof(short), \"Vector2S\")]\n[TOverload(typeof(ushort), \"2S\", \"2US\", \"Vector2US\")]\npublic static partial class V2SAdd\n{\n\t[return: T]\n\tpublic static ref Vector2\u003cshort\u003e Add(\n\t\t[T] [Integrity] this ref Vector2\u003cshort\u003e current,\n\t\t[T] Vector2\u003cshort\u003e vector)\n\t{\n\t\tcurrent.X += vector.X;\n\t\tcurrent.Y += vector.Y;\n\t\treturn ref current;\n\t}\n}\n```\n\n## Generated part\n```csharp\npublic static partial class V2SAdd\n{\n\t// Generated by: DecompositionOverload\n\tpublic static ref Vector2\u003cshort\u003e Add(this ref Vector2\u003cshort\u003e current, short vectorX, short vectorY)\n\t{\n\t\tcurrent.X += vectorX;\n\t\tcurrent.Y += vectorY;\n\t\treturn ref current;\n\t}\n\t// Generated by: CastTransitionOverloads\n\tpublic static ref Vector2\u003cshort\u003e Add(this ref Vector2\u003cshort\u003e current, Vector2\u003cushort\u003e vector0) =\u003e\n\t\tref Add(ref current, (short) vector0.X, (short) vector0.Y);\n}\n\npublic static partial class V2USAdd\n{\n\t// Generated by: DecompositionOverload\n\tpublic static ref Vector2\u003cushort\u003e Add(this ref Vector2\u003cushort\u003e current, ushort vectorX, ushort vectorY)\n\t{\n\t\tcurrent.X += vectorX;\n\t\tcurrent.Y += vectorY;\n\t\treturn ref current;\n\t}\n\t// Generated by: IntegrityOverload\n\tpublic static ref Vector2\u003cushort\u003e Add(this ref Vector2\u003cushort\u003e current, Vector2\u003cushort\u003e vector)\n\t{\n\t\tcurrent.X += vector.X;\n\t\tcurrent.Y += vector.Y;\n\t\treturn ref current;\n\t}\n\t// Generated by: CastTransitionOverloads\n\tpublic static ref Vector2\u003cushort\u003e Add(this ref Vector2\u003cushort\u003e current, Vector2\u003cshort\u003e vector0) =\u003e\n\t\tref Add(ref current, (ushort) vector0.X, (ushort) vector0.Y);\n}\n```\n\n# Parameter overload creation with ref attribute\n## User template\n```csharp\n[assembly: Formatter(\n\t\"Vector2S\",\n\ttypeof(Vector2\u003c\u003e),\n\tnew object[] {\"T\"},\n\tnew object[]\n\t{\n\t\tnameof(Vector2\u003cshort\u003e.X), \"T\",\n\t\tnameof(Vector2\u003cshort\u003e.Y), \"T\"\n\t})]\n\n[assembly: Formatter(\n\t\"Vector2US\",\n\ttypeof(Vector2\u003c\u003e),\n\tnew object[] {\"T\"},\n\tnew object[]\n\t{\n\t\tnameof(Vector2\u003cushort\u003e.X), \"T\",\n\t\tnameof(Vector2\u003cushort\u003e.Y), \"T\"\n\t})]\n\n[TSpecify(typeof(short), \"Vector2S\")]\n[TOverload(typeof(ushort), \"2S\", \"2US\", \"Vector2US\")]\npublic static partial class V2SAdd\n{\n\t[return: T]\n\tpublic static ref Vector2\u003cshort\u003e Add(\n\t\t[T] [Integrity] this ref Vector2\u003cshort\u003e current,\n\t\t[T] [Ref] Vector2\u003cshort\u003e vector)\n\t{\n\t\tcurrent.X += vector.X;\n\t\tcurrent.Y += vector.Y;\n\t\treturn ref current;\n\t}\n}\n```\n\n## Generated part\n```csharp\npublic static partial class V2SAdd\n{\n\t// Generated by: DecompositionOverload\n\tpublic static ref Vector2\u003cshort\u003e Add(this ref Vector2\u003cshort\u003e current, short vectorX, short vectorY)\n\t{\n\t\tcurrent.X += vectorX;\n\t\tcurrent.Y += vectorY;\n\t\treturn ref current;\n\t}\n\t// Generated by: RefIntegrityOverloads\n\tpublic static ref Vector2\u003cshort\u003e Add(this ref Vector2\u003cshort\u003e current, ref Vector2\u003cshort\u003e vector)\n\t{\n\t\tcurrent.X += vector.X;\n\t\tcurrent.Y += vector.Y;\n\t\treturn ref current;\n\t}\n}\n\npublic static partial class V2USAdd\n{\n\t// Generated by: DecompositionOverload\n\tpublic static ref Vector2\u003cushort\u003e Add(this ref Vector2\u003cushort\u003e current, ushort vectorX, ushort vectorY)\n\t{\n\t\tcurrent.X += vectorX;\n\t\tcurrent.Y += vectorY;\n\t\treturn ref current;\n\t}\n\t// Generated by: IntegrityOverload\n\tpublic static ref Vector2\u003cushort\u003e Add(this ref Vector2\u003cushort\u003e current, Vector2\u003cushort\u003e vector)\n\t{\n\t\tcurrent.X += vector.X;\n\t\tcurrent.Y += vector.Y;\n\t\treturn ref current;\n\t}\n\t// Generated by: RefIntegrityOverloads\n\tpublic static ref Vector2\u003cushort\u003e Add(this ref Vector2\u003cushort\u003e current, ref Vector2\u003cushort\u003e vector)\n\t{\n\t\tcurrent.X += vector.X;\n\t\tcurrent.Y += vector.Y;\n\t\treturn ref current;\n\t}\n}\n```\n\n# Development\n## How to debug?\n- Use the [launchSettings.json](Properties/launchSettings.json) profile.\n- Debug tests.\n\n## How to see on generated sources?\nAdd the next PropertyGroup into your .csproj file which uses Overloader:\n```xml\n\u003cPropertyGroup\u003e\n\t\u003cEmitCompilerGeneratedFiles\u003etrue\u003c/EmitCompilerGeneratedFiles\u003e\n\t\u003cCompilerGeneratedFilesOutputPath\u003e$(BaseIntermediateOutputPath)\\..\\..\\$(AssemblyName).Generated\u003c/CompilerGeneratedFilesOutputPath\u003e\n\u003c/PropertyGroup\u003e\n```\nSee on \"$(AssemblyName).Generated\" folder.\n\n## How can I determine which syntax nodes I should expect?\nConsider installing the Roslyn syntax tree viewer plugin [Rossynt](https://plugins.jetbrains.com/plugin/16902-rossynt/).\n\n# License\nOverloader distributed under [MIT](./LICENSE) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femptycoder%2FOverloader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femptycoder%2FOverloader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femptycoder%2FOverloader/lists"}