CsToMd
Visual Studio extension and dotnet CLI tool to generate the Markdown Docs from the C# Tests keeping your Docs and Tests in sync!
Install / Use
/learn @dadhi/CsToMdREADME
CsToMd
Idea and Overview
The dotnet CLI tool to convert C# file with Unit Tests into the Markdown documentation.
The idea is to have a normal C# .cs file with the special comments /*md, md*/, and //md which will be stripped when converting the file into the respective Markdown .md file. There are a couple of additional features but this is basically it.
Now you have the documentation always up-to-date with the runnable samples in the normal .NET Test library project with NUnit, XUnit, etc.
You may check the DryIoc documentation project for the real-world case example.
The additional features:
- Directive to automatically wrap code in code fence with the optional language, e.g. add
//md code:csharp, or just//md code:to add fences, and//md code:--to stop adding fences. The directive may be used multiple times through the file. - Converting the section outlined with
//md{and//md}comments into the collapsed markdown details. - The optional
cstomd.configfile in the folder with the lines starters to be removed completely from the generated documentation file.
Dotnet CLI tool
The dotnet-cstomd is a dotnet CLI tool. It may be called from the command line and from the MSBuild scripts (enabling the document generation in the build pipeline).
I addition the dotnet tool enables the documentation development in the Visual Studio Code.

Ad-hoc document generation
- Install the dotnet-cstomd globally from the nuget, e.g. in the shell of your choice
dotnet tool install --global dotnet-cstomd --version 1.2.1. Now you can invokecstomd MyClass.csdirectly and get theMyClass.mdoutput.
Build integration
-
Switch to your project:
cd path\to\MyProject -
Add the tool manifest file:
dotnet new tool-manifest -
Install the tool:
dotnet tool install dotnet-cstomd --version 1.2.1 --roll-forward(the manifest file will be updated and later used for restore) -
Add the section to your project:
<ItemGroup> <DocFile Include="**\*.cs" /> </ItemGroup> <Target Name="MdGenerate" BeforeTargets="BeforeBuild"> <Exec WorkingDirectory="$(ProjectDir)" Command="dotnet cstomd %(DocFile.Identity)" /> </Target>You may check the DryIoc documentation project file for the real-world case example.
-
You may run the document generation target without the rest of the build:
dotnet msbuild -target:MdGenerate path\to\MyProject\MyProject.csproj
You may create a helper shell script with the command above.
Here is the MS tutorial for installing and using the local tools.
Visual Studio extension
This extension for Visual Studio 2019+ contains the CustomTool File Generator.
When applied to the C# source file it looks like this:

How to use
- Install the extension directly from the marketplace in Visual Studio or download the extension vsix file from the release page.
- In properties of your .cs file set the
CustomToolproperty toCsToMd. - Save the .cs file
- Check the generated .md file under the .cs file in Solution Explorer
Related Skills
node-connect
345.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
prose
345.9kOpenProse VM skill pack. Activate on any `prose` command, .prose files, or OpenProse mentions; orchestrates multi-agent workflows.
frontend-design
106.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
Writing Hookify Rules
106.4kThis skill should be used when the user asks to "create a hookify rule", "write a hook rule", "configure hookify", "add a hookify rule", or needs guidance on hookify rule syntax and patterns.
