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 - 245 Examples of Roslyn Source Code Generators / 16 created by Microsoft /
# RSCG - 246 Examples of Roslyn Source Code Generators / 16 created by Microsoft /

The RSCG_Examples repository is a comprehensive documentation system that automatically processes and showcases 245 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 246 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 : 2025-12-12 => 12 December 2025
## Latest Update : 2025-12-13 => 13 December 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 @@ -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 245 Roslyn Source Code Generators that I have tested you can see and download source code example.
Those are the 246 Roslyn Source Code Generators that I have tested you can see and download source code example.
( including 16 from Microsoft )
### 246. [Imposter](https://ignatandrei.github.io/RSCG_Examples/v2/docs/Imposter) , in the [Tests](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#tests) category

Generated on : 2025-12-13 => 13 December 2025

<details>
<summary>Expand</summary>



Author: Bitchiko Tchelidze

Imposter — Source-generated test doubles, zero runtime overhead. A high-performance Roslyn incremental source generator that produces imposters (mocks/stubs) for interfaces and overridable class members via GenerateImposterAttribute. Ships analyzer + runtime in a single package.

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


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

Source: [https://github.com/themidnightgospel/Imposter](https://github.com/themidnightgospel/Imposter)

</details>

### 245. [Monify](https://ignatandrei.github.io/RSCG_Examples/v2/docs/Monify) , in the [PrimitiveObsession](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#primitiveobsession) category

Generated on : 2025-12-12 => 12 December 2025
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-12-12 => 12 December 2025
## Latest Update : 2025-12-13 => 13 December 2025



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

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

,{
"file": "rscg_examples/Imposter/src/TestClock/Usings.cs",
"description": "File Usings.cs ",
"pattern": "this is the code"
}

,{
"file": "rscg_examples/Imposter/src/TestClock/TestClock.cs",
"description": "File TestClock.cs ",
"pattern": "this is the code"
}


,{
"file": "rscg_examples/Imposter/src/TestClock/obj/GX/Imposter.CodeGenerator/Imposter.CodeGenerator.CodeGenerator.ImposterGenerator/IMyClockImposter.g.cs",
"description": "Generated File 1 from 1 : IMyClockImposter.g.cs ",
"line": 1
}

Comment on lines +6 to +31
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Check if the generated file is present in the repo
find . -name "IMyClockImposter.g.cs" -type f 2>/dev/null | head -20

Repository: ignatandrei/RSCG_Examples

Length of output: 51


🏁 Script executed:

# Check .gitignore to see if obj/ is ignored
cat .gitignore 2>/dev/null | grep -E "^obj/|^.*obj/.*" | head -20

Repository: ignatandrei/RSCG_Examples

Length of output: 51


🏁 Script executed:

# Look for the Usings.cs and TestClock.cs files to check patterns
find . -path "*/Imposter/src/TestClock/Usings.cs" -o -path "*/Imposter/src/TestClock/TestClock.cs" | head -20

Repository: ignatandrei/RSCG_Examples

Length of output: 175


🏁 Script executed:

# Check if there are any checked-in generated files under src/
find . -path "*/Imposter/src/*/generated/*" -o -path "*/Imposter/src/*/*.g.cs" 2>/dev/null | head -20

Repository: ignatandrei/RSCG_Examples

Length of output: 51


🏁 Script executed:

# Read Usings.cs to check for the pattern "this is the code"
cat -n ./v2/rscg_examples/Imposter/src/TestClock/Usings.cs

Repository: ignatandrei/RSCG_Examples

Length of output: 256


🏁 Script executed:

# Read TestClock.cs to check for the pattern "this is the code"
cat -n ./v2/rscg_examples/Imposter/src/TestClock/TestClock.cs

Repository: ignatandrei/RSCG_Examples

Length of output: 606


🏁 Script executed:

# Verify the tour file exists and show its full content
cat -n ./v2/.tours/Imposter.tour

Repository: ignatandrei/RSCG_Examples

Length of output: 1292


Fix tour patterns and remove reference to build-generated file.

The patterns "this is the code" (lines 16 and 22) do not match any content in Usings.cs or TestClock.cs. Replace them with actual matching text from those files, or omit the pattern field.

The referenced generated file at obj/GX/Imposter.CodeGenerator/.../IMyClockImposter.g.cs (line 27) does not exist in the repository and is only created during build. Remove this step or replace it with a checked-in snapshot of the generated output under a stable path like src/TestClock/generated/.

🤖 Prompt for AI Agents
In v2/.tours/Imposter.tour around lines 6 to 31, the tour uses non-matching
patterns ("this is the code") for Usings.cs and TestClock.cs and references a
build-generated file under obj/GX/.../IMyClockImposter.g.cs that doesn't exist
in the repo; update the two entries to use real text that appears in those files
(or remove the pattern field entirely) and delete or replace the generated-file
step with a stable, checked-in generated snapshot (for example move the
generated output to src/TestClock/generated/ and reference that path) so the
tour only points to files that exist in source control.

],

