Skip to content

Commit 1eb2a74

Browse files
committed
zip
1 parent 6eb29e2 commit 1eb2a74

16 files changed

Lines changed: 113 additions & 22 deletions

v2/book/examples/Aigamo.MatchGenerator.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h2>Info</h2>
1212

1313
<h2>About</h2>
1414

15-
Transform enums into tagged unions -with error in Match !
15+
Generates exhaustive Match() extension methods for enums and abstract record hierarchies (tagged unions), ensuring compile-time safety — all cases must be handled.How to use 1. Add [GenerateMatch] attribute to an enum or abstract record: [GenerateMatch] public enum CarTypes { None, Dacia, Tesla, BMW, Mercedes } [GenerateMatch] abstract record MaritalStatus; sealed record Single : MaritalStatus; sealed record Married : MaritalStatus; 2. Use the generated .Match() method — all cases required (compile error if any missing): var msg = car.Match( onBMW: () =&gt; &quot;this is bmw&quot;, onDacia: () =&gt; &quot;this is dacia&quot;, onMercedes: () =&gt; &quot;this is mercedes&quot;, onNone: () =&gt; &quot;this is none&quot;, onTesla: () =&gt; &quot;this is tesla&quot; );You can use for Transforming enums/records into exhaustive pattern matching (discriminated unions style). If a case is missing in Match(), it&#x27;s a compile-time error
1616

1717
<h2>
1818
How to use

v2/book/examples/AssemblyMetadata.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h2>Info</h2>
1212

1313
<h2>About</h2>
1414

15-
Generate date time based metadata for assemblies.
15+
Generates compile-time assembly metadata constants (build date, year, time, etc.) — access build info as typed properties without runtime reflection.How to use1. Add the package as an Analyzer (no runtime reference needed):```xml&lt;PackageReference Include=&quot;AssemblyMetadata&quot; Version=&quot;2.0.16&quot; PrivateAssets=&quot;all&quot; OutputItemType=&quot;Analyzer&quot; ReferenceOutputAssembly=&quot;false&quot; /&gt;```2. Use the generated AssemblyMetadataInfo class directly:```csharpConsole.WriteLine(BenjaminAbt.AssemblyMetadata.AssemblyMetadataInfo.BuildInfo.BuildDateYear);```You can use for Embedding build date/time metadata into assemblies as compile-time constants — useful for version screens, diagnostics, or &#x27;built on&#x27; display info without runtime I/O or reflection.
1616

1717
<h2>
1818
How to use
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
2+
<h1>RSCG nr 267 : Maestria.TypeProviders</h1>
3+
4+
<h2>Info</h2>
5+
Nuget : <a href="https://www.nuget.org/packages/Maestria.TypeProviders/" target="_blank">https://www.nuget.org/packages/Maestria.TypeProviders/</a>
6+
7+
<p>You can find more details at : <a href="https://github.com/MaestriaNet/TypeProviders" target="_blank"> https://github.com/MaestriaNet/TypeProviders</a></p>
8+
9+
<p>Author :Fábio Monteiro Naspolini</p>
10+
11+
<p>Source: <a href="https://github.com/MaestriaNet/TypeProviders" target="_blank">https://github.com/MaestriaNet/TypeProviders</a> </p>
12+
13+
<h2>About</h2>
14+
15+
Generating strong typed code from Excel.
16+
17+
<h2>
18+
How to use
19+
</h2>
20+
<h3>
21+
Add reference to the <a href="https://www.nuget.org/packages/Maestria.TypeProviders/" target="_blank">Maestria.TypeProviders</a> in the csproj
22+
</h3>
23+
<img src="images/Maestria.TypeProviders/DemoExcel.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/Maestria.TypeProviders/csFiles/Program.cs.png" width="580" height="580" />
31+
<hr />
32+
33+
<br />
34+
I have <b>coded</b> the file MyExcelPerson.cs
35+
<br />
36+
<img src="images/Maestria.TypeProviders/csFiles/MyExcelPerson.cs.png" width="580" height="580" />
37+
<hr />
38+
39+
<br />
40+
I have <b>coded</b> the file Person.cs
41+
<br />
42+
<img src="images/Maestria.TypeProviders/csFiles/Person.cs.png" width="580" height="580" />
43+
<hr />
44+
<h3>And here are the <i>generated</i> files</h3>
45+
46+
<br />
47+
The file <i>generated</i> is DemoExcel.MyExcelPerson.g.cs
48+
<br />
49+
<img src="images/Maestria.TypeProviders/generated/DemoExcel.MyExcelPerson.g.cs.png" width="580" height="580" />
50+
51+
<br />
52+
The file <i>generated</i> is ExcelExtensions.g.cs
53+
<br />
54+
<img src="images/Maestria.TypeProviders/generated/ExcelExtensions.g.cs.png" width="580" height="580" />
55+
56+
<br />
57+
The file <i>generated</i> is ExcelGeneratorException.g.cs
58+
<br />
59+
<img src="images/Maestria.TypeProviders/generated/ExcelGeneratorException.g.cs.png" width="580" height="580" />
60+
61+
<br />
62+
The file <i>generated</i> is ExcelProviderAttribute.g.cs
63+
<br />
64+
<img src="images/Maestria.TypeProviders/generated/ExcelProviderAttribute.g.cs.png" width="580" height="580" />
65+
66+
<p>
67+
You can download the code and this page as pdf from
68+
<a target="_blank" href='https://ignatandrei.github.io/RSCG_Examples/v2/docs/Maestria.TypeProviders'>
69+
https://ignatandrei.github.io/RSCG_Examples/v2/docs/Maestria.TypeProviders
70+
</a>
71+
</p>
72+
73+
74+
<p>
75+
You can see the whole list at
76+
<a target="_blank" href='https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG'>
77+
https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG
78+
</a>
79+
</p>
80+

