Skip to content

Commit 9272a07

Browse files
authored
Merge pull request #326 from ignatandrei/Hsu.Sg.FluentMember
fluent member
2 parents 6e29b5f + b50865b commit 9272a07

File tree

29 files changed

+856
-153
lines changed

29 files changed

+856
-153
lines changed

README.md

Lines changed: 68 additions & 39 deletions
Large diffs are not rendered by default.

v2/Generator/all.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,4 @@ Nr,Key,Source,Category
169169
168,Credfeto.Version.Information.Generator, https://github.com/credfeto/credfeto-version-constants-generator,EnhancementProject
170170
169,GenPack, https://github.com/dimohy/GenPack,Serializer
171171
170,QueryStringGenerator, https://github.com/tparviainen/query-string-generator,EnhancementClass
172+
171,Hsu.Sg.FluentMember, https://github.com/hsu-net/source-generators,Builder

v2/RSCGExamplesData/GeneratorDataRec.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,10 +1016,17 @@
10161016
"Category": 16,
10171017
"dtStart": "2024-11-06T00:00:00",
10181018
"show": true
1019-
},{
1019+
},
1020+
{
10201021
"ID":"QueryStringGenerator",
10211022
"Category": 5,
10221023
"dtStart": "2024-11-07T00:00:00",
10231024
"show": true
1025+
},
1026+
{
1027+
"ID":"Hsu.Sg.FluentMember",
1028+
"Category": 4,
1029+
"dtStart": "2024-11-08T00:00:00",
1030+
"show": true
10241031
}
10251032
]

v2/RSCGExamplesData/NoExample.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,5 +834,10 @@
834834
"ID":178,
835835
"name":"https://github.com/immediateplatform/immediate.apis",
836836
"why":"later"
837+
},
838+
{
839+
"ID":179,
840+
"name":"Hsu.Sg.Proxy https://github.com/hsu-net/source-generators/",
841+
"why":"later"
837842
}
838843
]
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
2+
<h1>RSCG nr 171 : Hsu.Sg.FluentMember</h1>
3+
4+
<h2>Info</h2>
5+
Nuget : <a href="https://www.nuget.org/packages/Hsu.Sg.FluentMember/" target="_blank">https://www.nuget.org/packages/Hsu.Sg.FluentMember/</a>
6+
7+
<p>You can find more details at : <a href="https://github.com/hsu-net/source-generators" target="_blank"> https://github.com/hsu-net/source-generators</a></p>
8+
9+
<p>Author :Net Hsu</p>
10+
11+
<p>Source : <a href="https://github.com/hsu-net/source-generators" target="_blank">https://github.com/hsu-net/source-generators</a> </p>
12+
13+
<h2>About</h2>
14+
15+
Adding builder pattern to classes
16+
17+
<h2>
18+
How to use
19+
</h2>
20+
<h3>
21+
Add reference to the <a href="https://www.nuget.org/packages/Hsu.Sg.FluentMember/" target="_blank">Hsu.Sg.FluentMember</a> in the csproj
22+
</h3>
23+
<img src="images/Hsu.Sg.FluentMember/Builder.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/Hsu.Sg.FluentMember/csFiles/Program.cs.png" width="580" height="580" />
31+
<hr />
32+
33+
<br />
34+
I have <b>coded</b> the file Person.cs
35+
<br />
36+
<img src="images/Hsu.Sg.FluentMember/csFiles/Person.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 Hsu.Sg.FluentMember.gen.cs
42+
<br />
43+
<img src="images/Hsu.Sg.FluentMember/generated/Hsu.Sg.FluentMember.gen.cs.png" width="580" height="580" />
44+
45+
<p>
46+
You can download the code and this page as pdf from
47+
<a target="_blank" href='https://ignatandrei.github.io/RSCG_Examples/v2/docs/Hsu.Sg.FluentMember'>
48+
https://ignatandrei.github.io/RSCG_Examples/v2/docs/Hsu.Sg.FluentMember
49+
</a>
50+
</p>
51+
52+
53+
<p>
54+
You can see the whole list at
55+
<a target="_blank" href='https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG'>
56+
https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG
57+
</a>
58+
</p>
59+

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 170 RSCG with examples =>
20+
This is the list of 171 RSCG with examples =>
2121
</h1>
2222