"ref": "main"

}
1 change: 1 addition & 0 deletions v2/Generator/all.csv
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,4 @@ Nr,Key,Source,Category
243,RSCG_MCP2File, https://github.com/ignatandrei/RSCG_OpenApi2MCP,MCP
244,BoolParameterGenerator, https://github.com/9swampy/BoolEnumGenerator,Bool
245,Monify, https://github.com/MooVC/monify,PrimitiveObsession
246,Imposter, https://github.com/themidnightgospel/Imposter,Tests
8 changes: 7 additions & 1 deletion v2/RSCGExamplesData/GeneratorDataRec.json
Original file line number Diff line number Diff line change
Expand Up @@ -1485,5 +1485,11 @@
"dtStart": "2025-12-12T00:00:00",
"show": true

}
},
{
"ID": "Imposter",
"Category": 13,
"dtStart": "2025-12-13T00:00:00",
"show": true
},
]
59 changes: 59 additions & 0 deletions v2/book/examples/Imposter.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

<h1>RSCG nr 246 : Imposter</h1>

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

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

<p>Author :Bitchiko Tchelidze</p>

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

<h2>About</h2>

Generate classes from interfaces and allows return of mock data.Useful for testing and prototyping.

Comment on lines +9 to +16
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix minor spacing/typos in public HTML text.

-<p>Author :Bitchiko Tchelidze</p>
+<p>Author : Bitchiko Tchelidze</p>
@@
-Generate classes from interfaces and allows return of mock data.Useful for testing and prototyping.
+Generate classes from interfaces and allows return of mock data. Useful for testing and prototyping.
📝 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
<p>Author :Bitchiko Tchelidze</p>
<p>Source: <a href="https://github.com/themidnightgospel/Imposter" target="_blank">https://github.com/themidnightgospel/Imposter</a> </p>
<h2>About</h2>
Generate classes from interfaces and allows return of mock data.Useful for testing and prototyping.
<p>Author : Bitchiko Tchelidze</p>
<p>Source: <a href="https://github.com/themidnightgospel/Imposter" target="_blank">https://github.com/themidnightgospel/Imposter</a> </p>
<h2>About</h2>
Generate classes from interfaces and allows return of mock data. Useful for testing and prototyping.
🤖 Prompt for AI Agents
In v2/book/examples/Imposter.html around lines 9–16, fix minor spacing and typos
in the public text: change "Author :Bitchiko Tchelidze" to "Author: Bitchiko
Tchelidze", ensure a space after "Source:" if missing, and rewrite the
description sentence to proper grammar and spacing — e.g. "Generates classes
from interfaces and allows returning mock data. Useful for testing and
prototyping." Update the HTML text accordingly.

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

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

<br />
The file <i>generated</i> is IMyClockImposter.g.cs
<br />
<img src="images/Imposter/generated/IMyClockImposter.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/Imposter'>
https://ignatandrei.github.io/RSCG_Examples/v2/docs/Imposter
</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 245 RSCG with examples =>
This is the list of 246 RSCG with examples =>
</h1>

<table >
Expand Down Expand Up @@ -1006,6 +1006,10 @@ <h1>
<td>245</td>
<td><a href="examples/Monify.html">Monify</a></td>
</tr>
<tr>
<td>246</td>
<td><a href="examples/Imposter.html">Imposter</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 @@ -259,6 +259,7 @@ input-files:
- examples/RSCG_MCP2File.html
- examples/BoolParameterGenerator.html
- examples/Monify.html
- examples/Imposter.html

