{"id":27057934,"url":"https://github.com/mrange/t4include","last_synced_at":"2025-04-05T11:34:09.259Z","repository":{"id":5232988,"uuid":"6409785","full_name":"mrange/T4Include","owner":"mrange","description":"T4Include is C# code intended to be reused as source (as opposed to as binary aka assemblies)","archived":false,"fork":false,"pushed_at":"2017-01-15T22:52:08.000Z","size":1215,"stargazers_count":23,"open_issues_count":4,"forks_count":9,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-05-29T08:37:27.582Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrange.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License.html","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-10-26T20:10:26.000Z","updated_at":"2023-12-12T10:00:49.000Z","dependencies_parsed_at":"2022-08-19T15:20:29.956Z","dependency_job_id":null,"html_url":"https://github.com/mrange/T4Include","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrange%2FT4Include","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrange%2FT4Include/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrange%2FT4Include/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrange%2FT4Include/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrange","download_url":"https://codeload.github.com/mrange/T4Include/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247332060,"owners_count":20921849,"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":"2025-04-05T11:34:08.821Z","updated_at":"2025-04-05T11:34:09.243Z","avatar_url":"https://github.com/mrange.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"T4Include\n=========\n\nT4Include is a library of small and useful functions intended to be \nincluded as source code in .NET (as opposed to referencing them as an assembly which is \nthe standard way of sharing code in .NET).\n\nTo make it easier to get started T4Include can be installed using nuget: \u003chttp://nuget.org/packages/T4Include/\u003e\n\nThe nuget package contains:\n\n```\n  * IncludeHeader.ttinclude    - Shared functionality\n  * IncludeLocalFile.ttinclude - Includes source files located on the local harddrive\n  * IncludeWebFile.ttinclude   - Includes source files located on the web\n  * IncludeProject.ttinclude   - Includes source files located in another C# project\n  * Include_T4Include.tt       - Example on how to reference the source\n```\n\nExample on how to reference dapper:\n```code\n\u003c#\n    Namespace = \"InternalizedDapper\";\n    Includes = new []\n        {\n            Include (@\"StackExchange/dapper-dot-net/master/Dapper%20NET40/SqlMapper.cs\"),\n        };\n#\u003e\n\n\u003c#@ include file=\"$(SolutionDir)\\packages\\T4Include.1.1.2\\T4\\IncludeWebFile.ttinclude\" #\u003e\n```\n\nWhy include source code?\n========================\n\nIs including source code better than referencing an assembly?\n\nIn my humble opinion sharing code by assemblies has some drawbacks that \noccasionally makes assemblies feel clunky.\n\n  * An assembly is a visible dependency:\n    * Visible dependencies cause headaches because we can get version conflicts in large applications with many dependencies. GAC is intended to solve this but requires administrator credentials.\n    * Included source code is an invisible dependency creating no versions conflicts.\n  * We can't cherry-pick functionality from an assembly:\n    * If an assembly contains 1% of functionality I find useful then I still have to ship the 99% non-useful functionality and the hosting executable has to spend time loading it.\n    * Including source code allows cherry-picking of functionality from a library such as T4Include\n  * An assembly requires a certain runtime:\n    * When referencing a .NET4.5 assembly my application has to be using .NET4.5. Sometimes I have hard restrictions on .NET2.0 and then I can't use the function even though I know that the function in question is compatible with .NET2.0.\n    * Included source code can be made to target multiple platforms such as; .NET4.5, .NET2.0, SilverLight, Windows Store and so on\n\nIncluding source doesn't replace referencing an assembly but for sharing code that should be easy to share (i.e. utility functions, collections, extension methods and so on) including source code is a great alternative to referencing an assembly.\n\nHistory of T4Include\n====================\n\nAfter working in a couple of large organizations with the vision of creating product lines I have been subjected to some of the pains of trying to incorporate product line assets into a single hosting process. This is often painful, sometimes impossible.\n\nThis is a difficult problem and in order to succeed, the whole product line has to be constructed from the start with an eye on how their assets will be integrated with other assets in a single hosting process. At the start of a project, this is often overlooked or forgotten and the problem is first realized when the first application team tries to integrate disparate assets.\n\nAfter a few years of projects of this type, I started thinking about C++ and boost. Boost has two classes of functionality:\n * One part which requires a precompiled library. This is difficult to integrate:\n  * Needs correct compiler\n  * Needs correct architecture\n  * Needs correct build\n  * Creates visible dependencies (with all its woes)\n  * Has to be integrated in the existing build process which slows the often already slow process\n * Another part which only requires the referencing code to #include the file\n  * Often template classes because in C++ template classes can't be put in a precompiled library\n  * Just works\n\nI wanted something like C++'s #include in C#, hence T4Include. But T4Include goes further:\n * It can include from web resources\n * It can include whole projects\n * Including is done when the T4 file output is rebuilt, not necessarily during build \n  * Saves compile time\n * Included code is version controlled in the target project\n  * Simplifies branching\n  * Simplifies change management\n  * Robust\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrange%2Ft4include","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrange%2Ft4include","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrange%2Ft4include/lists"}