Code Monkey home page Code Monkey logo

dotnet's Introduction

Structurizr for .NET

This repo is a port of the Structurizr for Java library but has drifted out of sync, and some newer features are missing. I will continue to support the Java-based Structurizr tooling but, due to time constraints, I will no longer be making updates to this codebase or releases via NuGet. The code remains open source, so you are welcome to fork the repo and make your own releases.

Unless you are planning to use .NET code to generate parts of your software architecture model, the Structurizr DSL is the recommended tooling for authoring Structurizr workspaces.

A quick example

As an example, the following C# code can be used to create a software architecture model that describes a user using a software system.

Workspace workspace = new Workspace("Getting Started", "This is a model of my software system.");
Model model = workspace.Model;

Person user = model.AddPerson("User", "A user of my software system.");
SoftwareSystem softwareSystem = model.AddSoftwareSystem("Software System", "My software system.");
user.Uses(softwareSystem, "Uses");

ViewSet viewSet = workspace.Views;
SystemContextView contextView = viewSet.CreateSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");
contextView.AddAllSoftwareSystems();
contextView.AddAllPeople();

Styles styles = viewSet.Configuration.Styles;
styles.Add(new ElementStyle(Tags.SoftwareSystem) { Background = "#1168bd", Color = "#ffffff" });
styles.Add(new ElementStyle(Tags.Person) { Background = "#08427b", Color = "#ffffff", Shape = Shape.Person });

The view can then be exported to be visualised using the Structurizr cloud service or an on-premises installation.

Table of contents

dotnet's People

Contributors

briggysmalls avatar coldacid avatar dependabot[bot] avatar grudolf avatar lbragaglia avatar lniedzielski avatar malclear avatar simonbrowndotje avatar simonedamico 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dotnet's Issues

Null reference in GetWorkspace when downloaded workspace isn't encrypted

Hi,
I'm getting a null reference error in GetWorkspace when trying to upload a client side encrypted workspace.
The workspace is new and empty.
In the Java version there is a check for encryption on the returned workspace - this check is missing in the .Net version.
The result is that it is not possible to create an encrypted workspace.

WorkspaceUtils does not load containers' properties

After use the method LoadWorkspaceFromJson from the WorkspaceUtils, the containers from the loaded workspace don't contain the previous saved properties.

I've checked that all properties are in the JSON file but not in the objects after deserialization.

Regards.

Interfaces as components and 'orphan implementation components'

Hi all!

I suppose that this 'issue' is affecting to many people but maybe they have found some workarounds or the API supports it but I haven't found how to do it.

Let me explain the case...

Inside my containers I have many components related to each other with no problem but sometimes those components are declared as interfaces.
I'm using interfaces because they could be instanced by objects that implement the mentioned interface for different purposes and behaviors.

I haven't found how to make relationships programmatically between 'component interfaces' and the components that implement them.
The 'implementations components' appears on the chart as orphans components.

Is it possible? If not, could it be a new feature?

I've attached a quick schema just to clarify it.

image

Only works for .Net 4.5.2 or greater

I'm trying to use it un a project using .NET 4.5 and it fails because it forcefully requires at least .NET 4.5.2. Can you downgrade the framework? Thank you.

Question: Is it possible to render a local workspace model, and not saving it to my cloud workspace?

Hi, I just aqquired a Structurizr cloud license, but I have some problems in making the implementation that fullfill my requirements.

So first off, I am making a website that relies on Structurizr to render and show business models (a markets stakeholders and their relationships) on my site primarily through the provided iframe and image render functionality. This is used for educational and business uses. At first i used the PlantUML extension, which worked well, but it sadly was way to static, and did not allow the representation that I need. I now moved to a cloud plan to use the Structurizr rendered C4 model, which is perfect for my needs.

Problem is I only need to render these models with Structurizr, but I am not interested in saving the data to a workspace for the following reason:

I need an unlimited amount of workspaces in that case, as each and every user should be able to create whatever amount of business models on the site (a business model == a workspace.Model in my situation).

So my question is if it is possible to render a local workspace model with the Structurizr C4 Model, without needing to push it to my cloud workspace. If so how, and are there any disadvantages? As the only other solution I see is to use my workspace as a temporary "server" to render a pushed model. This would most certainly give me problems with multiple concurrent users, and it is inherently a very hacky solution I don't like.