# or you may use input-file: with a single value
# defaults:
Expand Down
22 changes: 22 additions & 0 deletions v2/rscg_examples/Imposter/description.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"generator":{
"name":"Imposter",
"nuget":[
"https://www.nuget.org/packages/Imposter/"
],
"link":"https://github.com/themidnightgospel/Imposter",
"author":"Bitchiko Tchelidze",
"source":"https://github.com/themidnightgospel/Imposter"
},
"data":{
"goodFor":["Generate classes from interfaces and allows return of mock data.","Useful for testing and prototyping."],
"csprojDemo":"TestClock.csproj",
"csFiles":["TestClock.cs","Usings.cs"],
"excludeDirectoryGenerated":[""],
"includeAdditionalFiles":[""]
},
"links":{
"blog":"",
"video":""
}
}
1 change: 1 addition & 0 deletions v2/rscg_examples/Imposter/nuget.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Imposter — Source-generated test doubles, zero runtime overhead. A high-performance Roslyn incremental source generator that produces imposters (mocks/stubs) for interfaces and overridable class members via GenerateImposterAttribute. Ships analyzer + runtime in a single package.
154 changes: 154 additions & 0 deletions v2/rscg_examples/Imposter/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<p align="center">
<img src="docs/imposter_logo.png" alt="Imposter logo" width="140" />
</p>

<p align="center">
Fast and Memory-Efficient Mocking Library
</p>

