Skip to content
Merged

first #502

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

The RSCG_Examples repository is a comprehensive documentation system that automatically processes and showcases 268 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 269 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-05-13 => 13 May 2026
## Latest Update : 2026-05-14 => 14 May 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 268 Roslyn Source Code Generators that I have tested you can see and download source code example.
Those are the 269 Roslyn Source Code Generators that I have tested you can see and download source code example.
( including 16 from Microsoft )
### 269. [LinkDotNet.Enumeration](https://ignatandrei.github.io/RSCG_Examples/v2/docs/LinkDotNet.Enumeration) , in the [Enum](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#enum) category

Generated on : 2026-05-14 => 14 May 2026

<details>
<summary>Expand</summary>



Author: Steven Giesel

Source code generated enumeration with completeness!

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


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

Source: [https://github.com/linkdotnet/Enumeration](https://github.com/linkdotnet/Enumeration)

</details>

### 268. [GenerateDispose](https://ignatandrei.github.io/RSCG_Examples/v2/docs/GenerateDispose) , in the [Disposer](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#disposer) category

Generated on : 2026-05-13 => 13 May 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-05-13 => 13 May 2026
## Latest Update : 2026-05-14 => 14 May 2026



Expand Down
6 changes: 6 additions & 0 deletions v2/RSCGExamplesData/GeneratorDataRec.json
Original file line number Diff line number Diff line change
Expand Up @@ -1624,5 +1624,11 @@
"Category": 18,
"dtStart": "2026-05-13T00:00:00",
"show": true
},
{
"ID": "LinkDotNet.Enumeration",
"Category": 19,
"dtStart": "2026-05-14T00:00:00",
"show": true
}
]
64 changes: 64 additions & 0 deletions v2/book/examples/LinkDotNet.Enumeration.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

<h1>RSCG nr 269 : LinkDotNet.Enumeration</h1>

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

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

<p>Author :Steven Giesel</p>

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

<h2>About</h2>

Generating enumeration from classes in C# with matching

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

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

<br />
The file <i>generated</i> is CarTypes.g.cs
<br />
<img src="images/LinkDotNet.Enumeration/generated/CarTypes.g.cs.png" width="580" height="580" />

<br />
The file <i>generated</i> is EnumerationAttribute.g.cs
<br />
<img src="images/LinkDotNet.Enumeration/generated/EnumerationAttribute.g.cs.png" width="580" height="580" />

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Escape the special character in HTML.

The > character should be escaped as &gt; in HTML content.

🔧 Proposed fix
-This is the list of 269 RSCG with examples =>
+This is the list of 269 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 269 RSCG with examples =>
This is the list of 269 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, Replace the literal ">" character in the HTML
content string "This is the list of 269 RSCG with examples =>" with its
HTML-escaped entity "&gt;"; update the text in v2/book/list.html so the line
reads "This is the list of 269 RSCG with examples =&gt;" to prevent
rendering/parsing issues.

</h1>

