Coder Social home page Coder Social logo

dotmorten / dotnetomdgenerator Goto Github PK

View Code? Open in Web Editor NEW
183.0 13.0 19.0 1 MB

A Roslyn-based cross-platform tool that generates an object model diagram from a set of C# source files or assemblies

License: Apache License 2.0

C# 83.13% HTML 16.87%
model-diagram roslyn cross-platform dotnet analyzer object-model object-model-diagram csharp tool

dotnetomdgenerator's Introduction

.NET Object Model Diagram Generator

A cross-platform Roslyn-based tool that generates an object model diagram of a set of C# source files and/or .NET assemblies

Sponsoring

If you like this library and use it a lot, consider sponsoring me. Anything helps and encourages me to keep going.

See here for details: https://github.com/sponsors/dotMorten

Install

Run the following command from commandline (requires .NET Core 2.1 installed):

dotnet tool install --global dotMorten.OmdGenerator

Usage:

generateomd /source=[source folder] /compareSource=[oldSourceFolder] /preprocessors=[defines] /format=[html|image] /showPrivate /showInternal

Required parameters:
  source            Specifies the folder of source files to include for the object model.
                    Separate with ; for multiple folders
or
  assemblies        Specifies a set of assemblies to include for the object model.
                    Separate with ; for multiple assemblies, or use wildcards
				
Optional parameters:
  compareSource     Specifies a folder of old source to compare and generate a diff model
                    This can be useful for finding API changes or compare branches
  compareAssemblies Specifies a set of old assemblies to compare and generate a adiff model.
                    Separate with; for multiple assemblies, or use wildcards
  format            Format to generate: 
                       'html' a single html output (html is default)
                       'md' for markdown you can copy-paste to for instance GitHub.
		       Specify multiple with a semicolon seperator, and use an output filename without extension
  preprocessors     Define a set of preprocessors values. Use ; to separate multiple
  exclude           Defines one or more strings that can't be part of the path Ie '*/Samples/*;*/UnitTests/*'
                    (use forward slash for folder separators)
  regexfilter       Defines a regular expression for filtering on full file names in the source
  showPrivate       Show private members (default is false)
  showInternal      Show internal members (default is false)
  output            Filename to write the output to (extension is optional, but exclude the extension if you specify multiple formats)

NuGet

As an alternative you can also reference a NuGet package to your class library, and set up a post-build script to generate an Object Model Diagram HTML file:

Install-Package dotMorten.OmdGenerator 

Add the following to your project:

  <Target Name="GenerateObjectModel" AfterTargets="Compile">
    <Exec Command="dotnet &quot;$(DotNetOMDGeneratorToolPath)&quot; /source=&quot;@(Compile)&quot; /preprocessors=&quot;$(DefineConstants)&quot; /output=&quot;$(OutputPath)$(TargetName)&quot;" WorkingDirectory="$(ProjectDir)" />
  </Target>
 

An example of a generated output for all of .NET Core can be found here.

It can also be used to compare two folders (for instance two separate branches) and only show changes to the API. Here's an example of .NET CoreFX v2.0 vs Master.

Screenshot

Examples

Generate OMD for .NET Core FX source code, and ignore ref and test folders:

generateomd /source=c:\github\dotnet\corefx\src /exclude="*/ref/*;*/tests/*;*/perftests/*"

Compare .NET CoreFX Master with v2.0.0 repo branches directly from their Github zipped downloads:

generateomd /source=https://github.com/dotnet/corefx/archive/master.zip /compareSource=https://github.com/dotnet/corefx/archive/release/2.0.0.zip /exclude="*/ref/*;*/tests/*;*/perftests/*"

What's new in Xamarin.Forms? Compare assemblies from the nuget cache:

generateomd /assemblies=%USERPROFILE%\.nuget\packages\xamarin.forms\3.3.0.912540\lib\netstandard2.0\*.dll /compareAsssemblies=%USERPROFILE%\.nuget\packages\xamarin.forms\3.2.0.871581\lib\netstandard2.0\*.dll

dotnetomdgenerator's People

Contributors

dotmorten avatar skendrot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dotnetomdgenerator's Issues

Add Mermaid output for markdown support

Suggestion: Use the new Tuple syntax with names

e.g.

    public static IEnumerable<(IMethodSymbol symbol, bool wasRemoved)> GetConstructors(this INamedTypeSymbol type, INamedTypeSymbol oldType)
    {
        if (oldType == null || type == null)
            return GetConstructors(type ?? oldType).Select(p => (p, type == null));
        var newMembers = GetConstructors(type);
        var oldMembers = GetConstructors(oldType);
        return newMembers.Except(oldMembers, Generator.MethodComparer.Comparer).Select(p => (p, false))
            .Union(oldMembers.Except(newMembers, Generator.MethodComparer.Comparer).Select(p => (p, true)))
            .OrderBy(t => t.symbol.Name);
    }

And none of that nasty Item1, Item2 stuff.

Is there a way to extend the code so that it also works with C# script?

Hi,

I'm using C# scripts in my application that are compiled by Roslyn. Because it are scripts the outer part of the script does not contain a class. So when I now try your tool it will always end up empty.

A C# script looks like this... it's entry point is Main()

using System;
using System.Collections.Generic;

// Wordt gebruikt door de GetPolisNumbersFromAttachments methode
private string _attachmentsText = null;

private struct DefinedFields
{
	public bool Found;
	public string Folder;
	public string DocumentInhoud;
	public string Zoekgegeven;
}

private string Property1
{
    get 
	{
		return "Hello";
	}
}


private string Method1(string prop1)
{
	return "Hello from method 1"
}

public void Main()
{
}

I'm trying to generate an OMD for this. But because there is no class around this it is always empty.

I already tried to do it this way

class Script { " + script + " }

But then I still don't have any methods

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.