Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# RSCG - 254 Examples of Roslyn Source Code Generators / 16 created by Microsoft /
# RSCG - 255 Examples of Roslyn Source Code Generators / 16 created by Microsoft /

The RSCG_Examples repository is a comprehensive documentation system that automatically processes and showcases 254 Roslyn Source Code Generator (RSCG) examples. The system transforms individual RSCG projects into structured documentation with code examples and cross-referenced content with a searchable website and code example exports.
The RSCG_Examples repository is a comprehensive documentation system that automatically processes and showcases 255 Roslyn Source Code Generator (RSCG) examples. The system transforms individual RSCG projects into structured documentation with code examples and cross-referenced content with a searchable website and code example exports.

This system serves as both a learning resource for .NET developers interested in source generators and an automated pipeline for maintaining up-to-date documentation about the RSCG ecosystem

## Latest Update : 2026-02-02 => 02 February 2026
## Latest Update : 2026-02-13 => 13 February 2026

If you want to see examples with code, please click ***[List V2](https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG)***

Expand All @@ -24,8 +24,30 @@ If you want to be notified each time I add a new RSCG example , please click htt

## Content

Those are the 254 Roslyn Source Code Generators that I have tested you can see and download source code example.
Those are the 255 Roslyn Source Code Generators that I have tested you can see and download source code example.
( including 16 from Microsoft )
### 255. [KnockOff](https://ignatandrei.github.io/RSCG_Examples/v2/docs/KnockOff) , in the [Tests](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#tests) category

Generated on : 2026-02-13 => 13 February 2026

<details>
<summary>Expand</summary>



Author: Keith Voels

A Roslyn Source Generator for creating unit test stubs. Unlike Moq's fluent runtime configuration, KnockOff uses partial classes for compile-time setup—trading flexibility for readability and performance.

