AdaskoTheBeAsT.Typewriter.CodeModel
4.17.0
dotnet add package AdaskoTheBeAsT.Typewriter.CodeModel --version 4.17.0
NuGet\Install-Package AdaskoTheBeAsT.Typewriter.CodeModel -Version 4.17.0
<PackageReference Include="AdaskoTheBeAsT.Typewriter.CodeModel" Version="4.17.0" />
<PackageVersion Include="AdaskoTheBeAsT.Typewriter.CodeModel" Version="4.17.0" />
<PackageReference Include="AdaskoTheBeAsT.Typewriter.CodeModel" />
paket add AdaskoTheBeAsT.Typewriter.CodeModel --version 4.17.0
#r "nuget: AdaskoTheBeAsT.Typewriter.CodeModel, 4.17.0"
#:package AdaskoTheBeAsT.Typewriter.CodeModel@4.17.0
#addin nuget:?package=AdaskoTheBeAsT.Typewriter.CodeModel&version=4.17.0
#tool nuget:?package=AdaskoTheBeAsT.Typewriter.CodeModel&version=4.17.0
🧩 Typewriter CodeModel
CodeModel contracts, configuration types, and helper extension methods for Typewriter .tst templates, #load C# helper files, and external template helper libraries.
✨ What is included
Typewriter.CodeModel(File,Class,Record,Struct,Interface,Enum,EnumValue,Delegate,Method,Property,Parameter,Field,Constant,Event,Attribute,AttributeArgument,DocComment,Type,TypeParameter, collections, andNameCasehelpers)Typewriter.Configuration(Settings,PartialRenderingMode,DateLibrary)Typewriter.Extensions.Documentation(DocCommentExtensions)Typewriter.Extensions.Types(TypeExtensions)Typewriter.Extensions.WebApi(HttpMethodExtensions,RequestDataExtensions,UrlExtensions)Typewriter.VisualStudio(ILog,NullLog)
🚀 Referencing without conflicts
Typewriter's CLI and language server already load Typewriter.CodeModel in the template host. Follow the patterns below so IDE IntelliSense works in your helper .cs files without shipping unnecessary runtime DLLs or causing duplicate-assembly (CS0433) conflicts.
1. Reference as a compile-only dependency (PrivateAssets="all" + ExcludeAssets="runtime")
Add the package with PrivateAssets="all" and ExcludeAssets="runtime" so it is available to the IDE and compiler for IntelliSense, does not flow transitively to downstream projects, and is not copied into your application's runtime bin output:
<ItemGroup>
<PackageReference Include="AdaskoTheBeAsT.Typewriter.CodeModel" Version="4.17.0" PrivateAssets="all" ExcludeAssets="runtime" />
</ItemGroup>
2. Using #load C# helper files vs #r helper assemblies
When a .tst template uses #load "TemplateHelpers.cs", Typewriter splices the body of TemplateHelpers.cs directly into the generated TypewriterTemplateHost class.
Because #load files often contain bare methods (such as string ToCustomName(Class c) => ...;) rather than a top-level class declaration, compiling bare methods directly inside a standard .csproj will fail with C# compiler errors (CS0116 / CS8803).
Choose one of the following patterns to get full IDE IntelliSense on Typewriter.CodeModel types without breaking your build:
Option A — Conditional
#if !TYPEWRITERclass wrapper (recommended for#loadhelper files): Typewriter automatically defines theTYPEWRITERpreprocessor symbol when compiling.tsttemplates and#loadfiles. Wrap your bare helper methods in#if !TYPEWRITER ... #endifwith apartial classso multiple#loadfiles compile cleanly inside a standard.csprojwithout requiring any custom<DefineConstants>or thin.tstwrapper methods:// templates/_helpers/ModelHelpers.cs using Typewriter.CodeModel; #if !TYPEWRITER public partial class _ { #endif public string CustomTypeName(Class c) => $"I{c.Name}Dto"; #if !TYPEWRITER } #endifThen load and use the helper directly in your
.tsttemplate:${ #load "_helpers/ModelHelpers.cs" } $Classes[$CustomTypeName]Option B — Static class inside
#loadwith thin template wrappers: Write astatic classinside your.cshelper file so it compiles cleanly as valid C# in any project that referencesAdaskoTheBeAsT.Typewriter.CodeModel:// templates/_helpers/ModelHelpers.cs using Typewriter.CodeModel; static class ModelHelpers { public static string GetCustomTypeName(Class c) => $"I{c.Name}Dto"; }Because
#loadsplicesstatic class ModelHelpersas a nested class inside the template host, expose a one-line wrapper method in the template (or at the bottom of the#loadfile if excluded fromCompile):${ #load "_helpers/ModelHelpers.cs" string CustomTypeName(Class c) => ModelHelpers.GetCustomTypeName(c); }Option C — Compiled helper class library with
#r(recommended for large or unit-tested helpers): Put your helper methods in apublic staticclass inside a dedicated helper project (netstandard2.0ornet10.0) that referencesAdaskoTheBeAsT.Typewriter.CodeModelwithPrivateAssets="all" ExcludeAssets="runtime":using Typewriter.CodeModel; namespace MyProject.TypewriterHelpers; public static class ModelHelpers { public static string GetCustomTypeName(Class c) => $"I{c.Name}Dto"; }Then reference the compiled helper assembly from your
.tsttemplate:${ #r "bin/Release/netstandard2.0/MyProject.TypewriterHelpers.dll" using MyProject.TypewriterHelpers; string CustomTypeName(Class c) => ModelHelpers.GetCustomTypeName(c); }Option D — Bare
#loadmethods excluded from the application build: IfTemplateHelpers.cscontains bare methods without a wrappingclassor#if !TYPEWRITERguard, exclude the template helper folder fromCompilein your application.csprojsodotnet buildignores it while the project still holds theAdaskoTheBeAsT.Typewriter.CodeModelpackage reference:<ItemGroup> <PackageReference Include="AdaskoTheBeAsT.Typewriter.CodeModel" Version="4.17.0" PrivateAssets="all" ExcludeAssets="runtime" /> <Compile Remove="templates/**/*.cs" /> <None Include="templates/**/*.cs" /> </ItemGroup>
3. Do not #r this package inside .tst templates
Do not add #r "nuget: AdaskoTheBeAsT.Typewriter.CodeModel" or #r "Typewriter.CodeModel.dll" inside .tst files. The Typewriter engine and language server automatically reference the host's Typewriter.CodeModel assembly and import the default Typewriter.* namespaces for every template.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.