Skip to content

Commit

Permalink
Continuous improvements (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
SlavaVedernikov authored Apr 27, 2024
2 parents 9b0c408 + bcba0d9 commit b573f24
Show file tree
Hide file tree
Showing 897 changed files with 443 additions and 1,194 deletions.
4 changes: 2 additions & 2 deletions C4InterFlow.Automation/C4InterFlow.Automation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<Deterministic>true</Deterministic>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Version>1.1.0</Version>
<Version>1.2.0</Version>
</PropertyGroup>

<PropertyGroup>
<PackageId>C4InterFlow.Automation</PackageId>
<PackageVersion>1.1.0</PackageVersion>
<PackageVersion>1.2.0</PackageVersion>
<Authors>Slava Vedernikov</Authors>
<Description>Revolutionise your Application Architecture Documentation with C4InterFlow. Designed for Architects and Engineers, this tool leverages the widely-recognised C4 Model (Architecture Visualisation framework), enhanced with unique features like Interface and Flow, to describe your Application Architecture as Code. Experience an intuitive, efficient way to document complex systems, ensuring clarity and consistency across your teams and products.</Description>
<Copyright>Copyright 2024 Slava Vedernikov</Copyright>
Expand Down
22 changes: 12 additions & 10 deletions C4InterFlow.Automation/Writers/CSharpToAnyAaCWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,23 +190,25 @@ public Dictionary<string, string> GetSoftwareSystemTypeMappings(string typeName,

// Get the symbol info for the method
var methodSymbolInfo = semanticModel.GetSymbolInfo(invocation.Expression);
var methodSymbol = (IMethodSymbol)methodSymbolInfo.Symbol;
var methodSymbol = (IMethodSymbol)(methodSymbolInfo.Symbol ?? methodSymbolInfo.CandidateSymbols.FirstOrDefault());

// Get the type arguments
var typeArguments = methodSymbol.TypeArguments;

if (typeArguments.Count() == 2)
if (methodSymbol != null)
{
var interfaceName = typeArguments[0].ToDisplayString();
var implementationName = typeArguments[1].ToDisplayString();
var typeArguments = methodSymbol.TypeArguments;

if (!result.ContainsKey(interfaceName))
if (typeArguments.Count() == 2)
{
result.Add(interfaceName, implementationName);
}
var interfaceName = typeArguments[0].ToDisplayString();
var implementationName = typeArguments[1].ToDisplayString();

}
if (!result.ContainsKey(interfaceName))
{
result.Add(interfaceName, implementationName);
}

}
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion C4InterFlow.Cli/C4InterFlow.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>1.1.0</Version>
<Version>1.2.0</Version>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
Expand Down
2 changes: 1 addition & 1 deletion C4InterFlow.Cli/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"C4InterFlow.Cli": {
"commandName": "Project",
"commandLineArgs": "draw-diagrams --aac-input-paths \"C:\\C4InterFlow\\Samples\\E-Commerce Platform\\Yaml\\Architecture\" --aac-reader-strategy \"C4InterFlow.Automation.Readers.YamlAaCReaderStrategy,C4InterFlow.Automation\" --interfaces ECommercePlatform.SoftwareSystems.BuyingAndMerchandisingApp.Interfaces.CreatePurchaseOrder --levels-of-details context --scopes software-system-interface --types c4-sequence --output-dir \"C:\\C4InterFlow\\Samples\\E-Commerce Platform\\Yaml\\Diagrams\""
"commandLineArgs": "draw-diagrams --business-processes BtcTurk.BusinessProcesses.* --levels-of-details container --types c4-sequence --aac-reader-strategy \"C4InterFlow.Automation.Readers.YamlAaCReaderStrategy,C4InterFlow.Automation\" --aac-input-paths \"C:\\Data\\Work\\BtcTurk\\Architecture\\Borsa Istanbul\\BIST Integration\\Architecture\" --output-dir \"C:\\Data\\Work\\BtcTurk\\Architecture\\Borsa Istanbul\\BIST Integration\\Diagrams\""
}
}
}
4 changes: 2 additions & 2 deletions C4InterFlow/C4InterFlow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<Deterministic>true</Deterministic>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Version>1.1.0</Version>
<Version>1.2.0</Version>
</PropertyGroup>

