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
<PackageReference Include="Ubiquity.NET.SrcGeneration" Version="20.1.8" />
<PackageVersion Include="Ubiquity.NET.SrcGeneration" Version="20.1.8" />
<PackageReference Include="Ubiquity.NET.SrcGeneration" />
paket add Ubiquity.NET.SrcGeneration --version 20.1.8
#r "nuget: Ubiquity.NET.SrcGeneration, 20.1.8"
#:package Ubiquity.NET.SrcGeneration@20.1.8
#addin nuget:?package=Ubiquity.NET.SrcGeneration&version=20.1.8
#tool nuget:?package=Ubiquity.NET.SrcGeneration&version=20.1.8
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
StringExtensionsto 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.
- Currently the only escape processed is
- 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
IndentedTextWriterExtensionsto provide extensions for anIndentedTextWriter- Extensions to support auto out-denting via IDisposable in a RAII like pattern
- Extension to write an empty line (Without any indentation)
- While
IndentedTextWriterhas this via theIndentedTextWriter.WriteLineNoTabs(string), this extension makes it simpler and clearer what the intent was.
- While
- 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".
CSharpLanguagecontains 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.
IndentedTextWriterCsExtensionsTo provide extensions toIndentedTextWriterthat are specific to the C# language.- Write a
auto-generatedcomment in a form recognized by the compiler asgeneratedfor 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).
- Write a
TextWriterCsExtensionto provide more extensions to aTextWriterthat 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
summarytag. - Method to write an XML Doc comment
remarkstag. - Method to write an XML Doc comment
summaryandremarkstags with optional defaultsummarycontents - Method to write a
usingdirective.
| 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 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. |
-
.NETStandard 2.0
- System.Collections.Immutable (>= 10.0.0)
- Ubiquity.NET.Extensions (>= 20.1.8)
-
net8.0
- Ubiquity.NET.Extensions (>= 20.1.8)
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 |