{"id":29124888,"url":"https://github.com/h-shahzaib/flynth","last_synced_at":"2025-06-29T21:07:28.299Z","repository":{"id":275958456,"uuid":"927720552","full_name":"h-shahzaib/Flynth","owner":"h-shahzaib","description":"A modern, easy-to-use, and readable alternative to legacy text templating and source code generation libraries, featuring a C# based fluent API.","archived":false,"fork":false,"pushed_at":"2025-06-26T09:58:56.000Z","size":80,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-26T10:36:32.675Z","etag":null,"topics":["c-sharp","code","csharp","easy","fluent","gen","generator","library","modern","sharp","source"],"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/h-shahzaib.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,"zenodo":null}},"created_at":"2025-02-05T12:38:58.000Z","updated_at":"2025-06-26T09:58:59.000Z","dependencies_parsed_at":"2025-02-05T17:44:18.913Z","dependency_job_id":"0c2d7fa3-9505-40a7-99ff-b4cff3a902fd","html_url":"https://github.com/h-shahzaib/Flynth","commit_stats":null,"previous_names":["shahzaib1432/fluentsourcegenerator","h-shahzaib/fluent-source-generator","h-shahzaib/flynth"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/h-shahzaib/Flynth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h-shahzaib%2FFlynth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h-shahzaib%2FFlynth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h-shahzaib%2FFlynth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h-shahzaib%2FFlynth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/h-shahzaib","download_url":"https://codeload.github.com/h-shahzaib/Flynth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h-shahzaib%2FFlynth/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262667296,"owners_count":23345534,"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":["c-sharp","code","csharp","easy","fluent","gen","generator","library","modern","sharp","source"],"created_at":"2025-06-29T21:07:23.169Z","updated_at":"2025-06-29T21:07:28.286Z","avatar_url":"https://github.com/h-shahzaib.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flynth.CSharp\n\n\u003e **Flynth.CSharp** is a fluent, zero-dependency source code generator for C#.\n\u003e It helps you create structured C# source code through a clean, builder-style API — so you can focus on _what_ to generate, not _how_ to format it.\n\n---\n\n## 📦 Installation\n\nInstall via the .NET CLI:\n\n```\ndotnet add package Flynth.CSharp\n```\n\n---\n\n## 🚀 Overview\n\nBuilt on **.NET Standard 2.0**, Flynth.CSharp works across **all .NET versions** with **no external dependencies**.\nIt handles indentation, structure, formatting, and character escaping — all out of the box.\n\n---\n\n## ✨ Key Features\n\n### ✅ Fluent API — Code That Writes Code\n\nWrite source generation logic that looks nearly identical to the output.\nNo manual formatting, indentation, or brace management required.\n\n### 🧠 Token-Aware Formatting\n\nThe builder system knows its context — it places line breaks and indentation only where needed, making your generated code clean and readable.\n\n### 🔄 Character Replacement System\n\nWrite code with backticks instead of escaped double quotes:\n\n```csharp\n_method.Line(\"Console.WriteLine(`Hello World!`);\");\n```\n\nYou can customize or remove replacements:\n\n```csharp\n_root.ChildOptions.RegisterCharReplacement('`', '\"');\n_root.ChildOptions.RemoveCharReplacement('`');\n```\n\n---\n\n## 🧪 Example\n\nThis C# code:\n\n```csharp\nusing System.IO;\nusing System.Collections.Generic;\n\nnamespace MyNamespace\n{\n    public class Program\n    {\n        public static async Task Main(string[] args)\n        {\n            Console.WriteLine(\"Hello World!\");\n            Console.WriteLine(\"Hello World!\");\n\n            var employees = await m_DbContext.Employees\n               .Where(i =\u003e i.Age \u003e= 30)\n               .ToListAsync();\n\n            Console.WriteLine($\"Total employees count: {employees.Count}\");\n        }\n    }\n}\n```\n\nCan be generated like this:\n\n```csharp\nusing Flynth.CSharp;\n\nvar _root = new SourceBuilder();\n_root.Using(\"System.IO\");\n_root.Using(\"System.Collections.Generic\");\n\n_root.Namespace(\"MyNamespace\", _namespace =\u003e\n{\n    _namespace.Class(\"public\", \"Program\", _class =\u003e\n    {\n        _class.Method(\"public static async\", \"Task\", \"Main\", \"string[] args\", _method =\u003e\n        {\n            _method.Line(\"Console.WriteLine(`Hello World!`);\");\n            _method.Line(\"Console.WriteLine(`Hello World!`);\");\n\n            _method.Lines(\n                \"var employees = await m_DbContext.Employees\",\n                \"   .Where(i =\u003e i.Age \u003e= 30)\",\n                \"   .ToListAsync();\"\n            );\n\n            _method.Line(\"Console.WriteLine($`Total employees count: {employees.Count}`);\");\n        });\n    });\n});\n\nvar result = _root.ToString();\n```\n\n---\n\n## ⚠️ Compatibility Note\n\nFlynth works with all .NET targets that support **.NET Standard 2.0**.\nIf you're using older .NET versions like .NET Core \u003c 3.0 or .NET Framework, be aware of this:\n\n### 🔁 Variable Name Conflicts in Nested Scopes\n\nOlder compilers don't allow reuse of the same variable name inside nested lambdas:\n\n```csharp\n_class.Method(\"public\", \"void\", \"Main\", \"\", _method =\u003e\n{\n    _method.Line(\"var number = 10;\");\n\n    _method.Method(\"\", \"void\", \"InnerMethod\", \"\", _method =\u003e // ❌ Conflict\n    {\n        _method.Line(\"var number = 20;\");\n    });\n});\n```\n\n#### ✅ Solution:\n\nUse a different name in inner scopes (e.g. `_inner_method`).\n\n---\n\n## 🤔 Why Flynth?\n\n- ✅ Fluent, readable, and chainable API\n- ✅ No need to manage syntax or formatting manually\n- ✅ Output closely mirrors your generation code\n- ✅ No dependencies\n- ✅ Works with any .NET project\n\n---\n\n## 📚 Getting Started\n\n1. Install the package\n2. Use `SourceBuilder` to define your structure\n3. Call `.ToString()` to get the generated code\n\n---\n\n## 🔗 Links\n\n- 📦 NuGet: [https://www.nuget.org/packages/Flynth.CSharp/](https://www.nuget.org/packages/Flynth.CSharp/)\n- 💻 GitHub: [https://github.com/h-shahzaib/Flynth](https://github.com/h-shahzaib/Flynth)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fh-shahzaib%2Fflynth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fh-shahzaib%2Fflynth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fh-shahzaib%2Fflynth/lists"}