diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index bd97492..c87e81a 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -7,7 +7,7 @@ on: branches: [ main ] env: - VERSION: 3.2.${{ github.run_number }} + VERSION: 4.0.${{ github.run_number }} NUGET_INDEX: https://api.nuget.org/v3/index.json BUILD_TYPE: Release @@ -33,10 +33,14 @@ jobs: - name: Build run: dotnet build --no-restore --configuration Release -p:PackageVersion=${{env.VERSION}} - - name: Test + - name: Unit Tests run: dotnet test ./tests/**/*.UnitTests.csproj --no-restore + + - name: Integrated Tests + run: dotnet test ./tests/**/*.IntegratedTests.csproj --no-restore - name: Publish Artifact + if: github.ref == 'refs/heads/main' run: | dotnet pack --no-restore --configuration ${{ env.BUILD_TYPE }} -p:PackageVersion=${{ env.VERSION }} dotnet nuget push ./src/**/*.${{ env.VERSION }}.nupkg --api-key ${{ secrets.NUGET_KEY }} --source ${{ env.NUGET_INDEX }} diff --git a/README.md b/README.md index b080982..3bc3812 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,8 @@ dotnet add package C4Sharp ### Dependencies You need these things to run C4Sharp: - - [.NET Standard 2.1](https://docs.microsoft.com/pt-br/dotnet/standard/net-standard) + - [.NET 5.0+](https://docs.microsoft.com/pt-br/dotnet/standard/net-standard) - [Java](https://www.java.com/en/download/) - - [Graphviz](https://plantuml.com/graphviz-dot) ### Coding diff --git a/samples/C4Sharp.Sample.Orders/Program.cs b/samples/C4Sharp.Sample.Orders/Program.cs index 80c4dc8..ae2e6e9 100644 --- a/samples/C4Sharp.Sample.Orders/Program.cs +++ b/samples/C4Sharp.Sample.Orders/Program.cs @@ -1,11 +1,11 @@ using C4Sharp.Diagrams; -using C4Sharp.Models.Plantuml; +using C4Sharp.Models.Plantuml.IO; namespace C4Sharp.Sample.Orders { internal static class Program { - private static void Main(string[] args) + private static void Main() { var diagrams = new Diagram[] { diff --git a/samples/C4Sharp.Sample/Program.cs b/samples/C4Sharp.Sample/Program.cs index 6a587c6..5532a0c 100644 --- a/samples/C4Sharp.Sample/Program.cs +++ b/samples/C4Sharp.Sample/Program.cs @@ -1,13 +1,12 @@ using C4Sharp.Diagrams; -using C4Sharp.Models; -using C4Sharp.Models.Plantuml; +using C4Sharp.Models.Plantuml.IO; using C4Sharp.Sample.Diagrams; namespace C4Sharp.Sample { internal static class Program { - private static void Main(string[] args) + private static void Main() { var diagrams = new Diagram[] { diff --git a/src/C4Sharp/C4Sharp.csproj b/src/C4Sharp/C4Sharp.csproj index beba49d..1ddd04b 100644 --- a/src/C4Sharp/C4Sharp.csproj +++ b/src/C4Sharp/C4Sharp.csproj @@ -11,12 +11,13 @@ https://github.com/8T4/c4sharp git c4, diagrams - 3.2.0 + 4.0.0 https://github.com/8T4/c4sharp/blob/main/LICENSE true true snupkg 9 + enable @@ -34,8 +35,8 @@ - + - + diff --git a/src/C4Sharp/Diagrams/Diagram.cs b/src/C4Sharp/Diagrams/Diagram.cs index 6e268cc..019312a 100644 --- a/src/C4Sharp/Diagrams/Diagram.cs +++ b/src/C4Sharp/Diagrams/Diagram.cs @@ -15,7 +15,7 @@ public abstract record Diagram public bool LayoutWithLegend { get; set; } public bool ShowLegend { get; set; } public bool LayoutAsSketch { get; set; } - public string Title { get; set; } + public string? Title { get; set; } public DiagramLayout FlowVisualization { get; set; } public Structure[] Structures { get; set; } public Relationship[] Relationships { get; set; } diff --git a/src/C4Sharp/Extensions/ResourceMethods.cs b/src/C4Sharp/Extensions/ResourceMethods.cs index 9b5e836..e48a5a4 100644 --- a/src/C4Sharp/Extensions/ResourceMethods.cs +++ b/src/C4Sharp/Extensions/ResourceMethods.cs @@ -2,7 +2,7 @@ using System.Diagnostics.CodeAnalysis; using System.IO; using System.Reflection; -using C4Sharp.Models.Plantuml; +using C4Sharp.Models.Plantuml.IO; namespace C4Sharp.Extensions { @@ -12,24 +12,17 @@ namespace C4Sharp.Extensions [ExcludeFromCodeCoverage] internal static class ResourceMethods { - /// - /// Get Stream from plantuml.jar file - /// - /// Stream - /// - public static Stream GetPlantumlResource() => GetResourceByName("C4Sharp.Resources.plantuml.jar"); - /// /// Get resource string content from resource file /// /// file name /// resource content /// - public static string GetResource(string name) + public static string GetResourceContent(string name) { try { - using var stream = GetResourceByName($"C4Sharp.Resources.{name}"); + using var stream = GetResourceStream(name); using var reader = new StreamReader(stream ?? throw new InvalidOperationException()); return reader.ReadToEnd(); } @@ -45,13 +38,13 @@ public static string GetResource(string name) /// /// /// - private static Stream GetResourceByName(string name) + public static Stream? GetResourceStream(string name) { try { return Assembly .GetExecutingAssembly() - .GetManifestResourceStream(name); + .GetManifestResourceStream($"C4Sharp.Resources.{name}"); } catch (Exception e) { diff --git a/src/C4Sharp/FileSystem/C4SharpDirectory.cs b/src/C4Sharp/FileSystem/C4SharpDirectory.cs index da62fea..1d523cd 100644 --- a/src/C4Sharp/FileSystem/C4SharpDirectory.cs +++ b/src/C4Sharp/FileSystem/C4SharpDirectory.cs @@ -17,48 +17,5 @@ internal static class C4SharpDirectory /// Default Resource Folder Name /// public static string ResourcesFolderName => Path.Join("..", ".c4s"); - - /// - /// Load all C4_Plantuml files - /// - public static void LoadResources(string path = null) - { - var local = path is null - ? Path.Join(DirectoryName, ResourcesFolderName) - : Path.Join(path, ResourcesFolderName); - - LoadResource(local, "C4"); - LoadResource(local, "C4_Component"); - LoadResource(local, "C4_Container"); - LoadResource(local, "C4_Context"); - LoadResource(local, "C4_Deployment"); - } - - /// - /// Load C4_Plantuml file - /// - /// - /// - /// - private static void LoadResource(string resourcesPath, string resourceName) - { - try - { - var path = Path.Join(resourcesPath, $"{resourceName}.puml"); - - if (File.Exists(path)) - { - return; - } - - var stream = ResourceMethods.GetResource($"{resourceName}.puml"); - Directory.CreateDirectory(resourcesPath); - File.WriteAllText(path, stream); - } - catch (Exception e) - { - throw new C4FileException("An exception occured while the package try loading the resource files", e); - } - } } } \ No newline at end of file diff --git a/src/C4Sharp/Models/Component.cs b/src/C4Sharp/Models/Component.cs index 58f2418..dde6119 100644 --- a/src/C4Sharp/Models/Component.cs +++ b/src/C4Sharp/Models/Component.cs @@ -15,6 +15,6 @@ namespace C4Sharp.Models /// public sealed record Component(string Alias, string Label) : Structure(Alias, Label) { - public string Technology { get; init; } + public string? Technology { get; init; } } } \ No newline at end of file diff --git a/src/C4Sharp/Models/Container.cs b/src/C4Sharp/Models/Container.cs index ad497ba..b6ddfa8 100644 --- a/src/C4Sharp/Models/Container.cs +++ b/src/C4Sharp/Models/Container.cs @@ -19,7 +19,7 @@ public sealed record Container(string Alias, string Label) : Structure(Alias, La { private readonly Dictionary _instances = new(); public ContainerType ContainerType{ get; init; } - public string Technology { get; init; } + public string? Technology { get; init; } public Container this[int index] => this.GetInstance(index); /// diff --git a/src/C4Sharp/Models/ContainerBoundary.cs b/src/C4Sharp/Models/ContainerBoundary.cs index 17d8796..4e81e18 100644 --- a/src/C4Sharp/Models/ContainerBoundary.cs +++ b/src/C4Sharp/Models/ContainerBoundary.cs @@ -9,7 +9,7 @@ namespace C4Sharp.Models /// public sealed record ContainerBoundary(string Alias, string Label) : Structure(Alias, Label) { - public IEnumerable Components { get; init; } + public IEnumerable Components { get; init; } = Array.Empty(); public IEnumerable Relationships { get; init; } = Array.Empty(); } } \ No newline at end of file diff --git a/src/C4Sharp/Models/DeploymentNode.cs b/src/C4Sharp/Models/DeploymentNode.cs index 3186296..2911466 100644 --- a/src/C4Sharp/Models/DeploymentNode.cs +++ b/src/C4Sharp/Models/DeploymentNode.cs @@ -13,7 +13,7 @@ namespace C4Sharp.Models public sealed record DeploymentNode(string Alias, string Label) : Structure(Alias, Label) { public IEnumerable Nodes { get; init; } = Array.Empty(); - public Dictionary Properties { get; init; } - public Container Container { get; init; } + public Dictionary Properties { get; init; } = new(); + public Container? Container { get; init; } } } \ No newline at end of file diff --git a/src/C4Sharp/Models/Plantuml/PlantumlDiagram.cs b/src/C4Sharp/Models/Plantuml/Extensions/PlantumlDiagram.cs similarity index 98% rename from src/C4Sharp/Models/Plantuml/PlantumlDiagram.cs rename to src/C4Sharp/Models/Plantuml/Extensions/PlantumlDiagram.cs index 0548c90..b22bc4f 100644 --- a/src/C4Sharp/Models/Plantuml/PlantumlDiagram.cs +++ b/src/C4Sharp/Models/Plantuml/Extensions/PlantumlDiagram.cs @@ -3,7 +3,7 @@ using C4Sharp.Diagrams; using C4Sharp.FileSystem; -namespace C4Sharp.Models.Plantuml +namespace C4Sharp.Models.Plantuml.Extensions { /// /// Parser Diagram to PlantUML diff --git a/src/C4Sharp/Models/Plantuml/PlantumlRelationship.cs b/src/C4Sharp/Models/Plantuml/Extensions/PlantumlRelationship.cs similarity index 96% rename from src/C4Sharp/Models/Plantuml/PlantumlRelationship.cs rename to src/C4Sharp/Models/Plantuml/Extensions/PlantumlRelationship.cs index e4c77ed..cd69c3d 100644 --- a/src/C4Sharp/Models/Plantuml/PlantumlRelationship.cs +++ b/src/C4Sharp/Models/Plantuml/Extensions/PlantumlRelationship.cs @@ -1,6 +1,6 @@ using C4Sharp.Models.Relationships; -namespace C4Sharp.Models.Plantuml +namespace C4Sharp.Models.Plantuml.Extensions { /// /// Parser Relationship to PlantUML diff --git a/src/C4Sharp/Models/Plantuml/PlantumlStructure.cs b/src/C4Sharp/Models/Plantuml/Extensions/PlantumlStructure.cs similarity index 97% rename from src/C4Sharp/Models/Plantuml/PlantumlStructure.cs rename to src/C4Sharp/Models/Plantuml/Extensions/PlantumlStructure.cs index 89561f2..517799e 100644 --- a/src/C4Sharp/Models/Plantuml/PlantumlStructure.cs +++ b/src/C4Sharp/Models/Plantuml/Extensions/PlantumlStructure.cs @@ -3,7 +3,7 @@ using C4Sharp.Extensions; using C4Sharp.Models.Relationships; -namespace C4Sharp.Models.Plantuml +namespace C4Sharp.Models.Plantuml.Extensions { /// /// PlantUML Parser @@ -134,7 +134,7 @@ private static string ToPumlString(this DeploymentNode deployment, int concat = stream.AppendLine(); } - if (deployment.Properties != null) + if (deployment.Properties.Any()) { foreach (var (key, value) in deployment.Properties) { @@ -142,11 +142,11 @@ private static string ToPumlString(this DeploymentNode deployment, int concat = } } - stream.AppendLine(deployment.Tags is null + stream.AppendLine(!deployment.Tags.Any() ? $"{spaces}Deployment_Node({deployment.Alias}, \"{deployment.Label}\", \"{deployment.Description}\") {{" : $"{spaces}Deployment_Node({deployment.Alias}, \"{deployment.Label}\", \"{deployment.Description}\", $tags=\"{string.Join(',', deployment.Tags)}\") {{"); - if (deployment.Nodes != null) + if (deployment.Nodes.Any()) { foreach (var node in deployment.Nodes) { diff --git a/src/C4Sharp/Models/Plantuml/PlantumlException.cs b/src/C4Sharp/Models/Plantuml/IO/PlantumlException.cs similarity index 90% rename from src/C4Sharp/Models/Plantuml/PlantumlException.cs rename to src/C4Sharp/Models/Plantuml/IO/PlantumlException.cs index cea6bc5..85e8d1f 100644 --- a/src/C4Sharp/Models/Plantuml/PlantumlException.cs +++ b/src/C4Sharp/Models/Plantuml/IO/PlantumlException.cs @@ -1,6 +1,6 @@ using System; -namespace C4Sharp.Models.Plantuml +namespace C4Sharp.Models.Plantuml.IO { /// /// PlantumlException diff --git a/src/C4Sharp/Models/Plantuml/PlantumlFile.cs b/src/C4Sharp/Models/Plantuml/IO/PlantumlFile.cs similarity index 95% rename from src/C4Sharp/Models/Plantuml/PlantumlFile.cs rename to src/C4Sharp/Models/Plantuml/IO/PlantumlFile.cs index cbffd6f..07672cd 100644 --- a/src/C4Sharp/Models/Plantuml/PlantumlFile.cs +++ b/src/C4Sharp/Models/Plantuml/IO/PlantumlFile.cs @@ -1,10 +1,11 @@ -using C4Sharp.Diagrams; -using C4Sharp.FileSystem; -using System; +using System; using System.Collections.Generic; using System.IO; +using C4Sharp.Diagrams; +using C4Sharp.FileSystem; +using C4Sharp.Models.Plantuml.Extensions; -namespace C4Sharp.Models.Plantuml +namespace C4Sharp.Models.Plantuml.IO { /// /// PUML File Utils @@ -55,7 +56,6 @@ public static void Export(this PlantumlSession session, string path, IEnumerable { session.Execute(path, true, "svg"); } - } /// @@ -70,7 +70,6 @@ private static void Save(Diagram diagram, string path, PlantumlSession session) { lock (Lock) { - C4SharpDirectory.LoadResources(path); var filePath = Path.Combine(path, $"{diagram.Slug()}.puml"); Directory.CreateDirectory(path); File.WriteAllText(filePath, diagram.ToPumlString(session.StandardLibraryBaseUrl)); diff --git a/src/C4Sharp/Models/Plantuml/IO/PlantumlResources.cs b/src/C4Sharp/Models/Plantuml/IO/PlantumlResources.cs new file mode 100644 index 0000000..6207701 --- /dev/null +++ b/src/C4Sharp/Models/Plantuml/IO/PlantumlResources.cs @@ -0,0 +1,77 @@ +using System; +using System.IO; +using C4Sharp.Extensions; +using C4Sharp.FileSystem; + +namespace C4Sharp.Models.Plantuml.IO +{ + internal static class PlantumlResources + { + /// + /// Load all C4_Plantuml files + /// + public static void LoadResources(string path) + { + var local = string.IsNullOrEmpty(path) + ? Path.Join(C4SharpDirectory.DirectoryName, C4SharpDirectory.ResourcesFolderName) + : Path.Join(path, C4SharpDirectory.ResourcesFolderName); + + LoadResource(local, "C4"); + LoadResource(local, "C4_Component"); + LoadResource(local, "C4_Container"); + LoadResource(local, "C4_Context"); + LoadResource(local, "C4_Deployment"); + } + + /// + /// Load C4_Plantuml file + /// + /// + /// + /// + private static void LoadResource(string resourcesPath, string resourceName) + { + try + { + var path = Path.Join(resourcesPath, $"{resourceName}.puml"); + + if (File.Exists(path)) + { + return; + } + + var stream = ResourceMethods.GetResourceContent($"{resourceName}.puml"); + Directory.CreateDirectory(resourcesPath); + File.WriteAllText(path, stream); + } + catch (Exception e) + { + throw new C4FileException("An exception occured while the package try loading the resource files", e); + } + } + + /// + /// Get Stream from plantuml.jar file + /// + /// Stream + /// + public static string LoadPlantumlJar() + { + try + { + const string resourceName = "plantuml.jar"; + var fileName = Path.GetTempFileName(); + + var stream = ResourceMethods.GetResourceStream(resourceName) ?? throw new InvalidOperationException(); + using var file = new FileStream(fileName, FileMode.Create, FileAccess.Write); + stream.CopyTo(file); + + return fileName; + } + catch (Exception e) + { + throw new PlantumlException($"{nameof(PlantumlException)}: Could not load plantuml engine.", e); + } + } + } +} \ No newline at end of file diff --git a/src/C4Sharp/Models/Plantuml/PlantumlSession.cs b/src/C4Sharp/Models/Plantuml/IO/PlantumlSession.cs similarity index 80% rename from src/C4Sharp/Models/Plantuml/PlantumlSession.cs rename to src/C4Sharp/Models/Plantuml/IO/PlantumlSession.cs index 86da69c..6a20dd5 100644 --- a/src/C4Sharp/Models/Plantuml/PlantumlSession.cs +++ b/src/C4Sharp/Models/Plantuml/IO/PlantumlSession.cs @@ -1,10 +1,9 @@ using System; using System.Diagnostics; using System.IO; -using System.Runtime.Versioning; using System.Text; -namespace C4Sharp.Models.Plantuml +namespace C4Sharp.Models.Plantuml.IO { /// /// Session @@ -14,7 +13,7 @@ public class PlantumlSession : IDisposable public bool StandardLibraryBaseUrl { get; private set; } public bool GenerateDiagramImages { get; private set; } public bool GenerateDiagramSvgImages { get; private set; } - private string FilePath { get; } + private string? PlantumlJarPath { get; set; } private ProcessStartInfo ProcessInfo { get; } /// @@ -22,7 +21,7 @@ public class PlantumlSession : IDisposable /// public PlantumlSession() { - FilePath = PlantumlResource.Load(); + PlantumlJarPath = null; ProcessInfo = new ProcessStartInfo { FileName = "java", @@ -32,23 +31,6 @@ public PlantumlSession() }; } - /// - /// Constructor with credentials to impersonate - /// - /// - /// - [SupportedOSPlatform("windows")] - public PlantumlSession(string username, string password) : this() - { - if (!OperatingSystem.IsWindows()) - { - return; - } - - ProcessInfo.UserName = username; - ProcessInfo.PasswordInClearText = password; - } - /// /// The C4Sharp has embedded the current version of C4-PluntUML. /// But, if you want to use the C4-PlantUML up-to-date version from their repo, @@ -94,17 +76,20 @@ internal void Execute(string path, bool processWholeDirectory, string generatedI { try { + PlantumlResources.LoadResources(path); + PlantumlJarPath ??= PlantumlResources.LoadPlantumlJar(); + var directory = processWholeDirectory ? path - : new FileInfo(path)?.Directory?.FullName; - + : new FileInfo(path)?.Directory?.FullName; + if (string.IsNullOrEmpty(directory)) { throw new PlantumlException($"{nameof(PlantumlException)}: puml file not found."); } var results = new StringBuilder(); - + var jar = CalculateJarCommand(StandardLibraryBaseUrl, generatedImageFormat, directory); ProcessInfo.Arguments = $"{jar} {path}"; @@ -129,11 +114,14 @@ private string CalculateJarCommand(bool useStandardLibrary, string generatedImag const string includeLocalFilesArg = "-DRELATIVE_INCLUDE=\".\""; var resourcesOriginArg = useStandardLibrary ? string.Empty : includeLocalFilesArg; - var imageFormatOutputArg = string.IsNullOrWhiteSpace(generatedImageFormat) ? string.Empty: $"-t{generatedImageFormat}"; + var imageFormatOutputArg = string.IsNullOrWhiteSpace(generatedImageFormat) + ? string.Empty + : $"-t{generatedImageFormat}"; - return $"-jar {FilePath} {resourcesOriginArg} {imageFormatOutputArg} -verbose -o \"{directory}\" -charset UTF-8"; + return + $"-jar {PlantumlJarPath} {resourcesOriginArg} {imageFormatOutputArg} -Playout=smetana -verbose -o \"{directory}\" -charset UTF-8"; } - + /// /// Using the -pipe option, you can easily use PlantUML in your scripts. /// With this option, a diagram description is received through standard input and the PNG file is generated to standard output. @@ -145,13 +133,12 @@ private string CalculateJarCommand(bool useStandardLibrary, string generatedImag { try { - var results = new StringBuilder(); - - var jar = StandardLibraryBaseUrl - ? $"-jar {FilePath} -verbose -charset UTF-8" - : $"-jar {FilePath} -DRELATIVE_INCLUDE=\".\" -verbose -charset UTF-8"; + PlantumlJarPath ??= PlantumlResources.LoadPlantumlJar(); + var results = new StringBuilder(); var fileName = Guid.NewGuid().ToString("N"); + var standardLibraryBaseUrlArgs = StandardLibraryBaseUrl ? string.Empty : "-DRELATIVE_INCLUDE=\".\""; + var jar = $"-jar {PlantumlJarPath} {standardLibraryBaseUrlArgs} -Playout=smetana -verbose -charset UTF-8"; ProcessInfo.Arguments = $"{jar} -pipe > {fileName}.png"; ProcessInfo.RedirectStandardOutput = true; @@ -159,11 +146,8 @@ private string CalculateJarCommand(bool useStandardLibrary, string generatedImag ProcessInfo.StandardOutputEncoding = Encoding.UTF8; var process = new Process { StartInfo = ProcessInfo }; - - process.OutputDataReceived += (p, args) => - { - results.AppendLine(args.Data); - }; + + process.OutputDataReceived += (_, args) => { results.AppendLine(args.Data); }; process.Start(); process.StandardInput.Write(input); @@ -186,7 +170,17 @@ private string CalculateJarCommand(bool useStandardLibrary, string generatedImag /// public void Dispose() { - PlantumlResource.Clear(FilePath); + try + { + if (PlantumlJarPath is not null) + { + File.Delete(PlantumlJarPath); + } + } + catch + { + // ignored + } } } } \ No newline at end of file diff --git a/src/C4Sharp/Models/Plantuml/PlantumlStream.cs b/src/C4Sharp/Models/Plantuml/IO/PlantumlStream.cs similarity index 54% rename from src/C4Sharp/Models/Plantuml/PlantumlStream.cs rename to src/C4Sharp/Models/Plantuml/IO/PlantumlStream.cs index 57ce704..ac59597 100644 --- a/src/C4Sharp/Models/Plantuml/PlantumlStream.cs +++ b/src/C4Sharp/Models/Plantuml/IO/PlantumlStream.cs @@ -1,14 +1,14 @@ -using System.Collections.Generic; using System.IO; using C4Sharp.Diagrams; +using C4Sharp.Models.Plantuml.Extensions; -namespace C4Sharp.Models.Plantuml +namespace C4Sharp.Models.Plantuml.IO { public static class PlantumlStream { - private static readonly object Lock = new object(); + private static readonly object Lock = new(); - public static (string, Stream) GetStream(this PlantumlSession session, Diagram diagram) + public static (string fileName, Stream fileContent) GetStream(this PlantumlSession session, Diagram diagram) { lock (Lock) { diff --git a/src/C4Sharp/Models/Plantuml/PlantumlResource.cs b/src/C4Sharp/Models/Plantuml/PlantumlResource.cs deleted file mode 100644 index 3a285cd..0000000 --- a/src/C4Sharp/Models/Plantuml/PlantumlResource.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.IO; -using C4Sharp.Extensions; - -namespace C4Sharp.Models.Plantuml -{ - /// - /// PlantUML Resources - /// - internal static class PlantumlResource - { - /// - /// Load plantuml.jar as tempfile - /// - /// tempfile name - /// - public static string Load() - { - try - { - var fileName = Path.GetTempFileName(); - - using var resource = ResourceMethods.GetPlantumlResource(); - using var file = new FileStream(fileName, FileMode.Create, FileAccess.Write); - resource.CopyTo(file); - - return fileName; - } - catch (Exception e) - { - throw new PlantumlException($"{nameof(PlantumlException)}: Could not load plantuml engine.", e); - } - } - - /// - /// Clear - /// - /// - public static void Clear(string file) - { - try - { - File.Delete(file); - } - catch - { - // ignored - } - } - } -} \ No newline at end of file diff --git a/src/C4Sharp/Resources/plantuml.jar b/src/C4Sharp/Resources/plantuml.jar index f23a1ae..65b4894 100644 Binary files a/src/C4Sharp/Resources/plantuml.jar and b/src/C4Sharp/Resources/plantuml.jar differ diff --git a/tests/C4Sharp.IntegratedTests/ExportingDiagramTests.cs b/tests/C4Sharp.IntegratedTests/ExportingDiagramTests.cs index 8abc6f3..83b0519 100644 --- a/tests/C4Sharp.IntegratedTests/ExportingDiagramTests.cs +++ b/tests/C4Sharp.IntegratedTests/ExportingDiagramTests.cs @@ -2,7 +2,7 @@ using System.IO; using C4Sharp.Diagrams; using C4Sharp.IntegratedTests.Stubs.Diagrams; -using C4Sharp.Models.Plantuml; +using C4Sharp.Models.Plantuml.IO; using Xunit; namespace C4Sharp.IntegratedTests diff --git a/tests/C4Sharp.IntegratedTests/GettingStreamDiagramTests.cs b/tests/C4Sharp.IntegratedTests/GettingStreamDiagramTests.cs index 82f8b91..961f221 100644 --- a/tests/C4Sharp.IntegratedTests/GettingStreamDiagramTests.cs +++ b/tests/C4Sharp.IntegratedTests/GettingStreamDiagramTests.cs @@ -1,6 +1,5 @@ -using C4Sharp.Diagrams; using C4Sharp.IntegratedTests.Stubs.Diagrams; -using C4Sharp.Models.Plantuml; +using C4Sharp.Models.Plantuml.IO; using FluentAssertions; using Xunit; diff --git a/tests/C4Sharp.UnitTests/C4Sharp.UnitTests.csproj b/tests/C4Sharp.UnitTests/C4Sharp.UnitTests.csproj index 1f1ede7..e0c3f61 100644 --- a/tests/C4Sharp.UnitTests/C4Sharp.UnitTests.csproj +++ b/tests/C4Sharp.UnitTests/C4Sharp.UnitTests.csproj @@ -21,7 +21,7 @@ - + diff --git a/tests/C4Sharp.UnitTests/Diagrams/DiagramTests.cs b/tests/C4Sharp.UnitTests/Diagrams/DiagramTests.cs index dbeab6b..92228b4 100644 --- a/tests/C4Sharp.UnitTests/Diagrams/DiagramTests.cs +++ b/tests/C4Sharp.UnitTests/Diagrams/DiagramTests.cs @@ -1,10 +1,6 @@ -using System; using C4Sharp.Diagrams; using C4Sharp.Diagrams.Core; using C4Sharp.Diagrams.Supplementary; -using C4Sharp.Models.Plantuml; -using C4Sharp.Models.Relationships; -using C4Sharp.Sample.Diagrams; using FluentAssertions; using Xunit;