Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# RSCG - 209 Examples of Roslyn Source Code Generators / 14 created by Microsoft /
# RSCG - 210 Examples of Roslyn Source Code Generators / 14 created by Microsoft /

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

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

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

## Content

Those are the 209 Roslyn Source Code Generators that I have tested you can see and download source code example.
Those are the 210 Roslyn Source Code Generators that I have tested you can see and download source code example.
( including 14 from Microsoft )
### 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
### 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

Generated on : 2025-07-24 => 24 July 2025
Generated on : 2025-07-28 => 28 July 2025

<details>
<summary>Expand</summary>



Author: Black White Yoshi

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.

Nuget: [https://www.nuget.org/packages/AssemblyVersionInfo/](https://www.nuget.org/packages/AssemblyVersionInfo/)


Link: [https://ignatandrei.github.io/RSCG_Examples/v2/docs/AssemblyVersionInfo](https://ignatandrei.github.io/RSCG_Examples/v2/docs/AssemblyVersionInfo)

Source: [https://github.com/BlackWhiteYoshi/AssemblyVersionInfo](https://github.com/BlackWhiteYoshi/AssemblyVersionInfo)

</details>

### 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

Generated on : 2025-07-27 => 27 July 2025

<details>
<summary>Expand</summary>
Expand Down
2 changes: 1 addition & 1 deletion later.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Just later

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



Expand Down
3 changes: 2 additions & 1 deletion v2/Generator/all.csv
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,5 @@ Nr,Key,Source,Category
206,ShadowWriterBuilder, https://github.com/StefanStolz/ShadowWriter,Builder
207,AutoInterface, https://github.com/BlackWhiteYoshi/AutoInterface,Interface
208,AsyncIt, https://github.com/oleg-shilo/AsyncIt,Async
209,ShadowWriterProjectInfo, https://github.com/StefanStolz/ShadowWriter,Builder
209,ShadowWriterProjectInfo, https://github.com/StefanStolz/ShadowWriter,EnhancementProject
210,AssemblyVersionInfo, https://github.com/BlackWhiteYoshi/AssemblyVersionInfo,EnhancementProject
10 changes: 8 additions & 2 deletions v2/RSCGExamplesData/GeneratorDataRec.json
Original file line number Diff line number Diff line change
Expand Up @@ -1259,8 +1259,14 @@
},
{
"ID":"ShadowWriterProjectInfo",
"Category": 4,
"dtStart": "2025-07-24T00:00:00",
"Category": 1,
"dtStart": "2025-07-27T00:00:00",
"show": true
},
{
"ID":"AssemblyVersionInfo",
"Category": 1,
"dtStart": "2025-07-28T00:00:00",
"show": true
}
]
68 changes: 68 additions & 0 deletions v2/book/examples/AssemblyVersionInfo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

<h1>RSCG nr 210 : AssemblyVersionInfo</h1>

<h2>Info</h2>
Nuget : <a href="https://www.nuget.org/packages/AssemblyVersionInfo/" target="_blank">https://www.nuget.org/packages/AssemblyVersionInfo/</a>

<p>You can find more details at : <a href="https://github.com/BlackWhiteYoshi/AssemblyVersionInfo" target="_blank"> https://github.com/BlackWhiteYoshi/AssemblyVersionInfo</a></p>

<p>Author :Black White Yoshi</p>

<p>Source: <a href="https://github.com/BlackWhiteYoshi/AssemblyVersionInfo" target="_blank">https://github.com/BlackWhiteYoshi/AssemblyVersionInfo</a> </p>

<h2>About</h2>

Generating assembly version and other info from csproj to csharp

<h2>
How to use
</h2>
<h3>
Add reference to the <a href="https://www.nuget.org/packages/AssemblyVersionInfo/" target="_blank">AssemblyVersionInfo</a> in the csproj
</h3>
<img src="images/AssemblyVersionInfo/DemoAttr.csproj.png" width="580" height="580" />

<h3>This was for me the <b>starting</b> code</h3>

<br />
I have <b>coded</b> the file Program.cs
<br />
<img src="images/AssemblyVersionInfo/csFiles/Program.cs.png" width="580" height="580" />
<hr />
<h3>And here are the <i>generated</i> files</h3>

<br />
The file <i>generated</i> is Assembly.g.cs
<br />
<img src="images/AssemblyVersionInfo/generated/Assembly.g.cs.png" width="580" height="580" />

<br />
The file <i>generated</i> is BuilderAttribute.g.cs
<br />
<img src="images/AssemblyVersionInfo/generated/BuilderAttribute.g.cs.png" width="580" height="580" />

<br />
The file <i>generated</i> is NullObjectAttribute.g.cs
<br />
<img src="images/AssemblyVersionInfo/generated/NullObjectAttribute.g.cs.png" width="580" height="580" />

<br />
The file <i>generated</i> is ShadowWriter.TheProject.g.cs
<br />
<img src="images/AssemblyVersionInfo/generated/ShadowWriter.TheProject.g.cs.png" width="580" height="580" />

<p>
You can download the code and this page as pdf from
<a target="_blank" href='https://ignatandrei.github.io/RSCG_Examples/v2/docs/AssemblyVersionInfo'>
https://ignatandrei.github.io/RSCG_Examples/v2/docs/AssemblyVersionInfo
</a>
</p>


<p>
You can see the whole list at
<a target="_blank" href='https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG'>
https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG
</a>
</p>

6 changes: 5 additions & 1 deletion v2/book/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</head>
<body>
<h1>
This is the list of 209 RSCG with examples =>
This is the list of 210 RSCG with examples =>
</h1>

<table >
Expand Down Expand Up @@ -862,6 +862,10 @@ <h1>
<td>209</td>
<td><a href="examples/ShadowWriterProjectInfo.html">ShadowWriterProjectInfo</a></td>
</tr>
<tr>
<td>210</td>
<td><a href="examples/AssemblyVersionInfo.html">AssemblyVersionInfo</a></td>
</tr>
</table>


Expand Down
1 change: 1 addition & 0 deletions v2/book/pandocHTML.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ input-files:
- examples/AutoInterface.html
- examples/AsyncIt.html
- examples/ShadowWriterProjectInfo.html
- examples/AssemblyVersionInfo.html

# or you may use input-file: with a single value
# defaults:
Expand Down
22 changes: 22 additions & 0 deletions v2/rscg_examples/AssemblyVersionInfo/description.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"generator":{
"name":"AssemblyVersionInfo",
"nuget":[
"https://www.nuget.org/packages/AssemblyVersionInfo/"
],
"link":"https://github.com/BlackWhiteYoshi/AssemblyVersionInfo",
"author":"Black White Yoshi",
"source":"https://github.com/BlackWhiteYoshi/AssemblyVersionInfo"
},
"data":{
"goodFor":["Generating assembly version and other info from csproj to csharp"],
"csprojDemo":"DemoAttr.csproj",
"csFiles":["Program.cs"],
"excludeDirectoryGenerated":[""],
"includeAdditionalFiles":[""]
},
"links":{
"blog":"",
"video":""
}
}
1 change: 1 addition & 0 deletions v2/rscg_examples/AssemblyVersionInfo/nuget.txt
Original file line number Diff line number Diff line change
@@ -0,0 +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.
46 changes: 46 additions & 0 deletions v2/rscg_examples/AssemblyVersionInfo/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# AssemblyVersionInfo

