{"id":15036170,"url":"https://github.com/nyrest/fastgenericnew","last_synced_at":"2026-04-02T01:35:36.717Z","repository":{"id":40304512,"uuid":"311108413","full_name":"Nyrest/FastGenericNew","owner":"Nyrest","description":"The ultimate fast alternative to Activator.CreateInstance\u003cT\u003e / new T()","archived":false,"fork":false,"pushed_at":"2025-03-18T01:47:22.000Z","size":4557,"stargazers_count":252,"open_issues_count":4,"forks_count":9,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-03T04:11:22.313Z","etag":null,"topics":["activator","createinstance","csharp","csharp-library","csharp-sourcegenerator","delegate","dotnet","dotnet-core","expression","fast","generic","incremental","library","netframework","nuget","optimization","performance","roslyn","roslyn-analyzer","sourcegenerator"],"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/Nyrest.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":"2020-11-08T16:44:23.000Z","updated_at":"2025-04-02T21:41:00.000Z","dependencies_parsed_at":"2023-11-10T16:25:40.236Z","dependency_job_id":"9c1eed0e-add7-40ce-ae11-d6084656c97f","html_url":"https://github.com/Nyrest/FastGenericNew","commit_stats":{"total_commits":84,"total_committers":4,"mean_commits":21.0,"dds":0.3928571428571429,"last_synced_commit":"3e42654acf289b7d4ce54da500d77825c2553e2b"},"previous_names":["bthree496/fastgenericnew","nyerst/fastgenericnew"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nyrest%2FFastGenericNew","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nyrest%2FFastGenericNew/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nyrest%2FFastGenericNew/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nyrest%2FFastGenericNew/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nyrest","download_url":"https://codeload.github.com/Nyrest/FastGenericNew/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248168094,"owners_count":21058767,"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":["activator","createinstance","csharp","csharp-library","csharp-sourcegenerator","delegate","dotnet","dotnet-core","expression","fast","generic","incremental","library","netframework","nuget","optimization","performance","roslyn","roslyn-analyzer","sourcegenerator"],"created_at":"2024-09-24T20:30:24.996Z","updated_at":"2026-04-02T01:35:36.691Z","avatar_url":"https://github.com/Nyrest.png","language":"C#","readme":"\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/Nyrest/FastGenericNew\"\u003e\u003cimg height=\"320\" src=\"https://github.com/Nyrest/FastGenericNew/raw/main/Assets/FastGenericNew-Wide.svg\"\u003e\u003c/a\u003e\n  \n  \u003ca href=\"https://github.com/Nyrest/FastGenericNew/actions/workflows/tests.yml\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/Nyrest/FastGenericNew/tests.yml?style=for-the-badge\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.nuget.org/packages/FastGenericNew/\"\u003e\u003cimg src=\"https://img.shields.io/nuget/vpre/FastGenericNew?style=for-the-badge\u0026color=0065b3\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.nuget.org/packages/FastGenericNew.SourceGenerator/\"\u003e\u003cimg src=\"https://img.shields.io/nuget/vpre/FastGenericNew.SourceGenerator?label=SourceGenerator\u0026style=for-the-badge\u0026color=0065b3\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n## ✨ Features\n\n- ✔️ **The best** `CreateInstance` ever\n  - Up to 50x faster than `Activator.CreateInstance\u003cT\u003e`\n  - Generic Parameters Support\n  - Zero boxing/unboxing\n  - TryGetValue-like TryFastNew API\n  - Link Mode `PublishTrimmed` Support\n  - Non-Public Constructor Support\n  - No Generic Constraints\n  - Compatible with .NET Standard 2.0\n  - Multiple backend implementations\n  - Heavily tested on Win/Mac/Linux\n\n- 🪛 **Modern** Compiler Integration\n  - Source Generator v2 (Incremental Generator)\n  - Highly Configurable ([Props](https://github.com/Nyrest/FastGenericNew/wiki/SourceGenerator-Options))\n  - Multi-threaded Generation\n\n- 🔥 **Latest** C#/.NET Features Support\n  - [C# 8 Nullable](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/nullable-reference-types) Support\n  - [C# 10 Parameterless struct constructors](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-10.0/parameterless-struct-constructors) Support (Both invokes or not)\n  - WebAssembly Support\n\n## 🔧 Installation\n\n\u003e You should only use one of them\n\n### Pre-Compiled Version\n\n```powershell\ndotnet add package FastGenericNew --version 3.3.1\n```\n\n```xml\n\u003cItemGroup\u003e\n  \u003cPackageReference Include=\"FastGenericNew\" Version=\"3.3.1\" /\u003e\n\u003c/ItemGroup\u003e\n```\n\n### SourceGenerator Version\n\n```powershell\ndotnet add package FastGenericNew.SourceGenerator --version 3.3.1\n```\n\n```xml\n\u003cItemGroup\u003e\n  \u003cPackageReference Include=\"FastGenericNew.SourceGenerator\" Version=\"3.3.1\" /\u003e\n\u003c/ItemGroup\u003e\n```\n#### SourceGeneratorV2 requires\n\u003e ***.NET Standard 2.0*** or above  \n\u003e ***C# 8.0*** or above  \n\u003e ***Roslyn 4.0.1*** or above  \n\u003e ***Modern IDE*** *(Optional)*  [VS2022, Rider, VSCode]\n\n## 📖 Examples\n\n```cs\nusing FastGenericNew;\n\n// Simply replace 'Activator' to 'FastNew'\nvar obj = FastNew.CreateInstance\u003cT\u003e();\n\n// With parameter(s)\nvar obj2 = FastNew.CreateInstance\u003cT, string\u003e(\"text\");\nvar obj3 = FastNew.CreateInstance\u003cT, string, int\u003e(\"text\", 0);\n\n// Try pattern\n// NOTE: The try pattern will only check if the constructor can be called.\n//       It will not catch or handle any exceptions thrown in the constructor.\nif (FastNew.TryCreateInstance\u003cT, string\u003e(\"arg0\", out T result));\n{\n    // ...\n}\n```\n\n### Notes\n\n\u003e **With .NET Framework**, `Activator.CreateInstance\u003cT\u003e()` invokes the parameterless constructor of **ValueType** if  \n\u003e the constraint is `where T : new()` but appears to **ignore the parameterless constructor if the constraint is `where T : struct`**.  \n\u003e **But `FastNew.CreateInstance\u003cT\u003e()` will always invoke the parameterless constructor if it's available.**  \n\u003e \n\u003e If you don't want to invoke the parameterless constructor of **ValueType**,\n\u003e consider using `FastNew.NewOrDefault\u003cT\u003e()` which **will never invoke the parameterless constructor of `ValueType`**\n\n## 🚀 Benchmark  \n\nCheck the full benchmark results here:  \nhttps://github.com/Nyrest/FastGenericNew/blob/main/benchmark_results.md\n\n### **Environment**\n\n```\nBenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.3958/23H2/2023Update/SunValley3)\nAMD Ryzen 9 3900X, 1 CPU, 24 logical and 12 physical cores\n.NET SDK 9.0.100-preview.7.24407.12\n  [Host]     : .NET 8.0.3 (8.0.324.11423), X64 RyuJIT AVX2\n  Job-GFVMQQ : .NET 5.0.17 (5.0.1722.21314), X64 RyuJIT AVX2\n  Job-FGYWFO : .NET 6.0.33 (6.0.3324.36610), X64 RyuJIT AVX2\n  Job-LODQQQ : .NET 8.0.3 (8.0.324.11423), X64 RyuJIT AVX2\n  Job-NXJWMD : .NET 9.0.0 (9.0.24.40507), X64 RyuJIT AVX2\n  Job-VBBRLS : .NET Framework 4.8.1 (4.8.9256.0), X64 RyuJIT VectorSize=256\n```\n\n### Reference Types\n\n[![Benchmark Result of Reference Types](https://raw.githubusercontent.com/Nyrest/FastGenericNew/main/Assets/benchmark_reference.png)](https://github.com/Nyrest/FastGenericNew/blob/main/src/FastGenericNew.Benchmarks/Units/ReferenceTypeBenchmark.cs)\n\n### Value Types\n\n[![Benchmark Result of Value Types](https://raw.githubusercontent.com/Nyrest/FastGenericNew/main/Assets/benchmark_value.png)](https://github.com/Nyrest/FastGenericNew/blob/main/src/FastGenericNew.Benchmarks/Units/ValueTypeBenchmark.cs)\n\n## 📜 License\n\nFastGenericNew is licensed under the [MIT](LICENSE) license.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnyrest%2Ffastgenericnew","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnyrest%2Ffastgenericnew","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnyrest%2Ffastgenericnew/lists"}