<PropertyGroup>
<PackageId>C4InterFlow</PackageId>
<PackageVersion>1.1.0</PackageVersion>
<PackageVersion>1.2.0</PackageVersion>
<Authors>Slava Vedernikov</Authors>
<Description>Revolutionise your Application Architecture Documentation with C4InterFlow. Designed for Architects and Engineers, this tool leverages the widely-recognised C4 Model (Architecture Visualisation framework), enhanced with unique features like Interface and Flow, to describe your Application Architecture as Code. Experience an intuitive, efficient way to document complex systems, ensuring clarity and consistency across your teams and products.</Description>
<Copyright>Copyright 2024 Slava Vedernikov</Copyright>
Expand Down
2 changes: 1 addition & 1 deletion C4InterFlow/Cli/Commands/DrawDiagramsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ private static void DrawC4Diagrams(string scope, string levelOfDetails, Interfac
return null;

else
return $"{businessProcess.Label} - {ToPrettyName(diagramType)} - {ToPrettyName(levelOfDetails)} level)";
return $"{businessProcess.Label} - {ToPrettyName(diagramType)} - {ToPrettyName(levelOfDetails)} level";
}

private static bool TryGetDiagramPath(string scope, string levelOfDetails, string diagramType, out string path, out string fileName, string? outputSubDirectory = null, string? diagramNamePrefix = null)
Expand Down
Binary file modified C4InterFlow/Resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 13 additions & 6 deletions C4InterFlow/Structures/Flow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public Flow[] GetUseFlows()
return result.ToArray();
}

internal Flow[] GetFlowsByType(Flow flow, FlowType type)
internal Flow[] GetFlowsByType(Flow flow, FlowType type, bool isRecursive = true)
{
var result = new List<Flow>();

Expand All @@ -130,14 +130,21 @@ internal Flow[] GetFlowsByType(Flow flow, FlowType type)

if (segment.Flows == null) continue;

foreach (var useSegment in segment.Flows)
if(isRecursive)
{
result.AddRange(GetFlowsByType(useSegment, type));
foreach (var useSegment in segment.Flows)
{
result.AddRange(GetFlowsByType(useSegment, type));
}
}
}
else
{
result.AddRange(GetFlowsByType(segment, type));
if (isRecursive)
{
result.AddRange(GetFlowsByType(segment, type));
}

}
}

