Skip to content

Commit ce7d48c

Browse files
committed
factory
1 parent df2b994 commit ce7d48c

File tree

19 files changed

+695
-228
lines changed

19 files changed

+695
-228
lines changed

README.md

Lines changed: 64 additions & 56 deletions
Large diffs are not rendered by default.

later.md

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Just later
22

3-
## Latest Update : 2025-08-11 => 11 August 2025
3+
## Latest Update : 2025-08-12 => 12 August 2025
44

55

66

@@ -122,175 +122,163 @@ Why I have not tested : later
122122

123123

124124

125-
20) [https://github.com/ivmazurenko/factory-generator]( https://github.com/ivmazurenko/factory-generator) , https://github.com/ivmazurenko/factory-generator
125+
20) [https://github.com/JasonBock/CslaGeneratorSerialization]( https://github.com/JasonBock/CslaGeneratorSerialization) , https://github.com/JasonBock/CslaGeneratorSerialization
126126

127127
Why I have not tested : later
128128

129129

130130

131-
21) [https://github.com/JasonBock/CslaGeneratorSerialization]( https://github.com/JasonBock/CslaGeneratorSerialization) , https://github.com/JasonBock/CslaGeneratorSerialization
131+
21) [https://github.com/MarkFl12/BlazorLinks]( https://github.com/MarkFl12/BlazorLinks) , https://github.com/MarkFl12/BlazorLinks
132132

133133
Why I have not tested : later
134134

135135

136136

137-
22) [https://github.com/JinShil/JinShil.MixinSourceGenerator]( https://github.com/JinShil/JinShil.MixinSourceGenerator) , https://github.com/JinShil/JinShil.MixinSourceGenerator
137+
22) [https://github.com/MeltyPlayer/Schema]( https://github.com/MeltyPlayer/Schema) , https://github.com/MeltyPlayer/Schema
138138

139139
Why I have not tested : later
140140

141141

142142

143-
23) [https://github.com/MarkFl12/BlazorLinks]( https://github.com/MarkFl12/BlazorLinks) , https://github.com/MarkFl12/BlazorLinks
143+
23) [https://github.com/stbychkov/AutoLoggerMessage]( https://github.com/stbychkov/AutoLoggerMessage) , https://github.com/stbychkov/AutoLoggerMessage
144144

145145
Why I have not tested : later
146146

147147

148148

149-
24) [https://github.com/MeltyPlayer/Schema]( https://github.com/MeltyPlayer/Schema) , https://github.com/MeltyPlayer/Schema
149+
24) [https://github.com/Stepami/visitor-net]( https://github.com/Stepami/visitor-net) , https://github.com/Stepami/visitor-net
150150

151151
Why I have not tested : later
152152

153153

154154

155-
25) [https://github.com/stbychkov/AutoLoggerMessage]( https://github.com/stbychkov/AutoLoggerMessage) , https://github.com/stbychkov/AutoLoggerMessage
155+
25) [https://github.com/SzymonHalucha/Minerals.AutoCommands]( https://github.com/SzymonHalucha/Minerals.AutoCommands) , https://github.com/SzymonHalucha/Minerals.AutoCommands
156156

157157
Why I have not tested : later
158158

159159

160160

161-
26) [https://github.com/Stepami/visitor-net]( https://github.com/Stepami/visitor-net) , https://github.com/Stepami/visitor-net
161+
26) [https://github.com/Teleopti/Saspect]( https://github.com/Teleopti/Saspect) , https://github.com/Teleopti/Saspect
162162

163163
Why I have not tested : later
164164

165165

166166

167-
27) [https://github.com/SzymonHalucha/Minerals.AutoCommands]( https://github.com/SzymonHalucha/Minerals.AutoCommands) , https://github.com/SzymonHalucha/Minerals.AutoCommands
167+
27) [https://github.com/TheFo2sh/AsyncFlow]( https://github.com/TheFo2sh/AsyncFlow) , https://github.com/TheFo2sh/AsyncFlow
168168

169169
Why I have not tested : later
170170

171171

172172

173-
28) [https://github.com/Teleopti/Saspect]( https://github.com/Teleopti/Saspect) , https://github.com/Teleopti/Saspect
173+
28) [https://github.com/wieslawsoltes/ReactiveGenerator]( https://github.com/wieslawsoltes/ReactiveGenerator) , https://github.com/wieslawsoltes/ReactiveGenerator
174174

175175
Why I have not tested : later
176176

177177

178178

179-
29) [https://github.com/TheFo2sh/AsyncFlow]( https://github.com/TheFo2sh/AsyncFlow) , https://github.com/TheFo2sh/AsyncFlow
179+
29) [laker]( https://github.com/Lakerfield/Lakerfield.Rpc) , https://github.com/Lakerfield/Lakerfield.Rpc
180180

181181
Why I have not tested : later
182182

183183

184184

185-
30) [https://github.com/wieslawsoltes/ReactiveGenerator]( https://github.com/wieslawsoltes/ReactiveGenerator) , https://github.com/wieslawsoltes/ReactiveGenerator
185+
30) [ManagedDotnetProfiler]( https://github.com/kevingosse/ManagedDotnetProfiler) , https://github.com/kevingosse/ManagedDotnetProfiler
186186

187187
Why I have not tested : later
188188

189189

190190

191-
31) [laker]( https://github.com/Lakerfield/Lakerfield.Rpc) , https://github.com/Lakerfield/Lakerfield.Rpc
191+
31) [Maui.BindableProperty.Generator]( https://github.com/rrmanzano/maui-bindableproperty-generator) , https://github.com/rrmanzano/maui-bindableproperty-generator
192192

193193
Why I have not tested : later
194194

195195

196196

197-
32) [ManagedDotnetProfiler]( https://github.com/kevingosse/ManagedDotnetProfiler) , https://github.com/kevingosse/ManagedDotnetProfiler
197+
32) [Minerals.AutoCQRS]( https://github.com/SzymonHalucha/Minerals.AutoCQRS) , https://github.com/SzymonHalucha/Minerals.AutoCQRS
198198

199199
Why I have not tested : later
200200

201201

202202

203-
33) [Maui.BindableProperty.Generator]( https://github.com/rrmanzano/maui-bindableproperty-generator) , https://github.com/rrmanzano/maui-bindableproperty-generator
203+
33) [Minerals.AutoDomain]( https://github.com/SzymonHalucha/Minerals.AutoDomain) , https://github.com/SzymonHalucha/Minerals.AutoDomain
204204

205205
Why I have not tested : later
206206

207207

208208

209-
34) [Minerals.AutoCQRS]( https://github.com/SzymonHalucha/Minerals.AutoCQRS) , https://github.com/SzymonHalucha/Minerals.AutoCQRS
209+
34) [MvvmGen]( https://github.com/thomasclaudiushuber/mvvmgen) , https://github.com/thomasclaudiushuber/mvvmgen
210210

211211
Why I have not tested : later
212212

213213

214214

215-
35) [Minerals.AutoDomain]( https://github.com/SzymonHalucha/Minerals.AutoDomain) , https://github.com/SzymonHalucha/Minerals.AutoDomain
215+
35) [observable]( https://github.com/notanaverageman/Bindables) , https://github.com/notanaverageman/Bindables
216216

217217
Why I have not tested : later
218218

219219

220220

221-
36) [MvvmGen]( https://github.com/thomasclaudiushuber/mvvmgen) , https://github.com/thomasclaudiushuber/mvvmgen
221+
36) [Overloader]( https://github.com/emptycoder/Overloader) , https://github.com/emptycoder/Overloader
222222

223223
Why I have not tested : later
224224

225225

226226

227-
37) [observable]( https://github.com/notanaverageman/Bindables) , https://github.com/notanaverageman/Bindables
227+
37) [PolySharp]( https://github.com/Sergio0694/PolySharp) , https://github.com/Sergio0694/PolySharp
228228

229229
Why I have not tested : later
230230

231231

232232

233-
38) [Overloader]( https://github.com/emptycoder/Overloader) , https://github.com/emptycoder/Overloader
233+
38) [RazorGen]( https://github.com/dartk/RazorGen) , https://github.com/dartk/RazorGen
234234

235235
Why I have not tested : later
236236

237237

238238

239-
39) [PolySharp]( https://github.com/Sergio0694/PolySharp) , https://github.com/Sergio0694/PolySharp
239+
39) [schema]( https://github.com/MeltyPlayer/Schema) , https://github.com/MeltyPlayer/Schema
240240

241241
Why I have not tested : later
242242

243243

244244

245-
40) [RazorGen]( https://github.com/dartk/RazorGen) , https://github.com/dartk/RazorGen
245+
40) [SogePoco]( https://github.com/d-p-y/SogePoco) , https://github.com/d-p-y/SogePoco
246246

247247
Why I have not tested : later
248248

249249

250250

251-
41) [schema]( https://github.com/MeltyPlayer/Schema) , https://github.com/MeltyPlayer/Schema
251+
41) [SourceCrafter.HttpServiceClientGenerator]( https://github.com/pedro-gilmora/SourceCrafter.HttpServiceClientGenerator/) , https://github.com/pedro-gilmora/SourceCrafter.HttpServiceClientGenerator/
252252

253253
Why I have not tested : later
254254

255255

256256

257-
42) [SogePoco]( https://github.com/d-p-y/SogePoco) , https://github.com/d-p-y/SogePoco
257+
42) [ST.NSwag.ServerSourceGenerator]( https://github.com/s-tarasov/ST.NSwag.ServerSourceGenerator) , https://github.com/s-tarasov/ST.NSwag.ServerSourceGenerator
258258

259259
Why I have not tested : later
260260

261261

262262

263-
43) [SourceCrafter.HttpServiceClientGenerator]( https://github.com/pedro-gilmora/SourceCrafter.HttpServiceClientGenerator/) , https://github.com/pedro-gilmora/SourceCrafter.HttpServiceClientGenerator/
263+
43) [StrongInject]( https://github.com/YairHalberstadt/stronginject/) , https://github.com/YairHalberstadt/stronginject/
264264

265265
Why I have not tested : later
266266

267267

268268

269-
44) [ST.NSwag.ServerSourceGenerator]( https://github.com/s-tarasov/ST.NSwag.ServerSourceGenerator) , https://github.com/s-tarasov/ST.NSwag.ServerSourceGenerator
269+
44) [TupleOverloadGenerator]( https://github.com/ProphetLamb/TupleOverloadGenerator) , https://github.com/ProphetLamb/TupleOverloadGenerator
270270

271271
Why I have not tested : later
272272

273273

274274

275-
45) [StrongInject]( https://github.com/YairHalberstadt/stronginject/) , https://github.com/YairHalberstadt/stronginject/
275+
45) [ValueLink]( https://github.com/archi-Doc/ValueLink) , https://github.com/archi-Doc/ValueLink
276276

277277
Why I have not tested : later
278278

279279

280280

281-
46) [TupleOverloadGenerator]( https://github.com/ProphetLamb/TupleOverloadGenerator) , https://github.com/ProphetLamb/TupleOverloadGenerator
282-
283-
Why I have not tested : later
284-
285-
286-
287-
47) [ValueLink]( https://github.com/archi-Doc/ValueLink) , https://github.com/archi-Doc/ValueLink
288-
289-
Why I have not tested : later
290-
291-
292-
293-
48) [Visor]( https://github.com/Tinkoff/Visor) , https://github.com/Tinkoff/Visor
281+
46) [Visor]( https://github.com/Tinkoff/Visor) , https://github.com/Tinkoff/Visor
294282

295283
Why I have not tested : later
296284

v2/Generator/all.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,4 @@ Nr,Key,Source,Category
222222
221,RxSourceGenerator, https://github.com/Zalutskii/Reactive-Extensions-event-generator,RX
223223
222,Finch.Generators, https://github.com/ivmazurenko/finch,Database
224224
223,JinShil.MixinSourceGenerator, https://github.com/JinShil/JinShil.MixinSourceGenerator,Mixin
225+
224,FactoryGenerator.Abstractions, https://github.com/ivmazurenko/factory-generator,DependencyInjection

v2/RSCGExamplesData/GeneratorDataRec.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,5 +1347,11 @@
13471347
"Category": 39,
13481348
"dtStart": "2025-08-11T00:00:00",
13491349
"show": true
1350+
},
1351+
{
1352+
"ID":"FactoryGenerator.Abstractions",
1353+
"Category": 7,
1354+
"dtStart": "2025-08-12T00:00:00",
1355+
"show": true
13501356
}
13511357
]

