Skip to content

Commit

Permalink
Merge pull request #38 from 8T4/refac/general-refactoring
Browse files Browse the repository at this point in the history
Refac/general refactoring
  • Loading branch information
yanjustino authored Dec 26, 2022
2 parents ebbbdc6 + f42049c commit 8f607d4
Show file tree
Hide file tree
Showing 153 changed files with 1,015 additions and 2,407 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
branches: [ main ]

env:
VERSION: 5.2.${{ github.run_number }}
CLI_VERSION: 1.2.${{ github.run_number }}-beta
VERSION: 6.0.${{ github.run_number }}
CLI_VERSION: 2.0.${{ github.run_number }}
NUGET_INDEX: https://api.nuget.org/v3/index.json
BUILD_TYPE: Release

Expand Down Expand Up @@ -37,9 +37,6 @@ jobs:
- name: Build
run: dotnet build --no-restore --configuration Release

- name: Unit Tests
run: dotnet test ./tests/**/*.UnitTests.csproj --no-restore

- name: Integrated Tests
run: dotnet test ./tests/**/*.IntegratedTests.csproj --no-restore

Expand Down
17 changes: 0 additions & 17 deletions C4Sharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C4Sharp", "src\C4Sharp\C4Sh
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C4Sharp.IntegratedTests", "tests\C4Sharp.IntegratedTests\C4Sharp.IntegratedTests.csproj", "{652679C0-4067-4ED5-8D97-48A765E7A965}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C4Sharp.UnitTests", "tests\C4Sharp.UnitTests\C4Sharp.UnitTests.csproj", "{4B6E0F06-65DA-43FB-A984-A08DC6B66665}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C4Sharp.Tools", "src\C4Sharp.Tools\C4Sharp.Tools.csproj", "{AEF17681-C9AB-4C49-8B06-06E5AF8C4237}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C4Bank.Deposit", "samples\C4Bank\C4Bank.Deposit\C4Bank.Deposit.csproj", "{DF24F4F5-0404-4B8F-9549-69222A1620A7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "C4Bank", "C4Bank", "{7F4EACE0-1CC1-44B0-A038-3D74E00A9572}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Basic", "Basic", "{EBA828C5-ACB9-4B6E-9513-BF4F612ECEAA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C4Sharp.Sample", "samples\Basic\C4Sharp.Sample\C4Sharp.Sample.csproj", "{CEAA41B3-F197-4663-A845-E4F5DB7DC2E8}"
Expand All @@ -36,18 +30,10 @@ Global
{652679C0-4067-4ED5-8D97-48A765E7A965}.Debug|Any CPU.Build.0 = Debug|Any CPU
{652679C0-4067-4ED5-8D97-48A765E7A965}.Release|Any CPU.ActiveCfg = Release|Any CPU
{652679C0-4067-4ED5-8D97-48A765E7A965}.Release|Any CPU.Build.0 = Release|Any CPU
{4B6E0F06-65DA-43FB-A984-A08DC6B66665}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4B6E0F06-65DA-43FB-A984-A08DC6B66665}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4B6E0F06-65DA-43FB-A984-A08DC6B66665}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4B6E0F06-65DA-43FB-A984-A08DC6B66665}.Release|Any CPU.Build.0 = Release|Any CPU
{AEF17681-C9AB-4C49-8B06-06E5AF8C4237}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AEF17681-C9AB-4C49-8B06-06E5AF8C4237}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AEF17681-C9AB-4C49-8B06-06E5AF8C4237}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AEF17681-C9AB-4C49-8B06-06E5AF8C4237}.Release|Any CPU.Build.0 = Release|Any CPU
{DF24F4F5-0404-4B8F-9549-69222A1620A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DF24F4F5-0404-4B8F-9549-69222A1620A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DF24F4F5-0404-4B8F-9549-69222A1620A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DF24F4F5-0404-4B8F-9549-69222A1620A7}.Release|Any CPU.Build.0 = Release|Any CPU
{CEAA41B3-F197-4663-A845-E4F5DB7DC2E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CEAA41B3-F197-4663-A845-E4F5DB7DC2E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CEAA41B3-F197-4663-A845-E4F5DB7DC2E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -56,10 +42,7 @@ Global
GlobalSection(NestedProjects) = preSolution
{B3850A7A-EBB2-4C33-827B-98B88901A638} = {758DA496-3186-4129-B0FA-5C3205B52763}
{652679C0-4067-4ED5-8D97-48A765E7A965} = {2EAFABEF-1FBB-4DEB-A620-52CBF42F1736}
{4B6E0F06-65DA-43FB-A984-A08DC6B66665} = {2EAFABEF-1FBB-4DEB-A620-52CBF42F1736}
{AEF17681-C9AB-4C49-8B06-06E5AF8C4237} = {758DA496-3186-4129-B0FA-5C3205B52763}
{7F4EACE0-1CC1-44B0-A038-3D74E00A9572} = {53454ACB-CE39-4F53-AB32-C28C15720537}
{DF24F4F5-0404-4B8F-9549-69222A1620A7} = {7F4EACE0-1CC1-44B0-A038-3D74E00A9572}
{EBA828C5-ACB9-4B6E-9513-BF4F612ECEAA} = {53454ACB-CE39-4F53-AB32-C28C15720537}
{CEAA41B3-F197-4663-A845-E4F5DB7DC2E8} = {EBA828C5-ACB9-4B6E-9513-BF4F612ECEAA}
EndGlobalSection
Expand Down
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public class ContainerDiagram : DiagramBuildRunner
protected override string Title => "C4Bank Context of Deposit Area";
protected override DiagramType DiagramType => DiagramType.Container;


protected override IEnumerable<Structure> Structures() => new Structure[]
protected override IEnumerable<Structure> Structures => new Structure[]
{
new Person("Customer", "Customer", "Bank Customer"),
new SoftwareSystem("OTBank.Finance", "Finance", "OTBank Finance System", Boundary.External),
Expand All @@ -57,7 +56,7 @@ public class ContainerDiagram : DiagramBuildRunner
),
};

