Skip to content

Commit 4bcd397

Browse files
authored
Merge pull request #387 from ignatandrei/AssemblyVersionInfo
2 parents 6bff40a + 65fdea8 commit 4bcd397

27 files changed

Lines changed: 830 additions & 63 deletions

File tree

README.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# RSCG - 209 Examples of Roslyn Source Code Generators / 14 created by Microsoft /
1+
# RSCG - 210 Examples of Roslyn Source Code Generators / 14 created by Microsoft /
22

3-
## Latest Update : 2025-07-26 => 26 July 2025
3+
## Latest Update : 2025-07-28 => 28 July 2025
44

55
If you want to see examples with code, please click ***[List V2](https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG)***
66

@@ -20,11 +20,33 @@ If you want to be notified each time I add a new RSCG example , please click htt
2020

2121
## Content
2222

23-
Those are the 209 Roslyn Source Code Generators that I have tested you can see and download source code example.
23+
Those are the 210 Roslyn Source Code Generators that I have tested you can see and download source code example.
2424
( including 14 from Microsoft )
25-
### 209. [ShadowWriterProjectInfo](https://ignatandrei.github.io/RSCG_Examples/v2/docs/ShadowWriterProjectInfo) , in the [Builder](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#builder) category
25+
### 210. [AssemblyVersionInfo](https://ignatandrei.github.io/RSCG_Examples/v2/docs/AssemblyVersionInfo) , in the [EnhancementProject](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#enhancementproject) category
2626

