Skip to content

Commit 243b734

Browse files
authored
Merge pull request #502 from ignatandrei/496-httpsgithubcomlinkdotnetenumeration
first
2 parents 2d39730 + 3accacc commit 243b734

30 files changed

Lines changed: 1373 additions & 29 deletions

File tree

README.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# RSCG - 268 Examples of Roslyn Source Code Generators / 16 created by Microsoft /
1+
# RSCG - 269 Examples of Roslyn Source Code Generators / 16 created by Microsoft /
22

3-
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.
3+
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.
44

55
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
66

7-
## Latest Update : 2026-05-13 => 13 May 2026
7+
## Latest Update : 2026-05-14 => 14 May 2026
88

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

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

2525
## Content
2626

27-
Those are the 268 Roslyn Source Code Generators that I have tested you can see and download source code example.
27+
Those are the 269 Roslyn Source Code Generators that I have tested you can see and download source code example.
2828
( including 16 from Microsoft )
29+
### 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
30+
31+
Generated on : 2026-05-14 => 14 May 2026
32+
33+
<details>
34+
<summary>Expand</summary>
35+
36+
37+
38+
Author: Steven Giesel
39+
40+
Source code generated enumeration with completeness!
41+
42+
Nuget: [https://www.nuget.org/packages/LinkDotNet.Enumeration/](https://www.nuget.org/packages/LinkDotNet.Enumeration/)
43+
44+
45+
Link: [https://ignatandrei.github.io/RSCG_Examples/v2/docs/LinkDotNet.Enumeration](https://ignatandrei.github.io/RSCG_Examples/v2/docs/LinkDotNet.Enumeration)
46+
47+
Source: [https://github.com/linkdotnet/Enumeration](https://github.com/linkdotnet/Enumeration)
48+
49+
</details>
50+
2951
### 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
3052

3153
Generated on : 2026-05-13 => 13 May 2026

later.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Just later
22

3-
## Latest Update : 2026-05-13 => 13 May 2026
3+
## Latest Update : 2026-05-14 => 14 May 2026
44

55

66

v2/RSCGExamplesData/GeneratorDataRec.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,5 +1624,11 @@
16241624
"Category": 18,
16251625
"dtStart": "2026-05-13T00:00:00",
16261626
"show": true
1627+
},
1628+
{
1629+
"ID": "LinkDotNet.Enumeration",
1630+
"Category": 19,
1631+
"dtStart": "2026-05-14T00:00:00",
1632+
"show": true
16271633
}
16281634
]
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
2+
<h1>RSCG nr 269 : LinkDotNet.Enumeration</h1>
3+
4+
<h2>Info</h2>
5+
Nuget : <a href="https://www.nuget.org/packages/LinkDotNet.Enumeration/" target="_blank">https://www.nuget.org/packages/LinkDotNet.Enumeration/</a>
6+
7+
<p>You can find more details at : <a href="https://github.com/linkdotnet/Enumeration" target="_blank"> https://github.com/linkdotnet/Enumeration</a></p>
8+
9+
<p>Author :Steven Giesel</p>
10+
11+
<p>Source: <a href="https://github.com/linkdotnet/Enumeration" target="_blank">https://github.com/linkdotnet/Enumeration</a> </p>
12+
13+
<h2>About</h2>
14+
15+
Generating enumeration from classes in C# with matching
16+
17+
<h2>
18+
How to use
19+
</h2>
20+
<h3>
21+
Add reference to the <a href="https://www.nuget.org/packages/LinkDotNet.Enumeration/" target="_blank">LinkDotNet.Enumeration</a> in the csproj
22+
</h3>
23+
<img src="images/LinkDotNet.Enumeration/EnumDemo.csproj.png" width="580" height="580" />
24+
25+
<h3>This was for me the <b>starting</b> code</h3>
26+
27+
<br />
28+
I have <b>coded</b> the file Program.cs
29+
<br />
30+
<img src="images/LinkDotNet.Enumeration/csFiles/Program.cs.png" width="580" height="580" />
31+
<hr />
32+
33+
<br />
34+
I have <b>coded</b> the file CarTypes.cs
35+
<br />
36+
<img src="images/LinkDotNet.Enumeration/csFiles/CarTypes.cs.png" width="580" height="580" />
37+
<hr />
38+
<h3>And here are the <i>generated</i> files</h3>
39+
40+
<br />
41+
The file <i>generated</i> is CarTypes.g.cs
42+
<br />
43+
<img src="images/LinkDotNet.Enumeration/generated/CarTypes.g.cs.png" width="580" height="580" />
44+
45+
<br />
46+
The file <i>generated</i> is EnumerationAttribute.g.cs
47+
<br />
48+
<img src="images/LinkDotNet.Enumeration/generated/EnumerationAttribute.g.cs.png" width="580" height="580" />
49+
50+
<p>
51+
You can download the code and this page as pdf from
52+
<a target="_blank" href='https://ignatandrei.github.io/RSCG_Examples/v2/docs/LinkDotNet.Enumeration'>
53+
https://ignatandrei.github.io/RSCG_Examples/v2/docs/LinkDotNet.Enumeration
54+
</a>
55+
</p>
56+
57+
58+
<p>
59+
You can see the whole list at
60+
<a target="_blank" href='https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG'>
61+
https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG
62+
</a>
63+
</p>
64+

v2/book/list.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</head>
1818
<body>
1919
<h1>
20-
This is the list of 268 RSCG with examples =>
20+
This is the list of 269 RSCG with examples =>
2121
</h1>
2222

2323
<table >
@@ -1098,6 +1098,10 @@ <h1>
10981098
<td>268</td>
10991099
<td><a href="examples/GenerateDispose.html">GenerateDispose</a></td>
11001100
</tr>
1101+
<tr>
1102+
<td>269</td>
1103+
<td><a href="examples/LinkDotNet.Enumeration.html">LinkDotNet.Enumeration</a></td>
1104+
</tr>
11011105
</table>
11021106

11031107

v2/book/pandocHTML.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ input-files:
282282
- examples/Aigamo.MatchGenerator.html
283283
- examples/Maestria.TypeProviders.html
284284
- examples/GenerateDispose.html
285+
- examples/LinkDotNet.Enumeration.html
285286

286287
# or you may use input-file: with a single value
287288
# defaults:

v2/docFind.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,5 +1606,11 @@
16061606
"category": "Disposer",
16071607
"href": "/RSCG_Examples/v2/docs/GenerateDispose/",
16081608
"body": "A Rosyln-powered generator for the Dispose-pattern\u0027s boilerplate code."
1609+
},
1610+
{
1611+
"title": "LinkDotNet.Enumeration",
1612+
"category": "Enum",
1613+
"href": "/RSCG_Examples/v2/docs/LinkDotNet.Enumeration/",
1614+
"body": "Source code generated enumeration with completeness!"
16091615
}
16101616
]

