Skip to content

Commit

Permalink
Merge pull request #6 from gman-au/5-error-encountered-index-and-coun…
Browse files Browse the repository at this point in the history
…t-must-refer-to-a-location-within-the-string-parameter-count

Added more logging, adjusted newline length for string replace with m…
  • Loading branch information
gubpalma authored Jul 25, 2024
2 parents 1ef4226 + dcd32e5 commit 1c73b6e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/6.0/Siren.Infrastructure.Io/FileWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void Perform(
);

// +2 for length of carriage return (otherwise appends line feed each re-write)
var lengthToTrim = MermaidConstants.SirenAnchorEnd.Length + 2;
var lengthToTrim = MermaidConstants.SirenAnchorEnd.Length + Environment.NewLine.Length;

if (sirenAnchorEndPosition < 0)
{
Expand Down
20 changes: 20 additions & 0 deletions src/6.0/Siren.Infrastructure.Rendering/MermaidRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,25 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Extensions.Logging;
using Siren.Domain;

namespace Siren.Infrastructure.Rendering
{
public class MermaidRenderer : IDomainRenderer
{
private readonly ILogger<MermaidRenderer> _logger;

public MermaidRenderer(ILogger<MermaidRenderer> logger)
{
_logger = logger;
}

public StringBuilder Perform(Universe universe)
{
_logger
.LogInformation("Commencing render to Mermaid syntax");

var result = new StringBuilder();

// Text in file replace header
Expand All @@ -28,6 +39,9 @@ public StringBuilder Perform(Universe universe)
result
.AppendLine($"\t{MermaidConstants.MermaidErDiagramHeader}");

_logger
.LogInformation("Rendered header");

foreach (var entity in universe.Entities)
{
// Entity header
Expand Down Expand Up @@ -58,6 +72,9 @@ public StringBuilder Perform(Universe universe)

result
.AppendLine();

_logger
.LogInformation($"Rendered entity: {entity.ShortName}");
}

// Entity footer
Expand Down Expand Up @@ -85,6 +102,9 @@ public StringBuilder Perform(Universe universe)
result
.AppendLine(MermaidConstants.SirenAnchorEnd);

_logger
.LogInformation("Completed render to Mermaid syntax");

return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@
<ProjectReference Include="..\Siren.Domain\Siren.Domain.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
</ItemGroup>

</Project>

0 comments on commit 1c73b6e

Please sign in to comment.