AssemblyVersionInfo is a very simple source generator that generates constant strings of your assembly name and version.
The intended usage is for the [GeneratedCodeAttribute](https://learn.microsoft.com/en-us//dotnet/api/system.codedom.compiler.generatedcodeattribute).

All it does is generating a the static class *Assembly* in the namespace *AssemblyVersionInfo*:

```csharp
// <auto-generated/>

namespace AssemblyVersionInfo;

internal static class Assembly {
public const string NAME = "{{compilation.name}}";

public const string VERSION_MAJOR = "{{compilation.version.Major}}";
public const string VERSION_MINOR = "{{compilation.version.Minor}}";
public const string VERSION_BUILD = "{{compilation.version.Build}}";
public const string VERSION_REVISION = "{{compilation.version.Revision}}";

public const string VERSION = "{{compilation.version}}";
public const string VERSION_MAJOR_MINOR = "{{compilation.version.Major}}.{{compilation.version.Minor}}";
public const string VERSION_MAJOR_MINOR_BUILD = "{{compilation.version.Major}}.{{compilation.version.Minor}}.{{compilation.version.Build}}";
}
```


<br></br>
## Get Started

1. Add PackageReference to your .csproj file.

```xml
<ItemGroup>
<PackageReference Include="AssemblyVersionInfo" Version="{latest version}" PrivateAssets="all" />
</ItemGroup>
```

2. Access the strings in the *Assembly* class.

```csharp
using AssemblyVersionInfo;

const string example = $"AssemblyName={Assembly.NAME}, AssemblyVersion={Assembly.VERSION}";
Console.WriteLine(example);
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

{
"$schema": "https://aka.ms/codetour-schema",
"title": "AssemblyVersionInfo",
"steps":
[
{
"file": "DemoAttr/DemoAttr.csproj",
"description": "First, we add Nuget [AssemblyVersionInfo](https://www.nuget.org/packages/AssemblyVersionInfo/) in csproj ",
"pattern": "AssemblyVersionInfo"
}

,{
"file": "DemoAttr/Program.cs",
"description": "File Program.cs \r\n>> dotnet run --project DemoAttr/DemoAttr.csproj ",
"pattern": "this is the code"
}


,{
"file": "DemoAttr/obj/GX/ShadowWriter/ShadowWriter.ProjectInfoGenerator/ShadowWriter.TheProject.g.cs",
"description": "Generated File 4 from 4 : ShadowWriter.TheProject.g.cs ",
"line": 1
}

,{
"file": "DemoAttr/obj/GX/ShadowWriter/ShadowWriter.NullObjectGenerator/NullObjectAttribute.g.cs",
"description": "Generated File 3 from 4 : NullObjectAttribute.g.cs ",
"line": 1
}

,{
"file": "DemoAttr/obj/GX/ShadowWriter/ShadowWriter.BuilderGenerator/BuilderAttribute.g.cs",
"description": "Generated File 2 from 4 : BuilderAttribute.g.cs ",
"line": 1
}

,{
"file": "DemoAttr/obj/GX/AssemblyVersionInfo/AssemblyVersionInfo.Generator/Assembly.g.cs",
"description": "Generated File 1 from 4 : Assembly.g.cs ",
"line": 1
}

],

"ref": "main"

}
25 changes: 25 additions & 0 deletions v2/rscg_examples/AssemblyVersionInfo/src/DemoAttr.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36408.4 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DemoAttr", "DemoAttr\DemoAttr.csproj", "{E7AE387F-3B33-41EF-A809-94E5C21EDBFC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E7AE387F-3B33-41EF-A809-94E5C21EDBFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E7AE387F-3B33-41EF-A809-94E5C21EDBFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E7AE387F-3B33-41EF-A809-94E5C21EDBFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E7AE387F-3B33-41EF-A809-94E5C21EDBFC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {75065D34-E2FE-414E-BE26-D871D5945284}
EndGlobalSection
EndGlobal
23 changes: 23 additions & 0 deletions v2/rscg_examples/AssemblyVersionInfo/src/DemoAttr/DemoAttr.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>


<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
</PropertyGroup>


<ItemGroup>
<PackageReference Include="AssemblyVersionInfo" Version="1.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
4 changes: 4 additions & 0 deletions v2/rscg_examples/AssemblyVersionInfo/src/DemoAttr/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Access project information anywhere in your code
Console.WriteLine($"Project Name: {AssemblyVersionInfo.Assembly.NAME}");
Console.WriteLine($"Project Version: {AssemblyVersionInfo.Assembly.VERSION}");
;
39 changes: 39 additions & 0 deletions v2/rscg_examples/AssemblyVersionInfo/video.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"scriptName": "AssemblyVersionInfo",
"steps":
[
{"typeStep":"exec","arg":"clipchamp.exe launch"},
{"typeStep":"text","arg": "Welcome to Roslyn Examples"},
{"typeStep":"text","arg":"If you want to see more examples , see List Of RSCG"},
{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG"},
{"typeStep":"text","arg": "My name is Andrei Ignat and I am deeply fond of Roslyn Source Code Generator. "},

{"typeStep":"text","arg": "Today I will present AssemblyVersionInfo . Generating assembly version and other info from csproj to csharp ."},
{"typeStep":"browser","arg":"https://www.nuget.org/packages/AssemblyVersionInfo/"},
{"typeStep":"text","arg": "The whole example is here"},
{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/AssemblyVersionInfo"},
{"typeStep":"text","arg": "You can download the code from here"},
{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/AssemblyVersionInfo#download-example-net--c-"},
{"typeStep":"text","arg":"Here is the code downloaded "},
{"typeStep":"exec","arg":"explorer.exe /select,D:\\gth\\RSCG_Examples\\v2\\rscg_examples\\AssemblyVersionInfo\\src\\DemoAttr.sln"},
{"typeStep":"text","arg": "So , let's start the project with Visual Studio Code "},
{"typeStep":"stepvscode","arg": "-n D:\\gth\\RSCG_Examples\\v2\\rscg_examples\\AssemblyVersionInfo\\src"},

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

{"typeStep":"stepvscode","arg": "-r -g D:\\gth\\RSCG_Examples\\v2\\rscg_examples\\AssemblyVersionInfo\\src\\DemoAttr\\DemoAttr.csproj"},

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

{"typeStep":"hide","arg": "now execute the tour in VSCode"},
{"typeStep":"tour", "arg": "src/.tours/"},
{"typeStep":"text","arg":" And I will execute the project"},
{"typeStep":"showproj", "arg":"DemoAttr.csproj"},
{"typeStep":"text","arg":" This concludes the project"},
{"typeStep":"waitseconds","arg":"30"},
{"typeStep":"text","arg": "Remember, you can download the code from here"},
{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/AssemblyVersionInfo#download-example-net--c-",
SpeakTest=" "},
Comment thread
ignatandrei marked this conversation as resolved.
{"typeStep":"waitseconds","arg":"30"},
]
}
Loading