With this script in place, run it to (re-)generate the HTML diagrammer at your leisure. Note that `--output-folder .` directs the output to the current directory.
With this script in place, run it to (re-)generate the HTML diagrammer at your leisure. Note that `--outputdir .` directs the output to the current directory.
## Automatically
### Automatically
If you want to deploy an up-to-date HTML diagrammer as part of your live documentation,
you'll want to automate its regeneration to keep it in sync with your code base.
For example, you might like to share the diagrammer on a web server or - in general - with users
who cannot or may not regenerate it; lacking either access to the netAmermaid console app or permission to use it.
who cannot or may not regenerate it; lacking either access to the ilspycmd console app or permission to use it.
In such cases, you can dangle the regeneration off the end of either your build or deployment pipeline.
Note that the macros used here apply to [MSBuild](https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild) for [Visual Studio](https://learn.microsoft.com/en-us/visualstudio/ide/reference/pre-build-event-post-build-event-command-line-dialog-box) and your mileage may vary with VS for Mac or VS Code.
### After building
#### After building
To regenerate the HTML diagrammer from your output assembly after building,
add something like the following to your project file.
@ -130,43 +130,43 @@ Note that the `Condition` here is optional and configures this step to only run
@@ -130,43 +130,43 @@ Note that the `Condition` here is optional and configures this step to only run
**Compiler-generated** types and their nested types are **excluded by default**.
Consider sussing out **big source assemblies** using [ILSpy](https://github.com/icsharpcode/ILSpy) first to get an idea about which subdomains to include in your diagrammers. Otherwise you may experience long build times and large file sizes for the diagrammer as well as a looong type selection opening it. At some point, mermaid may refuse to render all types in your selection because their definitions exceed the maximum input size. If that's where you find yourself, you may want to consider
- using `--include` and `--exclude` to **limit the scope of the individual diagrammer to a certain subdomain**
- using `--generate-diagrammer-include` and `--generate-diagrammer-exclude` to **limit the scope of the individual diagrammer to a certain subdomain**
- generating **multiple diagrammers for different subdomains**.
## Advanced configuration examples
### Advanced configuration examples
Above examples show how the most important options are used. Let's have a quick look at the remaining ones, which allow for customization in your project setup and diagrams.
### Filter extracted types
#### Filter extracted types
Sometimes the source assembly contains way more types than are sensible to diagram. Types with metadata for validation or mapping for example. Or auto-generated types.
Especially if you want to tailor a diagrammer for a certain target audience and hide away most of the supporting type system to avoid noise and unnecessary questions.
In these scenarios you can supply Regular Expressions for types to `--include` (white-list) and `--exclude` (black-list).
A third option `--report-excluded` will output a `.txt` containing the list of effectively excluded types next to the HTML diagrammer containing the effectively included types.
In these scenarios you can supply Regular Expressions for types to `--generate-diagrammer-include` (white-list) and `--generate-diagrammer-exclude` (black-list).
A third option `--generate-diagrammer-report-excluded` will output a `.txt` containing the list of effectively excluded types next to the HTML diagrammer containing the effectively included types.
@ -175,21 +175,21 @@ This example
@@ -175,21 +175,21 @@ This example
- nested types called `Metadata` and
- types ending in `Map` in descendant `.Data.` namespaces.
### Strip namespaces from XML comments
#### Strip namespaces from XML comments
You can reduce the noise in the member lists of classes on your diagrams by supplying a space-separated list of namespaces to omit from the output like so:
You can reduce the noise in the XML documentation comments on classes on your diagrams by supplying a space-separated list of namespaces to omit from the output like so:
To **extract the type info from the source assembly**, the netAmermaid CLI side-loads it including all its dependencies.
To **extract the type info from the source assembly**, ILSpy side-loads it including all its dependencies.
The extracted type info is **structured into a model optimized for the HTML diagrammer** and serialized to JSON. The model is a mix between drop-in type definitions in mermaid class diagram syntax and destructured metadata about relations, inheritance and documentation comments.
@ -16,9 +16,9 @@ And what's the point? Like any other hand-crafted documentation, **they're alway
@@ -16,9 +16,9 @@ And what's the point? Like any other hand-crafted documentation, **they're alway
After a while their usability becomes a function of **how much time you want to spend maintaining** them.
Also, they're next to useless in conversations about the *boundaries* of whatever subdomain or Aggregate you're looking at - because they **lack the interactivity to let you peek beyond the boundary**.
**netAmermaid** helps you create useful on-the-fly class diagrams within seconds in two simple steps:
**ILSpy** helps you create useful on-the-fly class diagrams within seconds in two simple steps:
1. Point the **command line tool** at an assembly to extract its type information
1. Point the [**command line tool**](https://github.com/icsharpcode/ILSpy/tree/master/ICSharpCode.ILSpyCmd#readme) at an assembly to extract its type information
and **build a [HTML5](https://en.wikipedia.org/wiki/HTML5#New_APIs) diagramming app** from it.
To get it hot off your latest build, you can script this step and run it just before using the diagrammer - or
hook it into your build pipeline to automate it for Continuous Integration.
@ -29,15 +29,15 @@ or export it as either SVG, PNG or in [mermaid class diagram syntax](https://mer
@@ -29,15 +29,15 @@ or export it as either SVG, PNG or in [mermaid class diagram syntax](https://mer
If [**XML documentation comments** are available for the source assembly](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/#create-xml-documentation-output), they're **used to annotate types and members on the generated diagrams**. Commented symbols show up highlighted, making the documentation accessible on hover.
What netAmermaid offers is an **overview** over types, their members and **relations** and the ability to **unfold the domain** along them until you have enough **context** to make an informed decision. Use it as
Generated diagrammers offer an **overview** over types, their members and **relations** and the ability to **unfold the domain** along them until you have enough **context** to make an informed decision. Use them as
- a **mental mapping** tool to get your bearings in an **unknown domain**.
- a **communication** tool for **your own domain** - when talking about the bigger picture with your team mates or even non-technical shareholders like product owners and users.
# Check out the demo
Have a look at the diagrammer generated for [SubTubular](https://github.com/h0lg/SubTubular):
It's got some [type relations](https://raw.githack.com/h0lg/SubTubular/netAmermaid2/netAmermaid/class-diagrammer.html?d=LR&i=tim&t=Caption-CaptionTrack-PaddedMatch-IncludedMatch-Video-VideoSearchResult-CaptionTrackResult)
and [inheritance](https://raw.githack.com/h0lg/SubTubular/netAmermaid2/netAmermaid/class-diagrammer.html?d=LR&i=tim&t=RemoteValidated-SearchChannel-SearchCommand-Shows-SearchPlaylist-SearchPlaylistCommand-OrderOptions-SearchVideos)
Have a look at the diagrammer generated for the [ICSharpCode.Decompiler.TypeSystem namespace](https://github.com/icsharpcode/ILSpy/tree/master/ICSharpCode.Decompiler/TypeSystem):
It's got some [type relations](https://ilspy.net/ICSharpCode.Decompiler/diagrammer/index.html?t=IType-ITypeDefinition&d=LR&i=tm)
and [inheritance](https://ilspy.net/ICSharpCode.Decompiler/diagrammer/index.html?t=IEntity-IEvent-IField-IMember-IMethod-IModule-INamedElement-INamespace-IParameter-IProperty-ISymbol-IVariable&d=LR&i=tim)