Nuget: [https://www.nuget.org/packages/KnockOff/](https://www.nuget.org/packages/KnockOff/)


Link: [https://ignatandrei.github.io/RSCG_Examples/v2/docs/KnockOff](https://ignatandrei.github.io/RSCG_Examples/v2/docs/KnockOff)

Source: [https://github.com/NeatooDotNet/KnockOff](https://github.com/NeatooDotNet/KnockOff)

</details>

### 254. [ErrorOrX](https://ignatandrei.github.io/RSCG_Examples/v2/docs/ErrorOrX) , in the [API](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#api) category

Generated on : 2026-02-02 => 02 February 2026
Expand Down
2 changes: 1 addition & 1 deletion later.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Just later

## Latest Update : 2026-02-02 => 02 February 2026
## Latest Update : 2026-02-13 => 13 February 2026



Expand Down
42 changes: 42 additions & 0 deletions v2/.tours/KnockOff.tour
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

{
"$schema": "https://aka.ms/codetour-schema",
"title": "KnockOff",
"steps":
[
{
"file": "rscg_examples/KnockOff/src/TestClock/TestClock.csproj",
"description": "First, we add Nuget [KnockOff](https://www.nuget.org/packages/KnockOff/) in csproj ",
"pattern": "KnockOff"
}

,{
"file": "rscg_examples/KnockOff/src/TestClock/TestClock.cs",
"description": "File TestClock.cs ",
"pattern": "this is the code"
}

,{
"file": "rscg_examples/KnockOff/src/Mock/IMyClock.cs",
"description": "File IMyClock.cs ",
"pattern": "this is the code"
}


,{
"file": "rscg_examples/KnockOff/src/TestClock/obj/GX/KnockOff.Generator/KnockOff.KnockOffGenerator/QuickStartRepoStub.g.cs",
"description": "Generated File 2 from 2 : QuickStartRepoStub.g.cs ",
"line": 1
}

,{
"file": "rscg_examples/KnockOff/src/TestClock/obj/GX/KnockOff.Generator/KnockOff.KnockOffGenerator/QuickStartRepoStub.Base.g.cs",
"description": "Generated File 1 from 2 : QuickStartRepoStub.Base.g.cs ",
"line": 1
}

],

"ref": "main"

}
2 changes: 1 addition & 1 deletion v2/Generator/DocusaurusExample.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Source: {{ Description.Generator.Source }}
{{image}}
:::

### Original Readme
## Original Readme
:::note

{{Description.OriginalReadme}}
Expand Down
7 changes: 6 additions & 1 deletion v2/Generator/MultiGeneratorV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,14 @@ public string[] SourceNoRSCG()
text = text.Replace("(LICENSE.TXT)", $"({d.Generator!.Source}/LICENSE.TXT)");
text = text.Replace("(docs/building.md)", $"({d.Generator!.Source}/docs/building.md)");
text = text.Replace("(./", $"({d.Generator!.Source}/");

text = text.Replace("(skills/", $"({d.Generator!.Source}/skills");

text = text.Replace("Access them as a ReadOnlySpan<byte>", "Access them as a ReadOnlySpan\\<byte\\>");
text = text.Replace("### ", "##### ");
text = text.Replace("## ", "#### ");
text = text.Replace("# ", "### ");
Comment on lines +230 to +232
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The heading replacement logic is flawed and causes unintended side effects. The sequential string replacements on lines 230-232 replace ALL occurrences of "# ", "## ", and "### " in the text, not just markdown headings at the start of lines. This causes "C# class" to become "C### class" when line 232 executes. The replacements should use regex with line-start anchors (e.g., Regex.Replace(text, @"^### ", "##### ", RegexOptions.Multiline)) to only affect actual markdown headings, not inline text containing hash symbols.

Copilot uses AI. Check for mistakes.
Comment on lines +230 to +232
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Cascading replacements corrupt markdown headers.

These three sequential Replace calls interfere with each other. For example, an ## Hello input:

  1. Line 230: no match for "### " → unchanged "## Hello"
  2. Line 231: matches "## " → becomes "#### Hello"
  3. Line 232: "# " matches inside "#### Hello" at the last # → becomes "###### Hello" (expected "#### ")

Similarly, ### Hello ends up with 9 # characters instead of 5.

A single replacement achieves the intended +2 level shift for all headers, because it only matches the last # (immediately before the space) in any header prefix:

Proposed fix
-            text = text.Replace("### ", "##### ");
-            text = text.Replace("## ", "#### ");
-            text = text.Replace("# ", "### ");
+            text = text.Replace("# ", "### ");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
text = text.Replace("### ", "##### ");
text = text.Replace("## ", "#### ");
text = text.Replace("# ", "### ");
text = text.Replace("# ", "### ");
🤖 Prompt for AI Agents
In `@v2/Generator/MultiGeneratorV2.cs` around lines 230 - 232, The current
sequential Replace calls on the text variable incorrectly cascade and
over-augment markdown headers; replace those three Replace(...) calls with a
single regex-based replacement that matches a header prefix (one or more '#'
followed by a space) and uses a match evaluator to count the number of '#'
characters and return that many plus two '#' characters followed by a space,
ensuring "## Hello" -> "#### Hello" and "### Hello" -> "##### Hello"; update the
code where text is modified (the lines using text.Replace("### ", ...),
text.Replace("## ", ...), text.Replace("# ", ...)) to use
System.Text.RegularExpressions.Regex.Replace with the evaluator approach so all
header levels are shifted exactly +2.

text= text.Replace("C###", "C#");

return text;
}
;
Expand Down
1 change: 1 addition & 0 deletions v2/Generator/all.csv
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,4 @@ Nr,Key,Source,Category
252,RSCG_idempotency, https://github.com/ignatandrei/RSCG_idempotency,Idempotency
253,FastCloner, https://github.com/lofcz/FastCloner/,Clone
254,ErrorOrX, https://github.com/ANcpLua/ErrorOrX,API
255,KnockOff, https://github.com/NeatooDotNet/KnockOff,Tests
6 changes: 6 additions & 0 deletions v2/RSCGExamplesData/GeneratorDataRec.json
Original file line number Diff line number Diff line change
Expand Up @@ -1540,5 +1540,11 @@
"Category": 15,
"dtStart": "2026-02-02T00:00:00",
"show": true
},
{
"ID": "KnockOff",
"Category": 13,
"dtStart": "2026-02-13T00:00:00",
"show": true
}
]
4 changes: 2 additions & 2 deletions v2/book/examples/ErrorOrX.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ <h1>RSCG nr 254 : ErrorOrX</h1>
<h2>Info</h2>
Nuget : <a href="https://www.nuget.org/packages/ErrorOrX/" target="_blank">https://www.nuget.org/packages/ErrorOrX/</a>

<p>You can find more details at : <a href="https://github.com/ANcpLua/ErrorOrX/" target="_blank"> https://github.com/ANcpLua/ErrorOrX/</a></p>
<p>You can find more details at : <a href="https://github.com/ANcpLua/ErrorOrX" target="_blank"> https://github.com/ANcpLua/ErrorOrX</a></p>

<p>Author :Alexander Nachtmanns</p>

<p>Source: <a href="https://github.com/ANcpLua/ErrorOrX/" target="_blank">https://github.com/ANcpLua/ErrorOrX/</a> </p>
<p>Source: <a href="https://github.com/ANcpLua/ErrorOrX" target="_blank">https://github.com/ANcpLua/ErrorOrX</a> </p>

<h2>About</h2>

Expand Down
64 changes: 64 additions & 0 deletions v2/book/examples/KnockOff.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

<h1>RSCG nr 255 : KnockOff</h1>

<h2>Info</h2>
Nuget : <a href="https://www.nuget.org/packages/KnockOff/" target="_blank">https://www.nuget.org/packages/KnockOff/</a>

<p>You can find more details at : <a href="https://github.com/NeatooDotNet/KnockOff" target="_blank"> https://github.com/NeatooDotNet/KnockOff</a></p>

<p>Author :Keith Voels</p>

Comment on lines +9 to +10
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix minor spacing in the author line.

Line 9 is missing a space after the colon.