v2/book/examples/NLog.Extensions.ThisClass.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h2>Info</h2>
1212

1313
<h2>About</h2>
1414

15-
Generate the NLog register for a class.
15+
Generates a strongly-typed NLog Logger property per class at compile time — no manual LogManager.GetCurrentClassLogger() boilerplate.How to use 1. Mark a partial class with [ClassLoggerLazy]:```charp [ClassLoggerLazy] partial class Person { public string Name() { Logger.Error(&quot;This is an error message from the Name method.&quot;); return $&quot;{FirstName} {LastName}&quot;; } }``` 2. The generated Logger is lazily initialized and scoped to the class — use it directly:```charp var person = new Person { FirstName = &quot;Andrei&quot;, LastName = &quot;Ignat&quot; }; Console.WriteLine(person.Name()); // logs error, returns &quot;Andrei Ignat&quot;```You can use for Auto-wiring NLog class loggers at compile time with zero boilerplate.
1616

1717
<h2>
1818
How to use

v2/book/examples/Najlot.Audit.SourceGenerator.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h2>Info</h2>
1212

1313
<h2>About</h2>
1414

15-
Generating audit code for classes with properties.
15+
Generates audit/change-tracking code at compile time — detects which properties changed between two snapshots of an object. How to use 1. Mark your entity and a partial provider with [AuditProvider]:```charp [AuditProvider] public partial class Person { public string FirstName { get; set; } = string.Empty; public string LastName { get; set; } = string.Empty; public int Id { get; set; } } [AuditProvider] public partial class PersonAuditProvider { [AuditIgnore(nameof(Person.Id))] public static partial IEnumerable&lt;PropertyValue&gt; GetPropertyValues(Person entity); }``` 2. Take a snapshot, mutate, then get changes:```charp var audit = new Audit(); audit.RegisterProvider&lt;PersonAuditProvider&gt;(); var snapshot = audit.CreateSnapshot(p); p.LastName = &quot;Ignat&quot;; foreach (var change in snapshot.GetChanges()) Console.WriteLine($&quot;{change.Path}: {change.OldValue} → {change.NewValue}&quot;);``` You can use for Property-level change tracking / audit logs at compile time. Supports [AuditIgnore] to exclude properties.
1616

1717
<h2>
1818
How to use

v2/book/examples/Pekspro.DataAnnotationValuesExtractor.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h2>Info</h2>
1212

1313
<h2>About</h2>
1414

15-
Generating code to extract values from data annotations in C#.
15+
Generates typed constants from DataAnnotations attributes ([Range], [StringLength], [Required], [Display]) at compile time — no reflection needed to read annotation values.How to use 1. Decorate your model with standard DataAnnotations:```charp partial class Person { [Display(Name = &quot;First name&quot;)] [StringLength(100, MinimumLength = 3)] public string? FirstName { get; set; } [Range(18, 200)] public int Age { get; set; } }``` 2. Declare a partial extractor class targeting the model:```charp [DataAnnotationValuesOptions(StringLength = true, Range = true, Required = true, Display = true)] [DataAnnotationValuesToGenerate(typeof(Person))] partial class Values { }``` 3. Access generated constants:```charp Console.WriteLine(Person.Annotations.Age.Minimum); // 18 Console.WriteLine(Person.Annotations.FirstName.MinimumLength); // 3 Console.WriteLine(Person.Annotations.FirstName.MaximumLength); // 100```You can use for Reusing DataAnnotation constraint values (min/max lengths, ranges) in UI or validation logicwithout duplicating magic numbers or using reflection.
1616

1717
<h2>
1818
How to use

v2/book/examples/REslava.ResultFlow.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h2>Info</h2>
1212

1313
<h2>About</h2>
1414