problem loading workspace in Structurizr

I have problem loading workspace in Structurizr ,
When I do the upload model, to specific workspace, let’s say Workspace ID: 1

I get following error window

error

Performing upload to alternate workspace (Id: 2), comletes sucessfully

We have updated structurizr to the latest version, build 1765 and We have updated .NET client library to the latest version (v0.9.5), but the problem exists.
Could you help me?
Thanks in advance !

UsesComponent how to use correctly

Hello

I'm new to structurizr and try to etablish a relationship between a controller and a model.

This looks this way:

    [Component(Description = "Account controller", Technology = "C#")]
    [UsedByPerson("User", Description = "Uses")]
    public class AccountController : Controller
    {
        private readonly UserManager<CustomUser> _userManager;
    }

My model is CustomUser:

    [Component(Description = "Custom user model", Technology = "C#")]
    public class CustomUser : IdentityUser
    {
        public string FirstName { get; set; }
    }

In this case I have no chance to use UsesComponent, if I want to show the relationship, I need to use:

        [UsesComponent("Uses model", Technology = "C#")]
        private CustomUser userForDocumentationOnly = null; 

in the controller. This seems very ugly and I'm sure, I'm doing something wrong. Whats the correct approach?

Thanks

client.PutWorkspace(Structurizr.WorkspaceId, structurizrDiagram.Workspace); fails in a docker container.

For some reason running the application with docker fails to put the workspace. I use docker in my CI flow with Azure, so it would really be ideal if this worked.
I have my ApiKey, ApiSecret and workspace set correctly, so I really don't understand why.

The error given is this:

{
    "model": {
        "people":[],
        "softwareSystems":[ {
            "location":"Unspecified",
            "containers":[],
            "name":"«Customer»\nsad",
            "description":"dada",
            "relationships":[ {
                "description":"dadas",
                "sourceId":"1",
                "destinationId":"1",
                "technology":"Goods",
                "id":"2",
                "tags":"Relationship,Synchronous,Green",
                "properties": {}
                ,
                "perspectives": []
            }
            ],
            "id":"1",
            "tags":"Element,Software System,Customer",
            "properties": {}
            ,
            "perspectives":[]
        }
        ],
        "deploymentNodes":[]
    }
    ,
    "views": {
        "systemLandscapeViews":[],
        "systemContextViews":[ {
            "animations":[],
            "key":"hidden",
            "softwareSystemId":"1",
            "description":"sad",
            "title":"dsad",
            "elements":[ {
                "properties": {}
                ,
                "id": "1"
            }
            ],
            "relationships":[ {
                "properties": {}
                ,
                "id": "2"
            }
            ],
            "automaticLayout": {
                "vertices": true, "rankSeparation": 300, "nodeSeparation": 600, "edgeSeparation": 200
            }
        }
        ],
        "containerViews":[],
        "componentViews":[],
        "dynamicViews":[],
        "deploymentViews":[],
        "filteredViews":[],
        "configuration": {
            "styles": {
                "relationships":[ {
                    "tag": "DodgerBlue", "color": "#1e90ff"
                }
                ,
                {
                    "tag": "Green", "color": "#008000"
                }
                ,
                {
                    "tag": "Blue", "color": "#0000ff"
                }
                ,
                {
                    "tag": "Purple", "color": "#800080"
                }
                ,
                {
                    "tag": "DarkOrange", "color": "#ff8c00"
                }
                ,
                {
                    "tag": "Relationship", "routing": "Direct"
                }
                ],
                "elements":[ {
                    "tag": "Element", "background": "#438dd5", "color": "#ffffff", "metadata": false
                }
                ]
            }
            ,
            "branding": {}
            ,
            "terminology": {}
            ,
            "lastSavedView":"Test",
            "viewSortOrder":"Default"
        }
    }
    ,
    "documentation": {
        "sections": [], "decisions": [], "images": []
    }
    ,
    "id":51859,
    "name":"dsad",
    "description":"sad",
    "lastModifiedDate":"2020-05-04T11:11:11.8121127Z",
    "lastModifiedAgent":"structurizr-dotnet/0.9.6",
    "configuration": {
        "users": []
    }
}

