{"id":23895228,"url":"https://github.com/bigabdoul/dynamic-fluent-apis","last_synced_at":"2026-05-14T01:39:12.953Z","repository":{"id":136101565,"uuid":"187099214","full_name":"bigabdoul/dynamic-fluent-apis","owner":"bigabdoul","description":"Provides functionalities that allow building a dynamic assembly with fluent API support for types from another assembly.","archived":false,"fork":false,"pushed_at":"2020-10-09T00:26:17.000Z","size":72,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-14T01:03:02.820Z","etag":null,"topics":["c-sharp","common-intermediate-language","dotnet","dynamic-programming","fluent-api","fluent-design","object-oriented-assembly-language","object-oriented-programming","reflection"],"latest_commit_sha":null,"homepage":null,"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/bigabdoul.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-05-16T20:48:03.000Z","updated_at":"2020-10-09T00:26:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"c7f537b7-d890-494f-8b59-deecb5288f16","html_url":"https://github.com/bigabdoul/dynamic-fluent-apis","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bigabdoul/dynamic-fluent-apis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigabdoul%2Fdynamic-fluent-apis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigabdoul%2Fdynamic-fluent-apis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigabdoul%2Fdynamic-fluent-apis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigabdoul%2Fdynamic-fluent-apis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bigabdoul","download_url":"https://codeload.github.com/bigabdoul/dynamic-fluent-apis/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigabdoul%2Fdynamic-fluent-apis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33006648,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"ssl_error","status_checked_at":"2026-05-13T13:14:51.610Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","common-intermediate-language","dotnet","dynamic-programming","fluent-api","fluent-design","object-oriented-assembly-language","object-oriented-programming","reflection"],"created_at":"2025-01-04T15:52:44.748Z","updated_at":"2026-05-14T01:39:12.948Z","avatar_url":"https://github.com/bigabdoul.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dynamic-fluent-apis\n\nDynamicFluentApis is a .NET (Framework 4.6.1) project written in C# which provides functionalities that allow you to build dynamic assemblies with fluent API support, for types located in other assemblies. Simply put, never, ever write that kind of code again:\n\n```C#\nusing System;\n\nnamespace Demo1.LegacyWayOfProvidingFluentApiSupport\n{\n    public class Program\n    {\n        public static void Main()\n        {\n            var p = new PersonWrapper()\n                .FirstName(\"Abdoul\")\n                .LastName(\"Kaba\")\n                .BirthDate(new DateTime(1990,7,29))\n                .Object;\n            Console.Write($\"Hello, {p.FirstName}! You say you are {p.Age} \");\n            Console.WriteLine(\"and your last name is {p.LastName}, right?\");\n        }\n\n        public interface IPerson\n        {\n            string FirstName { get; set; }\n            string LastName { get; set; }\n            DateTime BirthDate { get; set; }\n            double Age { get; }\n        }\n\n        public class Person : IPerson\n        {\n            public virtual string FirstName { get; set; }\n            public virtual string LastName { get; set; }\n            public virtual DateTime BirthDate { get; set; }\n            public double Age { get =\u003e DateTime.Today.Subtract(BirthDate).TotalDays / 365; }\n        }\n\n        public class PersonWrapper\n        {\n            IPerson _person;\n\n            public PersonWrapper()\n            {\n                _person = new Person();\n            }\n\n            public PersonWrapper(IPerson person)\n            {\n                _person = person;\n            }\n\n            public string FirstName() =\u003e _person.FirstName;\n\n            public PersonWrapper FirstName(string value)\n            {\n                _person.FirstName = value;\n                return this;\n            }\n\n            public string LastName() =\u003e _person.LastName;\n\n            public PersonWrapper LastName(string value)\n            {\n                _person.LastName = value;\n                return this;\n            }\n\n            public DateTime BirthDate() =\u003e _person.BirthDate;\n\n            public PersonWrapper BirthDate(DateTime value)\n            {\n                _person.BirthDate = value;\n                return this;\n            }\n\n            public IPerson Object { get =\u003e _person; }\n        }\n    }\n}\n```\n\nWhat's the problem with the code above? Well, technically not much! But, for every single type you want to be fluent API capable, you need to manually write a wrapper class like `PersonWrapper` just to be able to chain method calls. This can be tedious when you have an assembly with dozens or even hundreds of interesting types you want to support.\n\nThat's where `DynamicFluentApis` steps in and generates all that boiler-plate code for you. So, instead of writing code like the one above, you just let `DynamicFluentApis` generate another dynamic assembly for you that supports fluent API on whatever types you want. You then just grab that assembly and add it as a reference to the latest hot project you're working on.\n\n## Steps to generate a dynamic assembly with fluent API support\n\nFirst things first.\n\n1. From your favourite command line or terminal, change the working directory to one of your liking and then pull this repo with git (or download a zipped version): `\u003e git clone https://github.com/bigabdoul/dynamic-fluent-apis.git`\n2. Reference both projects, namely `DynamicFluentApis` and `DynamicFluentApis.Core`, within a new console or a unit test project (using .NET Framework 4.6.1).\n3. Add a reference to the console project from the library/libraries or project(s) you want to provide fluent API support with. Let's call these referenced assemblies `HumanResources` and `HumanResources.Web.Mvc` for instance.\n4. Pretending that `HumanResources` contains the `Person` class, and `HumanResources.Web.Mvc` contains the `BootstrapModalModel` class, write the following code to get started:\n\n```C#\nusing System;\nusing static System.Console;\nusing DynamicFluentApis;\nusing DynamicFluentApis.Core;\nusing HumanResources;\nusing HumanResources.Web.Mvc;\n\nnamespace Demo2.GeneratingDynamicAssemblies\n{\n    public class Program\n    {\n        public static void Main()\n        {\n            try\n            {\n                // generate a dynamic assembly for the single Person class (very unlikely)\n                // minimalistic approach:\n                var result = FluentApiFactory.Configure().Scan(typeof(Person)).Build().ReleaseResources().Result();\n\n                WriteAssemblyLocation(result);\n\n                // or if you want to scan the whole HumanResources assembly\n                // you have to be explicit; the ScanAssembly(Assembly) and\n                // ScanAssemblyFrom(Type) methods retrieve only types marked\n                // with the custom attribute FluentApiTargetAttribute\n                var types = typeof(Person).Assembly.GetTypes();\n\n                result = FluentApiFactory.Configure(overwrite: true).Scan(types).Build().ReleaseResources().Result();\n\n                WriteAssemblyLocation(result);\n\n                // you can even generate multiple dynamic assemblies\n                // with this full-blown approach:\n                using (var config = FluentApiFactory.Configure(true))\n                {\n                    FluentApiFactoryExecutionResult result1 = null;\n                    result = config\n                        .OnError(error =\u003e WriteLine($\"A critical error occured: {error}\"))\n                        .OnDeleteError((error, builder, file) =\u003e\n                            WriteLine($\"Could not delete the file '{file}'. Reason for failure: {error.Message}\")\n                        )\n                        .WithOverwriteOptions()\n                        // these 'Set...' methods modify the default prefix and suffix values\n                        // public interface IPerson {...}\n                        // internal sealed class PersonCloned : IPerson {...}\n                        .SetProxyClassNameSuffix(\"Cloned\")\n                        .SetFluentTypeNamePrefix(\"Magic\")\n                        // public class MagicPerson { ... public virtual IPerson Target { get; } }\n                        .SetWrappedObjectPropertyName(\"Target\")\n                        .WithConfig()\n                        .ScanAssemblyFrom(typeof(Person))\n                        .Build()\n                        .SetResult(r =\u003e result1 = r)\n                        .Reset()\n                        // default options use 'Proxy' suffix (the above would have been \n                        // 'PersonProxy' instead of 'PersonCloned'),\n                        // and 'Fluent' prefix ('FluentPerson' instead of 'MagicPerson')\n                        .WithDefaultOptions(overwrite: true)\n                        .ScanAssemblyFrom(typeof(BootstrapModalModel))\n                        // will generate, amongst others, the following types:\n                        // public interface IBootstrapModalModel {...}\n                        // internal sealed class BootstrapModalModelProxy : IBootstrapModalModel {...}\n                        // public class FluentBootstrapModalModel {...}\n                        .Build()\n                        .Result();\n\n                    WriteAssemblyLocation(result);\n                    WriteAssemblyLocation(result1);\n                }\n\n                if (result.Succeeded)\n                {\n                    WriteLine(\"What's next? Grab that file and a reference to it in your project.\");\n                    WriteLine(\"You'll be able to use your fluent wrapper as shown in the next demo.\");\n                    Write(\"The assemblies' names are similar to: HumanResources.DynamicFluentApis.abcdef.dll \");\n                    WriteLine(\"and HumanResources.Web.Mvc.DynamicFluentApis.fedcba.dll\");\n                    Write(\"Where 'abcdef' and 'fedcba' are (for instance) the hash codes generated \");\n                    WriteLine(\"for the dynamic fluent API assemblies.\");\n                }\n            }\n            catch(Exception ex)\n            {\n                WriteLine($\"An unexpected error occured: {ex.Message}\");\n            }\n\n            void WriteAssemblyLocation(FluentApiFactoryExecutionResult result)\n            {\n                if (true == result?.Succeeded)\n                {\n                    WriteLine($\"The generated assembly is {Environment.CurrentDirectory}\\\\{result.AssemblyFileName}!\");\n                }\n                else\n                {\n                    WriteLine(\"Could not create the assembly!\");\n                }\n            }\n        }\n    }\n}\n```\n\n## What's going on\n\nYou get the idea? Perfect! Now, before we proceed to see how we can use the assemblies generated in the previous demo, let's examine what's going on here.\n\n## Using the dynamic assemblies\n\n```C#\nusing System;\nusing DynamicFluentApis.Core;\nusing HumanResources.DynamicFluentApis;\nusing HumanResources.Web.Mvc.DynamicFluentApis;\nusing static System.Console;\n\nnamespace Demo3.ShowcasingFluentApiSupport\n{\n    public class Program\n    {\n        public static void Main()\n        {\n            // fluent API support demo coming soon...\n        }\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigabdoul%2Fdynamic-fluent-apis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbigabdoul%2Fdynamic-fluent-apis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigabdoul%2Fdynamic-fluent-apis/lists"}