Skip to content
Merged

first #508

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 - 272 Examples of Roslyn Source Code Generators / 16 created by Microsoft /
# RSCG - 273 Examples of Roslyn Source Code Generators / 16 created by Microsoft /

The RSCG_Examples repository is a comprehensive documentation system that automatically processes and showcases 272 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 273 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-06-29 => 29 June 2026
## Latest Update : 2026-06-30 => 30 June 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 272 Roslyn Source Code Generators that I have tested you can see and download source code example.
Those are the 273 Roslyn Source Code Generators that I have tested you can see and download source code example.
( including 16 from Microsoft )
### 273. [ScottEncodingGenerator](https://ignatandrei.github.io/RSCG_Examples/v2/docs/ScottEncodingGenerator) , in the [FunctionalProgramming](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#functionalprogramming) category

Generated on : 2026-06-30 => 30 June 2026

<details>
<summary>Expand</summary>



Author: Georgiy Petrov

Roslyn incremental source generator for partial interfaces and abstract partial classes that generates Match methods, nested case implementations, and companion module helpers for Scott-encoded types.

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


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

Source: [https://github.com/Georgiy-Petrov/ScottEncodingGenerator](https://github.com/Georgiy-Petrov/ScottEncodingGenerator)

</details>

### 272. [AlephMapper](https://ignatandrei.github.io/RSCG_Examples/v2/docs/AlephMapper) , in the [Database](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#database) category

Generated on : 2026-06-29 => 29 June 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-06-29 => 29 June 2026
## Latest Update : 2026-06-30 => 30 June 2026



Expand Down
5 changes: 4 additions & 1 deletion v2/Generator/MultiGeneratorV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,10 @@ private async Task<Description> GatherData(int nr, string generator, string root
Description? desc = null;
try
{
desc = JsonSerializer.Deserialize<Description>(text);
var opt = new JsonSerializerOptions(JsonSerializerOptions.Default);
opt.AllowTrailingCommas = true;

desc = JsonSerializer.Deserialize<Description>(text,opt);
Comment on lines +436 to +439
}
catch (Exception ex)
{
Expand Down
1 change: 1 addition & 0 deletions v2/Generator/all.csv
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,4 @@ Nr,Key,Source,Category
270,AssemblyMetadata.Generators, https://github.com/loresoft/AssemblyMetadata.Generators,EnhancementProject
271,TypedStateBuilder.Generator, https://github.com/Georgiy-Petrov/TypedStateBuilder.Generator,Builder
272,AlephMapper, https://github.com/Raffinert/AlephMapper,Database
273,ScottEncodingGenerator, https://github.com/Georgiy-Petrov/ScottEncodingGenerator,FunctionalProgramming
6 changes: 6 additions & 0 deletions v2/RSCGExamplesData/GeneratorDataRec.json
Original file line number Diff line number Diff line change
Expand Up @@ -1648,5 +1648,11 @@
"Category": 14,
"dtStart": "2026-06-29T00:00:00",
"show": true
},
{
"ID":"ScottEncodingGenerator",
"Category": 10,
"dtStart": "2026-06-30T00:00:00",
"show": true
}
]
70 changes: 70 additions & 0 deletions v2/book/examples/ScottEncodingGenerator.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

<h1>RSCG nr 273 : ScottEncodingGenerator</h1>

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

<p>You can find more details at : <a href="https://github.com/Georgiy-Petrov/ScottEncodingGenerator" target="_blank"> https://github.com/Georgiy-Petrov/ScottEncodingGenerator</a></p>

<p>Author :Georgiy Petrov</p>

<p>Source: <a href="https://github.com/Georgiy-Petrov/ScottEncodingGenerator" target="_blank">https://github.com/Georgiy-Petrov/ScottEncodingGenerator</a> </p>
Comment on lines +5 to +11

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Add rel="noopener noreferrer" to every new-tab link.

These target="_blank" anchors expose the opener window to reverse-tabnabbing. Please add the rel attribute on the NuGet, GitHub, and docs links in this page.

🔒 Suggested fix
- <a href="https://github.com/Georgiy-Petrov/ScottEncodingGenerator" target="_blank">https://github.com/Georgiy-Petrov/ScottEncodingGenerator</a>
+ <a href="https://github.com/Georgiy-Petrov/ScottEncodingGenerator" target="_blank" rel="noopener noreferrer">https://github.com/Georgiy-Petrov/ScottEncodingGenerator</a>

Also applies to: 21-23, 56-68

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@v2/book/examples/ScottEncodingGenerator.html` around lines 5 - 11, Add
rel="noopener noreferrer" to every anchor in this page that opens in a new tab
to prevent reverse-tabnabbing. Update the links in ScottEncodingGenerator.html
that use target="_blank" for the NuGet, GitHub, and related docs references, and
make sure the same change is applied to the other matching anchors mentioned in
the comment. Locate the affected markup by the existing target="_blank"
attributes and keep the link text and URLs unchanged.


<h2>About</h2>

Usage 1. You declare a union-like type as an abstract partial class and annotate it with ScottEncoding.2. Inside it, you define each case as a sealed partial nested class (in this sample: Ok and None).3. Your business logic returns one of those cases (Ok when save succeeds, None when it does not).4. Consumer code can handle results either with normal C# pattern matching or with the generated functional matching API.2. What the generator adds1. A Match contract on the parent union type, plus per-case implementations that dispatch to the correct handler.2. A companion module with factory helpers to construct each case (Ok / None) without directly calling constructors.3. A fluent matching flow (IfOk(...).IfNone(...)) built on top of Match.4. A generated ScottEncodingAttribute definition, so the attribute is available at compile time.

<h2>
How to use
</h2>
<h3>
Add reference to the <a href="https://www.nuget.org/packages/ScottEncodingGenerator/" target="_blank">ScottEncodingGenerator</a> in the csproj
</h3>
<img src="images/ScottEncodingGenerator/UnionTypesDemo.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 Program.cs
<br />
<img src="images/ScottEncodingGenerator/csFiles/Program.cs.png" width="580" height="580" />
<hr />

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

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

<br />
The file <i>generated</i> is global__UnionTypesDemo_ResultSave_T_.ScottEncoding.g.cs
<br />
<img src="images/ScottEncodingGenerator/generated/global__UnionTypesDemo_ResultSave_T_.ScottEncoding.g.cs.png" width="580" height="580" />

<br />
The file <i>generated</i> is ScottEncodingAttribute.g.cs
<br />
<img src="images/ScottEncodingGenerator/generated/ScottEncodingAttribute.g.cs.png" width="580" height="580" />
Comment on lines +23 to +54

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add alt text to the screenshots.

All of the screenshots on this page are meaningful content, but the <img> tags omit alt. That leaves screen-reader users with no description of the examples.

♿ Suggested fix
- <img src="images/ScottEncodingGenerator/UnionTypesDemo.csproj.png" width="580" height="580" />
+ <img src="images/ScottEncodingGenerator/UnionTypesDemo.csproj.png" width="580" height="580" alt="UnionTypesDemo.csproj screenshot" />

Apply the same pattern to the other screenshots.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@v2/book/examples/ScottEncodingGenerator.html` around lines 23 - 54, Add
descriptive alt text to every meaningful screenshot in
ScottEncodingGenerator.html so screen-reader users can understand the examples;
update each img tag in the ScottEncodingGenerator section, using the surrounding
labels like UnionTypesDemo.csproj, Program.cs, ResultSave.cs, SaveToDatabase.cs,
and the generated file screenshots to craft concise descriptions. Apply the same
alt-text pattern consistently across all images on the page, including the
starting code and generated files screenshots.


<p>
You can download the code and this page as pdf from
<a target="_blank" href='https://ignatandrei.github.io/RSCG_Examples/v2/docs/ScottEncodingGenerator'>
https://ignatandrei.github.io/RSCG_Examples/v2/docs/ScottEncodingGenerator
</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 272 RSCG with examples =>
This is the list of 273 RSCG with examples =>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Escape the > in the heading text.

HTMLHint will keep flagging this raw >; &gt; preserves the rendered text and fixes the markup error.

Proposed fix
-This is the list of 273 RSCG with examples =>
+This is the list of 273 RSCG with examples =&gt;
📝 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
This is the list of 273 RSCG with examples =>
This is the list of 273 RSCG with examples =&gt;
🧰 Tools
🪛 HTMLHint (1.9.2)

[error] 20-20: Special characters must be escaped : [ > ].

(spec-char-escape)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@v2/book/list.html` at line 20, The heading text in the book list contains a
raw greater-than symbol that triggers HTMLHint; update the heading content to
use the escaped form so the rendered text stays the same while the markup
becomes valid. Locate the list heading text in the book list template and
replace the raw symbol with the corresponding HTML entity, keeping the rest of
the heading unchanged.

Source: Linters/SAST tools

</h1>

<table >
Expand Down Expand Up @@ -1114,6 +1114,10 @@ <h1>
<td>272</td>
<td><a href="examples/AlephMapper.html">AlephMapper</a></td>
</tr>
<tr>
<td>273</td>
<td><a href="examples/ScottEncodingGenerator.html">ScottEncodingGenerator</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 @@ -286,6 +286,7 @@ input-files:
- examples/AssemblyMetadata.Generators.html
- examples/TypedStateBuilder.Generator.html
- examples/AlephMapper.html
- examples/ScottEncodingGenerator.html

# or you may use input-file: with a single value
# defaults:
Expand Down
6 changes: 6 additions & 0 deletions v2/docFind.json
Original file line number Diff line number Diff line change
Expand Up @@ -1630,5 +1630,11 @@
"category": "Database",
"href": "/RSCG_Examples/v2/docs/AlephMapper/",
"body": "Source generator for creating projectable companions"
},
{
"title": "ScottEncodingGenerator",
"category": "FunctionalProgramming",
"href": "/RSCG_Examples/v2/docs/ScottEncodingGenerator/",
"body": "Roslyn incremental source generator for partial interfaces and abstract partial classes that generates Match methods, nested case implementations, and companion module helpers for Scott-encoded types."
}
]
33 changes: 33 additions & 0 deletions v2/rscg_examples/ScottEncodingGenerator/description.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"generator":{
"name":"ScottEncodingGenerator",
"nuget":[
"https://www.nuget.org/packages/ScottEncodingGenerator/"
],
"link":"https://github.com/Georgiy-Petrov/ScottEncodingGenerator",
"author":"Georgiy Petrov",
"source":"https://github.com/Georgiy-Petrov/ScottEncodingGenerator"
},
"data":{
"goodFor":["Usage ",
"1. You declare a union-like type as an abstract partial class and annotate it with ScottEncoding.",
"2. Inside it, you define each case as a sealed partial nested class (in this sample: Ok and None).",
"3. Your business logic returns one of those cases (Ok when save succeeds, None when it does not).",
"4. Consumer code can handle results either with normal C# pattern matching or with the generated functional matching API.",
"",
"2. What the generator adds",
"1. A Match contract on the parent union type, plus per-case implementations that dispatch to the correct handler.",
"2. A companion module with factory helpers to construct each case (Ok / None) without directly calling constructors.",
"3. A fluent matching flow (IfOk(...).IfNone(...)) built on top of Match.",
"4. A generated ScottEncodingAttribute definition, so the attribute is available at compile time."
],
"csprojDemo":"UnionTypesDemo.csproj",
"csFiles":["Program.cs","ResultSave.cs","SaveToDatabase.cs"],
"excludeDirectoryGenerated":[""],
"includeAdditionalFiles":[""]
},
"links":{
"blog":"",
"video":""
}
}
1 change: 1 addition & 0 deletions v2/rscg_examples/ScottEncodingGenerator/nuget.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Roslyn incremental source generator for partial interfaces and abstract partial classes that generates Match methods, nested case implementations, and companion module helpers for Scott-encoded types.
Loading
Loading