15-
Functional Code as Mermaid diagrams
15+
Generates Mermaid flowchart diagrams at compile time from fluent Result pipeline methods — visualize functional code flows as diagrams runtime overhead.How to use 1. Decorate a fluent Result method with [ResultFlow]:```charp [REslava.ResultFlow.ResultFlow] public static Result&lt;int&gt; GetValueFromConsole() { return Result&lt;string&gt;.Ok(value) .Ensure(s =&gt; !string.IsNullOrWhiteSpace(s), new Error(&quot;Input cannot be empty&quot;)) .Map(s =&gt; s.ToUpper()) .Tap(s =&gt; Console.WriteLine($&quot;Processed: {s}&quot;)) .Ensure(s =&gt; int.TryParse(s, out _), new Error(&quot;Input must be a valid integer&quot;)) .Map(s =&gt; int.Parse(s)); }``` 2. Access the generated Mermaid diagram as a compile-time const string:```charp Console.WriteLine(Generated.ResultFlow.Helpers_Flows.GetValueFromConsole); // outputs a Mermaid flowchart of the pipeline```You can use for Auto-generating up-to-date Mermaid pipeline diagrams from functional Result code at compile time — ideal for documentation, design reviews, or visualizing complex flows without manual diagram maintenance.
1616

1717
<h2>
1818
How to use

v2/book/examples/SvgIconGenerator.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h2>Info</h2>
1212

1313
<h2>About</h2>
1414

15-
Generating classes from SVG icons to be used in C# projects.
15+
Generates strongly-typed C# classes from SVG icon files at compile time — access SVG icons as typed properties with no runtime file I/O.How to use1. Add SVG files as AdditionalFiles in .csproj:```xml &lt;ItemGroup&gt; &lt;AdditionalFiles Include=&quot;Icons/*.svg&quot; /&gt; &lt;/ItemGroup&gt;``` 3. Declare a partial static class with [GenerateIcons]:```charp [GenerateIcons()] internal static partial class MyIcons;``` 3. Access icons as typed members (one per SVG file):```charp Console.WriteLine(MyIcons.Circle.Name); // &quot;Circle&quot; Console.WriteLine(MyIcons.Rect.InnerContent); // SVG inner XML``` You can use for Embedding SVG icons as compile-time constants with typed access — no file paths, no reflection, no runtime loading.
1616

1717
<h2>
1818
How to use

v2/book/examples/TaggedEnum.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h2>Info</h2>
1212

1313
<h2>About</h2>
1414

15-
Generate dictionary from enumAlso retrieved enum by value or name.And an extension method JSON serializer for enum.
15+
Generates dictionary-based lookup, fast string conversion, and name/value retrieval for enums with custom data tags — like tagged unions for enums.How to use1. Decorate with Tagged and attach Data to each member:```csharp[Tagged]public enum CarTypes{ [Data(&quot;this is none&quot;)] None, [Data(&quot;this is dacia&quot;)] Dacia, [Data(&quot;this is bmw&quot;)] BMW, [Data(&quot;this is mercedes&quot;)]Mercedes,}```2 Use generated extensions:```charpCarTypes.None.ToStringFast(); // &quot;None&quot;CarTypes.None.Data; // &quot;this is none&quot;EnumDemoCarTypesExtension.TryGetValueByName(&quot;None&quot;, out _); // true```You can use for Fast ToString() without reflection, attaching metadata to enum values via [Data], name-based lookup, and JSON serializer extensions for enums.
1616

1717
<h2>
1818
How to use

v2/book/examples/TypedPaths.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h2>Info</h2>
1212

1313
<h2>About</h2>
1414

15-
Generating strongly-typed paths for file system operations in C# projects.
15+
Turns a folder tree into strongly-typed path constants at compile time — access file/folder paths as typed properties instead of magic strings.How to use 1. Declare which folder to scan in .csproj:```xml &lt;ItemGroup&gt; &lt;PackageReference Include=&quot;TypedPaths.Generator&quot; Version=&quot;1.3.0&quot; /&gt; &lt;/ItemGroup&gt; &lt;ItemGroup&gt; &lt;TypedPathsFolder Include=&quot;a&quot; ClassName=&quot;Src&quot; /&gt; &lt;/ItemGroup&gt;``` 2. Access generated typed path constants:```charp Console.WriteLine(TypedPaths.Src.Andrei.Value); // strongly-typed path to the &quot;Andrei&quot; entry under folder &quot;a&quot; (e.g. &quot;a/Andrei&quot; or &quot;a\Andrei&quot; depending on OS) ```You can use for Eliminating magic path strings for file system operations — folder/file paths become compile-time constants with IntelliSense and refactoring safety.
1616

1717
<h2>
1818
How to use

0 commit comments

Comments
 (0)