Ubiquity.NET.SrcGeneration 20.1.8

Requires NuGet 4.9.0 or higher.

dotnet add package Ubiquity.NET.SrcGeneration --version 20.1.8
                    
NuGet\Install-Package Ubiquity.NET.SrcGeneration -Version 20.1.8
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Ubiquity.NET.SrcGeneration" Version="20.1.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ubiquity.NET.SrcGeneration" Version="20.1.8" />
                    
Directory.Packages.props
<PackageReference Include="Ubiquity.NET.SrcGeneration" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Ubiquity.NET.SrcGeneration --version 20.1.8
                    
#r "nuget: Ubiquity.NET.SrcGeneration, 20.1.8"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Ubiquity.NET.SrcGeneration@20.1.8
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Ubiquity.NET.SrcGeneration&version=20.1.8
                    
Install as a Cake Addin
#tool nuget:?package=Ubiquity.NET.SrcGeneration&version=20.1.8
                    
Install as a Cake Tool

Ubiquity.NET.SrcGeneration

This library provides support for source generation using System.CodeDom.Compiler.IndentedTextWriter. While .NET does have support for T4 to generate source that is used at runtime to generate a final source this can easily get VERY terse and hard to use. (Let alone debug, especially with respect to correct white space.) Thus, while it is useful for simpler templating when things get complicated and there are lots of "decisions" to make based on the input it can get downright unruly.

Support includes

  • StringExtensions to support manipulations of strings commonly used by source generators
    • Method to split a string into lines fit for use in XML doc comments
    • Method to escape processing for a single string for comments
      • Currently the only escape processed is '\n' which is transformed into an environment specific newline.
    • Method to split a string into lines where a newline is the delimiter
    • Method to Escape a string for use in XML (Specifically XML doc comments but any XML usage is valid)
    • Escaping a sequence of strings for use in XML doc comments
    • Sequence of string transforms to remove side by side duplicates
  • IndentedTextWriterExtensions to provide extensions for an IndentedTextWriter
    • Extensions to support auto out-denting via IDisposable in a RAII like pattern
    • Extension to write an empty line (Without any indentation)
      • While IndentedTextWriter has this via the IndentedTextWriter.WriteLineNoTabs(string), this extension makes it simpler and clearer what the intent was.
    • Extension to generate a block of code that has subsequent content indented.
      • Including an opening and closing text as well as an optional leading line
      <Leading Line Text>
      <Scope Begin Text>
      [additional lines of text]
      <Scope End - emmitted on Dispose of return (RAII pattern)>
      

C# target language specific support

While other languages are possible this is the only one currently "built-in".

  • CSharpLanguage contains constants and statics for generating C# source
    • Constants for the open/close of a scope ("{","}")
    • Array of known keywords to allow escaping text that uses them
    • Function to make an identifier out of a string
      • Keywords in the array of known keywords are escaped with a '@' prefix.
  • IndentedTextWriterCsExtensions To provide extensions to IndentedTextWriter that are specific to the C# language.
    • Write a auto-generated comment in a form recognized by the compiler as generated for use in determining if analyzers apply or not. (Usually analyzers are set to ignore generated code as it isn't something that is controlled by the developer).
    • Write an auto generated comment as a scope to allow adding custom content in the comment
      • Closing of the comment region doesn't occur until the return is Disposed (RAII pattern)
    • Write a namespace scope
      • All subsequent content is indented for the scope
      • Closing of the scope doesn't occur until the return is Disposed (RAII pattern).
    • Write a struct scope
      • All subsequent content is indented for the scope
      • Closing of the scope doesn't occur until the return is Disposed (RAII pattern).
    • Write an unsafe block scope
      • All subsequent content is indented for the scope
      • Closing of the scope doesn't occur until the return is Disposed (RAII pattern).
    • Write a generic scope
      • All subsequent content is indented for the scope
      • Closing of the scope doesn't occur until the return is Disposed (RAII pattern).
    • Write a multi-line comment
      • Creates a scope using "*" and "*/" as the beginning/ending of the block
      • Input string is escaped and converted to a sequence of lines that is emitted as the indented contents of the comment.
    • Write a class scope
      • All subsequent content is indented for the scope
      • Closing of the scope doesn't occur until the return is Disposed (RAII pattern).
  • TextWriterCsExtension to provide more extensions to a TextWriter that are specific to the C# language.
    • Method to write an attribute line
    • Method to write (without new line) an attribute
    • Method to write an XML Doc comment summary tag.
    • Method to write an XML Doc comment remarks tag.
    • Method to write an XML Doc comment summary and remarks tags with optional default summary contents
    • Method to write a using directive.
Product 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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Ubiquity.NET.SrcGeneration:

Package Downloads
Ubiquity.NET.Runtime.Utils

General use Support for interpreters/runtimes

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
20.1.8 424 11/17/2025
20.1.8-rc.3 221 11/16/2025
20.1.8-rc.2 158 11/14/2025
20.1.8-rc.1 220 11/13/2025
20.1.8-rc 216 11/2/2025
20.1.8-epsilon 140 10/11/2025