[![Build, Test, and Format verification](https://github.com/themidnightgospel/Imposter/actions/workflows/build-and-test.yml/badge.svg?branch=master)](https://github.com/themidnightgospel/Imposter/actions/workflows/build-and-test.yml)
[![Nuget](https://img.shields.io/nuget/v/Imposter.svg)](https://www.nuget.org/packages/Imposter)

Imposter is a mocking library that's using roslyn source generators to achieve high performance and low memory footprint.

Visit the [Docs](https://themidnightgospel.github.io/Imposter/) for more information

Comment on lines +12 to +15
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix “imoster” typo + minor grammar polish in README.
Line 38 says “imoster”; should be “imposter”. Also consider “Roslyn” capitalization and “memory-efficient” hyphenation.

-Imposter is a mocking library that's using roslyn source generators to achieve high performance and low memory footprint.
+Imposter is a mocking library that uses Roslyn source generators to achieve high performance and a low memory footprint.
@@
-Use `[GenerateImposter]` attribute in your **tests** project, this will generate an imoster
+Use `[GenerateImposter]` attribute in your **tests** project; this will generate an imposter
@@
-Then use can use the generated imposter in your tests
+Then you can use the generated imposter in your tests

Also applies to: 38-45

🧰 Tools
🪛 LanguageTool

[uncategorized] ~12-~12: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...ing roslyn source generators to achieve high performance and low memory footprint. Visit the [D...

(EN_COMPOUND_ADJECTIVE_INTERNAL)

🤖 Prompt for AI Agents
In v2/rscg_examples/Imposter/readme.txt around lines 12-15 and also lines 38-45,
correct the typo "imoster" to "imposter", capitalize "Roslyn", and hyphenate
"memory-efficient" (and optionally "high-performance") for grammar; update the
sentences so they read e.g. "Imposter is a mocking library that uses Roslyn
source generators to achieve high-performance and a memory-efficient footprint."
Ensure consistent capitalization and hyphenation throughout the file.

## 🚀 Quick Start

Add nuget package reference:

```bash
dotnet add package Imposter
```

Pick an interface or non-sealed class that you would like to generate an imposter for.

Say we have a below interface

```csharp

namespace Application.Domain;

public interface ICalculator
{
int Add(int a, int b);
}
```

Use `[GenerateImposter]` attribute in your **tests** project, this will generate an imoster

```csharp
[assembly: GenerateImposter(typeof(Application.Domain.ICalculator))]
```

Then use can use the generated imposter in your tests

```csharp
using System.Threading.Tasks;
using Imposter.Abstractions;

// c# 14
var imposter = ICalculator.Imposter();

// c# 9 - 13
// var imposter = new ICalculatorImposter();

imposter.Add(Arg<int>.Any(), Arg<int>.Any())
.Returns(1)
.Then()
.Returns(2);

var calculator = imposter.Instance();

calculator.Add(1, 2); // 1
calculator.Add(1, 2); // 2
```

Learn more: https://themidnightgospel.github.io/Imposter/

## ✨ Feature-Rich

- [Method Impersonation](https://themidnightgospel.github.io/Imposter/latest/methods/)
- [Property Impersonation](https://themidnightgospel.github.io/Imposter/latest/properties/)
- [Indexer Impersonation](https://themidnightgospel.github.io/Imposter/latest/indexers/)
- [Event Impersonation](https://themidnightgospel.github.io/Imposter/latest/events/)
- [Class Impersonation](https://themidnightgospel.github.io/Imposter/latest/base-implementation/)
- [Generics](https://themidnightgospel.github.io/Imposter/latest/generics/)
- [Implicit & Explicit Modes](https://themidnightgospel.github.io/Imposter/latest/implicit-vs-explicit/)
- [Use Base implementation](https://themidnightgospel.github.io/Imposter/latest/base-implementation/)
- [Async Support](https://themidnightgospel.github.io/Imposter/latest/methods/#async-methods)
- [Protected members Impersonation](https://themidnightgospel.github.io/Imposter/latest/methods/protected-members/)

## ⏱️ Benchmark

We benchmarked the simple method-impersonation scenario: we set up a `Square` method to return `input * input` and ran it for 1, 10, 100, and 1000 iterations.

```csharp
public interface ICalculator
{
int Square(int input);
}
```

Mean execution time

| Method | Iteration | Mean |
|-------------|-----------|----------------:|
| Moq | 1 | 69,346.1 ns |
| NSubstitute | 1 | 1,976.2 ns |
| FakItEasy | 1 | 2,006.7 ns |
| Imposter | 1 | **194.3 ns** |
| Moq | 10 | 686,282.9 ns |
| NSubstitute | 10 | 11,201.6 ns |
| FakItEasy | 10 | 12,399.0 ns |
| Imposter | 10 | **1,896.7 ns** |
| Moq | 100 | 6,804,897.3 ns |
| NSubstitute | 100 | 335,390.6 ns |
| FakItEasy | 100 | 258,220.2 ns |
| Imposter | 100 | **34,011.7 ns** |
| Moq | 1000 | 99,710,929.5 ns |
| NSubstitute | 1000 | 26,986,939.0 ns |
| FakItEasy | 1000 | 18,997,374.5 ns |
| Imposter | 1000 | **2,452,970.7 ns** |


Allocated Memory

| Method | Iteration | Allocated |
|-------------|-----------|------------:|
| Moq | 1 | 13.05 KB |
| NSubstitute | 1 | 7.84 KB |
| FakeItEasy | 1 | 5.84 KB |
| Imposter | 1 | **2.4 KB** |
| Moq | 10 | 115.73 KB |
| NSubstitute | 10 | 29.29 KB |
| FakeItEasy | 10 | 38.81 KB |
| Imposter | 10 | **22.37 KB** |
| Moq | 100 | 1416.91 KB |
| NSubstitute | 100 | 247.26 KB |
| FakeItEasy | 100 | 1033.38 KB |
| Imposter | 100 | **222.05 KB** |
| Moq | 1000 | 42275.19 KB |
| NSubstitute | 1000 | 2420.82 KB |
| FakeItEasy | 1000 | 77101.74 KB |
| Imposter | 1000 | **2218.93 KB** |


Benchmark Environment

```
BenchmarkDotNet v0.15.6, Windows 11 (10.0.26200.6899)
13th Gen Intel Core i9-13900HX 2.20GHz, 1 CPU, 32 logical and 24 physical cores
.NET SDK 10.0.100
[Host] : .NET 8.0.21 (8.0.21, 8.0.2125.47513), X64 RyuJIT x86-64-v3
DefaultJob : .NET 8.0.21 (8.0.21, 8.0.2125.47513), X64 RyuJIT x86-64-v3
```

See other benchmarks [benchmark](https://github.com/themidnightgospel/Imposter/blob/3172c333603fd2d76031b20be39753a9b62f31c3/benchmarks/Imposter.Benchmarks/ImposterVsMoqVsNSubstitute/SimpleMethodMockingBenchmarks.cs#L12)

## Docs
Docs: https://themidnightgospel.github.io/Imposter/

## License

Licensed under the MIT License. See LICENSE.txt for details.
7 changes: 7 additions & 0 deletions v2/rscg_examples/Imposter/src/MockData/IMyClock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace MockData;
public interface IMyClock
{
public DateTime GetNow();
public DateTime GetUtcNow();

}
Loading