diff --git a/README.md b/README.md index de31d6274..db02e8172 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# RSCG - 282 Examples of Roslyn Source Code Generators / 16 created by Microsoft / +# RSCG - 283 Examples of Roslyn Source Code Generators / 16 created by Microsoft / -The RSCG_Examples repository is a comprehensive documentation system that automatically processes and showcases 282 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 283 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-08-22 => 22 August 2026 +## Latest Update : 2026-08-23 => 23 August 2026 If you want to see examples with code, please click ***[List V2](https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG)*** @@ -24,8 +24,32 @@ If you want to be notified each time I add a new RSCG example , please click htt ## Content -Those are the 282 Roslyn Source Code Generators that I have tested you can see and download source code example. +Those are the 283 Roslyn Source Code Generators that I have tested you can see and download source code example. ( including 16 from Microsoft ) +### 283. [IncrementalSourceGenerator.BuilderPattern](https://ignatandrei.github.io/RSCG_Examples/v2/docs/IncrementalSourceGenerator.BuilderPattern) , in the [Builder](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#builder) category + +Generated on : 2026-08-23 => 23 August 2026 + +
+ Expand + + + +Author: Martin Barrett Nielsen + +Incremental source generator that that reduces boilerplate in test object builders + by generating the repetitive structure, while enabling developers to focus on the + more meaningful, hand-crafted logic via partial classes + +Nuget: [https://www.nuget.org/packages/IncrementalSourceGenerator.BuilderPattern/](https://www.nuget.org/packages/IncrementalSourceGenerator.BuilderPattern/) + + +Link: [https://ignatandrei.github.io/RSCG_Examples/v2/docs/IncrementalSourceGenerator.BuilderPattern](https://ignatandrei.github.io/RSCG_Examples/v2/docs/IncrementalSourceGenerator.BuilderPattern) + +Source: [https://github.com/MartinBarrettNielsen11/Incremental-source-generator-builder-pattern](https://github.com/MartinBarrettNielsen11/Incremental-source-generator-builder-pattern) + +
+ ### 282. [Clap.Net](https://ignatandrei.github.io/RSCG_Examples/v2/docs/Clap.Net) , in the [CommandLine](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#commandline) category Generated on : 2026-08-22 => 22 August 2026 diff --git a/later.md b/later.md index bf23de164..d8350b65d 100644 --- a/later.md +++ b/later.md @@ -1,6 +1,6 @@ # Just later -## Latest Update : 2026-08-22 => 22 August 2026 +## Latest Update : 2026-08-23 => 23 August 2026 diff --git a/v2/.tours/IncrementalSourceGenerator.BuilderPattern.tour b/v2/.tours/IncrementalSourceGenerator.BuilderPattern.tour new file mode 100644 index 000000000..8b9f4fee9 --- /dev/null +++ b/v2/.tours/IncrementalSourceGenerator.BuilderPattern.tour @@ -0,0 +1,54 @@ + +{ + "$schema": "https://aka.ms/codetour-schema", + "title": "IncrementalSourceGenerator.BuilderPattern", + "steps": + [ + { + "file": "rscg_examples/IncrementalSourceGenerator.BuilderPattern/src/Builder/Builder.csproj", + "description": "First, we add Nuget [IncrementalSourceGenerator.BuilderPattern](https://www.nuget.org/packages/IncrementalSourceGenerator.BuilderPattern/) in csproj ", + "pattern": "IncrementalSourceGenerator.BuilderPattern" + } + + ,{ + "file": "rscg_examples/IncrementalSourceGenerator.BuilderPattern/src/Builder/Person.cs", + "description": "File Person.cs ", + "pattern": "this is the code" + } + + ,{ + "file": "rscg_examples/IncrementalSourceGenerator.BuilderPattern/src/Builder/Program.cs", + "description": "File Program.cs \r\n>> dotnet run --project rscg_examples/IncrementalSourceGenerator.BuilderPattern/src/Builder/Builder.csproj ", + "pattern": "this is the code" + } + + + ,{ + "file": "rscg_examples/IncrementalSourceGenerator.BuilderPattern/src/Builder/obj/GX/Generator/Generator.Generator/DomainAssertionExtensions.g.cs", + "description": "Generated File 4 from 4 : DomainAssertionExtensions.g.cs ", + "line": 1 + } + + ,{ + "file": "rscg_examples/IncrementalSourceGenerator.BuilderPattern/src/Builder/obj/GX/Generator/Generator.Generator/Builder_PersonBuilder.g.cs", + "description": "Generated File 3 from 4 : Builder_PersonBuilder.g.cs ", + "line": 1 + } + + ,{ + "file": "rscg_examples/IncrementalSourceGenerator.BuilderPattern/src/Builder/obj/GX/Generator/Generator.Generator/Builder_Person.g.cs", + "description": "Generated File 2 from 4 : Builder_Person.g.cs ", + "line": 1 + } + + ,{ + "file": "rscg_examples/IncrementalSourceGenerator.BuilderPattern/src/Builder/obj/GX/Generator/Generator.Generator/BuilderAttribute.g.cs", + "description": "Generated File 1 from 4 : BuilderAttribute.g.cs ", + "line": 1 + } + + ], + + "ref": "main" + +} \ No newline at end of file diff --git a/v2/Generator/all.csv b/v2/Generator/all.csv index 8d7bffebe..3c4ff778b 100644 --- a/v2/Generator/all.csv +++ b/v2/Generator/all.csv @@ -281,3 +281,4 @@ Nr,Key,Source,Category 280,serde, https://github.com/serdedotnet/serde,Serializer 281,EndpointHelpers, https://github.com/gumbarros/EndpointHelpers,MVC 282,Clap.Net, https://github.com/simon-curtis/Clap.Net,CommandLine +283,IncrementalSourceGenerator.BuilderPattern, https://github.com/MartinBarrettNielsen11/Incremental-source-generator-builder-pattern,Builder diff --git a/v2/RSCGExamplesData/GeneratorDataRec.json b/v2/RSCGExamplesData/GeneratorDataRec.json index f981bc517..e993f97f8 100644 --- a/v2/RSCGExamplesData/GeneratorDataRec.json +++ b/v2/RSCGExamplesData/GeneratorDataRec.json @@ -1709,6 +1709,12 @@ "Category":32, "dtStart": "2026-08-22T00:00:00", "show": true + }, + { + "ID":"IncrementalSourceGenerator.BuilderPattern", + "Category": 4, + "dtStart": "2026-08-23T00:00:00", + "show": true } ] \ No newline at end of file diff --git a/v2/book/examples/IncrementalSourceGenerator.BuilderPattern.html b/v2/book/examples/IncrementalSourceGenerator.BuilderPattern.html new file mode 100644 index 000000000..369a7cb1c --- /dev/null +++ b/v2/book/examples/IncrementalSourceGenerator.BuilderPattern.html @@ -0,0 +1,74 @@ + +

RSCG nr 283 : IncrementalSourceGenerator.BuilderPattern

+ +

Info

+Nuget : https://www.nuget.org/packages/IncrementalSourceGenerator.BuilderPattern/ + +

You can find more details at : https://github.com/MartinBarrettNielsen11/Incremental-source-generator-builder-pattern

+ +

Author :Martin Barrett Nielsen

+ +

Source: https://github.com/MartinBarrettNielsen11/Incremental-source-generator-builder-pattern

+ +

About

+ +Generate builder pattern code for classes with many properties + +

+ How to use +

+

+ Add reference to the IncrementalSourceGenerator.BuilderPattern in the csproj +

+ + +

This was for me the starting code

+ +
+ I have coded the file Program.cs +
+ +
+ +
+ I have coded the file Person.cs +
+ +
+

And here are the generated files

+ +
+ The file generated is BuilderAttribute.g.cs +
+ + +
+ The file generated is Builder_Person.g.cs +
+ + +
+ The file generated is Builder_PersonBuilder.g.cs +
+ + +
+ The file generated is DomainAssertionExtensions.g.cs +
+ + +

+ You can download the code and this page as pdf from + + https://ignatandrei.github.io/RSCG_Examples/v2/docs/IncrementalSourceGenerator.BuilderPattern + +

+ + +

+ You can see the whole list at + + https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG + +

+ diff --git a/v2/book/list.html b/v2/book/list.html index a76b73702..74bc12286 100644 --- a/v2/book/list.html +++ b/v2/book/list.html @@ -17,7 +17,7 @@

-This is the list of 282 RSCG with examples => +This is the list of 283 RSCG with examples =>

@@ -1154,6 +1154,10 @@

+ + + +
282 Clap.Net
283IncrementalSourceGenerator.BuilderPattern
diff --git a/v2/book/pandocHTML.yaml b/v2/book/pandocHTML.yaml index 448881e85..7155f06d9 100644 --- a/v2/book/pandocHTML.yaml +++ b/v2/book/pandocHTML.yaml @@ -296,6 +296,7 @@ input-files: - examples/serde.html - examples/EndpointHelpers.html - examples/Clap.Net.html +- examples/IncrementalSourceGenerator.BuilderPattern.html # or you may use input-file: with a single value # defaults: diff --git a/v2/docFind.json b/v2/docFind.json index 3a0098279..a26e48355 100644 --- a/v2/docFind.json +++ b/v2/docFind.json @@ -1690,5 +1690,11 @@ "category": "CommandLine", "href": "/RSCG_Examples/v2/docs/Clap.Net/", "body": "Package Description" + }, + { + "title": "IncrementalSourceGenerator.BuilderPattern", + "category": "Builder", + "href": "/RSCG_Examples/v2/docs/IncrementalSourceGenerator.BuilderPattern/", + "body": "Incremental source generator that that reduces boilerplate in test object builders \n by generating the repetitive structure, while enabling developers to focus on the \n more meaningful, hand-crafted logic via partial classes" } ] \ No newline at end of file diff --git a/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/description.json b/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/description.json new file mode 100644 index 000000000..c9fc5fdfe --- /dev/null +++ b/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/description.json @@ -0,0 +1,22 @@ +{ + "generator":{ + "name":"IncrementalSourceGenerator.BuilderPattern", + "nuget":[ + "https://www.nuget.org/packages/IncrementalSourceGenerator.BuilderPattern/" + ], + "link":"https://github.com/MartinBarrettNielsen11/Incremental-source-generator-builder-pattern", + "author":"Martin Barrett Nielsen", + "source":"https://github.com/MartinBarrettNielsen11/Incremental-source-generator-builder-pattern" + }, + "data":{ + "goodFor":["Generate builder pattern code for classes with many properties"], + "csprojDemo":"Builder.csproj", + "csFiles":["Program.cs","Person.cs"], + "excludeDirectoryGenerated":[""], + "includeAdditionalFiles":[""] + }, + "links":{ + "blog":"", + "video":"" + } +} \ No newline at end of file diff --git a/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/nuget.txt b/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/nuget.txt new file mode 100644 index 000000000..5ac4d570b --- /dev/null +++ b/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/nuget.txt @@ -0,0 +1,3 @@ +Incremental source generator that that reduces boilerplate in test object builders + by generating the repetitive structure, while enabling developers to focus on the + more meaningful, hand-crafted logic via partial classes \ No newline at end of file diff --git a/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/src/Builder.slnx b/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/src/Builder.slnx new file mode 100644 index 000000000..507475890 --- /dev/null +++ b/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/src/Builder.slnx @@ -0,0 +1,3 @@ + + + diff --git a/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/src/Builder/Builder.csproj b/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/src/Builder/Builder.csproj new file mode 100644 index 000000000..403792c0e --- /dev/null +++ b/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/src/Builder/Builder.csproj @@ -0,0 +1,17 @@ + + + + Exe + net10.0 + enable + + + + true + $(BaseIntermediateOutputPath)\GX + + + + + + diff --git a/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/src/Builder/Person.cs b/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/src/Builder/Person.cs new file mode 100644 index 000000000..91038187c --- /dev/null +++ b/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/src/Builder/Person.cs @@ -0,0 +1,15 @@ +using Generator; +namespace Builder; + +[Builder(typeof(Person))] +public partial class PersonBuilder +{ + +} + +public class Person +{ + public string FirstName { get; set; } + public string LastName { get; set; } + public string FullName() => $"{FirstName} {LastName}"; +} \ No newline at end of file diff --git a/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/src/Builder/Program.cs b/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/src/Builder/Program.cs new file mode 100644 index 000000000..2943e97de --- /dev/null +++ b/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/src/Builder/Program.cs @@ -0,0 +1,12 @@ +using Builder; + +Console.WriteLine("create person builder"); + +var p = new PersonBuilder() + .WithFirstName("Andrei") + .WithLastName("Ignat") + .Build(); + + + +Console.WriteLine(p.FullName()); diff --git a/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/src/Builder/globals.cs b/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/src/Builder/globals.cs new file mode 100644 index 000000000..76d1fbe88 --- /dev/null +++ b/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/src/Builder/globals.cs @@ -0,0 +1 @@ +global using System; \ No newline at end of file diff --git a/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/video.json b/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/video.json new file mode 100644 index 000000000..03eb26288 --- /dev/null +++ b/v2/rscg_examples/IncrementalSourceGenerator.BuilderPattern/video.json @@ -0,0 +1,39 @@ +{ + "scriptName": "IncrementalSourceGenerator.BuilderPattern", + "steps": +[ + {"typeStep":"exec","arg":"clipchamp.exe launch"}, + {"typeStep":"text","arg": "Welcome to Roslyn Examples"}, + {"typeStep":"text","arg":"If you want to see more examples , see List Of RSCG"}, + {"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 IncrementalSourceGenerator.BuilderPattern . Generate builder pattern code for classes with many properties ."}, +{"typeStep":"browser","arg":"https://www.nuget.org/packages/IncrementalSourceGenerator.BuilderPattern/"}, +{"typeStep":"text","arg": "The whole example is here"}, +{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/IncrementalSourceGenerator.BuilderPattern"}, +{"typeStep":"text","arg": "You can download the code from here"}, +{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/IncrementalSourceGenerator.BuilderPattern#download-example-net--c-"}, +{"typeStep":"text","arg":"Here is the code downloaded "}, +{"typeStep":"exec","arg":"explorer.exe /select,D:\\gth\\RSCG_Examples\\v2\\Generator.sln"}, +{"typeStep":"text","arg": "So , let's start the project with Visual Studio Code "}, +{"typeStep":"stepvscode","arg": "-n D:\\gth\\RSCG_Examples\\v2"}, + +{"typeStep":"text","arg": "To use it ,you will put the Nuget IncrementalSourceGenerator.BuilderPattern into the csproj "}, + +{"typeStep":"stepvscode","arg": "-r -g D:\\gth\\RSCG_Examples\\v2\\rscg_examples\\IncrementalSourceGenerator.BuilderPattern\\src\\Builder\\Builder.csproj"}, + +{"typeStep":"text","arg": "And now I will show you an example of using IncrementalSourceGenerator.BuilderPattern"}, + +{"typeStep":"hide","arg": "now execute the tour in VSCode"}, +{"typeStep":"tour", "arg": "src/.tours/"}, +{"typeStep":"text","arg":" And I will execute the project"}, +{"typeStep":"showproj", "arg":"Builder.csproj"}, +{"typeStep":"text","arg":" This concludes the project"}, +{"typeStep":"waitseconds","arg":"30"}, +{"typeStep":"text","arg": "Remember, you can download the code from here"}, +{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/IncrementalSourceGenerator.BuilderPattern#download-example-net--c-", +SpeakTest=" "}, +{"typeStep":"waitseconds","arg":"30"}, +] +} diff --git a/v2/rscg_examples_site/docs/Authors/Martin_Barrett_Nielsen.md b/v2/rscg_examples_site/docs/Authors/Martin_Barrett_Nielsen.md new file mode 100644 index 000000000..ffd2b7127 --- /dev/null +++ b/v2/rscg_examples_site/docs/Authors/Martin_Barrett_Nielsen.md @@ -0,0 +1,7 @@ +# Author : Martin Barrett Nielsen + +Number RSCG: 1 + + + 1 [IncrementalSourceGenerator.BuilderPattern](/docs/IncrementalSourceGenerator.BuilderPattern) [![Nuget](https://img.shields.io/nuget/dt/IncrementalSourceGenerator.BuilderPattern?label=IncrementalSourceGenerator.BuilderPattern)](https://www.nuget.org/packages/IncrementalSourceGenerator.BuilderPattern/) ![GitHub Repo stars](https://img.shields.io/github/stars/MartinBarrettNielsen11/Incremental-source-generator-builder-pattern?style=social) 2026-08-23 + diff --git a/v2/rscg_examples_site/docs/Categories/Builder.md b/v2/rscg_examples_site/docs/Categories/Builder.md index f8e729e3b..6b8c32986 100644 --- a/v2/rscg_examples_site/docs/Categories/Builder.md +++ b/v2/rscg_examples_site/docs/Categories/Builder.md @@ -1,6 +1,6 @@

Builder

-Number RSCG: 9 +Number RSCG: 10 1 [Architect.DomainModeling](/docs/Architect.DomainModeling) [![Nuget](https://img.shields.io/nuget/dt/Architect.DomainModeling?label=Architect.DomainModeling)](https://www.nuget.org/packages/Architect.DomainModeling/) ![GitHub Repo stars](https://img.shields.io/github/stars/TheArchitectDev/Architect.DomainModeling?style=social) 2024-03-02 @@ -12,11 +12,13 @@ Number RSCG: 9 5 [Hsu.Sg.FluentMember](/docs/Hsu.Sg.FluentMember) [![Nuget](https://img.shields.io/nuget/dt/Hsu.Sg.FluentMember?label=Hsu.Sg.FluentMember)](https://www.nuget.org/packages/Hsu.Sg.FluentMember/) ![GitHub Repo stars](https://img.shields.io/github/stars/hsu-net/source-generators?style=social) 2024-11-08 - 6 [OrderedBuildersGenerator](/docs/OrderedBuildersGenerator) [![Nuget](https://img.shields.io/nuget/dt/OrderedBuildersGenerator?label=OrderedBuildersGenerator)](https://www.nuget.org/packages/OrderedBuildersGenerator/) ![GitHub Repo stars](https://img.shields.io/github/stars/Georgiy-Petrov/OrderedBuildersGenerator?style=social) 2025-12-18 + 6 [IncrementalSourceGenerator.BuilderPattern](/docs/IncrementalSourceGenerator.BuilderPattern) [![Nuget](https://img.shields.io/nuget/dt/IncrementalSourceGenerator.BuilderPattern?label=IncrementalSourceGenerator.BuilderPattern)](https://www.nuget.org/packages/IncrementalSourceGenerator.BuilderPattern/) ![GitHub Repo stars](https://img.shields.io/github/stars/MartinBarrettNielsen11/Incremental-source-generator-builder-pattern?style=social) 2026-08-23 - 7 [ShadowWriterBuilder](/docs/ShadowWriterBuilder) [![Nuget](https://img.shields.io/nuget/dt/ShadowWriter?label=ShadowWriter)](https://www.nuget.org/packages/ShadowWriter/) ![GitHub Repo stars](https://img.shields.io/github/stars/StefanStolz/ShadowWriter?style=social) 2025-07-24 + 7 [OrderedBuildersGenerator](/docs/OrderedBuildersGenerator) [![Nuget](https://img.shields.io/nuget/dt/OrderedBuildersGenerator?label=OrderedBuildersGenerator)](https://www.nuget.org/packages/OrderedBuildersGenerator/) ![GitHub Repo stars](https://img.shields.io/github/stars/Georgiy-Petrov/OrderedBuildersGenerator?style=social) 2025-12-18 - 8 [StepwiseBuilderGenerator](/docs/StepwiseBuilderGenerator) [![Nuget](https://img.shields.io/nuget/dt/StepwiseBuilderGenerator?label=StepwiseBuilderGenerator)](https://www.nuget.org/packages/StepwiseBuilderGenerator/) ![GitHub Repo stars](https://img.shields.io/github/stars/Georgiy-Petrov/StepwiseBuilderGenerator?style=social) 2025-03-23 + 8 [ShadowWriterBuilder](/docs/ShadowWriterBuilder) [![Nuget](https://img.shields.io/nuget/dt/ShadowWriter?label=ShadowWriter)](https://www.nuget.org/packages/ShadowWriter/) ![GitHub Repo stars](https://img.shields.io/github/stars/StefanStolz/ShadowWriter?style=social) 2025-07-24 - 9 [TypedStateBuilder.Generator](/docs/TypedStateBuilder.Generator) [![Nuget](https://img.shields.io/nuget/dt/TypedStateBuilder.Generator?label=TypedStateBuilder.Generator)](https://www.nuget.org/packages/TypedStateBuilder.Generator/) ![GitHub Repo stars](https://img.shields.io/github/stars/Georgiy-Petrov/TypedStateBuilder.Generator?style=social) 2026-05-16 + 9 [StepwiseBuilderGenerator](/docs/StepwiseBuilderGenerator) [![Nuget](https://img.shields.io/nuget/dt/StepwiseBuilderGenerator?label=StepwiseBuilderGenerator)](https://www.nuget.org/packages/StepwiseBuilderGenerator/) ![GitHub Repo stars](https://img.shields.io/github/stars/Georgiy-Petrov/StepwiseBuilderGenerator?style=social) 2025-03-23 + + 10 [TypedStateBuilder.Generator](/docs/TypedStateBuilder.Generator) [![Nuget](https://img.shields.io/nuget/dt/TypedStateBuilder.Generator?label=TypedStateBuilder.Generator)](https://www.nuget.org/packages/TypedStateBuilder.Generator/) ![GitHub Repo stars](https://img.shields.io/github/stars/Georgiy-Petrov/TypedStateBuilder.Generator?style=social) 2026-05-16 \ No newline at end of file diff --git a/v2/rscg_examples_site/docs/Categories/_PrimitiveBuilder.mdx b/v2/rscg_examples_site/docs/Categories/_PrimitiveBuilder.mdx index 5dc13f247..ecd603749 100644 --- a/v2/rscg_examples_site/docs/Categories/_PrimitiveBuilder.mdx +++ b/v2/rscg_examples_site/docs/Categories/_PrimitiveBuilder.mdx @@ -10,13 +10,15 @@ 5 [Hsu.Sg.FluentMember](/docs/Hsu.Sg.FluentMember) [![Nuget](https://img.shields.io/nuget/dt/Hsu.Sg.FluentMember?label=Hsu.Sg.FluentMember)](https://www.nuget.org/packages/Hsu.Sg.FluentMember/) ![GitHub Repo stars](https://img.shields.io/github/stars/hsu-net/source-generators?style=social) 2024-11-08 - 6 [OrderedBuildersGenerator](/docs/OrderedBuildersGenerator) [![Nuget](https://img.shields.io/nuget/dt/OrderedBuildersGenerator?label=OrderedBuildersGenerator)](https://www.nuget.org/packages/OrderedBuildersGenerator/) ![GitHub Repo stars](https://img.shields.io/github/stars/Georgiy-Petrov/OrderedBuildersGenerator?style=social) 2025-12-18 + 6 [IncrementalSourceGenerator.BuilderPattern](/docs/IncrementalSourceGenerator.BuilderPattern) [![Nuget](https://img.shields.io/nuget/dt/IncrementalSourceGenerator.BuilderPattern?label=IncrementalSourceGenerator.BuilderPattern)](https://www.nuget.org/packages/IncrementalSourceGenerator.BuilderPattern/) ![GitHub Repo stars](https://img.shields.io/github/stars/MartinBarrettNielsen11/Incremental-source-generator-builder-pattern?style=social) 2026-08-23 - 7 [ShadowWriterBuilder](/docs/ShadowWriterBuilder) [![Nuget](https://img.shields.io/nuget/dt/ShadowWriter?label=ShadowWriter)](https://www.nuget.org/packages/ShadowWriter/) ![GitHub Repo stars](https://img.shields.io/github/stars/StefanStolz/ShadowWriter?style=social) 2025-07-24 + 7 [OrderedBuildersGenerator](/docs/OrderedBuildersGenerator) [![Nuget](https://img.shields.io/nuget/dt/OrderedBuildersGenerator?label=OrderedBuildersGenerator)](https://www.nuget.org/packages/OrderedBuildersGenerator/) ![GitHub Repo stars](https://img.shields.io/github/stars/Georgiy-Petrov/OrderedBuildersGenerator?style=social) 2025-12-18 - 8 [StepwiseBuilderGenerator](/docs/StepwiseBuilderGenerator) [![Nuget](https://img.shields.io/nuget/dt/StepwiseBuilderGenerator?label=StepwiseBuilderGenerator)](https://www.nuget.org/packages/StepwiseBuilderGenerator/) ![GitHub Repo stars](https://img.shields.io/github/stars/Georgiy-Petrov/StepwiseBuilderGenerator?style=social) 2025-03-23 + 8 [ShadowWriterBuilder](/docs/ShadowWriterBuilder) [![Nuget](https://img.shields.io/nuget/dt/ShadowWriter?label=ShadowWriter)](https://www.nuget.org/packages/ShadowWriter/) ![GitHub Repo stars](https://img.shields.io/github/stars/StefanStolz/ShadowWriter?style=social) 2025-07-24 - 9 [TypedStateBuilder.Generator](/docs/TypedStateBuilder.Generator) [![Nuget](https://img.shields.io/nuget/dt/TypedStateBuilder.Generator?label=TypedStateBuilder.Generator)](https://www.nuget.org/packages/TypedStateBuilder.Generator/) ![GitHub Repo stars](https://img.shields.io/github/stars/Georgiy-Petrov/TypedStateBuilder.Generator?style=social) 2026-05-16 + 9 [StepwiseBuilderGenerator](/docs/StepwiseBuilderGenerator) [![Nuget](https://img.shields.io/nuget/dt/StepwiseBuilderGenerator?label=StepwiseBuilderGenerator)](https://www.nuget.org/packages/StepwiseBuilderGenerator/) ![GitHub Repo stars](https://img.shields.io/github/stars/Georgiy-Petrov/StepwiseBuilderGenerator?style=social) 2025-03-23 + + 10 [TypedStateBuilder.Generator](/docs/TypedStateBuilder.Generator) [![Nuget](https://img.shields.io/nuget/dt/TypedStateBuilder.Generator?label=TypedStateBuilder.Generator)](https://www.nuget.org/packages/TypedStateBuilder.Generator/) ![GitHub Repo stars](https://img.shields.io/github/stars/Georgiy-Petrov/TypedStateBuilder.Generator?style=social) 2026-05-16 ### See category diff --git a/v2/rscg_examples_site/docs/RSCG-Examples/IncrementalSourceGenerator.BuilderPattern.md b/v2/rscg_examples_site/docs/RSCG-Examples/IncrementalSourceGenerator.BuilderPattern.md new file mode 100644 index 000000000..f978d0a70 --- /dev/null +++ b/v2/rscg_examples_site/docs/RSCG-Examples/IncrementalSourceGenerator.BuilderPattern.md @@ -0,0 +1,330 @@ +--- +sidebar_position: 2830 +title: 283 - IncrementalSourceGenerator.BuilderPattern +description: Generate builder pattern code for classes with many properties +slug: /IncrementalSourceGenerator.BuilderPattern +--- +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import TOCInline from '@theme/TOCInline'; +import SameCategory from '../Categories/_PrimitiveBuilder.mdx'; + +# IncrementalSourceGenerator.BuilderPattern by Martin Barrett Nielsen + + + + +## NuGet / site data +[![Nuget](https://img.shields.io/nuget/dt/IncrementalSourceGenerator.BuilderPattern?label=IncrementalSourceGenerator.BuilderPattern)](https://www.nuget.org/packages/IncrementalSourceGenerator.BuilderPattern/) +[![GitHub last commit](https://img.shields.io/github/last-commit/MartinBarrettNielsen11/Incremental-source-generator-builder-pattern?label=updated)](https://github.com/MartinBarrettNielsen11/Incremental-source-generator-builder-pattern) +![GitHub Repo stars](https://img.shields.io/github/stars/MartinBarrettNielsen11/Incremental-source-generator-builder-pattern?style=social) + +## Details + +### Info +:::info + +Name: **IncrementalSourceGenerator.BuilderPattern** + +Incremental source generator that that reduces boilerplate in test object builders + by generating the repetitive structure, while enabling developers to focus on the + more meaningful, hand-crafted logic via partial classes + +Author: Martin Barrett Nielsen + +NuGet: +*https://www.nuget.org/packages/IncrementalSourceGenerator.BuilderPattern/* + + +You can find more details at https://github.com/MartinBarrettNielsen11/Incremental-source-generator-builder-pattern + +Source: https://github.com/MartinBarrettNielsen11/Incremental-source-generator-builder-pattern + +::: + +### Author +:::note +Martin Barrett Nielsen +![Alt text](https://github.com/MartinBarrettNielsen11.png) +::: + +## Original Readme +:::note + + + +::: + +### About +:::note + +Generate builder pattern code for classes with many properties + + +::: + +## How to use + +### Example (source csproj, source files) + + + + + +This is the CSharp Project that references **IncrementalSourceGenerator.BuilderPattern** +```xml showLineNumbers {15} + + + + Exe + net10.0 + enable + + + + true + $(BaseIntermediateOutputPath)\GX + + + + + + + +``` + + + + + + This is the use of **IncrementalSourceGenerator.BuilderPattern** in *Program.cs* + +```csharp showLineNumbers +using Builder; + +Console.WriteLine("create person builder"); + +var p = new PersonBuilder() + .WithFirstName("Andrei") + .WithLastName("Ignat") + .Build(); + + + +Console.WriteLine(p.FullName()); + +``` + + + + + This is the use of **IncrementalSourceGenerator.BuilderPattern** in *Person.cs* + +```csharp showLineNumbers +using Generator; +namespace Builder; + +[Builder(typeof(Person))] +public partial class PersonBuilder +{ + +} + +public class Person +{ + public string FirstName \{ get; set; } + public string LastName \{ get; set; } + public string FullName() => $"{FirstName} {LastName}"; +} +``` + + + + +### Generated Files + +Those are taken from $(BaseIntermediateOutputPath)\GX + + + + +```csharp showLineNumbers +#nullable enable +#pragma warning disable CA1813, CA1019, IDE0065, IDE0034, IDE0055 + +using System; + +namespace Generator; + +[System.CodeDom.Compiler.GeneratedCode("Generator", "v1")] +[AttributeUsage(AttributeTargets.Class)] +public sealed class BuilderAttribute(Type type) : Attribute +{ + public Type TargetType \{ get; \} = type; +} + +#pragma warning restore CA1813, CA1019, IDE0065, IDE0034, IDE0055 +``` + + + + +```csharp showLineNumbers +#nullable enable +#pragma warning disable IDE0055, IDE0008 + +using System; +using System.Linq; +using System.Collections.Generic; +using Generator; + +namespace Builder; + +[System.CodeDom.Compiler.GeneratedCode("Generator", "v1")] +public partial class Person +{ + private Func _factory = () => new(); + private readonly List> _domainRules = new(); + /// + /// Returns configured instance of Builder.PersonBuilder + /// + public Builder.PersonBuilder Build() + { + Builder.PersonBuilder instance = _factory(); + + _domainRules.ForEach(action => action(instance)); + + return instance; + } +} + +#pragma warning restore IDE0055, IDE0008 +``` + + + + +```csharp showLineNumbers +#nullable enable +#pragma warning disable IDE0055, IDE0008 + +using System; +using System.Linq; +using System.Collections.Generic; +using Generator; + +namespace Builder; + +[System.CodeDom.Compiler.GeneratedCode("Generator", "v1")] +public partial class PersonBuilder +{ + private Func _factory = () => new(); + private readonly List> _domainRules = new(); + private Func? _firstName; + private Func? _lastName; + + public PersonBuilder WithFirstName(string @firstName) + { + return WithFirstName(() => @firstName); + } + public PersonBuilder WithFirstName(Func @firstName) + { + _firstName = @firstName; + return this; + } + + public PersonBuilder WithLastName(string @lastName) + { + return WithLastName(() => @lastName); + } + public PersonBuilder WithLastName(Func @lastName) + { + _lastName = @lastName; + return this; + } + /// + /// Returns configured instance of Builder.Person + /// + public Builder.Person Build() + { + Builder.Person instance = _factory(); + + if(_firstName is not null) + instance.FirstName = _firstName.Invoke(); + + if(_lastName is not null) + instance.LastName = _lastName.Invoke(); + + _domainRules.ForEach(action => action(instance)); + + return instance; + } +} + +#pragma warning restore IDE0055, IDE0008 +``` + + + + +```csharp showLineNumbers +#pragma warning disable IDE0055, IDE0008 +#nullable enable + +using System; +using System.Collections.Generic; + +namespace Generator; + +[System.CodeDom.Compiler.GeneratedCode("Generator", "v1")] +public static class DomainAssertionExtensions +{ + /// + /// Adds a domain validation rule to be executed during the build phase. + /// + /// The list of post-build domain rules. + /// A function that returns true when the entity violates a rule. + /// The error message that will be thrown if the rule fails. + public static void AddDomainRule( + this List> _domainRules, + Func predicate, + string errorMessage) + { + _domainRules.Add(e => + { + if (predicate(e)) + throw new InvalidOperationException(errorMessage); + }); + } +} + +#pragma warning restore IDE0055, IDE0008 +``` + + + + +## Useful + +### Download Example (.NET C#) + +:::tip + +[Download Example project IncrementalSourceGenerator.BuilderPattern ](/sources/IncrementalSourceGenerator.BuilderPattern.zip) + +::: + + +### Share IncrementalSourceGenerator.BuilderPattern + + + +https://ignatandrei.github.io/RSCG_Examples/v2/docs/IncrementalSourceGenerator.BuilderPattern + + + diff --git a/v2/rscg_examples_site/docs/RSCG-Examples/index.md b/v2/rscg_examples_site/docs/RSCG-Examples/index.md index 3cfc8efb8..c91b1804c 100644 --- a/v2/rscg_examples_site/docs/RSCG-Examples/index.md +++ b/v2/rscg_examples_site/docs/RSCG-Examples/index.md @@ -1,7 +1,7 @@ --- sidebar_position: 30 -title: 282 RSCG list by category -description: 282 RSCG list by category +title: 283 RSCG list by category +description: 283 RSCG list by category slug: /rscg-examples --- @@ -206,7 +206,7 @@ import DocCardList from '@theme/DocCardList'; ## Builder
- Expand Builder =>examples:9 + Expand Builder =>examples:10 @@ -252,6 +252,11 @@ import DocCardList from '@theme/DocCardList'; [TypedStateBuilder.Generator](/docs/TypedStateBuilder.Generator) + + + +[IncrementalSourceGenerator.BuilderPattern](/docs/IncrementalSourceGenerator.BuilderPattern) +
@@ -1831,6 +1836,8 @@ flowchart LR; Builder--> TypedStateBuilder.Generator((TypedStateBuilder.Generator)) + Builder--> IncrementalSourceGenerator.BuilderPattern((IncrementalSourceGenerator.BuilderPattern)) + Clone--> CopyTo((CopyTo)) Clone--> Dolly((Dolly)) diff --git a/v2/rscg_examples_site/docs/about.md b/v2/rscg_examples_site/docs/about.md index 87bcf3496..86216573a 100644 --- a/v2/rscg_examples_site/docs/about.md +++ b/v2/rscg_examples_site/docs/about.md @@ -6,7 +6,7 @@ title: About ## Content You will find here code examples -of 282 Roslyn Source Code Generator (RSCG) +of 283 Roslyn Source Code Generator (RSCG) that can be useful for you. That means, you will write more elegant and concise code - even if the generators code is not always nice to look. ## Are those examples ready for production? diff --git a/v2/rscg_examples_site/docs/indexRSCG.md b/v2/rscg_examples_site/docs/indexRSCG.md index 6dbc9e76e..6df0bbab1 100644 --- a/v2/rscg_examples_site/docs/indexRSCG.md +++ b/v2/rscg_examples_site/docs/indexRSCG.md @@ -7,9 +7,9 @@ slug: /List-of-RSCG import useBaseUrl from '@docusaurus/useBaseUrl'; -## 282 RSCG with examples in descending chronological order +## 283 RSCG with examples in descending chronological order -This is the list of 282 ( 16 from Microsoft) RSCG with examples +This is the list of 283 ( 16 from Microsoft) RSCG with examples [See by category](/docs/rscg-examples) [See as json](/exports/RSCG.json) [See as Excel](/exports/RSCG.xlsx) @@ -20,6 +20,7 @@ This is the list of 282 ( 16 from Microsoft) RSCG with examples | No | Name | Date | Category | | --------- | ----- | ---- | -------- | +|283| [IncrementalSourceGenerator.BuilderPattern by Martin Barrett Nielsen ](/docs/IncrementalSourceGenerator.BuilderPattern)|2026-08-23 => 23 August 2026 | [Builder](/docs/Categories/Builder) | |282| [Clap.Net by Simon Curtis ](/docs/Clap.Net)|2026-08-22 => 22 August 2026 | [CommandLine](/docs/Categories/CommandLine) | |281| [EndpointHelpers by Gustavo Mauricio de Barros ](/docs/EndpointHelpers)|2026-08-21 => 21 August 2026 | [MVC](/docs/Categories/MVC) | |280| [serde by Andy Gocke ](/docs/serde)|2026-08-20 => 20 August 2026 | [Serializer](/docs/Categories/Serializer) | diff --git a/v2/rscg_examples_site/src/components/HomepageFeatures/index.js b/v2/rscg_examples_site/src/components/HomepageFeatures/index.js index 4fa2119b7..e44041272 100644 --- a/v2/rscg_examples_site/src/components/HomepageFeatures/index.js +++ b/v2/rscg_examples_site/src/components/HomepageFeatures/index.js @@ -4,7 +4,7 @@ import styles from './styles.module.css'; const FeatureList = [ { -title: '282 Examples (16 from MSFT)', +title: '283 Examples (16 from MSFT)', Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default, description: ( <> diff --git a/v2/rscg_examples_site/static/exports/RSCG.json b/v2/rscg_examples_site/static/exports/RSCG.json index d07b0d255..9d953071a 100644 --- a/v2/rscg_examples_site/static/exports/RSCG.json +++ b/v2/rscg_examples_site/static/exports/RSCG.json @@ -2257,6 +2257,14 @@ "Source": "https://github.com/simon-curtis/Clap.Net", "Category": "CommandLine", "AddedOn": "2026-08-22T00:00:00" + }, + { + "Name": "IncrementalSourceGenerator.BuilderPattern", + "Link": "https://ignatandrei.github.io/RSCG_Examples/v2/docs/IncrementalSourceGenerator.BuilderPattern", + "NuGet": "https://www.nuget.org/packages/IncrementalSourceGenerator.BuilderPattern/", + "Source": "https://github.com/MartinBarrettNielsen11/Incremental-source-generator-builder-pattern", + "Category": "Builder", + "AddedOn": "2026-08-23T00:00:00" } ] } \ No newline at end of file diff --git a/v2/rscg_examples_site/static/exports/RSCG.xlsx b/v2/rscg_examples_site/static/exports/RSCG.xlsx index aaab27310..78cf324a3 100644 Binary files a/v2/rscg_examples_site/static/exports/RSCG.xlsx and b/v2/rscg_examples_site/static/exports/RSCG.xlsx differ diff --git a/v2/rscg_examples_site/static/sources/IncrementalSourceGenerator.BuilderPattern.zip b/v2/rscg_examples_site/static/sources/IncrementalSourceGenerator.BuilderPattern.zip new file mode 100644 index 000000000..fbe31501d Binary files /dev/null and b/v2/rscg_examples_site/static/sources/IncrementalSourceGenerator.BuilderPattern.zip differ