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
30 changes: 26 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# RSCG - 260 Examples of Roslyn Source Code Generators / 16 created by Microsoft /
# RSCG - 261 Examples of Roslyn Source Code Generators / 16 created by Microsoft /

The RSCG_Examples repository is a comprehensive documentation system that automatically processes and showcases 260 Roslyn Source Code Generator (RSCG) examples. The system transforms individual RSCG projects into structured documentation with code examples and cross-referenced content with a searchable website and code example exports.
The RSCG_Examples repository is a comprehensive documentation system that automatically processes and showcases 261 Roslyn Source Code Generator (RSCG) examples. The system transforms individual RSCG projects into structured documentation with code examples and cross-referenced content with a searchable website and code example exports.

This system serves as both a learning resource for .NET developers interested in source generators and an automated pipeline for maintaining up-to-date documentation about the RSCG ecosystem

## Latest Update : 2026-04-02 => 02 April 2026
## Latest Update : 2026-04-03 => 03 April 2026

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 @@ -24,8 +24,30 @@ If you want to be notified each time I add a new RSCG example , please click htt

## Content

Those are the 260 Roslyn Source Code Generators that I have tested you can see and download source code example.
Those are the 261 Roslyn Source Code Generators that I have tested you can see and download source code example.
( including 16 from Microsoft )
### 261. [NLog.Extensions.ThisClass](https://ignatandrei.github.io/RSCG_Examples/v2/docs/NLog.Extensions.ThisClass) , in the [EnhancementClass](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#enhancementclass) category

Generated on : 2026-04-03 => 03 April 2026

<details>
<summary>Expand</summary>



Author: Trym Pet

Create class loggers using source generators powered by Roslyn.

Nuget: [https://www.nuget.org/packages/NLog.Extensions.ThisClass/](https://www.nuget.org/packages/NLog.Extensions.ThisClass/)


Link: [https://ignatandrei.github.io/RSCG_Examples/v2/docs/NLog.Extensions.ThisClass](https://ignatandrei.github.io/RSCG_Examples/v2/docs/NLog.Extensions.ThisClass)

Source: [https://github.com/trympet/ThisClass](https://github.com/trympet/ThisClass)

</details>

### 260. [AssemblyMetadata](https://ignatandrei.github.io/RSCG_Examples/v2/docs/AssemblyMetadata) , in the [EnhancementProject](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#enhancementproject) category

Generated on : 2026-04-02 => 02 April 2026
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 : 2026-04-02 => 02 April 2026
## Latest Update : 2026-04-03 => 03 April 2026



Expand Down
48 changes: 48 additions & 0 deletions v2/.tours/NLog.Extensions.ThisClass.tour
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

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

,{
"file": "rscg_examples/NLog.Extensions.ThisClass/src/LogDemo/Person.cs",
"description": "File Person.cs ",
"pattern": "this is the code"
}

,{
"file": "rscg_examples/NLog.Extensions.ThisClass/src/LogDemo/Program.cs",
"description": "File Program.cs \r\n>> dotnet run --project rscg_examples/NLog.Extensions.ThisClass/src/LogDemo/LogDemo.csproj ",
"pattern": "this is the code"
}


,{
"file": "rscg_examples/NLog.Extensions.ThisClass/src/LogDemo/obj/GX/NLog.Extensions.ThisClass/NLog.Extensions.ThisClass.ThisClassNLogGenerator/Person_ClassLoggerLazy.g.cs",
"description": "Generated File 3 from 3 : Person_ClassLoggerLazy.g.cs ",
"line": 1
}

,{
"file": "rscg_examples/NLog.Extensions.ThisClass/src/LogDemo/obj/GX/NLog.Extensions.ThisClass/NLog.Extensions.ThisClass.ThisClassNLogGenerator/ClassLoggerLazyAttribute.g.cs",
"description": "Generated File 2 from 3 : ClassLoggerLazyAttribute.g.cs ",
"line": 1
}

,{
"file": "rscg_examples/NLog.Extensions.ThisClass/src/LogDemo/obj/GX/NLog.Extensions.ThisClass/NLog.Extensions.ThisClass.ThisClassNLogGenerator/ClassLoggerAttribute.g.cs",
"description": "Generated File 1 from 3 : ClassLoggerAttribute.g.cs ",
"line": 1
}

],

"ref": "main"

}
1 change: 1 addition & 0 deletions v2/Generator/all.csv
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,4 @@ Nr,Key,Source,Category
258,REslava.ResultFlow, https://github.com/reslava/nuget-package-reslava-result/,Documentation
259,TypedPaths, https://github.com/AlexChim1231/TypedPaths/,FilesToCode
260,AssemblyMetadata, https://github.com/BenjaminAbt/AssemblyMetadata,EnhancementProject
261,NLog.Extensions.ThisClass, https://github.com/trympet/ThisClass,EnhancementClass
6 changes: 6 additions & 0 deletions v2/RSCGExamplesData/GeneratorDataRec.json
Original file line number Diff line number Diff line change
Expand Up @@ -1576,5 +1576,11 @@
"Category": 1,
"dtStart": "2026-04-02T00:00:00",
"show": true
},
{
"ID":"NLog.Extensions.ThisClass",
"Category": 5,
"dtStart": "2026-04-03T00:00:00",
"show": true
}
]
69 changes: 69 additions & 0 deletions v2/book/examples/NLog.Extensions.ThisClass.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@