Suggested change
-<p>Author :Keith Voels</p>
+<p>Author: Keith Voels</p>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<p>Author :Keith Voels</p>
<p>Author: Keith Voels</p>
🤖 Prompt for AI Agents
In `@v2/book/examples/KnockOff.html` around lines 9 - 10, The author line contains
"Author :Keith Voels" with no space after the colon; update the HTML paragraph
text (the "<p>Author :Keith Voels</p>" element) to insert a space after the
colon so it reads "Author: Keith Voels" (or "Author : Keith Voels" if you prefer
keeping the existing colon spacing), saving the change in the KnockOff.html
file.

<p>Source: <a href="https://github.com/NeatooDotNet/KnockOff" target="_blank">https://github.com/NeatooDotNet/KnockOff</a> </p>

<h2>About</h2>

Generating test stubs with mocking for interfaces

<h2>
How to use
</h2>
<h3>
Add reference to the <a href="https://www.nuget.org/packages/KnockOff/" target="_blank">KnockOff</a> in the csproj
</h3>
<img src="images/KnockOff/TestClock.csproj.png" width="580" height="580" />

<h3>This was for me the <b>starting</b> code</h3>

<br />
I have <b>coded</b> the file IMyClock.cs
<br />
<img src="images/KnockOff/csFiles/IMyClock.cs.png" width="580" height="580" />
<hr />

<br />
I have <b>coded</b> the file TestClock.cs
<br />
<img src="images/KnockOff/csFiles/TestClock.cs.png" width="580" height="580" />
<hr />
<h3>And here are the <i>generated</i> files</h3>

<br />
The file <i>generated</i> is QuickStartRepoStub.Base.g.cs
<br />
<img src="images/KnockOff/generated/QuickStartRepoStub.Base.g.cs.png" width="580" height="580" />

<br />
The file <i>generated</i> is QuickStartRepoStub.g.cs
<br />
<img src="images/KnockOff/generated/QuickStartRepoStub.g.cs.png" width="580" height="580" />
Comment on lines +23 to +48
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add alt text for images (accessibility).

The images are content-bearing (code snippets), so they should include descriptive alt text.

Suggested change (apply to all images)
-<img src="images/KnockOff/TestClock.csproj.png" width="580" height="580" />
+<img src="images/KnockOff/TestClock.csproj.png" width="580" height="580" alt="TestClock.csproj showing KnockOff package reference" />
🤖 Prompt for AI Agents
In `@v2/book/examples/KnockOff.html` around lines 23 - 48, Each <img> tag showing
code or generated files (TestClock.csproj.png, IMyClock.cs.png,
TestClock.cs.png, QuickStartRepoStub.Base.g.cs.png, QuickStartRepoStub.g.cs.png)
must include descriptive alt text; update each tag to add an alt attribute that
succinctly describes the image content (e.g., "TestClock.csproj contents showing
project settings", "IMyClock.cs interface code", "TestClock.cs implementation",
"QuickStartRepoStub.Base.g.cs generated base class", "QuickStartRepoStub.g.cs
generated stub"), so screen readers and accessibility tools can convey the
code-bearing images.


<p>
You can download the code and this page as pdf from
<a target="_blank" href='https://ignatandrei.github.io/RSCG_Examples/v2/docs/KnockOff'>
https://ignatandrei.github.io/RSCG_Examples/v2/docs/KnockOff
</a>
</p>


<p>
You can see the whole list at
<a target="_blank" href='https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG'>
https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG
</a>
</p>

6 changes: 5 additions & 1 deletion v2/book/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</head>
<body>
<h1>
This is the list of 254 RSCG with examples =>
This is the list of 255 RSCG with examples =>
</h1>

<table >
Expand Down Expand Up @@ -1042,6 +1042,10 @@ <h1>
<td>254</td>
<td><a href="examples/ErrorOrX.html">ErrorOrX</a></td>
</tr>
<tr>
<td>255</td>
<td><a href="examples/KnockOff.html">KnockOff</a></td>
</tr>
</table>


Expand Down
1 change: 1 addition & 0 deletions v2/book/pandocHTML.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ input-files:
- examples/RSCG_idempotency.html
- examples/FastCloner.html
- examples/ErrorOrX.html
- examples/KnockOff.html

# or you may use input-file: with a single value
# defaults:
Expand Down
22 changes: 22 additions & 0 deletions v2/rscg_examples/KnockOff/description.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"generator":{
"name":"KnockOff",
"nuget":[
"https://www.nuget.org/packages/KnockOff/"
],
"link":"https://github.com/NeatooDotNet/KnockOff",
"author":"Keith Voels",
"source":"https://github.com/NeatooDotNet/KnockOff"
},
"data":{
"goodFor":["Generating test stubs with mocking for interfaces"],
"csprojDemo":"TestClock.csproj",
"csFiles":["IMyClock.cs","TestClock.cs"],
"excludeDirectoryGenerated":[""],
"includeAdditionalFiles":[""]
},
"links":{
"blog":"",
"video":""
}
}
1 change: 1 addition & 0 deletions v2/rscg_examples/KnockOff/nuget.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A Roslyn Source Generator for creating unit test stubs. Unlike Moq's fluent runtime configuration, KnockOff uses partial classes for compile-time setup—trading flexibility for readability and performance.
Loading