Skip to content

Commit 0783aed

Browse files
committed
sec
1 parent 2f54649 commit 0783aed

8 files changed

Lines changed: 106 additions & 32 deletions

File tree

v2/.tours/SvgIconGenerator.tour

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,38 @@
55
"steps":
66
[
77
{
8-
"file": "rscg_examples/SvgIconGenerator/src/DemoSvg/DemoSvg/DemoSvg.csproj",
8+
"file": "rscg_examples/SvgIconGenerator/src/DemoSvg/DemoSvg.csproj",
99
"description": "First, we add Nuget [SvgIconGenerator](https://www.nuget.org/packages/SvgIconGenerator/) in csproj ",
1010
"pattern": "SvgIconGenerator"
1111
}
1212

1313
,{
14-
"file": "rscg_examples/SvgIconGenerator/src/DemoSvg/DemoSvg/Icons.cs",
14+
"file": "rscg_examples/SvgIconGenerator/src/DemoSvg/Icons.cs",
1515
"description": "File Icons.cs ",
1616
"pattern": "this is the code"
1717
}
1818

1919
,{
20-
"file": "rscg_examples/SvgIconGenerator/src/DemoSvg/DemoSvg/Program.cs",
21-
"description": "File Program.cs \r\n>> dotnet run --project rscg_examples/SvgIconGenerator/src/DemoSvg/DemoSvg/DemoSvg.csproj ",
20+
"file": "rscg_examples/SvgIconGenerator/src/DemoSvg/Program.cs",
21+
"description": "File Program.cs \r\n>> dotnet run --project rscg_examples/SvgIconGenerator/src/DemoSvg/DemoSvg.csproj ",
2222
"pattern": "this is the code"
2323
}
2424

2525

2626
,{
27-
"file": "rscg_examples/SvgIconGenerator/src/DemoSvg/DemoSvg/obj/GX/SvgIconGenerator/SvgIconGenerator.IconGenerator/MyIcons.g.cs",
27+
"file": "rscg_examples/SvgIconGenerator/src/DemoSvg/obj/GX/SvgIconGenerator/SvgIconGenerator.IconGenerator/MyIcons.g.cs",
2828
"description": "Generated File 3 from 3 : MyIcons.g.cs ",
2929
"line": 1
3030
}
3131

3232
,{
33-
"file": "rscg_examples/SvgIconGenerator/src/DemoSvg/DemoSvg/obj/GX/SvgIconGenerator/SvgIconGenerator.IconGenerator/IconDto.g.cs",
33+
"file": "rscg_examples/SvgIconGenerator/src/DemoSvg/obj/GX/SvgIconGenerator/SvgIconGenerator.IconGenerator/IconDto.g.cs",
3434
"description": "Generated File 2 from 3 : IconDto.g.cs ",
3535
"line": 1
3636
}
3737

3838
,{
39-
"file": "rscg_examples/SvgIconGenerator/src/DemoSvg/DemoSvg/obj/GX/SvgIconGenerator/SvgIconGenerator.IconGenerator/GenerateIconsAttribute.g.cs",
39+
"file": "rscg_examples/SvgIconGenerator/src/DemoSvg/obj/GX/SvgIconGenerator/SvgIconGenerator.IconGenerator/GenerateIconsAttribute.g.cs",
4040
"description": "Generated File 1 from 3 : GenerateIconsAttribute.g.cs ",
4141
"line": 1
4242
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
<h1>RSCG nr 262 : SvgIconGenerator</h1>
3+
4+
<h2>Info</h2>
5+
Nuget : <a href="https://www.nuget.org/packages/SvgIconGenerator/" target="_blank">https://www.nuget.org/packages/SvgIconGenerator/</a>
6+
7+
<p>You can find more details at : <a href="https://github.com/helluvamatt/SvgIconGenerator" target="_blank"> https://github.com/helluvamatt/SvgIconGenerator</a></p>
8+
9+
<p>Author :Matt Schneeberger</p>
10+
11+
<p>Source: <a href="https://github.com/helluvamatt/SvgIconGenerator" target="_blank">https://github.com/helluvamatt/SvgIconGenerator</a> </p>
12+
13+
<h2>About</h2>
14+
15+
Generating classes from SVG icons to be used in C# projects.
16+
17+
<h2>
18+
How to use
19+
</h2>
20+
<h3>
21+
Add reference to the <a href="https://www.nuget.org/packages/SvgIconGenerator/" target="_blank">SvgIconGenerator</a> in the csproj
22+
</h3>
23+
<img src="images/SvgIconGenerator/DemoSvg.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/SvgIconGenerator/csFiles/Program.cs.png" width="580" height="580" />
31+
<hr />
32+
33+
<br />
34+
I have <b>coded</b> the file Icons.cs
35+
<br />
36+
<img src="images/SvgIconGenerator/csFiles/Icons.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 GenerateIconsAttribute.g.cs
42+
<br />
43+
<img src="images/SvgIconGenerator/generated/GenerateIconsAttribute.g.cs.png" width="580" height="580" />
44+
45+
<br />
46+
The file <i>generated</i> is IconDto.g.cs
47+
<br />
48+
<img src="images/SvgIconGenerator/generated/IconDto.g.cs.png" width="580" height="580" />
49+
50+
<br />
51+
The file <i>generated</i> is MyIcons.g.cs
52+
<br />
53+
<img src="images/SvgIconGenerator/generated/MyIcons.g.cs.png" width="580" height="580" />
54+
55+
<p>
56+
You can download the code and this page as pdf from
57+
<a target="_blank" href='https://ignatandrei.github.io/RSCG_Examples/v2/docs/SvgIconGenerator'>
58+
https://ignatandrei.github.io/RSCG_Examples/v2/docs/SvgIconGenerator
59+
</a>
60+
</p>
61+
62+
63+
<p>
64+
You can see the whole list at
65+
<a target="_blank" href='https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG'>
66+
https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG
67+
</a>
68+
</p>
69+

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

2323
<table >
@@ -1070,6 +1070,10 @@ <h1>
10701070
<td>261</td>
10711071
<td><a href="examples/NLog.Extensions.ThisClass.html">NLog.Extensions.ThisClass</a></td>
10721072
</tr>
1073+
<tr>
1074+
<td>262</td>
1075+
<td><a href="examples/SvgIconGenerator.html">SvgIconGenerator</a></td>
1076+
</tr>
10731077
</table>
10741078

10751079

v2/book/pandocHTML.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ input-files:
275275
- examples/TypedPaths.html
276276
- examples/AssemblyMetadata.html
277277
- examples/NLog.Extensions.ThisClass.html
278+
- examples/SvgIconGenerator.html
278279

279280
# or you may use input-file: with a single value
280281
# defaults:

v2/rscg_examples/SvgIconGenerator/video.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
{"typeStep":"text","arg": "To use it ,you will put the Nuget SvgIconGenerator into the csproj "},
2323

24-
{"typeStep":"stepvscode","arg": "-r -g D:\\gth\\RSCG_Examples\\v2\\rscg_examples\\SvgIconGenerator\\src\\DemoSvg\\DemoSvg\\DemoSvg.csproj"},
24+
{"typeStep":"stepvscode","arg": "-r -g D:\\gth\\RSCG_Examples\\v2\\rscg_examples\\SvgIconGenerator\\src\\DemoSvg\\DemoSvg.csproj"},
2525

2626
{"typeStep":"text","arg": "And now I will show you an example of using SvgIconGenerator"},
2727

v2/rscg_examples_site/docs/RSCG-Examples/SvgIconGenerator.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,21 @@ Matt Schneeberger
4949
## Original Readme
5050
:::note
5151

52-
# SVG Icon Generator
52+
### SVG Icon Generator
5353

5454
A C# source generator that automatically creates strongly-typed icon properties from SVG files.
5555

56-
## Installation
56+
###### Installation
5757

5858
Install the NuGet package in your project:
5959

6060
```bash
6161
dotnet add package SvgIconGenerator
6262
```
6363

64-
## Usage
64+
###### Usage
6565

66-
### 1. Organize Your SVG Files
66+
######### 1. Organize Your SVG Files
6767

6868
Place your SVG icon files in a folder within your project (e.g., `Icons/`):
6969

@@ -76,7 +76,7 @@ YourProject/
7676
└── Program.cs
7777
```
7878

79-
### 2. Add SVG Files as AdditionalFiles
79+
######### 2. Add SVG Files as AdditionalFiles
8080

8181
In your `.csproj` file, add the SVG files as `AdditionalFiles`:
8282

@@ -88,7 +88,7 @@ In your `.csproj` file, add the SVG files as `AdditionalFiles`:
8888

8989
**Important**: Adding files as `AdditionalFiles` ensures that changes to SVG files trigger regeneration during incremental compilation.
9090

91-
### 3. Create an Icon Class
91+
######### 3. Create an Icon Class
9292

9393
Create a `static partial` class and decorate it with the `[GenerateIcons]` attribute:
9494

@@ -109,7 +109,7 @@ internal static partial class AllIcons;
109109
internal static partial class MyIcons;
110110
```
111111

112-
### 4. Access Generated Icons
112+
######### 4. Access Generated Icons
113113

114114
The source generator will create properties for each SVG file. Property names are automatically converted from kebab-case to PascalCase:
115115

@@ -122,7 +122,7 @@ Console.WriteLine($"ViewBox: {icon.DefaultAttributes["viewBox"]}");
122122
Console.WriteLine($"SVG content: {icon.InnerContent}");
123123
```
124124

125-
### 5. Render Icons
125+
######### 5. Render Icons
126126

127127
The `IconDto` contains everything needed to render the icon:
128128

@@ -155,11 +155,11 @@ string svg = RenderIcon(MyIcons.UserCircle, new Dictionary<string, string>
155155
});
156156
```
157157

158-
## Using with Popular Icon Libraries
158+
###### Using with Popular Icon Libraries
159159

160160
You can use this generator with popular icon libraries installed via NPM, such as Bootstrap Icons, Lucide, Heroicons, or Feather Icons.
161161

162-
### Example: Lucide Icons
162+
######### Example: Lucide Icons
163163

164164
1. Install Lucide icons via NPM:
165165

@@ -190,7 +190,7 @@ IconDto icon2 = LucideIcons.ShoppingCart;
190190
IconDto icon3 = LucideIcons.AlertTriangle;
191191
```
192192

193-
### Example: Bootstrap Icons
193+
######### Example: Bootstrap Icons
194194

195195
```bash
196196
npm install bootstrap-icons
@@ -207,7 +207,7 @@ npm install bootstrap-icons
207207
internal static partial class BootstrapIcons;
208208
```
209209

210-
### Example: Heroicons
210+
######### Example: Heroicons
211211

212212
```bash
213213
npm install heroicons
@@ -230,7 +230,7 @@ internal static partial class HeroiconsOutline;
230230
internal static partial class HeroiconsSolid;
231231
```
232232

233-
### Multiple Icon Sets
233+
######### Multiple Icon Sets
234234

235235
You can create multiple icon classes in the same project to organize different icon sets:
236236

@@ -253,7 +253,7 @@ internal static partial class CustomIcons;
253253
internal static partial class LogoIcons;
254254
```
255255

256-
## How It Works
256+
###### How It Works
257257

258258
1. The source generator reads SVG files from `AdditionalFiles` in your project
259259
2. Files are optionally filtered by glob pattern (if specified in the attribute)
@@ -264,15 +264,15 @@ internal static partial class LogoIcons;
264264
4. Generates a partial class with `IconDto` properties for each icon
265265
5. **Incremental compilation**: Changes to SVG files automatically trigger regeneration
266266

267-
## IconDto Structure
267+
###### IconDto Structure
268268

269269
The generated `IconDto` record contains:
270270

271271
- **Name** (`string`): The original kebab-case filename without extension
272272
- **DefaultAttributes** (`IReadOnlyDictionary<string, string>`): SVG root attributes like `viewBox`, `fill`, `stroke`, etc.
273273
- **InnerContent** (`string`): The inner HTML content (paths, circles, etc.)
274274

275-
## Example SVG Input
275+
###### Example SVG Input
276276

277277
Given an SVG file `Icons/user-circle.svg`:
278278

@@ -303,12 +303,12 @@ public static readonly IconDto UserCircle = new IconDto(
303303
"<circle cx=\"12\" cy=\"12\" r=\"10\"/><circle cx=\"12\" cy=\"10\" r=\"3\"/><path d=\"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662\"/>");
304304
```
305305

306-
## Requirements
306+
###### Requirements
307307

308308
- .NET Standard 2.0 or higher
309309
- C# 9.0 or higher (for record types)
310310

311-
## License
311+
###### License
312312

313313
See the repository for license information.
314314

@@ -360,7 +360,7 @@ This is the CSharp Project that references **SvgIconGenerator**
360360

361361
</TabItem>
362362

363-
<TabItem value="D:\gth\RSCG_Examples\v2\rscg_examples\SvgIconGenerator\src\DemoSvg\DemoSvg\Program.cs" label="Program.cs" >
363+
<TabItem value="D:\gth\RSCG_Examples\v2\rscg_examples\SvgIconGenerator\src\DemoSvg\Program.cs" label="Program.cs" >
364364

365365
This is the use of **SvgIconGenerator** in *Program.cs*
366366

@@ -374,7 +374,7 @@ Console.WriteLine(MyIcons.Rect.InnerContent);
374374
```
375375
</TabItem>
376376

377-
<TabItem value="D:\gth\RSCG_Examples\v2\rscg_examples\SvgIconGenerator\src\DemoSvg\DemoSvg\Icons.cs" label="Icons.cs" >
377+
<TabItem value="D:\gth\RSCG_Examples\v2\rscg_examples\SvgIconGenerator\src\DemoSvg\Icons.cs" label="Icons.cs" >
378378

379379
This is the use of **SvgIconGenerator** in *Icons.cs*
380380

@@ -400,7 +400,7 @@ Those are taken from $(BaseIntermediateOutputPath)\GX
400400
<Tabs>
401401

402402

403-
<TabItem value="D:\gth\RSCG_Examples\v2\rscg_examples\SvgIconGenerator\src\DemoSvg\DemoSvg\obj\GX\SvgIconGenerator\SvgIconGenerator.IconGenerator\GenerateIconsAttribute.g.cs" label="GenerateIconsAttribute.g.cs" >
403+
<TabItem value="D:\gth\RSCG_Examples\v2\rscg_examples\SvgIconGenerator\src\DemoSvg\obj\GX\SvgIconGenerator\SvgIconGenerator.IconGenerator\GenerateIconsAttribute.g.cs" label="GenerateIconsAttribute.g.cs" >
404404
```csharp showLineNumbers
405405
namespace SvgIconGenerator
406406
{
@@ -446,7 +446,7 @@ namespace SvgIconGenerator
446446
</TabItem>
447447

448448

449-
<TabItem value="D:\gth\RSCG_Examples\v2\rscg_examples\SvgIconGenerator\src\DemoSvg\DemoSvg\obj\GX\SvgIconGenerator\SvgIconGenerator.IconGenerator\IconDto.g.cs" label="IconDto.g.cs" >
449+
<TabItem value="D:\gth\RSCG_Examples\v2\rscg_examples\SvgIconGenerator\src\DemoSvg\obj\GX\SvgIconGenerator\SvgIconGenerator.IconGenerator\IconDto.g.cs" label="IconDto.g.cs" >
450450
```csharp showLineNumbers
451451
namespace SvgIconGenerator
452452
{
@@ -464,7 +464,7 @@ namespace SvgIconGenerator
464464
</TabItem>
465465

466466

467-
<TabItem value="D:\gth\RSCG_Examples\v2\rscg_examples\SvgIconGenerator\src\DemoSvg\DemoSvg\obj\GX\SvgIconGenerator\SvgIconGenerator.IconGenerator\MyIcons.g.cs" label="MyIcons.g.cs" >
467+
<TabItem value="D:\gth\RSCG_Examples\v2\rscg_examples\SvgIconGenerator\src\DemoSvg\obj\GX\SvgIconGenerator\SvgIconGenerator.IconGenerator\MyIcons.g.cs" label="MyIcons.g.cs" >
468468
```csharp showLineNumbers
469469
//------------------------------------------------------------------------------
470470
// <auto-generated>
-1 Bytes
Binary file not shown.
1.47 KB
Binary file not shown.

0 commit comments

Comments
 (0)