<h1>RSCG nr 261 : NLog.Extensions.ThisClass</h1>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add an HTML doctype declaration at the top.

The document starts with content but no doctype, which matches the static-analysis error and can cause standards-mode inconsistencies.

🛠️ Proposed fix
+<!doctype html>
 
 <h1>RSCG nr 261 :  NLog.Extensions.ThisClass</h1>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<h1>RSCG nr 261 : NLog.Extensions.ThisClass</h1>
<!doctype html>
<h1>RSCG nr 261 : NLog.Extensions.ThisClass</h1>
🧰 Tools
🪛 HTMLHint (1.9.2)

[error] 2-2: Doctype must be declared before any non-comment content.

(doctype-first)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@v2/book/examples/NLog.Extensions.ThisClass.html` at line 2, The HTML file is
missing a doctype declaration which can trigger standards-mode inconsistencies;
add the HTML5 doctype declaration (<!DOCTYPE html>) as the very first line of
v2/book/examples/NLog.Extensions.ThisClass.html so it appears before the
existing <h1> element and any other content, ensuring the document renders in
standards mode.


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

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

<p>Author :Trym Pet</p>

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

<h2>About</h2>

Generate the NLog register for a class.

<h2>
How to use
</h2>
<h3>
Add reference to the <a href="https://www.nuget.org/packages/NLog.Extensions.ThisClass/" target="_blank">NLog.Extensions.ThisClass</a> in the csproj
</h3>
<img src="images/NLog.Extensions.ThisClass/LogDemo.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/NLog.Extensions.ThisClass/csFiles/Program.cs.png" width="580" height="580" />
<hr />

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

<br />
The file <i>generated</i> is ClassLoggerAttribute.g.cs
<br />
<img src="images/NLog.Extensions.ThisClass/generated/ClassLoggerAttribute.g.cs.png" width="580" height="580" />

<br />
The file <i>generated</i> is ClassLoggerLazyAttribute.g.cs
<br />
<img src="images/NLog.Extensions.ThisClass/generated/ClassLoggerLazyAttribute.g.cs.png" width="580" height="580" />

<br />
The file <i>generated</i> is Person_ClassLoggerLazy.g.cs
<br />
<img src="images/NLog.Extensions.ThisClass/generated/Person_ClassLoggerLazy.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/NLog.Extensions.ThisClass'>
https://ignatandrei.github.io/RSCG_Examples/v2/docs/NLog.Extensions.ThisClass
</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 260 RSCG with examples =>
This is the list of 261 RSCG with examples =>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Escape special character to satisfy HTML linting.

Line 20 uses a raw > in text content; this is currently flagged by HTMLHint (spec-char-escape).

🔧 Proposed fix
-This is the list of 261 RSCG with examples =>
+This is the list of 261 RSCG with examples =&gt;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
This is the list of 261 RSCG with examples =>
This is the list of 261 RSCG with examples =&gt;
🧰 Tools
🪛 HTMLHint (1.9.2)

[error] 20-20: Special characters must be escaped : [ > ].

(spec-char-escape)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@v2/book/list.html` at line 20, The raw '>' character in the text "This is the
list of 261 RSCG with examples =>" is triggering HTML linting
(spec-char-escape); update the text in v2/book/list.html (the string containing
"This is the list of 261 RSCG with examples =>") to escape the greater-than sign
(e.g., replace '>' with '&gt;') so the content is valid HTML and passes
HTMLHint.

</h1>

<table >
Expand Down Expand Up @@ -1066,6 +1066,10 @@ <h1>
<td>260</td>
<td><a href="examples/AssemblyMetadata.html">AssemblyMetadata</a></td>
</tr>
<tr>
<td>261</td>
<td><a href="examples/NLog.Extensions.ThisClass.html">NLog.Extensions.ThisClass</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 @@ -274,6 +274,7 @@ input-files:
- examples/REslava.ResultFlow.html
- examples/TypedPaths.html
- examples/AssemblyMetadata.html
- examples/NLog.Extensions.ThisClass.html