v2/rscg_examples/GenerateDispose/description.json

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,54 @@
99
"source":"https://github.com/ItaiTzur76/GenerateDispose"
1010
},
1111
"data":{
12-
"goodFor":["Generating the Dispose method for a class that implements IDisposable."],
12+
"goodFor":["GenerateDispose for boilerplate reduction for IDisposable pattern",
13+
"### Purpose",
14+
"A Roslyn source generator that replaces the 10+ lines of IDisposable boilerplate code with a single attribute.",
15+
"It also automatically adapts the generated pattern when the class modifiers change (e.g. sealed to non-sealed).",
16+
"",
17+
"### How to Define",
18+
"```csharp showLineNumbers",
19+
"[GenerateDispose.SourceGenerators.GenerateDispose(nameof(Drop))]",
20+
"partial class DALDB : IDisposable // : IDisposable is optional!",
21+
"{",
22+
" private ConnectionDB cn;",
23+
" private ConnectionDB cn1;",
24+
"",
25+
" public DALDB()",
26+
" {",
27+
" cn = new ConnectionDB();",
28+
" cn1 = new ConnectionDB();",
29+
" }",
30+
"",
31+
" public void Drop() // Your custom disposal logic",
32+
" {",
33+
" cn.Dispose();",
34+
" cn1.Dispose();",
35+
" }",
36+
"}",
37+
"```",
38+
"",
39+
"- The class must be partial",
40+
"- Pass nameof(YourDisposeMethod) to the attribute - the method must be callable with no arguments",
41+
"",
42+
"### What Gets Generated",
43+
"- public void Dispose() (thread-safe, calls your method)",
44+
"- A private int _isDisposed field for double-dispose protection",
45+
"- Adapts to sealed vs non-sealed automatically (private vs protected virtual)",
46+
"",
47+
"### How to Use",
48+
"```csharp showLineNumbers",
49+
"using (var db = new DALDB())",
50+
"{",
51+
" // use db...",
52+
"} // Dispose() called automatically",
53+
"",
54+
"```",
55+
"### Key Benefits",
56+
"- 10+ lines of boilerplate replaced by 1 attribute",
57+
"- sealed changes auto-adapt the Dispose pattern",
58+
"- No manual IDisposable wiring needed",
59+
""],
1360
"csprojDemo":"IDisp.csproj",
1461
"csFiles":["Program.cs","DALDB.cs","ConnectionDB.cs"],
1562
"excludeDirectoryGenerated":[""],

v2/rscg_examples/GenerateDispose/video.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG"},
99
{"typeStep":"text","arg": "My name is Andrei Ignat and I am deeply fond of Roslyn Source Code Generator. "},
1010

11-
{"typeStep":"text","arg": "Today I will present GenerateDispose . Generating the Dispose method for a class that implements IDisposable. ."},
11+
{"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 ."},
1212
{"typeStep":"browser","arg":"https://www.nuget.org/packages/GenerateDispose/"},
1313
{"typeStep":"text","arg": "The whole example is here"},
1414
{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/GenerateDispose"},
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"generator":{
3+
"name":"LinkDotNet.Enumeration",
4+
"nuget":[
5+
"https://www.nuget.org/packages/LinkDotNet.Enumeration/"
6+
],
7+
"link":"https://github.com/linkdotnet/Enumeration",
8+
"author":"Steven Giesel",
9+
"source":"https://github.com/linkdotnet/Enumeration"
10+
},
11+
"data":{
12+
"goodFor":["Good for replacing enum + switch patterns with string-based enumerations with exhaustive pattern matching.",
13+
"",
14+
"### Purpose",
15+
"A source code generator that creates string-based enumerations (similar to Java enums / DDD value objects) with exhaustive pattern matching, replacing enum + switch patterns.",
16+
"",
17+
"### How to Define",
18+
"[Enumeration(Casing.Preserve, \"None\", \"Dacia\", \"Tesla\", \"BMW\", \"Mercedes\")]",
19+
"public sealed partial record CarTypes;",
20+
"",
21+
"### How to Use",
22+
"CarTypes.TryParse(\"BMW\", null, out var car);",
23+
"car.Match(onBMW: () => \"this is bmw\", onDacia: () => \"this is dacia\", ...);",
24+
"",
25+
"### Key Features",
26+
"- Exhaustive matching: Match() requires all values",
27+
"- Create / TryCreate: throws vs returns bool",
28+
"- IParsable: Minimal APIs & Model Binding",
29+
"- Implicit string conversion",
30+
"- CarTypes.All returns FrozenSet of CarTypes",
31+
"- JSON: GenerateJsonConverter = true"
32+
],
33+
"csprojDemo":"EnumDemo.csproj",
34+
"csFiles":["Program.cs","CarTypes.cs"],
35+
"excludeDirectoryGenerated":[""],
36+
"includeAdditionalFiles":[""]
37+
},
38+
"links":{
39+
"blog":"",
40+
"video":""
41+
}
42+
}

0 commit comments

Comments
 (0)