protected override IEnumerable<Relationship> Relationships() => new[]
protected override IEnumerable<Relationship> Relationships => new[]
{
It("Customer") > It("OTBank.Finance") | "send deposit",
It("OTBank.Finance") > It<DepositReceived>() | ("POST", "HTTP"),
Expand All @@ -73,7 +72,6 @@ public class ContainerDiagram : DiagramBuildRunner
}
```
<small><strong>Code 1</strong> - container diagram as code</small>
<small>see the complete code [here](./samples/C4Bank/C4Bank.Deposit/Architecure/ContainerDiagram.cs)</small>

### Compiling
There are two strategies for compiling diagrams in your project: self-compiling and using the `C4SCLI` tool.
Expand All @@ -94,8 +92,6 @@ internal static class Program
new PlantumlSession()
.UseDiagramImageBuilder()
.UseDiagramSvgImageBuilder()
.UseStandardLibraryBaseUrl()
.UseHtmlPageBuilder()
.Export(diagrams);
}
}
Expand All @@ -107,7 +103,7 @@ internal static class Program

The `C4SCLI` can be used in DevOps pipelines, removing the need to manually compile diagrams. For this, install `C4SCLI` tool and execute de the following command:
```shell
$ c4scli build <solution path> [-o <output path>] [-d <html>]
$ c4scli build <solution path> [-o <output path>]
```
⚠️ *only compatible with projects using c4sharp version 5.0+*

Expand Down
21 changes: 11 additions & 10 deletions samples/Basic/C4Sharp.Sample/Diagrams/ComponentDiagram.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using C4Sharp.Diagrams;
using C4Sharp.Models;
using C4Sharp.Models.Relationships;
using C4Sharp.Elements;
using C4Sharp.Elements.Boundaries;
using C4Sharp.Elements.Relationships;
using C4Sharp.Sample.Structures;

namespace C4Sharp.Sample.Diagrams
Expand All @@ -26,7 +27,7 @@ public class ComponentDiagram: DiagramBuildRunner
protected override DiagramLayout FlowVisualization => DiagramLayout.LeftRight;
protected override bool LayoutAsSketch => true;

protected override IEnumerable<Structure> Structures() => new Structure[]
protected override IEnumerable<Structure> Structures => new Structure[]
{
Spa,
MobileApp,
Expand All @@ -35,12 +36,12 @@ public class ComponentDiagram: DiagramBuildRunner
Boundary(),
};

protected override IEnumerable<Relationship> Relationships() => new Relationship[]
protected override IEnumerable<Relationship> Relationships => new Relationship[]
{
(Spa > Sign)["Uses", "JSON/HTTPS"],
(Spa > Accounts)["Uses", "JSON/HTTPS"],
(MobileApp > Sign)["Uses", "JSON/HTTPS"],
(MobileApp > Accounts)["Uses", "JSON/HTTPS"],
Spa > Sign | ("Uses", "JSON/HTTPS"),
Spa > Accounts | ("Uses", "JSON/HTTPS"),
MobileApp > Sign | ("Uses", "JSON/HTTPS"),
MobileApp > Accounts | ("Uses", "JSON/HTTPS")
};

private static ContainerBoundary Boundary()
Expand All @@ -58,8 +59,8 @@ private static ContainerBoundary Boundary()
{
Sign > Security,
Accounts > MainframeFacade,
(Security > SqlDatabase)["Read & write to", "JDBC"],
(MainframeFacade > Mainframe)["Uses", "XML/HTTPS"]
Security > SqlDatabase | ("Read & write to", "JDBC"),
MainframeFacade > Mainframe | ("Uses", "XML/HTTPS")
}
};
}
Expand Down
36 changes: 19 additions & 17 deletions samples/Basic/C4Sharp.Sample/Diagrams/ContainerDiagram.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using C4Sharp.Diagrams;
using C4Sharp.Models;
using C4Sharp.Models.Plantuml;
using C4Sharp.Models.Plantuml.Constants;
using C4Sharp.Models.Relationships;
using C4Sharp.Diagrams.Interfaces;
using C4Sharp.Elements;
using C4Sharp.Elements.Boundaries;
using C4Sharp.Elements.Plantuml;
using C4Sharp.Elements.Plantuml.Constants;
using C4Sharp.Elements.Relationships;
using C4Sharp.Sample.Structures;

namespace C4Sharp.Sample.Diagrams
Expand All @@ -14,7 +16,7 @@ public class ContainerDiagram: DiagramBuildRunner
protected override string Title => "Container diagram for Internet Banking System";
protected override DiagramType DiagramType => DiagramType.Container;

protected override IEnumerable<Structure> Structures() => new Structure[]
protected override IEnumerable<Structure> Structures => new Structure[]
{
People.Customer,
Systems.BankingSystem,
Expand All @@ -28,23 +30,23 @@ public class ContainerDiagram: DiagramBuildRunner
)
};

protected override IEnumerable<Relationship> Relationships() => new[]
protected override IEnumerable<Relationship> Relationships => new[]
{
(People.Customer > WebApp)["Uses", "HTTPS"],
(People.Customer > Spa)["Uses", "HTTPS"],
(People.Customer > MobileApp)["Uses"],
People.Customer > WebApp | ("Uses", "HTTPS"),
People.Customer > Spa | ("Uses", "HTTPS"),
People.Customer > MobileApp | "Uses",

(WebApp > Spa)["Delivers"][Position.Neighbor],
(Spa > BackendApi)["Uses", "async, JSON/HTTPS"],
(MobileApp > BackendApi)["Uses", "async, JSON/HTTPS"],
(SqlDatabase < BackendApi)["Uses", "async, JSON/HTTPS"][Position.Neighbor],
WebApp > Spa | "Delivers" | Position.Neighbor,
Spa > BackendApi | ("Uses", "async, JSON/HTTPS"),
MobileApp > BackendApi | ("Uses", "async, JSON/HTTPS"),
SqlDatabase < BackendApi | ("Uses", "async, JSON/HTTPS") | Position.Neighbor,

(People.Customer < Systems.MailSystem)["Sends e-mails to"],
(Systems.MailSystem < BackendApi)["Sends e-mails using", "sync, SMTP"],
(BackendApi > Systems.BankingSystem)["Uses", "sync/async, XML/HTTPS"][Position.Neighbor]
People.Customer < Systems.MailSystem | "Sends e-mails to",
Systems.MailSystem < BackendApi | ("Sends e-mails using", "sync, SMTP"),
BackendApi > Systems.BankingSystem | ("Uses", "sync/async, XML/HTTPS") | Position.Neighbor
};

protected override IElementTag? SetTags()
protected override IElementTag SetTags()
{
return new ElementTag()
.AddElementTag("services", "#3F6684", shape: Shape.EightSidedShape);
Expand Down
21 changes: 11 additions & 10 deletions samples/Basic/C4Sharp.Sample/Diagrams/ContextDiagram.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using C4Sharp.Diagrams;
using C4Sharp.Models;
using C4Sharp.Models.Plantuml;
using C4Sharp.Models.Plantuml.Constants;
using C4Sharp.Models.Relationships;
using C4Sharp.Diagrams.Interfaces;
using C4Sharp.Elements;
using C4Sharp.Elements.Plantuml;
using C4Sharp.Elements.Plantuml.Constants;
using C4Sharp.Elements.Relationships;
using C4Sharp.Sample.Structures;

namespace C4Sharp.Sample.Diagrams
Expand All @@ -16,23 +17,23 @@ public class ContextDiagram : DiagramBuildRunner
protected override string Title => "System Context diagram for Internet Banking System";
protected override DiagramType DiagramType => DiagramType.Context;

protected override IEnumerable<Structure> Structures() => new Structure[]
protected override IEnumerable<Structure> Structures => new Structure[]
{
Customer,
BankingSystem,
Mainframe,
MailSystem
};

protected override IEnumerable<Relationship> Relationships() => new[]
protected override IEnumerable<Relationship> Relationships => new[]
{
(Customer > BankingSystem).AddTags("error"),
(Customer < MailSystem)["Sends e-mails to"],
(BankingSystem > MailSystem)["Sends e-mails", "SMTP"][Neighbor],
BankingSystem > Mainframe,
Customer < MailSystem | "Sends e-mails to",
BankingSystem > MailSystem | ("Sends e-mails", "SMTP") | Neighbor,
BankingSystem > Mainframe
};

protected override IElementStyle? SetStyle()
protected override IElementStyle SetStyle()
{
return new ElementStyle()
.UpdateElementStyle(ElementName.ExternalPerson, "#7f3b08", "#7f3b08")
Expand Down
10 changes: 5 additions & 5 deletions samples/Basic/C4Sharp.Sample/Diagrams/DeploymentDiagram.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using C4Sharp.Diagrams;
using C4Sharp.Models;
using C4Sharp.Models.Relationships;
using C4Sharp.Elements;
using C4Sharp.Elements.Relationships;
using C4Sharp.Sample.Structures;

namespace C4Sharp.Sample.Diagrams
Expand All @@ -10,14 +10,14 @@ public class DeploymentDiagram: DiagramBuildRunner
protected override string Title => "System Context diagram for Internet Banking System";
protected override DiagramType DiagramType => DiagramType.Deployment;

protected override IEnumerable<Structure> Structures() => new Structure[]
protected override IEnumerable<Structure> Structures => new Structure[]
{
BigBankNode(),
Nodes.Ios("ios", Containers.MobileApp),
Nodes.PersonalComputer("computer", Nodes.Browser("browser", Containers.Spa))
};

protected override IEnumerable<Relationship> Relationships() => new[]
protected override IEnumerable<Relationship> Relationships => new[]
{
(Containers.MobileApp > Containers.BackendApi)["Makes API calls to", "json/HTTPS"],
(Containers.Spa > Containers.BackendApi)["Makes API calls to", "json/HTTPS"],
Expand All @@ -30,7 +30,7 @@ protected override IEnumerable<Relationship> Relationships() => new[]

private static DeploymentNode BigBankNode()
{
return new ("plc", "Big Bank plc")
return new DeploymentNode("plc", "Big Bank plc")
{
Description = "Big Bank plc data center",
Nodes = new[]
Expand Down
26 changes: 14 additions & 12 deletions samples/Basic/C4Sharp.Sample/Diagrams/EnterpriseDiagram.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using C4Sharp.Diagrams;
using C4Sharp.Models;
using C4Sharp.Models.Plantuml;
using C4Sharp.Models.Plantuml.Constants;
using C4Sharp.Models.Relationships;
using C4Sharp.Diagrams.Interfaces;
using C4Sharp.Elements;
using C4Sharp.Elements.Boundaries;
using C4Sharp.Elements.Plantuml;
using C4Sharp.Elements.Plantuml.Constants;
using C4Sharp.Elements.Relationships;
using C4Sharp.Sample.Structures;

namespace C4Sharp.Sample.Diagrams
Expand All @@ -16,7 +18,7 @@ public class EnterpriseDiagram: DiagramBuildRunner
protected override string Title => "System Enterprise diagram for Internet Banking System";
protected override DiagramType DiagramType => DiagramType.Context;

protected override IEnumerable<Structure> Structures() => new Structure[]
protected override IEnumerable<Structure> Structures => new Structure[]
{
Customer,
EnterpriseBoundary(),
Expand All @@ -26,19 +28,19 @@ public class EnterpriseDiagram: DiagramBuildRunner

private static EnterpriseBoundary EnterpriseBoundary()
{
return new EnterpriseBoundary("eboundary", "Domain A")
return new EnterpriseBoundary("enterprise.boundary", "Domain A")
{
Structures = new Structure[]
{
BankingSystem,
new EnterpriseBoundary("eboundary1", "Domain Internal Users")
new EnterpriseBoundary("enterprise.boundary.1", "Domain Internal Users")
{
Structures = new Structure[]
{
InternalCustomer,
}
},
new EnterpriseBoundary("eboundary2", "Domain Managers")
new EnterpriseBoundary("enterprise.boundary.2", "Domain Managers")
{
Structures = new Structure[]
{
Expand All @@ -49,17 +51,17 @@ private static EnterpriseBoundary EnterpriseBoundary()
};
}

protected override IEnumerable<Relationship> Relationships() => new[]
protected override IEnumerable<Relationship> Relationships => new[]
{
Customer > BankingSystem,
InternalCustomer > BankingSystem,
Manager > BankingSystem,
(Customer < MailSystem)["Sends e-mails to"],
(BankingSystem > MailSystem)["Sends e-mails", "SMTP"][Neighbor],
Customer < MailSystem | "Sends e-mails to",
BankingSystem > MailSystem | ("Sends e-mails", "SMTP") | Neighbor,
BankingSystem > Mainframe,
};

protected override IElementStyle? SetStyle()
protected override IElementStyle SetStyle()
{
return new ElementStyle()
.UpdateElementStyle(ElementName.ExternalPerson, "#7f3b08", "#7f3b08")
Expand Down
9 changes: 5 additions & 4 deletions samples/Basic/C4Sharp.Sample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using C4Sharp.Models.Plantuml.IO;
using C4Sharp.Elements.Plantuml.IO;
using C4Sharp.Sample.Diagrams;

namespace C4Sharp.Sample;
Expand All @@ -16,11 +16,12 @@ private static void Main()
new EnterpriseDiagram().Build(),
};

new PlantumlContext()
var context = new PlantumlContext();

context
.UseDiagramImageBuilder()
.UseDiagramSvgImageBuilder()
.UseStandardLibraryBaseUrl()
.UseHtmlPageBuilder()
//.UseStandardLibraryBaseUrl() //load the resources from github C4plantuml repository
.Export(diagrams);
}
}
2 changes: 1 addition & 1 deletion samples/Basic/C4Sharp.Sample/Structures/Components.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using C4Sharp.Models;
using C4Sharp.Elements;

namespace C4Sharp.Sample.Structures;

Expand Down
Loading

0 comments on commit 8f607d4

Please sign in to comment.