# or you may use input-file: with a single value
# defaults:
Expand Down
22 changes: 22 additions & 0 deletions v2/rscg_examples/NLog.Extensions.ThisClass/description.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"generator":{
"name":"NLog.Extensions.ThisClass",
"nuget":[
"https://www.nuget.org/packages/NLog.Extensions.ThisClass/"
],
"link":"https://github.com/trympet/ThisClass",
"author":"Trym Pet",
"source":"https://github.com/trympet/ThisClass"
},
"data":{
"goodFor":["Generate the NLog register for a class."],
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "goodFor" description says "Generate the NLog register for a class", but the package/docs describe creating class loggers. Consider changing this to "Generate an NLog logger for a class" (or similar) for clarity/consistency across generated docs.

Suggested change
"goodFor":["Generate the NLog register for a class."],
"goodFor":["Generate an NLog logger for a class."],

Copilot uses AI. Check for mistakes.
"csprojDemo":"LogDemo.csproj",
"csFiles":["Program.cs","Person.cs"],
"excludeDirectoryGenerated":[""],
"includeAdditionalFiles":[""]
},
"links":{
"blog":"",
"video":""
}
}
1 change: 1 addition & 0 deletions v2/rscg_examples/NLog.Extensions.ThisClass/nuget.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Create class loggers using source generators powered by Roslyn.
113 changes: 113 additions & 0 deletions v2/rscg_examples/NLog.Extensions.ThisClass/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# ThisClass
Exposes class and type information as constants in the ThisClass class using source generators powered by Roslyn, inspired by ThisAssembly.

## ThisClass
Add the `ThisClassAttribute` to generate type information for a class.
```csharp
[ThisClass]
partial class Demo
{
public Demo()
{
Logger.Info($"Hello from {ThisClass.FullName}"); // SampleApp.Demo
}
}
```


## NLog.Extensions.ThisClass
Create class loggers without using reflection.
```csharp
using SomeNamespace;

namespace SampleApp.NLog
{
...
namespace AnotherNamespace
{
using SomeOtherNamespace;
[ClassLoggerLazy]
partial class Demo2<T> : SomeInterface<T> where T : SomeOtherInterface
{
public static void SayHello()
{
Logger.Info("Hello");
}

[ClassLogger]
internal partial class NestedClass : SomeInterface<SomeOtherInterface>
{
}
}
}
}
```

Looks like this behind the scenes
```csharp
// <auto-generated/>
#nullable enable
namespace SampleApp.NLog
{
partial class Demo1
{
public static partial class ThisClass
{
/// <summary>
/// Gets the fully qualified name of the parent class, including the namespace but not the assembly.
/// </summary>
public const string FullName = "SampleApp.NLog.Demo1";
}
}
}

// <auto-generated/>
#nullable enable
namespace SampleApp.NLog
{
namespace AnotherNamespace
{
using SomeOtherNamespace;

partial class Demo2<T> : global::SomeNamespace.SomeInterface<T> where T : global::SomeOtherNamespace.SomeOtherInterface
{
public static partial class ThisClass
{
/// <summary>
/// Gets the fully qualified name of the parent class, including the namespace but not the assembly.
/// </summary>
public const string FullName = "SampleApp.NLog.AnotherNamespace.Demo2";
}

private static global::NLog.Logger? __loggerLazy;
private static global::NLog.Logger Logger => __loggerLazy ??= global::NLog.LogManager.GetLogger(ThisClass.FullName);
}
}
}

// <auto-generated/>
#nullable enable
namespace SampleApp.NLog
{
namespace AnotherNamespace
{
using SomeOtherNamespace;

partial class Demo2<T> : global::SomeNamespace.SomeInterface<T> where T : global::SomeOtherNamespace.SomeOtherInterface
{
partial class NestedClass : global::SomeNamespace.SomeInterface<global::SomeOtherNamespace.SomeOtherInterface>
{
public static partial class ThisClass
{
/// <summary>
/// Gets the fully qualified name of the parent class, including the namespace but not the assembly.
/// </summary>
public const string FullName = "SampleApp.NLog.AnotherNamespace.Demo2.NestedClass";
}

private static readonly global::NLog.Logger Logger = global::NLog.LogManager.GetLogger(ThisClass.FullName);
}
}
}
}
```
3 changes: 3 additions & 0 deletions v2/rscg_examples/NLog.Extensions.ThisClass/src/LogDemo.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Solution>
<Project Path="LogDemo/LogDemo.csproj" />
</Solution>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
<PackageReference Include="NLog" Version="6.1.2" />
<PackageReference Include="NLog.Extensions.Logging" Version="6.1.2" />
<PackageReference Include="NLog.Extensions.ThisClass" Version="1.6.7" />
</ItemGroup>

<ItemGroup>
<None Update="NLog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

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