{"id":25501074,"url":"https://github.com/NeVeSpl/NTypewriter","last_synced_at":"2025-11-11T22:30:20.314Z","repository":{"id":37475100,"uuid":"326057371","full_name":"NeVeSpl/NTypewriter","owner":"NeVeSpl","description":"File/code generator using Scriban text templates populated with C# code metadata from Roslyn API.","archived":false,"fork":false,"pushed_at":"2024-04-15T16:47:58.000Z","size":60490,"stargazers_count":112,"open_issues_count":13,"forks_count":23,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-16T03:41:04.881Z","etag":null,"topics":["code-generation","code-generator","csharp-to-typescript","documentation-as-code","documentation-generator","generator","live-documentation","ntypewriter","roslyn-generator","scriban","source-generator","static-file-generator","template","templating","text-templating","typewriter","visual-studio-extension"],"latest_commit_sha":null,"homepage":"https://nevespl.github.io/NTypewriter/","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/NeVeSpl.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","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}},"created_at":"2021-01-01T21:16:56.000Z","updated_at":"2024-05-08T19:08:36.000Z","dependencies_parsed_at":"2024-04-15T18:05:25.569Z","dependency_job_id":null,"html_url":"https://github.com/NeVeSpl/NTypewriter","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NeVeSpl%2FNTypewriter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NeVeSpl%2FNTypewriter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NeVeSpl%2FNTypewriter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NeVeSpl%2FNTypewriter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NeVeSpl","download_url":"https://codeload.github.com/NeVeSpl/NTypewriter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239592970,"owners_count":19664856,"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":["code-generation","code-generator","csharp-to-typescript","documentation-as-code","documentation-generator","generator","live-documentation","ntypewriter","roslyn-generator","scriban","source-generator","static-file-generator","template","templating","text-templating","typewriter","visual-studio-extension"],"created_at":"2025-02-19T04:01:59.690Z","updated_at":"2025-11-11T22:30:20.259Z","avatar_url":"https://github.com/NeVeSpl.png","language":"C#","funding_links":[],"categories":["Content"],"sub_categories":["183. [NTypewriter](https://ignatandrei.github.io/RSCG_Examples/v2/docs/NTypewriter) , in the [Templating](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#templating) category"],"readme":"# NTypewriter\n\n[![ci](https://github.com/NeVeSpl/NTypewriter/actions/workflows/CI.yml/badge.svg)](https://github.com/NeVeSpl/NTypewriter/actions/workflows/CI.yml)\n[![Visual Studio Marketplace Version](https://img.shields.io/visual-studio-marketplace/v/NeVeS.NTypewriterEditorForVisualStudio?color=%230429FF\u0026label=NTypewriter%20editor)](https://marketplace.visualstudio.com/items?itemName=NeVeS.NTypewriterEditorForVisualStudio)\n[![Nuget](https://img.shields.io/nuget/v/NTypewriter.SourceGenerator?color=%23004880\u0026label=NTypewriter.SourceGenerator)](https://www.nuget.org/packages/NTypewriter.SourceGenerator)\n[![Nuget](https://img.shields.io/nuget/v/NTypewriter?color=%23004880\u0026label=NTypewriter%20nugets)](https://www.nuget.org/packages?q=NTypewriter)\n\n![NTypewriter LivePreview](Documentation/LivePreview.gif)\n\n\u003ch3 align=\"center\"\u003e\nScriban templates + Roslyn C# code model =\u003e generated files\n\u003c/h3\u003e\n\u003ch4 align=\"center\"\u003e\ndesign/compile/run time == any time\n\u003c/h4\u003e\n\n\u003cins\u003eFor those who do not know Typewriter\u003c/ins\u003e:\n\nNTypewriter is files generator from text templates populated with meta-data about your C# code. It is like a specialized and more convenient T4 design-time template.\n\nWith NTypewriter you can:\n- auto-generate documentation for your C# code\n- create a typed TypeScript API client for your ASP.net web API\n\nNTypewriter comes in many flavours, that can be used according to your needs:\n- [NTypewriter editor for Visual Studio](Documentation/EditorForVisualStudio.md#NTypewriter-editor-for-Visual-Studio) - extension for Visual Studio that adds support for editing *.nt templates, with syntax highlighting, code completion, live preview, design time rendering, [available on vs marketplace](https://marketplace.visualstudio.com/items?itemName=NeVeS.NTypewriterEditorForVisualStudio)   \n- [NTypewriter.SourceGenerator](Documentation/SourceGenerator.md#NTypewriterSourceGenerator) - nuget, Roslyn source generator that renders *.nt templates during compilation, since it is a compiler extension, it can be used with any IDE or CI/pipeline that supports source generators\n- [NTypewriter.Online](https://nevespl.github.io/NTypewriter/) - blazor client side, online demo of NTypewriter capabilities\n- NTypewriter - nuget, library that enables you to create run time solution which will be able to render *.nt templates, for example: [your own CLI](Documentation/NTypewriter.md#Build-your-own-CLI)\n- NTypewriter.CodeModel.Roslyn - nuget, library that exposes C# code model from an instance of `Microsoft.CodeAnalysis.Compilation`, useful if you would like to use a different template engine  \n\nmore about NTypewriter architecture and all extension points that can be used, you will find [here](Documentation/Architecture.md#NTypewriter-architecture)\n\n\n\u003cins\u003eFor those who know Typewriter\u003c/ins\u003e:\n\nNTypewriter is a younger and more immature brother of beloved [Typewriter](https://github.com/frhagn/Typewriter). They share the same ideas but with a completely different implementation. NTypwriter uses [Scriban](https://github.com/scriban/scriban) as a template engine, thus template files are completely not interchangeable. While code model API is about 95% compatible between them, there are some differences. NTypewriter code model is 100% pure, without any amenities that help generate TS files. All things that help  generate TypeScript from ASP.NET are located in built-in functions: [Action](Documentation/BuiltInFunctions.md#actionfunctions), [Type](Documentation/BuiltInFunctions.md#typefunctions).\n\nOh, did I forget to mention that NTypewriter also solves most of the awaited issues of the Typewriter that were promised for 2.0 version:\n- support for attribute properties/values, statics, indexers, default parameters, nullable, records, constructors\n- output multiple types to a single file\n- include types in CodeModel from referenced assemblies/nugets\n- save generated file only when file content has changed\n- sharable custom functions between templates\n- full control over whitespaces\n- compile-time rendering, without any IDE needed\n- built-in support for getting all types used in type declaration ([Type.AllReferencedTypes](Documentation/BuiltInFunctions.md#allreferencedtypes))\n- you can debug custom functions\n\n \n### Index\n\n* [Typewriter vs NTypewriter](#Typewriter-vs-NTypewriter)\n* [Examples: *.nt templates](#Examples)\n* Getting started\n   * [NTypewriter editor for Visual Studio](Documentation/EditorForVisualStudio.md#Getting-started)\n       * [Install](Documentation/EditorForVisualStudio.md#Install)\n       * [CodeModel](Documentation/EditorForVisualStudio.md#CodeModel)\n       * [Capture](Documentation/EditorForVisualStudio.md#Capture)       \n       * [Save](Documentation/EditorForVisualStudio.md#Save)\n       * [Run](Documentation/EditorForVisualStudio.md#Run)\n       * [When something goes wrong](Documentation/EditorForVisualStudio.md#Error)\n   * [NTypewriter.SourceGenerator](Documentation/SourceGenerator.md)\n   * [Build your own CLI](Documentation/NTypewriter.md#Build-your-own-CLI)\n* Documentation\n   * [Template language](https://github.com/scriban/scriban/blob/master/doc/language.md)\n   * [Code model](Documentation/CodeModel.md)\n   * [Built-in functions](Documentation/BuiltInFunctions.md)   \n   * [Name vs BareName vs FullName](Documentation/NameVariants.md)\n   * Custom Functions\n       * [Nugets](Documentation/CustomFunctions.md#Nugets)\n       * [Custom functions](Documentation/CustomFunctions.md#Custom-functions)  \n       * [How to debug](Documentation/CustomFunctions.md#How-to-debug)\n   * Configuration\n       * [Nugets](Documentation/Configuration.md#Nugets)\n       * [Local vs Global configuration](Documentation/Configuration.md#local-vs-global-configuration)       \n       * Options    \n           * [AddGeneratedFilesToVSProject](Documentation/Configuration.md#AddGeneratedFilesToVSProject)\n           * [NamespacesToBeSearched](Documentation/Configuration.md#NamespacesToBeSearched)\n           * [ProjectsToBeSearched](Documentation/Configuration.md#ProjectsToBeSearched)  \n           * [SearchInReferencedProjectsAndAssemblies](Documentation/Configuration.md#SearchInReferencedProjectsAndAssemblies)   \n           * [RenderWhenTemplateIsSaved](Documentation/Configuration.md#renderwhentemplateissaved)\n           * [RenderWhenProjectBuildIsDone](Documentation/Configuration.md#RenderWhenProjectBuildIsDone)\n   * [Visual Studio Configuration](Documentation/EditorForVisualStudio.md#Configuration)\n       * [Live preview](Documentation/EditorForVisualStudio.md#Live-preview)\n        \n* [Known issues](#Known-issues)\n\n\n## Typewriter vs NTypewriter\n\n\u0026nbsp;| Typewriter | NTypewriter\n----------|------------ | -------------\nTemplate file extension | *.tst | *.nt\nSyntax   | typewriter syntax | [scriban scripting language](https://github.com/scriban/scriban/blob/master/doc/language.md)\nLambda filters | present | yes\nCan be used from CLI | no | yes \nCan be used in pipeline  | no | yes \nFull control over whitespaces | nope | [yup](https://github.com/scriban/scriban/blob/master/doc/language.md#14-whitespace-control)\nMapping | one input always produces one output file | you can generate as many files as you want\nLive preview | no | yes\n**Code model** | \nUnit of work | file | there is no concept of a file in NTypewriter, you work on compiled symbols\nAccess modifiers | code model contains only public types | code model contains all types \nPartial classes | treated as separate units | all parts of the class are treated as a whole unit\n**Automation** | \nAuto-render template on save| yes (opt-out is possible)| [yes (opt-in is possible)](Documentation/Configuration.md#renderwhentemplateissaved)\nAuto-render when C# file changes| yes (opt-out is possible)| no\nAuto-render on build | no | [yes (opt-in is possible)](Documentation/Configuration.md#RenderWhenProjectBuildIsDone)\n**Custom functions** | \nPlacement|inside template file (.tst)| in separate file (*.nt.cs)|\nCan be shared|separate for every template| shared between templates inside a project |\nCan be debug|no| [yes](Documentation/CustomFunctions.md#How-to-debug) |\nCan be unit tested | no | yes\n**VS Integration** |\nSupported versions of Visual Studio | 2015, 2017, 2019 | 2019 ([min ver 16.11.x](https://github.com/NeVeSpl/NTypewriter/issues/55)), 2022\nAdd generated files to VS project | yes (opt-out is possible) | [yes (opt-out is possible)](Documentation/Configuration.md#addgeneratedfilestovsproject)\nSync deleted or renamed C# types with generated files | there is a part of the code that should do that  but it does not work anymore | yes (only when the above option is enabled)\n\n\n\nTypewriter template:\n```\nmodule App { $Classes(*Model)[\n    export class $Name { $Properties[\n        public $name: $Type;]\n    }]\n}\n```\nequivalent NTypewriter template will be: ([open in NTypewriter.Online](https://nevespl.github.io/NTypewriter?exampleId=type01))\n```\n{{- for class in data.Classes | Symbols.WhereNameEndsWith \"Model\"\n        capture output -}}\nmodule App {\n    export class {{ class.Name }} {\n            {{- for property in class.Properties | Symbols.ThatArePublic }}\n        public {{ property.Name | String.ToCamelCase }}: {{ property.Type | Type.ToTypeScriptType }};\n            {{- end }}\n    }\n}\n    {{- end \n        filePath =  class.BareName | String.Append \".ts\"\n        Save output filePath\n    end }}\n```\n \nyes, it is more verbose, but maintaining it over time will be much easier. Both templates generate exactly the same output:\n```ts\nmodule App {\n    export class CustomerModel {\n        public id: number;\n        public name: string;\n        public orders: OrderModel[];\n    }\n}\n```\n\n## Examples\n\nAll [Typewriter examples](https://frhagn.github.io/Typewriter/pages/examples.html) are  available as .nt templates on github and also on NTypewriter.Online website. \n\u003e **Note**\n \u003e nt. templates produce exactly the same output as .tst templates, even bad output formatting was preserved, to make them easier to compare. \n\nexample | NTypewriter | Typewriter | Online\n--------|------------|------------|------------\nCreateYourFirstTemplate | [CreateYourFirstTemplate.nt](https://github.com/NeVeSpl/NTypewriter.Examples/blob/master/WebApplication/Examples/CreateYourFirstTemplate/nt/CreateYourFirstTemplate.nt) | [CreateYourFirstTemplate.tst](https://github.com/NeVeSpl/NTypewriter.Examples/blob/master/WebApplication/Examples/CreateYourFirstTemplate/tst/CreateYourFirstTemplate.tst) | [open](https://nevespl.github.io/NTypewriter?exampleId=type01)\nExtensions | [Extensions.nt](https://github.com/NeVeSpl/NTypewriter.Examples/blob/master/WebApplication/Examples/Extensions/nt/Extensions.nt) | [Extensions.tst](https://github.com/NeVeSpl/NTypewriter.Examples/blob/master/WebApplication/Examples/Extensions/tst/Extensions.tst) | [open](https://nevespl.github.io/NTypewriter?exampleId=type05)\nModelInterfaces | [ModelInterfaces.nt](https://github.com/NeVeSpl/NTypewriter.Examples/blob/master/WebApplication/Examples/ModelInterfaces/nt/ModelInterfaces.nt) | [ModelInterfaces.tst](https://github.com/NeVeSpl/NTypewriter.Examples/blob/master/WebApplication/Examples/ModelInterfaces/tst/ModelInterfaces.tst) | [open](https://nevespl.github.io/NTypewriter?exampleId=type02)\nKnockoutModels | [KnockoutModels.nt](https://github.com/NeVeSpl/NTypewriter.Examples/blob/master/WebApplication/Examples/KnockoutModels/nt/KnockoutModels.nt) | [KnockoutModels.tst](https://github.com/NeVeSpl/NTypewriter.Examples/blob/master/WebApplication/Examples/KnockoutModels/tst/KnockoutModels.tst) | [open](https://nevespl.github.io/NTypewriter?exampleId=type03)\nAngularWebAPIService | [AngularWebAPIService.nt](https://github.com/NeVeSpl/NTypewriter.Examples/blob/master/WebApplication/Examples/AngularWebAPIService/nt/AngularWebAPIService.nt) | [AngularWebAPIService.tst](https://github.com/NeVeSpl/NTypewriter.Examples/blob/master/WebApplication/Examples/AngularWebAPIService/tst/AngularWebAPIService.tst) | [open](https://nevespl.github.io/NTypewriter?exampleId=type04)\n\n## Known issues\n\nNTypewriter does not have own a lexer/parser as Typewriter has, and uses Scriban instead to do heavy work. Scriban works very well with fully correct templates,  but with incomplete templates during editing not so much. It is the source of the most glitches in the Editor. Scriban language is also typeless, thus doing code completion is challenging.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNeVeSpl%2FNTypewriter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FNeVeSpl%2FNTypewriter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNeVeSpl%2FNTypewriter/lists"}