{
    "success": false, "message": "The workspace could not be updated - please try again."
}

Do you know why this happens? Just to clarify this works perfectly well without docker using the same environment variables.

How to set location of elements in a view?

Hi,

I am trying to set the position of the elements in a diagram programmatically.
Right now, what structurizr generates looks like this
"elements": [ { "id": "33" }, { "id": "1" }, { "id": "2" }, { "id": "3" }, { "id": "75" } ]
If I upload the workspace to structurizr.com & use the editor to drag elements around the each object in the json has x and y property.

My question is how do i set the position programmatically without going through the editor?

I've tried finding the ElementView in View.Elements & then setting the X and Y but it doesn't work.

Thanks! :)

Attributes

Hi is there any plans with the .Net version to allow custom attributes to be added to classes so that they can be read e.g "Description", "Technology", "Uses". or have I just missed something

Updating diagram without running the code

Hi simon, my problem is more a question than an issue. I work for a company in Brazil and we are going to use structurizr for our software architecture projects. Now we are using .NET in visual studio code to build our diagrams, but we need to run the code to update it in structurizr. Is there anyway to update the diagram when building the project without needing to run it? Like updating when saving the file or in real-time?

Replace TypeBasedComponentFinderStrategy's use of reflection

Solutions with multiple projects that run on conflicting runtimes or have conflicting dependencies can't be analyzed with the existing TypeBasedComponentFinderStrategy, due to the fact that the strategy uses reflection and therefore requires all assemblies to be analyzed to be referenced by the project containing Structurizr code. For example, Xamarin projects cannot be analyzed for components due to the fact that each platform supported by Xamarin has its own platform-specific runtime on which the platform-specific apps are built; these projects cannot be added as references to a single project for analyzing the code for components.

Given the analysis abilities of the Roslyn compiler services, it may be better to use it instead and analyze the actual project source code instead of already-compiled assemblies that may not be loadable into the current process. This could also allow for the removal of AppDomain related code in the Structurizr .NET assembly which currently prevents its use with UWP projects (AppDomains are not supported in .NET Core or UWP).

Alternatively, if assemblies can be loaded without requiring references to them, as dotPeek or Reflector do things, then the issue can we solved without running everything through Roslyn although successful builds of each assembly in the project will still be required.

Publish latest to Nuget?

Hi Simon,

Would it be possible for you to cut a release and publish it to Nuget? I would like to use the Documentation feature.

Thanks!

Adding or changing the URL for an Icon in an ElementStyle resets the positions of all elements when uploaded

I have updated to version 0.9.1 and added icons to three of my ElementStyles. Each time I add or make a change to the Icon on one of these ElementStyles, then upload the workspace, the positions of all elements in all diagrams are reset, and all appear in the top left corner.

This is unusable as it means redesigning every diagram every time a new icon change is made.

Please tell me if there is a setting/fix/workaround for this.

How to change Component's/Container's Name

Hi,

Is it possible to change Component's or Container's name without re-creating it ? I see that the Name property has internal set and I could not find an easy way to change the name. Do you have any recommendation about it ?

export to excel

Hi,
can I export structurizr container diagrams to excel?
Thanks

Bug when exporting SystemLandscapeView to PlantUML

When running the BigBankPcl example through the PlantUMLWriter the SystemLandscapeView is exported with a bug.

As of commit: 7ec799e

Actual