2323
<table >
@@ -706,6 +706,10 @@ <h1>
706706
<td>170</td>
707707
<td><a href="examples/QueryStringGenerator.html">QueryStringGenerator</a></td>
708708
</tr>
709+
<tr>
710+
<td>171</td>
711+
<td><a href="examples/Hsu.Sg.FluentMember.html">Hsu.Sg.FluentMember</a></td>
712+
</tr>
709713
</table>
710714

711715

v2/book/pandocHTML.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ input-files:
184184
- examples/Credfeto.Version.Information.Generator.html
185185
- examples/GenPack.html
186186
- examples/QueryStringGenerator.html
187+
- examples/Hsu.Sg.FluentMember.html
187188

188189
# or you may use input-file: with a single value
189190
# defaults:
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"generator":{
3+
"name":"Hsu.Sg.FluentMember",
4+
"nuget":[
5+
"https://www.nuget.org/packages/Hsu.Sg.FluentMember/"
6+
],
7+
"link":"https://github.com/hsu-net/source-generators",
8+
"author":"Net Hsu",
9+
"source":"https://github.com/hsu-net/source-generators"
10+
},
11+
"data":{
12+
"goodFor":["Adding builder pattern to classes"],
13+
"csprojDemo":"Builder.csproj",
14+
"csFiles":["Program.cs","Person.cs"],
15+
"excludeDirectoryGenerated":[""],
16+
"includeAdditionalFiles":[""]
17+
},
18+
"links":{
19+
"blog":"",
20+
"video":""
21+
}
22+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a fluent member source generator.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Hsu.Sg
2+
3+
[![dev](https://github.com/hsu-net/source-generators/actions/workflows/build.yml/badge.svg?branch=dev)](https://github.com/hsu-net/source-generators/actions/workflows/build.yml)
4+
[![preview](https://github.com/hsu-net/source-generators/actions/workflows/deploy.yml/badge.svg?branch=preview)](https://github.com/hsu-net/source-generators/actions/workflows/deploy.yml)
5+
[![main](https://github.com/hsu-net/source-generators/actions/workflows/deploy.yml/badge.svg?branch=main)](https://github.com/hsu-net/source-generators/actions/workflows/deploy.yml)
6+
[![nuke build](https://img.shields.io/badge/nuke-build-yellow.svg)](https://github.com/nuke-build/nuke)
7+
8+
.NET source generators
9+
10+
## Package Version
11+
12+
| Name | Source | Stable | Preview |
13+
|---|---|---|---|
14+
| Hsu.Sg.Sync | Nuget | [![NuGet](https://img.shields.io/nuget/v/Hsu.Sg.Sync?style=flat-square)](https://www.nuget.org/packages/Hsu.Sg.Sync) | [![NuGet](https://img.shields.io/nuget/vpre/Hsu.Sg.Sync?style=flat-square)](https://www.nuget.org/packages/Hsu.Sg.Sync) |
15+
| Hsu.Sg.Sync | MyGet | [![MyGet](https://img.shields.io/myget/godsharp/v/Hsu.Sg.Sync?style=flat-square&label=myget)](https://www.myget.org/feed/godsharp/package/nuget/Hsu.Sg.Sync) | [![MyGet](https://img.shields.io/myget/godsharp/vpre/Hsu.Sg.Sync?style=flat-square&label=myget)](https://www.myget.org/feed/godsharp/package/nuget/Hsu.Sg.Sync) |
16+
| Hsu.Sg.Proxy | Nuget | [![NuGet](https://img.shields.io/nuget/v/Hsu.Sg.Proxy?style=flat-square)](https://www.nuget.org/packages/Hsu.Sg.Proxy) | [![NuGet](https://img.shields.io/nuget/vpre/Hsu.Sg.Proxy?style=flat-square)](https://www.nuget.org/packages/Hsu.Sg.Proxy) |
17+
| Hsu.Sg.Proxy | MyGet | [![MyGet](https://img.shields.io/myget/godsharp/v/Hsu.Sg.Proxy?style=flat-square&label=myget)](https://www.myget.org/feed/godsharp/package/nuget/Hsu.Sg.Proxy) | [![MyGet](https://img.shields.io/myget/godsharp/vpre/Hsu.Sg.Proxy?style=flat-square&label=myget)](https://www.myget.org/feed/godsharp/package/nuget/Hsu.Sg.Proxy) |
18+
| Hsu.Sg.FluentMember| Nuget | [![NuGet](https://img.shields.io/nuget/v/Hsu.Sg.FluentMember?style=flat-square)](https://www.nuget.org/packages/Hsu.Sg.FluentMember) | [![NuGet](https://img.shields.io/nuget/vpre/Hsu.Sg.FluentMember?style=flat-square)](https://www.nuget.org/packages/Hsu.Sg.FluentMember) |
19+
| Hsu.Sg.FluentMember| MyGet | [![MyGet](https://img.shields.io/myget/godsharp/v/Hsu.Sg.FluentMember?style=flat-square&label=myget)](https://www.myget.org/feed/godsharp/package/nuget/Hsu.Sg.FluentMember) | [![MyGet](https://img.shields.io/myget/godsharp/vpre/Hsu.Sg.FluentMember?style=flat-square&label=myget)](https://www.myget.org/feed/godsharp/package/nuget/Hsu.Sg.FluentMember) |
20+
21+
## Package Features
22+
23+
### Hsu.Sg.Sync
24+
25+
Generate a synchronous method from an asynchronous method.
26+
27+
Usages see [README](./src/Hsu.Sg.Sync/README.md)
28+
29+
### Hsu.Sg.Proxy
30+
31+
Generate a proxy object from a `struct` or `class` or `interface`.
32+
33+
Usages see [README](./src/Hsu.Sg.Proxy/README.md)
34+
35+
### Hsu.Sg.FluentMember
36+
37+
Generate a fluent method from a `struct` or `class`.
38+
39+
Usages see [README](./src/Hsu.Sg.FluentMember/README.md)
40+
41+
## References
42+
43+
- [Source Generators Cookbook](https://github.com/dotnet/roslyn/blob/main/docs/features/source-generators.cookbook.md)
44+
- [Incremental Generators](https://github.com/dotnet/roslyn/blob/main/docs/features/incremental-generators.md)
45+
46+
## License
47+
48+
[MIT](./LICENSE)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
{
3+
"$schema": "https://aka.ms/codetour-schema",
4+
"title": "Hsu.Sg.FluentMember",
5+
"steps":
6+
[
7+
{
8+
"file": "Builder/Builder.csproj",
9+
"description": "First, we add Nuget [Hsu.Sg.FluentMember](https://www.nuget.org/packages/Hsu.Sg.FluentMember/) in csproj ",
10+
"pattern": "Hsu.Sg.FluentMember"
11+
}
12+
13+
,{
14+
"file": "Builder/Person.cs",
15+
"description": "File Person.cs ",
16+
"pattern": "this is the code"
17+
}
18+
19+
,{
20+
"file": "Builder/Program.cs",
21+
"description": "File Program.cs \r\n>> dotnet run --project Builder/Builder.csproj ",
22+
"pattern": "this is the code"
23+
}
24+
25+
26+
,{
27+
"file": "Builder/obj/GX/Hsu.Sg.FluentMember/Hsu.Sg.FluentMember.Generator/Hsu.Sg.FluentMember.gen.cs",
28+
"description": "Generated File 1 from 1 : Hsu.Sg.FluentMember.gen.cs ",
29+
"line": 1
30+
}
31+
32+
],
33+
34+
"ref": "main"
35+
36+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31005.135
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Builder", "Builder\Builder.csproj", "{AFD63A05-F54B-4E4F-98E5-BBACBD9FD524}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{AFD63A05-F54B-4E4F-98E5-BBACBD9FD524}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{AFD63A05-F54B-4E4F-98E5-BBACBD9FD524}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{AFD63A05-F54B-4E4F-98E5-BBACBD9FD524}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{AFD63A05-F54B-4E4F-98E5-BBACBD9FD524}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {CCCECE32-B8C4-46A5-94BF-EC843EE4C618}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
<PropertyGroup>
9+
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
10+
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="Hsu.Sg.FluentMember" Version="2024.101.8-rc175707">
15+
<PrivateAssets>all</PrivateAssets>
16+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
17+
</PackageReference>
18+
</ItemGroup>
19+
20+
21+
22+
</Project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace Builder;
2+
[Hsu.Sg.FluentMember.FluentMember]
3+
public partial class Person
4+
{
5+
public string FirstName { get; init; }
6+
public string? MiddleName { get; init; }
7+
public string LastName { get; init; }
8+
9+
public string FullName()
10+
{
11+
return FirstName + " " + MiddleName + " "+LastName;
12+
}
13+
14+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
using Builder;
2+
3+
var pOld = new Person();
4+
pOld= pOld.WithFirstName("Andrei").WithLastName("Ignat").WithMiddleName("G");
5+
6+
System.Console.WriteLine(pOld.FullName());
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"scriptName": "Hsu.Sg.FluentMember",
3+
"steps":
4+
[
5+
{"typeStep":"exec","arg":"clipchamp.exe launch"},
6+
{"typeStep":"text","arg": "Welcome to Roslyn Examples"},
7+
{"typeStep":"text","arg":"If you want to see more examples , see List Of RSCG"},
8+
{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG"},
9+
{"typeStep":"text","arg": "My name is Andrei Ignat and I am deeply fond of Roslyn Source Code Generator. "},
10+
11+
{"typeStep":"text","arg": "Today I will present Hsu.Sg.FluentMember . Adding builder pattern to classes ."},
12+
{"typeStep":"browser","arg":"https://www.nuget.org/packages/Hsu.Sg.FluentMember/"},
13+
{"typeStep":"text","arg": "The whole example is here"},
14+
{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/Hsu.Sg.FluentMember"},
15+
{"typeStep":"text","arg": "You can download the code from here"},
16+
{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/Hsu.Sg.FluentMember#download-example-net--c-"},
17+
{"typeStep":"text","arg":"Here is the code downloaded "},
18+
{"typeStep":"exec","arg":"explorer.exe /select,D:\\gth\\RSCG_Examples\\v2\\rscg_examples\\Hsu.Sg.FluentMember\\src\\Builder.sln"},
19+
{"typeStep":"text","arg": "So , let's start the project with Visual Studio Code "},
20+
{"typeStep":"stepvscode","arg": "-n D:\\gth\\RSCG_Examples\\v2\\rscg_examples\\Hsu.Sg.FluentMember\\src"},
21+
22+
{"typeStep":"text","arg": "To use it ,you will put the Nuget Hsu.Sg.FluentMember into the csproj "},
23+
24+
{"typeStep":"stepvscode","arg": "-r -g D:\\gth\\RSCG_Examples\\v2\\rscg_examples\\Hsu.Sg.FluentMember\\src\\Builder\\Builder.csproj"},
25+
26+
{"typeStep":"text","arg": "And now I will show you an example of using Hsu.Sg.FluentMember"},
27+
28+
{"typeStep":"hide","arg": "now execute the tour in VSCode"},
29+
{"typeStep":"tour", "arg": "src/.tours/"},
30+
{"typeStep":"text","arg":" And I will execute the project"},
31+
{"typeStep":"showproj", "arg":"Builder.csproj"},
32+
{"typeStep":"text","arg":" This concludes the project"},
33+
{"typeStep":"waitseconds","arg":"30"},
34+
{"typeStep":"text","arg": "Remember, you can download the code from here"},
35+
{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/Hsu.Sg.FluentMember#download-example-net--c-",
36+
SpeakTest=" "},
37+
{"typeStep":"waitseconds","arg":"30"},
38+
]
39+
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<h1>Builder</h1>
22

3-
Number RSCG: 3
3+
Number RSCG: 4
44

55
1 [Architect.DomainModeling](/docs/Architect.DomainModeling)
66

77
2 [BuilderGenerator](/docs/BuilderGenerator)
88

99
3 [Fluentify](/docs/Fluentify)
10+
11+
4 [Hsu.Sg.FluentMember](/docs/Hsu.Sg.FluentMember)
1012

0 commit comments

Comments
 (0)