<table >
Expand Down Expand Up @@ -1098,6 +1098,10 @@ <h1>
<td>268</td>
<td><a href="examples/GenerateDispose.html">GenerateDispose</a></td>
</tr>
<tr>
<td>269</td>
<td><a href="examples/LinkDotNet.Enumeration.html">LinkDotNet.Enumeration</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 @@ -282,6 +282,7 @@ input-files:
- examples/Aigamo.MatchGenerator.html
- examples/Maestria.TypeProviders.html
- examples/GenerateDispose.html
- examples/LinkDotNet.Enumeration.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 @@ -1606,5 +1606,11 @@
"category": "Disposer",
"href": "/RSCG_Examples/v2/docs/GenerateDispose/",
"body": "A Rosyln-powered generator for the Dispose-pattern\u0027s boilerplate code."
},
{
"title": "LinkDotNet.Enumeration",
"category": "Enum",
"href": "/RSCG_Examples/v2/docs/LinkDotNet.Enumeration/",
"body": "Source code generated enumeration with completeness!"
}
]
49 changes: 48 additions & 1 deletion v2/rscg_examples/GenerateDispose/description.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,54 @@
"source":"https://github.com/ItaiTzur76/GenerateDispose"
},
"data":{
"goodFor":["Generating the Dispose method for a class that implements IDisposable."],
"goodFor":["GenerateDispose for boilerplate reduction for IDisposable pattern",
"### Purpose",
"A Roslyn source generator that replaces the 10+ lines of IDisposable boilerplate code with a single attribute.",
"It also automatically adapts the generated pattern when the class modifiers change (e.g. sealed to non-sealed).",
"",
"### How to Define",
"```csharp showLineNumbers",
"[GenerateDispose.SourceGenerators.GenerateDispose(nameof(Drop))]",
"partial class DALDB : IDisposable // : IDisposable is optional!",
"{",
" private ConnectionDB cn;",
" private ConnectionDB cn1;",
"",
" public DALDB()",
" {",
" cn = new ConnectionDB();",
" cn1 = new ConnectionDB();",
" }",
"",
" public void Drop() // Your custom disposal logic",
" {",
" cn.Dispose();",
" cn1.Dispose();",
" }",
"}",
"```",
"",
"- The class must be partial",
"- Pass nameof(YourDisposeMethod) to the attribute - the method must be callable with no arguments",
"",
"### What Gets Generated",
"- public void Dispose() (thread-safe, calls your method)",
"- A private int _isDisposed field for double-dispose protection",
"- Adapts to sealed vs non-sealed automatically (private vs protected virtual)",
"",
"### How to Use",
"```csharp showLineNumbers",
"using (var db = new DALDB())",
"{",
" // use db...",
"} // Dispose() called automatically",
"",
"```",
"### Key Benefits",
"- 10+ lines of boilerplate replaced by 1 attribute",
"- sealed changes auto-adapt the Dispose pattern",
"- No manual IDisposable wiring needed",
""],
"csprojDemo":"IDisp.csproj",
"csFiles":["Program.cs","DALDB.cs","ConnectionDB.cs"],
"excludeDirectoryGenerated":[""],
Expand Down
2 changes: 1 addition & 1 deletion v2/rscg_examples/GenerateDispose/video.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG"},
{"typeStep":"text","arg": "My name is Andrei Ignat and I am deeply fond of Roslyn Source Code Generator. "},

{"typeStep":"text","arg": "Today I will present GenerateDispose . Generating the Dispose method for a class that implements IDisposable. ."},
{"typeStep":"text","arg": "Today I will present GenerateDispose . GenerateDispose for boilerplate reduction for IDisposable pattern### PurposeA Roslyn source generator that replaces the 10+ lines of IDisposable boilerplate code with a single attribute.It also automatically adapts the generated pattern when the class modifiers change (e.g. sealed to non-sealed).### How to Define```csharp showLineNumbers[GenerateDispose.SourceGenerators.GenerateDispose(nameof(Drop))]partial class DALDB : IDisposable // : IDisposable is optional!{ private ConnectionDB cn; private ConnectionDB cn1; public DALDB() { cn = new ConnectionDB(); cn1 = new ConnectionDB(); } public void Drop() // Your custom disposal logic { cn.Dispose(); cn1.Dispose(); }}```- The class must be partial- Pass nameof(YourDisposeMethod) to the attribute - the method must be callable with no arguments### What Gets Generated- public void Dispose() (thread-safe, calls your method)- A private int _isDisposed field for double-dispose protection- Adapts to sealed vs non-sealed automatically (private vs protected virtual)### How to Use```csharp showLineNumbersusing (var db = new DALDB()){ // use db...} // Dispose() called automatically```### Key Benefits- 10+ lines of boilerplate replaced by 1 attribute- sealed changes auto-adapt the Dispose pattern- No manual IDisposable wiring needed ."},
{"typeStep":"browser","arg":"https://www.nuget.org/packages/GenerateDispose/"},
{"typeStep":"text","arg": "The whole example is here"},
{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/GenerateDispose"},
Expand Down
42 changes: 42 additions & 0 deletions v2/rscg_examples/LinkDotNet.Enumeration/description.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"generator":{
"name":"LinkDotNet.Enumeration",
"nuget":[
"https://www.nuget.org/packages/LinkDotNet.Enumeration/"
],
"link":"https://github.com/linkdotnet/Enumeration",
"author":"Steven Giesel",
"source":"https://github.com/linkdotnet/Enumeration"
},
"data":{
"goodFor":["Good for replacing enum + switch patterns with string-based enumerations with exhaustive pattern matching.",
"",
"### Purpose",
"A source code generator that creates string-based enumerations (similar to Java enums / DDD value objects) with exhaustive pattern matching, replacing enum + switch patterns.",
"",
"### How to Define",
"[Enumeration(Casing.Preserve, \"None\", \"Dacia\", \"Tesla\", \"BMW\", \"Mercedes\")]",
"public sealed partial record CarTypes;",
"",
"### How to Use",
"CarTypes.TryParse(\"BMW\", null, out var car);",
"car.Match(onBMW: () => \"this is bmw\", onDacia: () => \"this is dacia\", ...);",
"",
"### Key Features",
"- Exhaustive matching: Match() requires all values",
"- Create / TryCreate: throws vs returns bool",
"- IParsable: Minimal APIs & Model Binding",
"- Implicit string conversion",
"- CarTypes.All returns FrozenSet of CarTypes",
"- JSON: GenerateJsonConverter = true"
],
"csprojDemo":"EnumDemo.csproj",
"csFiles":["Program.cs","CarTypes.cs"],
"excludeDirectoryGenerated":[""],
"includeAdditionalFiles":[""]
},
"links":{
"blog":"",
"video":""
}
}
1 change: 1 addition & 0 deletions v2/rscg_examples/LinkDotNet.Enumeration/nuget.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Source code generated enumeration with completeness!
Loading
Loading