Notice the line package Big Bank plc {

@startuml
title System Landscape for Big Bank plc
caption The system landscape diagram for Big Bank plc.
actor "Personal Banking Customer" <<Person>> as 1
package Big Bank plc {
...
}
...
@enduml

Expected

Based on the other lines with package I expect it should have been package BigBankPlc {

@startuml
title System Landscape for Big Bank plc
caption The system landscape diagram for Big Bank plc.
actor "Personal Banking Customer" <<Person>> as 1
package BigBankPlc {
...
}
...
@enduml

DefaultLayoutMergeStrategy breaks in certain scenarios

I've been using a locally built version of the Structurizr client (I needed the SoftwareSystemInstance and couldn't wait for the Nuget), and I've since noticed that the DefaultLayoutMergeStrategy sometimes breaks on merging relationships (in method findRelationshipView()). Not fully sure in which scenarios exactly, but obviously in case of a pre-existing view that's undergoing change. It fails on retrieving elements from the elementMap; somehow an element that is expected is not available in the elementMap.

I can simply work around the error by stepping over the offending line and straight to the line that returns null, which leads to the expected result, but that's obviously just a workaround. I could create my own merging strategy to correct this behavior, but I imagine that this is not supposed to happen at all, i.e. it's a bug.

KeyNotFound-Exception while reflecting Generic Types

Dear Commuity,

I've an issue when trying to match Components which are based on Generics. It throws a KeyNotFound-Exception inside FindVisibility at Type type = _types[typeName];

Call-Stack:
ReflectionTypeRepository.FindVisibility
=> TypeMatcherComponentFinderStrategy.AfterFindComponents (while iterating through _supportingTypesStrategies)

The problem is that the type.AssemblyQualifiedName can't be matched using the previously generated dictionary.

Here's the code snippet responsible for generating the dictionary:

public ReflectionTypeRepository(string namespaceName, HashSet<Regex> exclusions)
        {
           ...

            IEnumerable<Type> types = from a in AppDomain.CurrentDomain.GetAssemblies()
                                    from t in a.GetTypes()
                                    where InNamespace(t)
                                    select t;

            foreach (Type type in types)
            {
                if (type.AssemblyQualifiedName != null)
                {
                    _types.Add(type.AssemblyQualifiedName, type);
                }
            }
        }

Here's the snippet, where it fails:

public string FindVisibility(string typeName)
{
  Type type = _types[typeName];
...
}

Why does it fail?
Well, while looking at the types saved inside the dictionary, I realized that the type.AssemblyQualifiedName-Strings aren't what I expected them to be: There are some odd characters mixed in the type names. Here's the list of types inside the dictionary:
TypeList_Dictionary.txt

Where are the odd characters coming from?
After some research I now know, that the Compiler generates some types on his own on several occasions. One of those ocassions are Closures. Here's a post presenting a list of compiler generated characters/words inside type names:
https://stackoverflow.com/questions/2508828/where-to-learn-about-vs-debugger-magic-names

I need your help!
Unfortunately I can't come up with a solution which is both sufficient for similar issues in the future and doesn't imply a major change in the code. So I'm really looking foward to your thoughts.

Add Intellisense info to all members

Hi,

Could you add Intellisense documentation to al public members/properties/etc. of the library? It is now sometimes hard to understand what the meaning is of all the different members.

Thanks

PlantUML does not show relationship's technology

I'm not sure if this is by design or not, but I wanted to define a relationship with a technology but without a description. The observed behaviour appears to me like a bug.

Expected

If a relationship is created that has a technology but no description, for the technology to be rendered on the diagram.

For example:

@startuml
title Test
component "A" <<Container>> as 1
component "B" <<Container>> as 2
1 ..> 2 :<<mytech>>
@enduml

Actual

The technology field is hidden unless the description is also provided.

Inspecting the UML output reveals that the technology is printed, but doesn't get rendered as there is no colon visible.

Actual output for example above (notice missing colon on relationship label):

@startuml
title Test
component "A" <<Container>> as 1
component "B" <<Container>> as 2
1 ..> 2  <<mytech>>
@enduml

See offending line here:

HasValue(relationship.Description) ? ": " + relationship.Description : "",

Could not load type 'Structurizr.Taggable' from assembly 'Structurizr.Core, Version=0.9.0.0

Hi,

I am trying to create a small example of a Dgml using the most recent nuget packages and am getting:

Could not load type 'Structurizr.Taggable' from assembly 'Structurizr.Core, Version=0.9.0.0

When I call:
var dgml = workspace.ToDgml();

Code is:
Workspace workspace = new Workspace("Getting Started", "This is a model of my software system.");
Model model = workspace.Model;

		Person user = model.AddPerson("User", "A user of my software system.");
		SoftwareSystem softwareSystem = model.AddSoftwareSystem("Software System", "My software system.");
		user.Uses(softwareSystem, "Uses");

		ViewSet viewSet = workspace.Views;
		SystemContextView contextView = viewSet.CreateSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");
		contextView.AddAllSoftwareSystems();
		contextView.AddAllPeople();

		Styles styles = viewSet.Configuration.Styles;
		styles.Add(new ElementStyle(Tags.SoftwareSystem) { Background = "#1168bd", Color = "#ffffff" });
		styles.Add(new ElementStyle(Tags.Person) { Background = "#08427b", Color = "#ffffff", Shape = Shape.Person });

		// Convert to DGML
		var dgml = workspace.ToDgml();
		// Write to file
		dgml.WriteToFile("example.dgml");

Missing dotnet reflection methods in Structurizr.Core-0.6.0 nuget package

Hi,
I just upgraded the Structurizr nuget package in my project to version 0.6.0 (previous version I worked with was 0.4.0.1). In this version, the reflection part no longer works, because (At least) the following reflection types seem to be missing:

  • TypeBasedComponentFinderStrategy
  • ExtendsClassTypeMatcher
    I see that they are still present in the git repository, so either I'm doing something wrong, or something is wrong with the nuget package.

I checked that everything is working normally until version 0.5.1. So, the change has been in the latest release of Structurizr.

Any ideas what this can be?

Views aren't positioning anything

Hopefully this is just me misunderstanding the documentation but using BigBankPlc.cs for example produces a diagram that looks like
image

I cannot find any documentation on how to automatically position them (which both the documentation and the example has no code about positioning them) or how I would even manually do this.

The X/Y position isn't exposed when you add the components and if you retrieve the Elements you get a copy so you can't directly set the X/Y position.

Can someone point me in the correct direction to produce an identical diagram to the ones in the example documentation?

unable to add reflection package version 0.7.0

Attempting to gather dependency information for package 'Structurizr.Reflection.0.7.0' with respect to project '*********************', targeting '.NETFramework,Version=v4.6.1'
Gathering dependency information took 1.08 sec
Attempting to resolve dependencies for package 'Structurizr.Reflection.0.7.0' with DependencyBehavior 'Lowest'
Unable to resolve dependencies. 'Newtonsoft.Json 11.0.2' is not compatible with 'Structurizr.Core 0.7.0 constraint: Newtonsoft.Json (>= 10.0.3)'.

SoftwareSystemInstance support

Hi all,
First of all thanks for the work you've put into this project.

Do you have any plans for SoftwareSystemInstance support in .NET?
AFAIK it is supported in DSL and Java.

Regards,
Sergii

Should I commit json output files

Hi. Every time I run the app to publish the diagrams, a JSON files gets created. Is it intended to be committed to my repository? Or maybe it's possible not to have it created in the first place?

System.Collections.Generic.KeyNotFoundException when getting a workspace

I'm testing Structurizr with Free plan and I regularly receive an error like that:

System.Collections.Generic.KeyNotFoundException: The given key '13' was not present in the dictionary. 
at System.Collections.Generic.Dictionary`2.get_Item(TKey key) 
at Structurizr.Model.GetElement(String id) 
at Structurizr.ViewSet.HydrateView(View view) 
at Structurizr.ViewSet.Hydrate() 
at Structurizr.Workspace.Hydrate() 
at Structurizr.IO.Json.JsonReader.Read(StringReader reader) 
at Structurizr.Api.StructurizrClient.GetWorkspace(Int64 workspaceId) 

I have 2 programs.

  • Program 1 creates a system view and some doc.
  • Program 2 creates a component view.

The error occurs after running Program 2 a few times (2, 3, sometimes more). Before the error the component view in Cloud looks ok. After the error occurred the component view in Cloud seems broken (some elements are missing).

The general structure of Program 2 is:

var c= new StructurizrClient(ApiKey, ApiSecret);
var ws = c.GetWorkspace(WorkspaceId);
var model = ws.Model;

var system = model.GetSoftwareSystemWithName("AAA");
if (system == null)
    system = model.AddSoftwareSystem("AAA", "");

var container = system.GetContainerWithName("Some container");
if (container == null)
   container = system.AddContainer("Some container", "", ".NET Core 2.2");

container.Components.Clear();

...
var controller = container.AddComponent("MySuperController", controllerType, null, ".NET Core API");

...
var queryHandler = container.AddComponent(name, type, null, "CQRS Query Handler");
controller.Uses(queryHandler, "Read data with");
...

var componentView = ws.Views.GetViewWithKey("Components") as ComponentView;

if (componentView == null)
   componentView = ws.Views.CreateComponentView(container, "Components", "");

componentView.AddAllElements();

AutoLayout

Whenever I run my .net core app to update the model, all my diagrams revert to being all bunched up. I have to edit the diagram and click on "AutoLayout". I've looked, but I can't find the method to call to do perform an auto-layout function.

problem loading workspace in Structurizr

HI
have problem loading workspace in Structurizr ,
When I do the upload model, to specific workspace, let’s say Workspace ID: 3

I get following error window
image

Performing upload to alternate workspace (Id: 2), comletes sucessfully

Could you help me?
Thanks in advance !

Add support for changing the Container tag string

I'd like to change the Container tag from "Container" to "Process" to avoid confusion with Docker containers.

Would it be possible to add support for this? or any guidance on how to go about it if i'd like to do it myself?

Unhandled exception when running Structurizr client with .NET Core 3.1.2

My code worked fine with .NET Core 2.2 but is now failing with .NET Core 3.1. It ran successfully the first time to create the models in the workspace; but every subsequent run (to update the model) fails with the following error:

C:\Users\grahae\gitrepos\proj\structurizr>dotnet run --framework=netcoreapp3.1
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at Structurizr.ViewSet.Hydrate()
at Structurizr.Workspace.Hydrate()
at Structurizr.IO.Json.JsonReader.Read(StringReader reader)
at Structurizr.Api.StructurizrClient.GetWorkspace(Int64 workspaceId)
at Structurizr.Api.StructurizrClient.PutWorkspace(Int64 workspaceId, Workspace workspace)
at Company.Program.Main() in C:\Users\grahae\gitrepos\proj\structurizr\Program.cs:line 25

My Program.cs code:

    class Program
    {
        private static IConfigurationRoot Configuration;        
        static void Main()
        {
            // read user secrets as part of initial set-up
            var builder = new ConfigurationBuilder();
            builder.AddUserSecrets<Program>();
            Configuration = builder.Build();
            // parse secret values from configuration variables
            long workspaceId = long.Parse(Configuration["Structurizr_WorkspaceId"]);
            string apiKey = Configuration["Structurizr_APIkey"];
            string apiSecret = Configuration["Structurizr_APIsecret"];
            // connect to Structurizr workspace
            StructurizrClient structurizrClient = new StructurizrClient(apiKey, apiSecret);
            // update Structurizr workspace with new diagrams
            structurizrClient.PutWorkspace(workspaceId, proj.Create());
        }
    }

My proj.Create() method:

        public static Workspace Create()
        {
                Workspace workspace = new Workspace("Company Landscape", "A C4 model of the entire Company Landscape.");
                Model model = workspace.Model;
                ViewSet views = workspace.Views;
        
                model.Enterprise = new Enterprise("Company");
        
                // people
                ...
                return workspace;
        }

I set my secrets like this:

dotnet user-secrets set Structurizr_WorkspaceId STRUCTURIZR_WORKSPACEID
dotnet user-secrets set Structurizr_APIkey STRUCTURIZR_APIKEY
dotnet user-secrets set Structurizr_APIsecret STRUCTURIZR_APISECRET

DynamicView with mutiple container

Hello,

I would like to add into a DynamicView multiple containers.

My use case is this following workflow:

  • MobileApp uses Api1 [container: API]
  • Api1 sends a message/event to BusXxx [container: events]

Why this simple scenario cannot be done?

Does not support UWP projects

The current version of Structurizr package cannot be added to UWP projects:

Package Structurizr.Core 0.4.0.1 is not compatible with uap10.0 (UAP,Version=v10.0). Package Structurizr.Core 0.4.0.1 supports: net40 (.NETFramework,Version=v4.0)

New build/deploy flow for NuGet?

I hope I'm not stepping on your toes with this, but I took some time this weekend to see how to get NuGet packages built automatically for the Structurizr .NET assemblies, and I think I have something workable in my new-build-script branch. It uses Appveyor instead of Travis CI to do builds, but handles build, test, and packaging properly. You can check out the build log and results at https://ci.appveyor.com/project/coldacid/structurizr-dotnet

The config for Appveyor uses git tags to determine the version to set, or relies on whatever version is in the .csproj files. The new style projects use a combination of VersionPrefix and VersionSuffix properties to determine the version for use in the assembly metadata as well as for NuGet packages, and this configuration will add a "pre-" suffix to non-tagged builds. It seems a bit jury-rigged since the dotnet pack CLI command doesn't properly handle version suffixes for project references and so has to use dotnet msbuild instead; however, the resulting packages have the correct version and reference metadata and should work well together.

This should be easily workable although the main version number and release notes will have to be updated in the .csproj files themselves for every release (the ReleaseNotes property before committing and tagging the release commit, and VersionPrefix immediately after so new builds don't get versions that would stick them as pre-release builds; this is why it's already set to 0.6.0 in the project files).

Create interfaces for all main components: e.g. IPerson, ISofwareSystem

Having classes Person and SoftwareSystem sealed without public interface makes it hard to implement any kind of extensibility.

I tried to introduce the concept of UseCase (not to overload system overview diagram with all possible connections), but in order to do that it would be nice to wrap and track somehow which relationships and which entities are used in which use-cases.

I can see two possible solutions:

  1. Make classes non-sealed and allow to override public methods.
  2. Introduce interfaces IPerson, ISoftwareSystem etc so that it is possible to implement Decorator pattern to track which entities are used and which relations are created in scope of every use-case.

PS: I might be missing something because I'm very new to Structurizr. I love the concept, but really missing a way to group use-cases.

Views should have an AddRelevantElements method

Hi. I am well-aware I might be missing a trick here, but I feel like I'm unable to generate C4 model views as they are spec'd. Thanks in advance for any attention you give this!

Context

The C4 model defines a scope, primary and secondary elements for all diagrams. An advantage of model based systems engineering, as this project provides, is that the primary and secondary elements can be inferred when given a scope.

For example, a Container diagram should contain:

  • [Primary elements] All Containers that are within the Software System scope (but none from outside it)
  • [Secondary elements] All Software Systems, and People that the aforementioned Containers connect to

The scope (here a SoftwareSystem) could be used to walk its primary elements (SoftwareSystem.Elements) and add relevant secondary elements.

Current

Currently views provide an AddNearestNeighbours(Element element) method, which add all related elements at the same depth and above.

The effect is that related elements at the same depth but with different parents, which should never be visible (see Primary elements rule), are added to the view. For example if a Component in one Container is connected to a Component in a different Container it is still added to the view.

Alternatively, AddAllElements correctly adds relevant Containers/Components, but adds all People/Software systems regardless of whether they are connected to the primary objects or not.

Proposal

Provide a new function on views that add all the relevant elements. For example, for the ComponentView:

/// <summary>
/// Adds relevant elements
/// </summary>
/// <remarks>
/// <para>
/// Primary elements: Adds Components within the container in scope.
/// </para>
/// <para>
/// Supporting elements: Containers (within the software system in scope) plus people and software systems directly connected to the components.
/// </para>
/// </remarks>
public void AddRelevantElements()
{
    // Add all components within the scoped container (primary elements)
    AddAllComponents();
    // Add containers within the the software system
    AddAllContainers();

    // Add people and software systems that are connected to primary elements
    foreach (Component component in Container.Components)
    {
        AddNearestNeighbours(component, typeof(Person));
        AddNearestNeighbours(component, typeof(SoftwareSystem));
    }
}

HttpClient shouldn't be disposed all the time

Hi,

Thanks for the great software and extra thanks for providing .net client libraries. I have been looking through the code and I noticed that HttpClient gets disposed every time a call is made to either: Get, Put. Lock or Unlock Workspace methods. Is there a reason for this decision, or it's just an oversight?

HttpClient should not be disposed on each call since that can lead to port exhaustion issues.
Preferred way would be using IHttpClientFactory, but having a static instance can also work in lots of scenarios and I would say in the case of Structurizr as well.

I would be wiling to contribute with a PR to fix this if you consider it an issue that should be fixed.

Kind regards,
Mirza

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.