Expand Down Expand Up @@ -552,7 +559,7 @@ public Flow If(string condition)
public Flow ElseIf(string condition)
{
var flowType = FlowType.ElseIf;
var parent = Parent;
var parent = Type == FlowType.ElseIf ? Parent : this;

if (!IsAllowed(parent.Type, flowType, out var message))
{
Expand All @@ -567,7 +574,7 @@ public Flow ElseIf(string condition)
public Flow Else()
{
var flowType = FlowType.Else;
var parent = this;
var parent = Type == FlowType.ElseIf ? Parent : this;

if (!IsAllowed(parent.Type, flowType, out var message))
{
Expand Down
45 changes: 34 additions & 11 deletions C4InterFlow/Visualisation/ComponentDiagram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using C4InterFlow.Structures.Boundaries;
using C4InterFlow.Structures.Relationships;
using C4InterFlow.Visualisation.Plantuml.Style;
using C4InterFlow.Commons.Extensions;

namespace C4InterFlow.Visualisation
{
Expand Down Expand Up @@ -192,10 +191,36 @@ private void PopulateStructures(IList<Structure> structures, Interface @interfac
{
structures.Add(interfaceOwner);
}
else if (interfaceOwner is Container &&
!structures.OfType<Container>().Any(x => x.Alias == interfaceOwner.Alias))
else if (interfaceOwner is Container)
{
structures.Add(interfaceOwner);
if (ShowBoundaries)
{
var container = (Container)interfaceOwner;
var softwareSystem = Utils.GetInstance<SoftwareSystem>(container.SoftwareSystem);
var softwareSystemBoundary = structures.OfType<SoftwareSystemBoundary>().FirstOrDefault(x => x.Alias == softwareSystem.Alias);

if (softwareSystemBoundary == null)
{
softwareSystemBoundary = new SoftwareSystemBoundary(softwareSystem.Alias, softwareSystem.Label)
{
Structures = new List<Structure>()
};

structures.Add(softwareSystemBoundary);
}

if (!softwareSystemBoundary.Structures.Any(x => x.Alias == container.Alias))
{
((List<Structure>)softwareSystemBoundary.Structures).Add(container);
}
}
else
{
if(!structures.OfType<Container>().Any(x => x.Alias == interfaceOwner.Alias))
{
structures.Add(interfaceOwner);
}
}
}
else if (interfaceOwner is Component)
{
Expand Down Expand Up @@ -238,18 +263,16 @@ private void PopulateStructures(IList<Structure> structures, Interface @interfac
}
else
{
if (!structures.Any(x => x.Alias == interfaceOwner.Alias))
if (!structures.OfType<Component>().Any(x => x.Alias == interfaceOwner.Alias))
{
structures.Add(interfaceOwner);
}
}
}


foreach (var usesInterface in @interface.Flow.GetUsesInterfaces())
{
PopulateStructures(structures, usesInterface);
}

foreach (var usesInterface in @interface.Flow.GetUsesInterfaces())
{
PopulateStructures(structures, usesInterface);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ private static StringBuilder BuildSequenceHeader(this StringBuilder stream, Diag
private static StringBuilder BuildSequenceBody(this StringBuilder stream, Diagram diagram, SequenceDiagramStyle style)
{
var flowParticipants = diagram.Flow?.Flows?
.Where(x => x.Type != Structures.Flow.FlowType.None)
.Select(x => Utils.GetInstance<Structures.Structure>(x.Owner))
.Where(x => x != null && !diagram.Structures.Any(s => s.Alias == x.Alias)).Distinct();

Expand Down
27 changes: 19 additions & 8 deletions C4InterFlow/Visualisation/Plantuml/PlantumlSequenceFlow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,16 @@ public static string ToPumlSequenceString(this Flow flow, SequenceDiagramStyle s
sb.AppendLine(flowRelationship.ToPumlSequenceString(style));
}


innerFlows.AddRange(flow.GetFlowsByType(flow, Flow.FlowType.Use));
innerFlows.AddRange(flow.GetFlowsByType(flow, Flow.FlowType.Return));
innerFlows.AddRange(flow.GetFlowsByType(flow, Flow.FlowType.ThrowException));
if (innerFlows.Any())
// TODO: Investigate why doing this in C4 sequence diagrams doesn't seem to work (out of memory java error when rendering)
if (style == SequenceDiagramStyle.PlantUML)
{
sb.AppendLine($"group {label}");
innerFlows.AddRange(flow.GetFlowsByType(flow, Flow.FlowType.Use, false));
innerFlows.AddRange(flow.GetFlowsByType(flow, Flow.FlowType.Return, false));
innerFlows.AddRange(flow.GetFlowsByType(flow, Flow.FlowType.ThrowException, false));
if (innerFlows.Any())
{
sb.AppendLine($"group {label}");
}
}
}

Expand All @@ -121,12 +124,20 @@ public static string ToPumlSequenceString(this Flow flow, SequenceDiagramStyle s

if (flow.Type == Flow.FlowType.If ||
flow.Type == Flow.FlowType.Loop ||
flow.Type == Flow.FlowType.Group ||
(flow.Type == Flow.FlowType.Use && innerFlows.Any()))
flow.Type == Flow.FlowType.Group)
{
sb.AppendLine("end");
}

// TODO: Investigate why doing this in C4 sequence diagrams doesn't seem to work (out of memory java error when rendering)
if (style == SequenceDiagramStyle.PlantUML)
{
if (flow.Type == Flow.FlowType.Use && innerFlows.Any())
{
sb.AppendLine("end");
}
}

return sb.ToString();
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ System_Boundary(ECommercePlatform.SoftwareSystems.BasketService, "Basket Service
Boundary_End()

Rel(C4InterFlow.SoftwareSystems.ExternalSystem, ECommercePlatform.SoftwareSystems.BasketService.Containers.Api, "Add Item")
group Add Item
Rel(ECommercePlatform.SoftwareSystems.BasketService.Containers.Api, ECommercePlatform.SoftwareSystems.BasketService.Containers.Database, "Insert Item")
end


@enduml
Loading

0 comments on commit b573f24

Please sign in to comment.