v2/RSCGExamplesData/NoExample.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -888,11 +888,6 @@
888888
"ID":218,
889889
"name":"https://github.com/Atoen/TextLocalizer",
890890
"why":"later"
891-
},
892-
{
893-
"ID":219,
894-
"name":"https://github.com/ivmazurenko/factory-generator",
895-
"why":"later"
896891
}
897892
,{
898893
"ID":220,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Package Description
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# FactoryGenerator
2+
3+
.NET source generator that automatically
4+
generates and registers [factories](https://github.com/ivmazurenko/factory-generator/blob/master/FactoryGenerator.Abstractions/IFactory.cs)
5+
6+
7+
## Installation
8+
9+
Add the following packages to your project:
10+
11+
```bash
12+
$ dotnet add package FactoryGenerator.Abstractions
13+
$ dotnet add package FactoryGenerator.Microsoft.Extensions.DependencyInjection
14+
```
15+
16+
## Usage
17+
18+
### Add the attribute to your class
19+
20+
Use one of the `GenerateIFactory` attributes to specify how your factory should be
21+
generated:
22+
23+
```c#
24+
[GenerateIFactory<int>]
25+
public class Service(int value, Dependency dependency)
26+
{
27+
// ...
28+
}
29+
```
30+
31+
This will generate an implementation of `IFactory<int, Service>`, allowing you to create instances of `Service` with an
32+
`int` parameter while automatically resolving other dependencies from the DI container. FactoryGenerator
33+
provides [multiple attribute variations](https://github.com/ivmazurenko/factory-generator/blob/master/FactoryGenerator.Abstractions/GenerateIFactoryAttribute.cs)
34+
depending on the number of parameters your factory should accept.
35+
36+
### Register generated factories in the DI container
37+
38+
The `RegisterGeneratedFactories()` method automatically registers all factories created by the source
39+
generator.
40+
41+
```c#
42+
43+
var serviceCollection = new ServiceCollection()
44+
.RegisterGeneratedFactories();
45+
46+
```
47+
48+
### Use the factory
49+
50+
```c#
51+
using var serviceProvider = serviceCollection.BuildServiceProvider();
52+
53+
var factory = serviceProvider.GetRequiredService<IFactory<int, Service>>();
54+
55+
var service = factory.Create(1);
56+
```
57+
58+
Full sample can be found [here](https://github.com/ivmazurenko/factory-generator/blob/master/Samples/Program.cs).
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
{
3+
"$schema": "https://aka.ms/codetour-schema",
4+
"title": "FactoryGenerator.Abstractions",
5+
"steps":
6+
[
7+
{
8+
"file": "InjectDemo/InjectDemo.csproj",
9+
"description": "First, we add Nuget [FactoryGenerator.Abstractions](https://www.nuget.org/packages/FactoryGenerator.Abstractions/) in csproj ",
10+
"pattern": "FactoryGenerator.Abstractions"
11+
}
12+
13+
,{
14+
"file": "InjectDemo/Person.cs",
15+
"description": "File Person.cs ",
16+
"pattern": "this is the code"
17+
}
18+
19+
,{
20+
"file": "InjectDemo/Program.cs",
21+
"description": "File Program.cs \r\n>> dotnet run --project InjectDemo/InjectDemo.csproj ",
22+
"pattern": "this is the code"
23+
}
24+
25+
26+
,{
27+
"file": "InjectDemo/obj/GX/FactoryGenerator.Microsoft.Extensions.DependencyInjection/FactoryGenerator.Microsoft.Extensions.DependencyInjection.FactoryGenerator/InjectDemo.PersonTypePersonFactoryFactory.g.cs",
28+
"description": "Generated File 2 from 2 : InjectDemo.PersonTypePersonFactoryFactory.g.cs ",
29+
"line": 1
30+
}
31+
32+
,{
33+
"file": "InjectDemo/obj/GX/FactoryGenerator.Microsoft.Extensions.DependencyInjection/FactoryGenerator.Microsoft.Extensions.DependencyInjection.FactoryGenerator/FactoryGenerator.Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.g.cs",
34+
"description": "Generated File 1 from 2 : FactoryGenerator.Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.g.cs ",
35+
"line": 1
36+
}
37+
38+
],
39+
40+
"ref": "main"
41+
42+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"scriptName": "FactoryGenerator.Abstractions",
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 FactoryGenerator.Abstractions . Generating DI Factory based on the first parameter(s) ."},
12+
{"typeStep":"browser","arg":"https://www.nuget.org/packages/FactoryGenerator.Abstractions/"},
13+
{"typeStep":"text","arg": "The whole example is here"},
14+
{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/FactoryGenerator.Abstractions"},
15+
{"typeStep":"text","arg": "You can download the code from here"},
16+
{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/FactoryGenerator.Abstractions#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\\FactoryGenerator.Abstractions\\src\\InjectDemo.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\\FactoryGenerator.Abstractions\\src"},
21+
22+
{"typeStep":"text","arg": "To use it ,you will put the Nuget FactoryGenerator.Abstractions into the csproj "},
23+
24+
{"typeStep":"stepvscode","arg": "-r -g D:\\gth\\RSCG_Examples\\v2\\rscg_examples\\FactoryGenerator.Abstractions\\src\\InjectDemo\\InjectDemo.csproj"},
25+
26+
{"typeStep":"text","arg": "And now I will show you an example of using FactoryGenerator.Abstractions"},
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":"InjectDemo.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/FactoryGenerator.Abstractions#download-example-net--c-",
36+
SpeakTest=" "},
37+
{"typeStep":"waitseconds","arg":"30"},
38+
]
39+
}

0 commit comments

Comments
 (0)