27-
Generated on : 2025-07-24 => 24 July 2025
27+
Generated on : 2025-07-28 => 28 July 2025
28+
29+
<details>
30+
<summary>Expand</summary>
31+
32+
33+
34+
Author: Black White Yoshi
35+
36+
AssemblyVersionInfo is a very simple source generator that generates constant strings of your assembly name and version. The intended usage is for the System.CodeDom.Compiler.GeneratedCodeAttribute.
37+
38+
Nuget: [https://www.nuget.org/packages/AssemblyVersionInfo/](https://www.nuget.org/packages/AssemblyVersionInfo/)
39+
40+
41+
Link: [https://ignatandrei.github.io/RSCG_Examples/v2/docs/AssemblyVersionInfo](https://ignatandrei.github.io/RSCG_Examples/v2/docs/AssemblyVersionInfo)
42+
43+
Source: [https://github.com/BlackWhiteYoshi/AssemblyVersionInfo](https://github.com/BlackWhiteYoshi/AssemblyVersionInfo)
44+
45+
</details>
46+
47+
### 209. [ShadowWriterProjectInfo](https://ignatandrei.github.io/RSCG_Examples/v2/docs/ShadowWriterProjectInfo) , in the [EnhancementProject](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#enhancementproject) category
48+
49+
Generated on : 2025-07-27 => 27 July 2025
2850

2951
<details>
3052
<summary>Expand</summary>

later.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Just later
22

3-
## Latest Update : 2025-07-26 => 26 July 2025
3+
## Latest Update : 2025-07-28 => 28 July 2025
44

55

66

v2/Generator/all.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,5 @@ Nr,Key,Source,Category
207207
206,ShadowWriterBuilder, https://github.com/StefanStolz/ShadowWriter,Builder
208208
207,AutoInterface, https://github.com/BlackWhiteYoshi/AutoInterface,Interface
209209
208,AsyncIt, https://github.com/oleg-shilo/AsyncIt,Async
210-
209,ShadowWriterProjectInfo, https://github.com/StefanStolz/ShadowWriter,Builder
210+
209,ShadowWriterProjectInfo, https://github.com/StefanStolz/ShadowWriter,EnhancementProject
211+
210,AssemblyVersionInfo, https://github.com/BlackWhiteYoshi/AssemblyVersionInfo,EnhancementProject

v2/RSCGExamplesData/GeneratorDataRec.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,8 +1259,14 @@
12591259
},
12601260
{
12611261
"ID":"ShadowWriterProjectInfo",
1262-
"Category": 4,
1263-
"dtStart": "2025-07-24T00:00:00",
1262+
"Category": 1,
1263+
"dtStart": "2025-07-27T00:00:00",
1264+
"show": true
1265+
},
1266+
{
1267+
"ID":"AssemblyVersionInfo",
1268+
"Category": 1,
1269+
"dtStart": "2025-07-28T00:00:00",
12641270
"show": true
12651271
}
12661272
]
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
2+
<h1>RSCG nr 210 : AssemblyVersionInfo</h1>
3+
4+
<h2>Info</h2>
5+
Nuget : <a href="https://www.nuget.org/packages/AssemblyVersionInfo/" target="_blank">https://www.nuget.org/packages/AssemblyVersionInfo/</a>
6+
7+
<p>You can find more details at : <a href="https://github.com/BlackWhiteYoshi/AssemblyVersionInfo" target="_blank"> https://github.com/BlackWhiteYoshi/AssemblyVersionInfo</a></p>
8+
9+
<p>Author :Black White Yoshi</p>
10+
11+
<p>Source: <a href="https://github.com/BlackWhiteYoshi/AssemblyVersionInfo" target="_blank">https://github.com/BlackWhiteYoshi/AssemblyVersionInfo</a> </p>
12+
13+
<h2>About</h2>
14+
15+
Generating assembly version and other info from csproj to csharp
16+
17+
<h2>
18+
How to use
19+
</h2>
20+
<h3>
21+
Add reference to the <a href="https://www.nuget.org/packages/AssemblyVersionInfo/" target="_blank">AssemblyVersionInfo</a> in the csproj
22+
</h3>
23+
<img src="images/AssemblyVersionInfo/DemoAttr.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/AssemblyVersionInfo/csFiles/Program.cs.png" width="580" height="580" />
31+
<hr />
32+
<h3>And here are the <i>generated</i> files</h3>
33+
34+
<br />
35+
The file <i>generated</i> is Assembly.g.cs
36+
<br />
37+
<img src="images/AssemblyVersionInfo/generated/Assembly.g.cs.png" width="580" height="580" />
38+
39+
<br />
40+
The file <i>generated</i> is BuilderAttribute.g.cs
41+
<br />
42+
<img src="images/AssemblyVersionInfo/generated/BuilderAttribute.g.cs.png" width="580" height="580" />
43+
44+
<br />
45+
The file <i>generated</i> is NullObjectAttribute.g.cs
46+
<br />
47+
<img src="images/AssemblyVersionInfo/generated/NullObjectAttribute.g.cs.png" width="580" height="580" />
48+
49+
<br />
50+
The file <i>generated</i> is ShadowWriter.TheProject.g.cs
51+
<br />
52+
<img src="images/AssemblyVersionInfo/generated/ShadowWriter.TheProject.g.cs.png" width="580" height="580" />
53+
54+
<p>
55+
You can download the code and this page as pdf from
56+
<a target="_blank" href='https://ignatandrei.github.io/RSCG_Examples/v2/docs/AssemblyVersionInfo'>
57+
https://ignatandrei.github.io/RSCG_Examples/v2/docs/AssemblyVersionInfo
58+
</a>
59+
</p>
60+
61+
62+
<p>
63+
You can see the whole list at
64+
<a target="_blank" href='https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG'>
65+
https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG
66+
</a>
67+
</p>
68+

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

2323
<table >
@@ -862,6 +862,10 @@ <h1>
862862
<td>209</td>
863863
<td><a href="examples/ShadowWriterProjectInfo.html">ShadowWriterProjectInfo</a></td>
864864
</tr>
865+
<tr>
866+
<td>210</td>
867+
<td><a href="examples/AssemblyVersionInfo.html">AssemblyVersionInfo</a></td>
868+
</tr>
865869
</table>
866870

867871

v2/book/pandocHTML.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ input-files:
223223
- examples/AutoInterface.html
224224
- examples/AsyncIt.html
225225
- examples/ShadowWriterProjectInfo.html
226+
- examples/AssemblyVersionInfo.html
226227

227228
# or you may use input-file: with a single value
228229
# defaults:
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"generator":{
3+
"name":"AssemblyVersionInfo",
4+
"nuget":[
5+
"https://www.nuget.org/packages/AssemblyVersionInfo/"
6+
],
7+
"link":"https://github.com/BlackWhiteYoshi/AssemblyVersionInfo",
8+
"author":"Black White Yoshi",
9+
"source":"https://github.com/BlackWhiteYoshi/AssemblyVersionInfo"
10+
},
11+
"data":{
12+
"goodFor":["Generating assembly version and other info from csproj to csharp"],
13+
"csprojDemo":"DemoAttr.csproj",
14+
"csFiles":["Program.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+
AssemblyVersionInfo is a very simple source generator that generates constant strings of your assembly name and version. The intended usage is for the System.CodeDom.Compiler.GeneratedCodeAttribute.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# AssemblyVersionInfo
2+
3+
AssemblyVersionInfo is a very simple source generator that generates constant strings of your assembly name and version.
4+
The intended usage is for the [GeneratedCodeAttribute](https://learn.microsoft.com/en-us//dotnet/api/system.codedom.compiler.generatedcodeattribute).
5+
6+
All it does is generating a the static class *Assembly* in the namespace *AssemblyVersionInfo*:
7+
8+
```csharp
9+
// <auto-generated/>
10+
11+
namespace AssemblyVersionInfo;
12+
13+
internal static class Assembly {
14+
public const string NAME = "{{compilation.name}}";
15+
16+
public const string VERSION_MAJOR = "{{compilation.version.Major}}";
17+
public const string VERSION_MINOR = "{{compilation.version.Minor}}";
18+
public const string VERSION_BUILD = "{{compilation.version.Build}}";
19+
public const string VERSION_REVISION = "{{compilation.version.Revision}}";
20+
21+
public const string VERSION = "{{compilation.version}}";
22+
public const string VERSION_MAJOR_MINOR = "{{compilation.version.Major}}.{{compilation.version.Minor}}";
23+
public const string VERSION_MAJOR_MINOR_BUILD = "{{compilation.version.Major}}.{{compilation.version.Minor}}.{{compilation.version.Build}}";
24+
}
25+
```
26+
27+
28+
<br></br>
29+
## Get Started
30+
31+
1. Add PackageReference to your .csproj file.
32+
33+
```xml
34+
<ItemGroup>
35+
<PackageReference Include="AssemblyVersionInfo" Version="{latest version}" PrivateAssets="all" />
36+
</ItemGroup>
37+
```
38+
39+
2. Access the strings in the *Assembly* class.
40+
41+
```csharp
42+
using AssemblyVersionInfo;
43+
44+
const string example = $"AssemblyName={Assembly.NAME}, AssemblyVersion={Assembly.VERSION}";
45+
Console.WriteLine(example);
46+
```

0 commit comments

Comments
 (0)