Skip to content

Commit

Permalink
#24: Fixed Sequence Diagram issue when there was loop after loop
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinCelej committed Jul 13, 2023
1 parent 6458605 commit 94a2359
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,15 @@ private string NextLevel(Type sourceType, string sourceTypeName, MethodBase sour

if(group != activeGroup)
{
if (activeGroup != null && group.StartsWith("else") == false)
diagram.AppendLine("end");

diagram.AppendLine(group);
}
activeGroup = group;
}
else if (activeGroup != null)
{
// TODO: Marcin Celej [from: Marcin Celej on: 12-07-2023]: does not work properly for loop after loop
diagram.AppendLine("end");
activeGroup = null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Technical Debt for Synergy.Contracts

Total: 6
Total: 9

## [SequenceDiagramDeactivationAttribute.cs](../../../Synergy.Architecture.Annotations/Diagrams/Sequence/SequenceDiagramDeactivationAttribute.cs)
- TODO: Marcin Celej [from: Marcin Celej on: 21-05-2023]: Use this attribute in some sample
Expand All @@ -17,5 +17,9 @@ Total: 6
## [ApiDescription.cs](../../../Synergy.Architecture.Diagrams/Api/ApiDescription.cs)
- TODO: Marcin Celej [from: Marcin Celej on: 08-04-2023]: remove this class from here - check what it is used for

## [SequenceDiagramSamples.cs](../../Samples/SequenceDiagramSamples.cs)
- TODO: Marcin Celej [from: Marcin Celej on: 08-04-2023]: provide samples here
## [TechnicalBlueprint.cs](../../../Synergy.Architecture.Diagrams/Documentation/TechnicalBlueprint.cs)
- TODO: Marcin Celej [from: Marcin Celej on: 12-06-2023]: Hide this class as it should be internal component store

## [SequenceDiagramUrl.cs](../../../Synergy.Architecture.Diagrams/Sequence/SequenceDiagramUrl.cs)
- TODO: Marcin Celej [from: Marcin Celej on: 06-07-2023]: Allow to inline self call
- TODO: Marcin Celej [from: Marcin Celej on: 06-07-2023]: Add configuration setting to generate only 'new' word here without exact ctor mentioned here - to simplify diagram
Original file line number Diff line number Diff line change
@@ -1,6 +1,58 @@
namespace Synergy.Architecture.Tests.Samples;
using Synergy.Architecture.Annotations.Diagrams.Sequence;
using Synergy.Architecture.Diagrams.Documentation;
using Synergy.Architecture.Diagrams.Sequence;
using Synergy.Documentation.Code;

namespace Synergy.Architecture.Tests.Samples;

public class SequenceDiagramSamples
{
// TODO: Marcin Celej [from: Marcin Celej on: 08-04-2023]: provide samples here
public static CodeFile SequenceDiagrams => CodeFolder.Current()
.File($"{nameof(SequenceDiagramSamples)}.md");

[Fact]
public async Task Sequence()
{
var blueprint = TechnicalBlueprint
.Titled("Sequence diagrams samples")
.Add(SequenceDiagramSamples.IfElseDiagrams())
.Add(LoopAfterLoopDiagram())
;

await File.WriteAllTextAsync(SequenceDiagrams.FilePath, blueprint.Render());
}

private static IEnumerable<SequenceDiagram> IfElseDiagrams()
{
yield return SequenceDiagram
.From(new SequenceDiagramActor("Some actor", Note: "very hand some"))
.Calling<SequenceDiagramSamples>(c => c.IfElse())
.Footer("This diagram shows if-else."
);
}

[SequenceDiagramExternalCall("Chrome", "https://www.google.com", Group = SequenceDiagramGroupType.Alt, GroupHeader = "when google is available")]
[SequenceDiagramExternalCall("Firefox", "https://www.foogle.com", Group = SequenceDiagramGroupType.Alt, GroupHeader = "when google is available")]
[SequenceDiagramExternalCall("Firefox", "https://www.google.com", Group = SequenceDiagramGroupType.Else, GroupHeader = "otherwise")]
private void IfElse()
{
}

private static IEnumerable<SequenceDiagram> LoopAfterLoopDiagram()
{
yield return SequenceDiagram
.From(new SequenceDiagramActor("Some actor", Note: "very hand some"))
.Calling<SequenceDiagramSamples>(c => c.LoopAfterLoop())
.Footer("This diagram shows loop placed after another loop."
);
}

[SequenceDiagramExternalCall("Chrome", "https://www.google.com", Group = SequenceDiagramGroupType.Loop, GroupHeader = "Looping until something happens")]
[SequenceDiagramExternalCall("Firefox", "https://www.foogle.com", Group = SequenceDiagramGroupType.Loop, GroupHeader = "Looping until something happens")]
[SequenceDiagramExternalCall("Firefox", "https://www.google.com", Group = SequenceDiagramGroupType.Loop, GroupHeader = "This should be different loop")]
private void LoopAfterLoop()
{
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Sequence diagrams samples

## SequenceDiagramSamples.IfElse()

**Root type:** `SequenceDiagramSamples` (from: `Synergy.Architecture.Tests`)

**Root method:**
```
IfElse() : void
```

![Sequence Diagram for SequenceDiagramSamples.IfElse()](http://www.plantuml.com/plantuml/png/V9BFJiCm3CRlbVeEravmQ7Ulq3J-IXmuZJiodTj4f769lGMUZGEFn2kGhjFOnBPR7Fq-v_Fd_7nzpqKnwAfpUIPlrlSOi8D0qhCNUY8HREc67CVh43Y2XXNbMSEi5E3PM86bnNRGYE4eO9k2d52PPshL9NH1xoloDTsDs0Axtf6KZyrzmYukyupySejYhHnWmHszZ4SKc0mbRCf9dat1fuU1rxJFLP3gJp3ebo3fDi_I56fhswDNE6xWaBaruP_kmGPg-2DDi7kec1rlLi7VEEWKeY4FBNFh2592k4RhyFLq6iLiD521KUsbcavZZENOeAovEwtRcZmKfktiXCCoWDLGY5RE63ZQQDz1MjD-55T5SIhOUK8t_-aN003__mC0)
<!--
@startuml
skinparam responseMessageBelowArrow true
footer This diagram shows if-else.
title
SequenceDiagramSamples.IfElse()
endtitle
actor Some_actor as "Some actor"
/ note over Some_actor: very hand some
participant SequenceDiagramSamples
participant Chrome
participant Firefox
Some_actor->SequenceDiagramSamples: IfElse()
alt when google is available
SequenceDiagramSamples->Chrome: https://www.google.com
SequenceDiagramSamples->Firefox: https://www.foogle.com
else otherwise
SequenceDiagramSamples->Firefox: https://www.google.com
end
Some_actor<--SequenceDiagramSamples
@enduml
-->

This diagram shows if-else.


## SequenceDiagramSamples.LoopAfterLoop()

**Root type:** `SequenceDiagramSamples` (from: `Synergy.Architecture.Tests`)

**Root method:**
```
LoopAfterLoop() : void
```

![Sequence Diagram for SequenceDiagramSamples.LoopAfterLoop()](http://www.plantuml.com/plantuml/png/b5AnJiCm4DqZvHzEdM18kaUeQW4nmLHsT2INsCBn6TiXy6qCV1A_m3cjIgksGwVusU_TlRkNt--VPOZeuz2RF0jlsZhqs8EduDW6Ug8GiADRCZoklESHeXyeprhcI1wUbGxGQEoI9YWU0nXc1yvWJGrWcqXeEIhvffSopwAEHYgiwNqWMzFzHht6tXaAvQEGLacM3bVNUKQssIgmZknXpJszR8uOO9OWJ72MPtEGLWJyGVky2WH_WKBRG93RF9CPewwrGnlXj8z3pftoHxe7xQdbJnbarwXOd2vMmT5KqvOIqBQ3mKPj9cjH9QpGERBYuNIvOh7nKu6AqOLgFX_7iUoOEqDbpVrvtTRpeL2Yt0bbsLjlKxAIw60QU2N9k6t9ayoTNY_ii6zjwl2_ifkYE1V0KgZJN_a7003__mC0)
<!--
@startuml
skinparam responseMessageBelowArrow true
footer This diagram shows loop placed after another loop.
title
SequenceDiagramSamples.LoopAfterLoop()
endtitle
actor Some_actor as "Some actor"
/ note over Some_actor: very hand some
participant SequenceDiagramSamples
participant Chrome
participant Firefox
Some_actor->SequenceDiagramSamples: LoopAfterLoop()
loop Looping until something happens
SequenceDiagramSamples->Chrome: https://www.google.com
SequenceDiagramSamples->Firefox: https://www.foogle.com
end
loop This should be different loop
SequenceDiagramSamples->Firefox: https://www.google.com
end
Some_actor<--SequenceDiagramSamples
@enduml
-->

This diagram shows loop placed after another loop.


Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DefineConstants>TRACE;CODE_ANALYSIS</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DefineConstants>TRACE;CODE_ANALYSIS</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="Verify.Xunit" Version="19.12.1" />
Expand Down

0 comments on commit 94a2359

Please sign in to comment.