-
-
Notifications
You must be signed in to change notification settings - Fork 6
knockoff #452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
knockoff #452
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
|
|
||
| { | ||
| "$schema": "https://aka.ms/codetour-schema", | ||
| "title": "KnockOff", | ||
| "steps": | ||
| [ | ||
| { | ||
| "file": "rscg_examples/KnockOff/src/TestClock/TestClock.csproj", | ||
| "description": "First, we add Nuget [KnockOff](https://www.nuget.org/packages/KnockOff/) in csproj ", | ||
| "pattern": "KnockOff" | ||
| } | ||
|
|
||
| ,{ | ||
| "file": "rscg_examples/KnockOff/src/TestClock/TestClock.cs", | ||
| "description": "File TestClock.cs ", | ||
| "pattern": "this is the code" | ||
| } | ||
|
|
||
| ,{ | ||
| "file": "rscg_examples/KnockOff/src/Mock/IMyClock.cs", | ||
| "description": "File IMyClock.cs ", | ||
| "pattern": "this is the code" | ||
| } | ||
|
|
||
|
|
||
| ,{ | ||
| "file": "rscg_examples/KnockOff/src/TestClock/obj/GX/KnockOff.Generator/KnockOff.KnockOffGenerator/QuickStartRepoStub.g.cs", | ||
| "description": "Generated File 2 from 2 : QuickStartRepoStub.g.cs ", | ||
| "line": 1 | ||
| } | ||
|
|
||
| ,{ | ||
| "file": "rscg_examples/KnockOff/src/TestClock/obj/GX/KnockOff.Generator/KnockOff.KnockOffGenerator/QuickStartRepoStub.Base.g.cs", | ||
| "description": "Generated File 1 from 2 : QuickStartRepoStub.Base.g.cs ", | ||
| "line": 1 | ||
| } | ||
|
|
||
| ], | ||
|
|
||
| "ref": "main" | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -224,9 +224,14 @@ public string[] SourceNoRSCG() | |||||||||
| text = text.Replace("(LICENSE.TXT)", $"({d.Generator!.Source}/LICENSE.TXT)"); | ||||||||||
| text = text.Replace("(docs/building.md)", $"({d.Generator!.Source}/docs/building.md)"); | ||||||||||
| text = text.Replace("(./", $"({d.Generator!.Source}/"); | ||||||||||
|
|
||||||||||
| text = text.Replace("(skills/", $"({d.Generator!.Source}/skills"); | ||||||||||
|
|
||||||||||
| text = text.Replace("Access them as a ReadOnlySpan<byte>", "Access them as a ReadOnlySpan\\<byte\\>"); | ||||||||||
| text = text.Replace("### ", "##### "); | ||||||||||
| text = text.Replace("## ", "#### "); | ||||||||||
| text = text.Replace("# ", "### "); | ||||||||||
|
Comment on lines
+230
to
+232
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cascading replacements corrupt markdown headers. These three sequential
Similarly, A single replacement achieves the intended +2 level shift for all headers, because it only matches the last Proposed fix- text = text.Replace("### ", "##### ");
- text = text.Replace("## ", "#### ");
- text = text.Replace("# ", "### ");
+ text = text.Replace("# ", "### ");📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| text= text.Replace("C###", "C#"); | ||||||||||
|
|
||||||||||
| return text; | ||||||||||
| } | ||||||||||
| ; | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,64 @@ | ||||||
|
|
||||||
| <h1>RSCG nr 255 : KnockOff</h1> | ||||||
|
|
||||||
| <h2>Info</h2> | ||||||
| Nuget : <a href="https://www.nuget.org/packages/KnockOff/" target="_blank">https://www.nuget.org/packages/KnockOff/</a> | ||||||
|
|
||||||
| <p>You can find more details at : <a href="https://github.com/NeatooDotNet/KnockOff" target="_blank"> https://github.com/NeatooDotNet/KnockOff</a></p> | ||||||
|
|
||||||
| <p>Author :Keith Voels</p> | ||||||
|
|
||||||
|
Comment on lines
+9
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix minor spacing in the author line. Line 9 is missing a space after the colon. Suggested change-<p>Author :Keith Voels</p>
+<p>Author: Keith Voels</p>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| <p>Source: <a href="https://github.com/NeatooDotNet/KnockOff" target="_blank">https://github.com/NeatooDotNet/KnockOff</a> </p> | ||||||
|
|
||||||
| <h2>About</h2> | ||||||
|
|
||||||
| Generating test stubs with mocking for interfaces | ||||||
|
|
||||||
| <h2> | ||||||
| How to use | ||||||
| </h2> | ||||||
| <h3> | ||||||
| Add reference to the <a href="https://www.nuget.org/packages/KnockOff/" target="_blank">KnockOff</a> in the csproj | ||||||
| </h3> | ||||||
| <img src="images/KnockOff/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 IMyClock.cs | ||||||
| <br /> | ||||||
| <img src="images/KnockOff/csFiles/IMyClock.cs.png" width="580" height="580" /> | ||||||
| <hr /> | ||||||
|
|
||||||
| <br /> | ||||||
| I have <b>coded</b> the file TestClock.cs | ||||||
| <br /> | ||||||
| <img src="images/KnockOff/csFiles/TestClock.cs.png" width="580" height="580" /> | ||||||
| <hr /> | ||||||
| <h3>And here are the <i>generated</i> files</h3> | ||||||
|
|
||||||
| <br /> | ||||||
| The file <i>generated</i> is QuickStartRepoStub.Base.g.cs | ||||||
| <br /> | ||||||
| <img src="images/KnockOff/generated/QuickStartRepoStub.Base.g.cs.png" width="580" height="580" /> | ||||||
|
|
||||||
| <br /> | ||||||
| The file <i>generated</i> is QuickStartRepoStub.g.cs | ||||||
| <br /> | ||||||
| <img src="images/KnockOff/generated/QuickStartRepoStub.g.cs.png" width="580" height="580" /> | ||||||
|
Comment on lines
+23
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add alt text for images (accessibility). The images are content-bearing (code snippets), so they should include descriptive Suggested change (apply to all images)-<img src="images/KnockOff/TestClock.csproj.png" width="580" height="580" />
+<img src="images/KnockOff/TestClock.csproj.png" width="580" height="580" alt="TestClock.csproj showing KnockOff package reference" />🤖 Prompt for AI Agents |
||||||
|
|
||||||
| <p> | ||||||
| You can download the code and this page as pdf from | ||||||
| <a target="_blank" href='https://ignatandrei.github.io/RSCG_Examples/v2/docs/KnockOff'> | ||||||
| https://ignatandrei.github.io/RSCG_Examples/v2/docs/KnockOff | ||||||
| </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> | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| { | ||
| "generator":{ | ||
| "name":"KnockOff", | ||
| "nuget":[ | ||
| "https://www.nuget.org/packages/KnockOff/" | ||
| ], | ||
| "link":"https://github.com/NeatooDotNet/KnockOff", | ||
| "author":"Keith Voels", | ||
| "source":"https://github.com/NeatooDotNet/KnockOff" | ||
| }, | ||
| "data":{ | ||
| "goodFor":["Generating test stubs with mocking for interfaces"], | ||
| "csprojDemo":"TestClock.csproj", | ||
| "csFiles":["IMyClock.cs","TestClock.cs"], | ||
| "excludeDirectoryGenerated":[""], | ||
| "includeAdditionalFiles":[""] | ||
| }, | ||
| "links":{ | ||
| "blog":"", | ||
| "video":"" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| A Roslyn Source Generator for creating unit test stubs. Unlike Moq's fluent runtime configuration, KnockOff uses partial classes for compile-time setup—trading flexibility for readability and performance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The heading replacement logic is flawed and causes unintended side effects. The sequential string replacements on lines 230-232 replace ALL occurrences of "# ", "## ", and "### " in the text, not just markdown headings at the start of lines. This causes "C# class" to become "C### class" when line 232 executes. The replacements should use regex with line-start anchors (e.g.,
Regex.Replace(text, @"^### ", "##### ", RegexOptions.Multiline)) to only affect actual markdown headings, not inline text containing hash symbols.