From 83206befb8b0256211fac37079ab5241f9cb7b3d Mon Sep 17 00:00:00 2001 From: "Thyge S. Steffensen" <31892312+thygesteffensen@users.noreply.github.com> Date: Thu, 28 Sep 2023 14:33:14 +0200 Subject: [PATCH 01/42] docs: Add NuGet install steps in README The README was incomplete missing the steps to install the tool globally from NuGet --- README.md | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 57353cc..99d3cd6 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,30 @@ _Read more at [https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools]( ## Install the tool globally +### Install the tool from NuGet +The latest version on NuGet can be installed globally by: +```sh +$ dotnet tool install --global EAVFW.Extensions.Manifest.ManifestEnricherTool +``` +_Instructions to install a specific version can be found on [NuGet](https://www.nuget.org/packages/EAVFW.Extensions.Manifest.ManifestEnricherTool)._ -### Install the tool from NuGet -Coming soon... +Invoke the tool globally by: +``` +$ eavfw-manifest +``` +_This is contradictory to invoking the tool installed locally by `$ dotnet eavfw-manifest`._ + +#### Update tool + +The tool can be updated globally by: +``` +$ dotnet tool update --global EAVFW.Extensions.Manifest.ManifestEnricherTool +``` + +#### Uninstall tool + +The tool can be uninstalled globally by: +``` +$ dotnet tool uninstall --global EAVFW.Extensions.Manifest.ManifestEnricherTool +``` From 2446e872fbeed3a198e8c273efc426c1a6ade5da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Thu, 9 Nov 2023 11:48:50 +0100 Subject: [PATCH 02/42] fix: added token support for eavfw sql apply --- .../Commands/SQLApplyCommand.cs | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLApplyCommand.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLApplyCommand.cs index 53a6157..1594d86 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLApplyCommand.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLApplyCommand.cs @@ -9,10 +9,34 @@ namespace EAVFW.Extensions.Manifest.ManifestEnricherTool.Commands { + /// + /// Example demonstrating creating a custom device code flow authentication provider and attaching it to the driver. + /// This is helpful for applications that wish to override the Callback for the Device Code Result implemented by the SqlClient driver. + /// + public class AccessTokenProvider : SqlAuthenticationProvider + { + private readonly string token; + + public AccessTokenProvider(string token) + { + this.token = token; + } + public override async Task AcquireTokenAsync(SqlAuthenticationParameters parameters) + { + + return new SqlAuthenticationToken(token, DateTime.UtcNow.AddHours(1)); + } + + public override bool IsSupported(SqlAuthenticationMethod authenticationMethod) => authenticationMethod.Equals(SqlAuthenticationMethod.ActiveDirectoryServicePrincipal); + + + } + public class SQLApplyCommand : Command { public Option ClientSecret = new Option("ClientSecret", ""); public Option ClientId = new Option("ClientId", ""); + public Option Token = new Option("Token", ""); public Option Server = new Option("Server", ""); public Option DatabaseName = new Option("DatabaseName", ""); @@ -40,7 +64,8 @@ public SQLApplyCommand() : base("apply") Files.AddAlias("-i"); Add(Files); - + Token.AddAlias("--token"); + Add(Token); Files.AllowMultipleArgumentsPerToken = true; @@ -54,10 +79,15 @@ private async Task Run(ParseResult arg1, IConsole arg2) var clientSecret = arg1.GetValueForOption(ClientSecret); var server = arg1.GetValueForOption(Server); var database = arg1.GetValueForOption(DatabaseName); + var token = arg1.GetValueForOption(Token); var files = arg1.GetValueForOption(Files); var _replacements = arg1.GetValueForOption(Replacements); + if (!string.IsNullOrEmpty(token)) + { + SqlAuthenticationProvider.SetProvider(SqlAuthenticationMethod.ActiveDirectoryServicePrincipal, new AccessTokenProvider(token)); + } // Use your own server, database, app ID, and secret. string ConnectionString = $@"Server={server}; Authentication=Active Directory Service Principal;Command Timeout=300; Encrypt=True; Database={database}; User Id={clientid}; Password={clientSecret}"; //var files = new[] { @"C:\dev\MedlemsCentralen\obj\dbinit\init.sql", @"C:\dev\MedlemsCentralen\obj\dbinit\init-systemadmin.sql" }; From d0f2a9f223c717b824c7f94f1c14104728cd328f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Thu, 9 Nov 2023 12:44:11 +0100 Subject: [PATCH 03/42] fix: added add user command to add webapp identity --- .../Commands/SQLApplyCommand.cs | 76 +++++++++++++++++++ .../Commands/SQLCommand.cs | 1 + 2 files changed, 77 insertions(+) diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLApplyCommand.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLApplyCommand.cs index 1594d86..e68143e 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLApplyCommand.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLApplyCommand.cs @@ -32,6 +32,82 @@ public override async Task AcquireTokenAsync(SqlAuthenti } + public class SQLUserCommand : Command + { + public Option ClientSecret = new Option("ClientSecret", ""); + public Option ClientId = new Option("ClientId", ""); + public Option Token = new Option("Token", ""); + public Option Server = new Option("Server", ""); + public Option DatabaseName = new Option("DatabaseName", ""); + public Option ExternalUserName = new Option("ExternalUserName", ""); + public Option ExternalUserObjId = new Option("ExternalUserObjId", ""); + + public SQLUserCommand() : base("add-user") + { + Server.AddAlias("-S"); + Add(Server); + + ClientSecret.AddAlias("--client-secret"); + Add(ClientSecret); + + ClientId.AddAlias("--client-id"); + Add(ClientId); + DatabaseName.AddAlias("-d"); + Add(DatabaseName); + + + Token.AddAlias("--token"); + Add(Token); + ExternalUserName.AddAlias("--external-user-name"); + Add(ExternalUserName); + ExternalUserObjId.AddAlias("--external-user-objid"); + Add(ExternalUserObjId); + + + Handler = CommandHandler.Create(Run); + } + private async Task Run(ParseResult arg1, IConsole arg2) + { + var clientid = arg1.GetValueForOption(ClientId); + var clientSecret = arg1.GetValueForOption(ClientSecret); + var server = arg1.GetValueForOption(Server); + var database = arg1.GetValueForOption(DatabaseName); + var token = arg1.GetValueForOption(Token); + var user = arg1.GetValueForOption(ExternalUserName); + var userid = arg1.GetValueForOption(ExternalUserObjId); + + if (!string.IsNullOrEmpty(token)) + { + SqlAuthenticationProvider.SetProvider(SqlAuthenticationMethod.ActiveDirectoryServicePrincipal, new AccessTokenProvider(token)); + } + // Use your own server, database, app ID, and secret. + string ConnectionString = $@"Server={server}; Authentication=Active Directory Service Principal;Command Timeout=300; Encrypt=True; Database={database}; User Id={clientid}; Password={clientSecret}"; + //var files = new[] { @"C:\dev\MedlemsCentralen\obj\dbinit\init.sql", @"C:\dev\MedlemsCentralen\obj\dbinit\init-systemadmin.sql" }; + + using (SqlConnection conn = new SqlConnection(ConnectionString)) + { + await conn.OpenAsync(); + + var cmd = conn.CreateCommand(); + + // var sid = "0x";// + string.Format("{0:X2}", Guid.Parse("3438c38d-c721-4373-943c-69b0dfe25462")); + var sid = "0x"; + foreach (var @byte in Guid.Parse(userid).ToByteArray()) { + sid += string.Format("{0:X2}", @byte); + } + + + cmd.CommandText = $@" CREATE USER [{user}] WITH DEFAULT_SCHEMA=[dbo], SID = {sid}, TYPE = E; + ALTER ROLE db_datareader ADD MEMBER [{user}]; + ALTER ROLE db_datawriter ADD MEMBER [{user}]; + ALTER ROLE db_ddladmin ADD MEMBER [{user}];"; + + var r = await cmd.ExecuteNonQueryAsync(); + Console.WriteLine("Rows changed: " + r); + } + } + + } public class SQLApplyCommand : Command { public Option ClientSecret = new Option("ClientSecret", ""); diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLCommand.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLCommand.cs index 17f7611..68d3720 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLCommand.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLCommand.cs @@ -55,6 +55,7 @@ public SQLCommand(IManifestPermissionGenerator manifestPermissionGenerator) : ba this.manifestPermissionGenerator = manifestPermissionGenerator ?? throw new ArgumentNullException(nameof(manifestPermissionGenerator)); Add(new SQLApplyCommand()); + Add(new SQLUserCommand()); } private async Task Run(ParseResult parseResult, IConsole console) From 910225e87415b381ba7b15544f029f2f6e42da87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Thu, 9 Nov 2023 12:57:19 +0100 Subject: [PATCH 04/42] fix: fixed the add user to only do owner --- .../Commands/SQLApplyCommand.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLApplyCommand.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLApplyCommand.cs index e68143e..ecf1c22 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLApplyCommand.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLApplyCommand.cs @@ -96,11 +96,17 @@ private async Task Run(ParseResult arg1, IConsole arg2) sid += string.Format("{0:X2}", @byte); } - - cmd.CommandText = $@" CREATE USER [{user}] WITH DEFAULT_SCHEMA=[dbo], SID = {sid}, TYPE = E; - ALTER ROLE db_datareader ADD MEMBER [{user}]; - ALTER ROLE db_datawriter ADD MEMBER [{user}]; - ALTER ROLE db_ddladmin ADD MEMBER [{user}];"; + + cmd.CommandText = $@"IF NOT EXISTS(SELECT 1 FROM sys.database_principals WHERE name ='{user}') + BEGIN + CREATE USER [{user}] WITH DEFAULT_SCHEMA=[dbo], SID = {sid}, TYPE = E; + END + IF IS_ROLEMEMBER('db_owner','$ServicePrincipalName') = 0 + BEGIN + ALTER ROLE db_owner ADD MEMBER [{user}] + END + GRANT CONTROL ON DATABASE::[{database}] TO [{user}];"; + var r = await cmd.ExecuteNonQueryAsync(); Console.WriteLine("Rows changed: " + r); From 54c55f3d82385c18c3dff3b3f8e9236e23c44bd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Thu, 9 Nov 2023 20:30:04 +0100 Subject: [PATCH 05/42] fix: added transaction support and error on replacements --- .../Commands/SQLApplyCommand.cs | 66 +++++++++++++++---- ...sions.Manifest.ManifestEnricherTool.csproj | 2 + 2 files changed, 56 insertions(+), 12 deletions(-) diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLApplyCommand.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLApplyCommand.cs index ecf1c22..d8f7730 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLApplyCommand.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLApplyCommand.cs @@ -1,5 +1,6 @@ using Microsoft.Data.SqlClient; using System; +using System.Collections.Generic; using System.CommandLine; using System.CommandLine.NamingConventionBinder; using System.CommandLine.Parsing; @@ -171,34 +172,55 @@ private async Task Run(ParseResult arg1, IConsole arg2) SqlAuthenticationProvider.SetProvider(SqlAuthenticationMethod.ActiveDirectoryServicePrincipal, new AccessTokenProvider(token)); } // Use your own server, database, app ID, and secret. - string ConnectionString = $@"Server={server}; Authentication=Active Directory Service Principal;Command Timeout=300; Encrypt=True; Database={database}; User Id={clientid}; Password={clientSecret}"; + string ConnectionString = + !string.IsNullOrEmpty(token + clientid + clientSecret) ? + $@"Server={server}; Authentication=Active Directory Service Principal;Command Timeout=300; Encrypt=True; Database={database}; User Id={clientid}; Password={clientSecret}" : + $@"Server={server}; Authentication=Active Directory Device Code Flow;Command Timeout=300; Encrypt=True; Database={database};Connect Timeout=180;"; //var files = new[] { @"C:\dev\MedlemsCentralen\obj\dbinit\init.sql", @"C:\dev\MedlemsCentralen\obj\dbinit\init-systemadmin.sql" }; - var replacements = _replacements.ToDictionary(k => k.Substring(0, k.IndexOf('=')), v => v.Substring(v.IndexOf('=') + 1)); + + Dictionary replacements = ExtractReplacemets(_replacements); using (SqlConnection conn = new SqlConnection(ConnectionString)) { - + await conn.OpenAsync(); - foreach(var file in files) + foreach (var file in files) { var cmdText = File.ReadAllText(file); - foreach(var r in replacements) + foreach (var r in replacements) { cmdText = cmdText.Replace($"$({r.Key})", r.Value); } - + var stack = new Stack(); - foreach (var sql in cmdText.Split("GO")) + // await ExecuteSQL(conn, "BEGIN TRANSACTION"); + + foreach (var sql in cmdText.Split("GO") + .Where(s=>!string.IsNullOrEmpty(s))) { + + if(string.Equals( sql , "BEGIN TRANSACTION;", StringComparison.OrdinalIgnoreCase)){ + stack.Push(conn.BeginTransaction()); + continue; + } + + if (string.Equals(sql, "COMMIT;", StringComparison.OrdinalIgnoreCase)) + { + stack.Pop().Commit(); + + continue; + } + using var cmd = conn.CreateCommand(); - + cmd.CommandText = sql.Trim(); - // await context.Context.Database.ExecuteSqlRawAsync(sql); + if (!string.IsNullOrEmpty(cmd.CommandText)) { + //Console.WriteLine("Executing: " + cmd.CommandText); var r = await cmd.ExecuteNonQueryAsync(); Console.WriteLine("Rows changed: " + r); } @@ -207,11 +229,31 @@ private async Task Run(ParseResult arg1, IConsole arg2) - - + + } - + + } + } + + private static Dictionary ExtractReplacemets(string[] _replacements) + { + try + { + return _replacements.ToDictionary(k => k.Substring(0, k.IndexOf('=')), v => v.Substring(v.IndexOf('=') + 1)); + }catch(Exception ex) + { + Console.WriteLine(string.Join("\n", _replacements)); + throw; } } + + private static async Task ExecuteSQL(SqlConnection conn, string sql) + { + using var cmd = conn.CreateCommand(); + + cmd.CommandText = sql; + var r = await cmd.ExecuteNonQueryAsync(); + } } } diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj index 3c92d6c..265b1f6 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj @@ -20,6 +20,8 @@ + + From b19305ceab9e2ef79fc92d514a521bf34030bbe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Fri, 10 Nov 2023 00:24:29 +0100 Subject: [PATCH 06/42] fix: sqlcommand IS_ROLEMEMBER --- .../Commands/SQLApplyCommand.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLApplyCommand.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLApplyCommand.cs index d8f7730..137f540 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLApplyCommand.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLApplyCommand.cs @@ -87,22 +87,25 @@ private async Task Run(ParseResult arg1, IConsole arg2) using (SqlConnection conn = new SqlConnection(ConnectionString)) { - await conn.OpenAsync(); - - var cmd = conn.CreateCommand(); - // var sid = "0x";// + string.Format("{0:X2}", Guid.Parse("3438c38d-c721-4373-943c-69b0dfe25462")); var sid = "0x"; - foreach (var @byte in Guid.Parse(userid).ToByteArray()) { + foreach (var @byte in Guid.Parse(userid).ToByteArray()) + { sid += string.Format("{0:X2}", @byte); } + + + await conn.OpenAsync(); + + var cmd = conn.CreateCommand(); + cmd.CommandText = $@"IF NOT EXISTS(SELECT 1 FROM sys.database_principals WHERE name ='{user}') BEGIN CREATE USER [{user}] WITH DEFAULT_SCHEMA=[dbo], SID = {sid}, TYPE = E; END - IF IS_ROLEMEMBER('db_owner','$ServicePrincipalName') = 0 + IF IS_ROLEMEMBER('db_owner','{user}') = 0 BEGIN ALTER ROLE db_owner ADD MEMBER [{user}] END From 35f8177ca508b65df7f698d963c957968c3a243c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thyge=20Sk=C3=B8dt=20Steffensen?= <31892312+thygesteffensen@users.noreply.github.com> Date: Thu, 2 Nov 2023 09:31:14 +0100 Subject: [PATCH 07/42] feat: Extract Plugin documentation version 1 --- .editorconfig | 4 + ...tensions.Manifest.ManifestEnricherTool.sln | 7 ++ .../AssemblyInfo.cs | 9 ++ .../CustomAssemblyResolver.cs | 36 ++++++ .../DocumentLogic.cs | 74 ++++++++++++ .../EAVFW.Extensions.Docs.Extracter.csproj | 17 +++ .../IDocumentLogic.cs | 15 +++ .../PluginDocumentation.cs | 34 ++++++ .../PluginInfo.cs | 28 +++++ .../XmlDocumentationHelper.cs | 65 ++++++++++ .../XmlMemberElement.cs | 12 ++ .../Commands/DocumentCommand.cs | 111 ++++++++++++++++++ ...sions.Manifest.ManifestEnricherTool.csproj | 5 +- .../Program.cs | 4 + .../Properties/launchSettings.json | 6 +- 15 files changed, 424 insertions(+), 3 deletions(-) create mode 100644 .editorconfig create mode 100644 src/EAVFW.Extensions.Docs.Extracter/AssemblyInfo.cs create mode 100644 src/EAVFW.Extensions.Docs.Extracter/CustomAssemblyResolver.cs create mode 100644 src/EAVFW.Extensions.Docs.Extracter/DocumentLogic.cs create mode 100644 src/EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj create mode 100644 src/EAVFW.Extensions.Docs.Extracter/IDocumentLogic.cs create mode 100644 src/EAVFW.Extensions.Docs.Extracter/PluginDocumentation.cs create mode 100644 src/EAVFW.Extensions.Docs.Extracter/PluginInfo.cs create mode 100644 src/EAVFW.Extensions.Docs.Extracter/XmlDocumentationHelper.cs create mode 100644 src/EAVFW.Extensions.Docs.Extracter/XmlMemberElement.cs create mode 100644 src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/DocumentCommand.cs diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..5b462cc --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +root = true + +[*] +insert_final_newline = true diff --git a/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln b/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln index 3120658..283985b 100644 --- a/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln +++ b/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln @@ -44,6 +44,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EAVFramework", "external\EA EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EAVFW.Extensions.Manifest.SDK", "external\EAVFramework\sdk\EAVFW.Extensions.Manifest.SDK.csproj", "{3BEF0769-ABD1-4D34-8004-C98DE9FB0339}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EAVFW.Extensions.Docs.Extracter", "src\EAVFW.Extensions.Docs.Extracter\EAVFW.Extensions.Docs.Extracter.csproj", "{432042AB-6A78-4ED7-B8AC-73B047F6630F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -64,6 +66,10 @@ Global {2F30C24A-421A-4309-9F07-99668EA70C25}.Debug|Any CPU.Build.0 = Debug|Any CPU {3BEF0769-ABD1-4D34-8004-C98DE9FB0339}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3BEF0769-ABD1-4D34-8004-C98DE9FB0339}.Debug|Any CPU.Build.0 = Debug|Any CPU + {432042AB-6A78-4ED7-B8AC-73B047F6630F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {432042AB-6A78-4ED7-B8AC-73B047F6630F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {432042AB-6A78-4ED7-B8AC-73B047F6630F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {432042AB-6A78-4ED7-B8AC-73B047F6630F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -75,6 +81,7 @@ Global {79505337-2855-4CC7-8FD3-D5AF31B18278} = {CAE8FBC9-BDC3-4F45-81E1-57506D609011} {2F30C24A-421A-4309-9F07-99668EA70C25} = {CAE8FBC9-BDC3-4F45-81E1-57506D609011} {3BEF0769-ABD1-4D34-8004-C98DE9FB0339} = {CAE8FBC9-BDC3-4F45-81E1-57506D609011} + {432042AB-6A78-4ED7-B8AC-73B047F6630F} = {0D61C87C-0809-4CD7-9200-D78AD11A1E22} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {036D5D82-DDA4-4600-B190-739D512F1062} diff --git a/src/EAVFW.Extensions.Docs.Extracter/AssemblyInfo.cs b/src/EAVFW.Extensions.Docs.Extracter/AssemblyInfo.cs new file mode 100644 index 0000000..d76edcc --- /dev/null +++ b/src/EAVFW.Extensions.Docs.Extracter/AssemblyInfo.cs @@ -0,0 +1,9 @@ +namespace EAVFW.Extensions.Docs.Extracter +{ + public class AssemblyInfo + { + public string Name { get; set; } = ""; + public string Version { get; set; } = ""; + public string Path { get; set; } + } +} diff --git a/src/EAVFW.Extensions.Docs.Extracter/CustomAssemblyResolver.cs b/src/EAVFW.Extensions.Docs.Extracter/CustomAssemblyResolver.cs new file mode 100644 index 0000000..a2922f3 --- /dev/null +++ b/src/EAVFW.Extensions.Docs.Extracter/CustomAssemblyResolver.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace EAVFW.Extensions.Docs.Extracter +{ + public static class CustomAssemblyResolver + { + public static Dictionary Dictionary { get; set; } = new(); + + public static Assembly? CustomAssemblyResolverEventHandler(object? sender, ResolveEventArgs args) + { + // Ignore missing resources + if (args.Name.Contains(".resources")) + return null; + + // check for assemblies already loaded + var assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.FullName == args.Name); + if (assembly != null) + return assembly; + + if (!Dictionary.TryGetValue(args.Name.Split(',').First(), out var assemblyInfo)) + return null; + + try + { + return Assembly.LoadFrom(assemblyInfo.Path); + } + catch (Exception) + { + return null; + } + } + } +} diff --git a/src/EAVFW.Extensions.Docs.Extracter/DocumentLogic.cs b/src/EAVFW.Extensions.Docs.Extracter/DocumentLogic.cs new file mode 100644 index 0000000..32535de --- /dev/null +++ b/src/EAVFW.Extensions.Docs.Extracter/DocumentLogic.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.Contracts; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Runtime.Loader; +using EAVFramework.Plugins; + +namespace EAVFW.Extensions.Docs.Extracter +{ + public class DocumentLogic : IDocumentLogic + { + private static Dictionary BuildAssemblyDictionary(IEnumerable binDirectories) + { + var dictionary = new Dictionary(); + + foreach (var directory in binDirectories) + { + var dlls = Directory.GetFiles(directory, "*.dll"); + foreach (var dll in dlls) + { + var assemblyName = AssemblyName.GetAssemblyName(dll); + + dictionary.TryAdd(assemblyName.Name!, new AssemblyInfo + { + Name = assemblyName.Name!, + Version = assemblyName.Version!.ToString(), + Path = dll + }); + } + } + + return dictionary; + } + + /// + public IEnumerable ExtractPluginDocumentation(PluginInfo pluginInfo) + { + var subDirectories = pluginInfo.RootPath.EnumerateDirectories("*", SearchOption.AllDirectories); + + var directoriesWithBin = + from d in subDirectories + where d.FullName.EndsWith($"bin/{pluginInfo.Configuration}/{pluginInfo.Framework}") + select d.FullName; + + CustomAssemblyResolver.Dictionary = BuildAssemblyDictionary(directoriesWithBin.AsQueryable()); + + var currentDomain = AppDomain.CurrentDomain; + currentDomain.AssemblyResolve += CustomAssemblyResolver.CustomAssemblyResolverEventHandler; + + var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(pluginInfo.AssemblyPath.FullName); + + var implementingTypes = assembly.GetTypes() + .Where(t => typeof(IPlugin).IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract); + + var plugins = + from implementingType in implementingTypes + let pluginRegistrations = implementingType.GetCustomAttributes() + let interface2 = implementingType.GetInterfaces() + .FirstOrDefault(i => i.GenericTypeArguments.Length == 2) + select new PluginDocumentation + { + PluginRegistrations = pluginRegistrations, + Name = implementingType.Name, + Summary = implementingType.GetDocumentation(), + Context = interface2.GetGenericArguments().First(), + Entity = interface2.GetGenericArguments().Last() + }; + + return plugins; + } + } +} diff --git a/src/EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj b/src/EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj new file mode 100644 index 0000000..f7d8b2d --- /dev/null +++ b/src/EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj @@ -0,0 +1,17 @@ + + + + 9.0 + net6.0 + enable + + + + + + + + + + + diff --git a/src/EAVFW.Extensions.Docs.Extracter/IDocumentLogic.cs b/src/EAVFW.Extensions.Docs.Extracter/IDocumentLogic.cs new file mode 100644 index 0000000..eb39f45 --- /dev/null +++ b/src/EAVFW.Extensions.Docs.Extracter/IDocumentLogic.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace EAVFW.Extensions.Docs.Extracter +{ + public interface IDocumentLogic + { + /// + /// Extract plugin metadata and summary from given Assembly using the DLL and .xml documentation files + /// created during a build. + /// + /// Remember to enable GenerateDocumentationFile for the project. + /// + IEnumerable ExtractPluginDocumentation(PluginInfo pluginInfo); + } +} diff --git a/src/EAVFW.Extensions.Docs.Extracter/PluginDocumentation.cs b/src/EAVFW.Extensions.Docs.Extracter/PluginDocumentation.cs new file mode 100644 index 0000000..b1830f2 --- /dev/null +++ b/src/EAVFW.Extensions.Docs.Extracter/PluginDocumentation.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json.Serialization; +using EAVFramework.Plugins; + +namespace EAVFW.Extensions.Docs.Extracter +{ + public class PluginDocumentation + { + [JsonIgnore] + public IEnumerable PluginRegistrations { get; set; } = + Array.Empty(); + + public string? Name { get; set; } + + [JsonIgnore] + public Type? Context { get; set; } + [JsonIgnore] + public Type? Entity { get; set; } + public string Summary { get; set; } = ""; + + + public override string ToString() + { + var summary = Summary?.Split("\n").Select(x => x.Trim()).ToArray() ?? Array.Empty(); + return $"Plugin: {Name} on {Entity.Name}\n* " + + string.Join("\n* ", PluginRegistrations.Select(x => $"{x.Operation} on {x.Execution} as {x.Order}")) + + '\n' + + string.Join('\n', summary) + + "\n\n"; + } + } +} diff --git a/src/EAVFW.Extensions.Docs.Extracter/PluginInfo.cs b/src/EAVFW.Extensions.Docs.Extracter/PluginInfo.cs new file mode 100644 index 0000000..f26bf60 --- /dev/null +++ b/src/EAVFW.Extensions.Docs.Extracter/PluginInfo.cs @@ -0,0 +1,28 @@ +using System; +using System.IO; + +namespace EAVFW.Extensions.Docs.Extracter +{ + public struct PluginInfo + { + public PluginInfo(DirectoryInfo rootPath, FileInfo assemblyPath, string configuration, string framework) + { + RootPath = !rootPath.Exists + ? throw new ArgumentException($"Directory {nameof(rootPath)} does not exists") + : rootPath; + AssemblyPath = !assemblyPath.Exists + ? throw new ArgumentException($"File {nameof(assemblyPath)} does not exists") + : assemblyPath; + + Configuration = string.IsNullOrWhiteSpace(configuration) + ? throw new ArgumentNullException(configuration) + : configuration; + Framework = string.IsNullOrWhiteSpace(framework) ? throw new ArgumentNullException(framework) : framework; + } + + public DirectoryInfo RootPath { get; } + public FileInfo AssemblyPath { get; } + public string Configuration { get; } + public string Framework { get; } + } +} diff --git a/src/EAVFW.Extensions.Docs.Extracter/XmlDocumentationHelper.cs b/src/EAVFW.Extensions.Docs.Extracter/XmlDocumentationHelper.cs new file mode 100644 index 0000000..e8f7565 --- /dev/null +++ b/src/EAVFW.Extensions.Docs.Extracter/XmlDocumentationHelper.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Xml; +using System.Xml.Serialization; + +namespace EAVFW.Extensions.Docs.Extracter +{ + public static class XmlDocumentationHelper + { + private static readonly Dictionary LoadedXmlDocumentation = new(); + private static readonly HashSet LoadedAssemblies = new(); + + public static string? GetDocumentation(this Type type) + { + LoadXmlDocumentation(type.Assembly); + + var key = $"T:{type.FullName}"; + LoadedXmlDocumentation.TryGetValue(key, out var docs); + return docs; + } + + private static void LoadXmlDocumentation(Assembly assembly) + { + if (LoadedAssemblies.Contains(assembly)) + return; // Already loaded + + var directoryPath = Path.GetDirectoryName(assembly.Location); + if (string.IsNullOrEmpty(directoryPath)) + return; + + var xmlFilePath = Path.Combine(directoryPath, assembly.GetName().Name + ".xml"); + + if (!File.Exists(xmlFilePath)) return; + + using var xmlReader = XmlReader.Create(new StringReader(File.ReadAllText(xmlFilePath))); + + + var started = false; + var name = ""; + while (xmlReader.Read()) + { + if (xmlReader.Name == "member") + { + started = true; + name = xmlReader.GetAttribute("name"); + continue; + } + + if (xmlReader is { Name: "member", NodeType: XmlNodeType.EndElement } && started) + { + name = ""; + started = false; + continue; + } + + if (xmlReader.Name == "summary" && !string.IsNullOrWhiteSpace(name)) + LoadedXmlDocumentation[name] = xmlReader.ReadInnerXml(); + } + + LoadedAssemblies.Add(assembly); + } + } +} diff --git a/src/EAVFW.Extensions.Docs.Extracter/XmlMemberElement.cs b/src/EAVFW.Extensions.Docs.Extracter/XmlMemberElement.cs new file mode 100644 index 0000000..ce53ecf --- /dev/null +++ b/src/EAVFW.Extensions.Docs.Extracter/XmlMemberElement.cs @@ -0,0 +1,12 @@ +using System.Xml.Serialization; + +namespace EAVFW.Extensions.Docs.Extracter +{ + [XmlRoot("member")] + public class XmlMemberElement + { + [XmlAttribute("name")] public string Name { get; set; } + + [XmlElement("summary")] public string Summary { get; set; } + } +} diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/DocumentCommand.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/DocumentCommand.cs new file mode 100644 index 0000000..b392f03 --- /dev/null +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/DocumentCommand.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.CommandLine.Parsing; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Text.Json; +using System.Threading.Tasks; +using EAVFW.Extensions.Docs.Extracter; + +namespace EAVFW.Extensions.Manifest.ManifestEnricherTool.Commands +{ + public class DocumentCommand : Command + { + private readonly IDocumentLogic documentLogic; + + + [Alias("-a")] + [Alias("--assembly")] + [Description("Path for the assembly")] + public FileInfo AssemblyPathOption { get; set; } + + [Alias("-p")] + [Alias("--probing-path")] + [Description("Path to probe for dependent assemblies")] + public DirectoryInfo RootPathOption { get; set; } + + [Alias("-c")] + [Alias("--configuration")] + [Description("Configuration for the built assembly")] + public string ConfigurationOption { get; set; } + + [Alias("-f")] + [Alias("--framework")] + [Description("Framework confugraiton for the built assembly")] + public string FrameworkOption { get; set; } + + + public DocumentCommand(IDocumentLogic documentLogic) : base("docs", "Generate documentation") + { + this.documentLogic = documentLogic ?? throw new ArgumentNullException(nameof(documentLogic)); + Handler = COmmandExtensions.Create(this, Array.Empty(), Run); + } + + private async Task Run(ParseResult parseResult, IConsole console) + { + if (IsMissingOptions(out var missing)) + { + Console.WriteLine("The following options are missed: " + string.Join(", ", missing)); + return 126; + } + + if (!RootPathOption.Exists) + { + Console.WriteLine("Probing path does not exists"); + return 1; + } + + if (!AssemblyPathOption.Exists) + { + Console.WriteLine("Assembly does not exists"); + return 1; + } + + var plugins = documentLogic + .ExtractPluginDocumentation(new PluginInfo(RootPathOption, AssemblyPathOption, ConfigurationOption, FrameworkOption)) + .ToArray(); + + var jsonString = JsonSerializer.Serialize(plugins, new JsonSerializerOptions + { + WriteIndented = true + }); + await File.WriteAllTextAsync("docs.json", jsonString); + + var groups = plugins.GroupBy(x => x.Entity!.Name); + + Console.WriteLine("# Plugins "); + foreach (var group in groups) + { + Console.WriteLine($"## {group.FirstOrDefault()?.Entity?.Name}"); + foreach (var pluginDocumentation in group) + { + Console.WriteLine(pluginDocumentation.ToString()); + } + } + + + return 0; + } + + private bool IsMissingOptions(out List missing) + { + missing = new List(); + + if (AssemblyPathOption == null) + missing.Add(nameof(AssemblyPathOption)); + + if (RootPathOption == null) + missing.Add(nameof(RootPathOption)); + + if (string.IsNullOrWhiteSpace(ConfigurationOption)) + missing.Add(nameof(ConfigurationOption)); + + if (string.IsNullOrWhiteSpace(FrameworkOption)) + missing.Add(nameof(FrameworkOption)); + + return false; + } + } +} diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj index 265b1f6..bf75144 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj @@ -48,4 +48,7 @@ - \ No newline at end of file + + + + diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Program.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Program.cs index d71f536..81bfd86 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Program.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Program.cs @@ -9,6 +9,7 @@ using Microsoft.Extensions.Logging; using System.CommandLine; using System.Threading.Tasks; +using EAVFW.Extensions.Docs.Extracter; using EAVFW.Extensions.Manifest.ManifestEnricherTool.Commands.Gzip; namespace EAVFW.Extensions.Manifest.ManifestEnricherTool @@ -28,11 +29,14 @@ static IServiceCollection ConfigureServices(IServiceCollection serviceCollection .AddManifestSDK() .AddSingleton(); + serviceCollection.AddSingleton(); + serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); + serviceCollection.AddSingleton(); serviceCollection.AddGPT(); serviceCollection.AddHttpClient(); diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json index aed73ed..7c30d12 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json @@ -3,7 +3,9 @@ "EAVFW.Extensions.Manifest.ManifestEnricherTool": { "commandName": "Project", "workingDirectory": "/Users/thyge/dev/playground", - "commandLineArgs": "binary --unzip 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" + "commandLineArgs": "docs -c Release -f net6.0 -a \"/Users/thyge/dev/hafnia/Letter of Indemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/Letter of Indemnity\"" +// "commandLineArgs": "binary --unzip 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" +// "commandLineArgs": "binary --unzip 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" // "commandLineArgs": "binary --unzip --pretty-print 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" // "commandLineArgs": "binary --unzip --pretty-print --output myjsonfile.json 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" // "commandLineArgs": "binary --zip {\"actions\":{\"CreateLOIDataRequestMessageAction\":{\"input\":{\"loirequest\":\"a4dd227a-efab-4cb5-3e2a-08dbcaf45591\",\"recipients\":[\"1504bf2f-cf6e-49c9-df39-08dbcaf6aa88\"]},\"status\":\"Succeded\",\"body\":\"a4dd227a-efab-4cb5-3e2a-08dbcaf45591\",\"failedReason\":null}},\"triggers\":{\"Trigger\":{\"time\":\"2023-10-12T07:41:42.311509+00:00\",\"body\":{\"entityName\":\"LetterofindemnityRequests\",\"recordId\":\"a4dd227a-efab-4cb5-3e2a-08dbcaf45591\",\"data\":{\"recipients\":[\"1504bf2f-cf6e-49c9-df39-08dbcaf6aa88\"]}}}}}" @@ -24,4 +26,4 @@ //"commandLineArgs": "--path C:\\dev\\hafnia\\loi\\src\\Hafnia.Models\\manifest.json --customizationprefix hafnia" } } -} \ No newline at end of file +} From af5f52b7682668494ecafc708c29661d155c8c19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thyge=20Sk=C3=B8dt=20Steffensen?= <31892312+thygesteffensen@users.noreply.github.com> Date: Wed, 8 Nov 2023 16:45:03 +0100 Subject: [PATCH 08/42] feat: Working version with Wizards --- .gitignore | 1 + ....ManifestEnricherTool.sln.DotSettings.user | 4 + .../DocumentLogic.cs | 121 +++++++++++++++--- .../IDocumentLogic.cs | 11 ++ .../{ => Plugin}/AssemblyInfo.cs | 0 .../{ => Plugin}/PluginDocumentation.cs | 0 .../{ => Plugin}/PluginInfo.cs | 0 .../{ => Plugin}/XmlDocumentationHelper.cs | 1 - .../{ => Plugin}/XmlMemberElement.cs | 0 .../Wizard/Wizards.cs | 101 +++++++++++++++ .../Commands/DocumentCommand.cs | 54 +++++++- ...sions.Manifest.ManifestEnricherTool.csproj | 2 +- .../Properties/launchSettings.json | 3 +- .../EAVFW.Extensions.Manifest.Tests.csproj | 1 + 14 files changed, 277 insertions(+), 22 deletions(-) create mode 100644 EAVFW.Extensions.Manifest.ManifestEnricherTool.sln.DotSettings.user rename src/EAVFW.Extensions.Docs.Extracter/{ => Plugin}/AssemblyInfo.cs (100%) rename src/EAVFW.Extensions.Docs.Extracter/{ => Plugin}/PluginDocumentation.cs (100%) rename src/EAVFW.Extensions.Docs.Extracter/{ => Plugin}/PluginInfo.cs (100%) rename src/EAVFW.Extensions.Docs.Extracter/{ => Plugin}/XmlDocumentationHelper.cs (98%) rename src/EAVFW.Extensions.Docs.Extracter/{ => Plugin}/XmlMemberElement.cs (100%) create mode 100644 src/EAVFW.Extensions.Docs.Extracter/Wizard/Wizards.cs diff --git a/.gitignore b/.gitignore index 5cb0f51..b4016f0 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ node_modules /.github/workflows/package-lock.json /artifacts *.csproj.user +.idea diff --git a/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln.DotSettings.user b/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln.DotSettings.user new file mode 100644 index 0000000..6f09b90 --- /dev/null +++ b/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln.DotSettings.user @@ -0,0 +1,4 @@ + + <SessionState ContinuousTestingMode="0" IsActive="True" Name="ZipAndUnZipTests" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> + <Solution /> +</SessionState> \ No newline at end of file diff --git a/src/EAVFW.Extensions.Docs.Extracter/DocumentLogic.cs b/src/EAVFW.Extensions.Docs.Extracter/DocumentLogic.cs index 32535de..ebefaec 100644 --- a/src/EAVFW.Extensions.Docs.Extracter/DocumentLogic.cs +++ b/src/EAVFW.Extensions.Docs.Extracter/DocumentLogic.cs @@ -1,10 +1,11 @@ using System; using System.Collections.Generic; -using System.Diagnostics.Contracts; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.Loader; +using System.Text.Json; +using System.Text.Json.Serialization; using EAVFramework.Plugins; namespace EAVFW.Extensions.Docs.Extracter @@ -36,6 +37,30 @@ private static Dictionary BuildAssemblyDictionary(IEnumera /// public IEnumerable ExtractPluginDocumentation(PluginInfo pluginInfo) + { + var assembly = LoadAssembly(pluginInfo); + + var implementingTypes = assembly.GetTypes() + .Where(t => typeof(IPlugin).IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract); + + var plugins = + from implementingType in implementingTypes + let pluginRegistrations = implementingType.GetCustomAttributes() + let _interface = implementingType.GetInterfaces() + .FirstOrDefault(i => i.GenericTypeArguments.Length == 2) + select new PluginDocumentation + { + PluginRegistrations = pluginRegistrations, + Name = implementingType.Name, + Summary = implementingType.GetDocumentation(), + Context = _interface.GetGenericArguments().First(), + Entity = _interface.GetGenericArguments().Last() + }; + + return plugins; + } + + private static Assembly LoadAssembly(PluginInfo pluginInfo) { var subDirectories = pluginInfo.RootPath.EnumerateDirectories("*", SearchOption.AllDirectories); @@ -50,25 +75,89 @@ where d.FullName.EndsWith($"bin/{pluginInfo.Configuration}/{pluginInfo.Framework currentDomain.AssemblyResolve += CustomAssemblyResolver.CustomAssemblyResolverEventHandler; var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(pluginInfo.AssemblyPath.FullName); + return assembly; + } - var implementingTypes = assembly.GetTypes() - .Where(t => typeof(IPlugin).IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract); + /// + public IEnumerable ExtractWizardDocumentation(FileInfo manifestFile, PluginInfo pluginInfo) + { + var assembly = LoadAssembly(pluginInfo); - var plugins = - from implementingType in implementingTypes - let pluginRegistrations = implementingType.GetCustomAttributes() - let interface2 = implementingType.GetInterfaces() - .FirstOrDefault(i => i.GenericTypeArguments.Length == 2) - select new PluginDocumentation + // Preloading types to easily query for documentation + var workflows = + from type in assembly.GetTypes() + // where type.IsAbstract && typeof(Workflow).IsAssignableFrom(type) + select type; + + // Load manifest + + + using var openStream = manifestFile.OpenRead(); + var jsonManifest = JsonDocument.ParseAsync(openStream).Result; + + // Find Wizards + var simpleManifest = new Dictionary(); + ExtractEntitiesWithWizards(jsonManifest.RootElement, simpleManifest); + + + // Glorified for loop? + var tabsWithWorkflows = + from entity in simpleManifest + from wizard in entity.Value.Wizards + from tabs in wizard.Value.Tabs + where tabs.Value.OnTransitionOut?.Workflow != null && tabs.Value.OnTransitionIn?.Workflow != null + select tabs.Value; + + foreach (var tabsWithWorkflow in tabsWithWorkflows) + { + if (!string.IsNullOrWhiteSpace(tabsWithWorkflow?.OnTransitionOut?.Workflow)) { - PluginRegistrations = pluginRegistrations, - Name = implementingType.Name, - Summary = implementingType.GetDocumentation(), - Context = interface2.GetGenericArguments().First(), - Entity = interface2.GetGenericArguments().Last() - }; + var workflow = tabsWithWorkflow.OnTransitionOut.Workflow!; + // look for workflow in types? + Console.WriteLine(workflow); + } + } - return plugins; + foreach (var (key, wizard) in simpleManifest) + { + var t = JsonSerializer.Serialize(wizard, new JsonSerializerOptions + { + WriteIndented = true, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull + }); + Console.WriteLine(t); + } + + + // Generate Wizard object + + + // Return Wizard object + return new List(); + } + + private void ExtractEntitiesWithWizards(JsonElement element, IDictionary entities) + { + if (element.ValueKind != JsonValueKind.Object) return; + + foreach (var property in element.EnumerateObject()) + { + if (!property.NameEquals("entities") || property.Value.ValueKind != JsonValueKind.Object) continue; + + var localEntities = + JsonSerializer.Deserialize>(property.Value.GetRawText(), + new JsonSerializerOptions + { + Converters = { new TabConverter() } + }); + + if (localEntities == null) return; + + foreach (var (key, value) in localEntities.Where(x => x.Value?.Wizards?.Any() ?? false)) + { + entities[key] = value; + } + } } } } diff --git a/src/EAVFW.Extensions.Docs.Extracter/IDocumentLogic.cs b/src/EAVFW.Extensions.Docs.Extracter/IDocumentLogic.cs index eb39f45..ff95e3a 100644 --- a/src/EAVFW.Extensions.Docs.Extracter/IDocumentLogic.cs +++ b/src/EAVFW.Extensions.Docs.Extracter/IDocumentLogic.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.IO; namespace EAVFW.Extensions.Docs.Extracter { @@ -9,7 +10,17 @@ public interface IDocumentLogic /// created during a build. /// /// Remember to enable GenerateDocumentationFile for the project. + /// /// IEnumerable ExtractPluginDocumentation(PluginInfo pluginInfo); + + /// + /// Extract Wizards from the given Manifest and generate documentation based on manifest metadata and workflow + /// CLR types and Actions + /// + /// + /// + /// + IEnumerable ExtractWizardDocumentation(FileInfo manifestFile, PluginInfo pluginInfo); } } diff --git a/src/EAVFW.Extensions.Docs.Extracter/AssemblyInfo.cs b/src/EAVFW.Extensions.Docs.Extracter/Plugin/AssemblyInfo.cs similarity index 100% rename from src/EAVFW.Extensions.Docs.Extracter/AssemblyInfo.cs rename to src/EAVFW.Extensions.Docs.Extracter/Plugin/AssemblyInfo.cs diff --git a/src/EAVFW.Extensions.Docs.Extracter/PluginDocumentation.cs b/src/EAVFW.Extensions.Docs.Extracter/Plugin/PluginDocumentation.cs similarity index 100% rename from src/EAVFW.Extensions.Docs.Extracter/PluginDocumentation.cs rename to src/EAVFW.Extensions.Docs.Extracter/Plugin/PluginDocumentation.cs diff --git a/src/EAVFW.Extensions.Docs.Extracter/PluginInfo.cs b/src/EAVFW.Extensions.Docs.Extracter/Plugin/PluginInfo.cs similarity index 100% rename from src/EAVFW.Extensions.Docs.Extracter/PluginInfo.cs rename to src/EAVFW.Extensions.Docs.Extracter/Plugin/PluginInfo.cs diff --git a/src/EAVFW.Extensions.Docs.Extracter/XmlDocumentationHelper.cs b/src/EAVFW.Extensions.Docs.Extracter/Plugin/XmlDocumentationHelper.cs similarity index 98% rename from src/EAVFW.Extensions.Docs.Extracter/XmlDocumentationHelper.cs rename to src/EAVFW.Extensions.Docs.Extracter/Plugin/XmlDocumentationHelper.cs index e8f7565..1ae0044 100644 --- a/src/EAVFW.Extensions.Docs.Extracter/XmlDocumentationHelper.cs +++ b/src/EAVFW.Extensions.Docs.Extracter/Plugin/XmlDocumentationHelper.cs @@ -3,7 +3,6 @@ using System.IO; using System.Reflection; using System.Xml; -using System.Xml.Serialization; namespace EAVFW.Extensions.Docs.Extracter { diff --git a/src/EAVFW.Extensions.Docs.Extracter/XmlMemberElement.cs b/src/EAVFW.Extensions.Docs.Extracter/Plugin/XmlMemberElement.cs similarity index 100% rename from src/EAVFW.Extensions.Docs.Extracter/XmlMemberElement.cs rename to src/EAVFW.Extensions.Docs.Extracter/Plugin/XmlMemberElement.cs diff --git a/src/EAVFW.Extensions.Docs.Extracter/Wizard/Wizards.cs b/src/EAVFW.Extensions.Docs.Extracter/Wizard/Wizards.cs new file mode 100644 index 0000000..4204c2a --- /dev/null +++ b/src/EAVFW.Extensions.Docs.Extracter/Wizard/Wizards.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace EAVFW.Extensions.Docs.Extracter +{ + public class Entity + { + [JsonPropertyName("wizards")] public Dictionary Wizards { get; set; } + } + + public class Wizard + { + [JsonPropertyName("title")] public string Title { get; set; } + + [JsonPropertyName("triggers")] public JsonElement Triggers { get; set; } + + [JsonPropertyName("tabs")] public Dictionary Tabs { get; set; } + } + + public struct Trigger + { + [JsonPropertyName("form")] public string Form { get; set; } + + [JsonPropertyName("ribbon")] public string Ribbon { get; set; } + } + + public class Tab + { + [JsonPropertyName("columns")] public JsonElement Columns { get; set; } + + [JsonPropertyName("visible")] public StringOrBoolean StringOrBoolean { get; set; } + + [JsonPropertyName("onTransitionOut")] public Transition? OnTransitionOut { get; set; } + + [JsonPropertyName("onTransitionIn")] public Transition? OnTransitionIn { get; set; } + + [JsonPropertyName("actions")] public JsonElement? Actions { get; set; } // TODO: This also needs to be enriched + } + + public struct StringOrBoolean + { + public StringOrBoolean(string stringValue) + { + StringValue = stringValue; + IsBool = false; + BooleanValue = default; + } + + public StringOrBoolean(bool booleanValue) + { + StringValue = default; + IsBool = false; + BooleanValue = booleanValue; + } + + public string? StringValue { get; } + + public bool BooleanValue { get; } + + public bool IsBool { get; } + } + + + public class TabConverter : JsonConverter + { + public override StringOrBoolean Read(ref Utf8JsonReader reader, Type typeToConvert, + JsonSerializerOptions options) + { + return reader.TokenType switch + { + JsonTokenType.String => new StringOrBoolean(reader.GetString() ?? ""), + JsonTokenType.False => new StringOrBoolean(false), + JsonTokenType.True => new StringOrBoolean(true), + _ => new StringOrBoolean() + }; + } + + public override void Write(Utf8JsonWriter writer, StringOrBoolean value, JsonSerializerOptions options) + { + if (value.IsBool) + writer.WriteBooleanValue(value.BooleanValue); + writer.WriteStringValue(value.StringValue); + } + } + + public class Transition + { + [JsonPropertyName("workflow")] public string? Workflow { get; set; } + + [JsonPropertyName("workflowSummary")] public string? WorkflowSummary { get; set; } + + [JsonPropertyName("message")] public Message? Message { get; set; } + } + + public class Message + { + [JsonPropertyName("title")] public string? Title { get; set; } + } +} diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/DocumentCommand.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/DocumentCommand.cs index b392f03..1384c3a 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/DocumentCommand.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/DocumentCommand.cs @@ -20,6 +20,11 @@ public class DocumentCommand : Command [Alias("--assembly")] [Description("Path for the assembly")] public FileInfo AssemblyPathOption { get; set; } + + [Alias("-m")] + [Alias("--manifest")] + [Description("Path for the manifest")] + public FileInfo ManifestPathOption { get; set; } [Alias("-p")] [Alias("--probing-path")] @@ -35,6 +40,19 @@ public class DocumentCommand : Command [Alias("--framework")] [Description("Framework confugraiton for the built assembly")] public string FrameworkOption { get; set; } + + + + [Alias("-t")] + [Alias("--target")] + [Description("Target?")] + public Targets Target { get; set; } + + public enum Targets + { + Plugins, + Wizards + } public DocumentCommand(IDocumentLogic documentLogic) : base("docs", "Generate documentation") @@ -62,9 +80,40 @@ private async Task Run(ParseResult parseResult, IConsole console) Console.WriteLine("Assembly does not exists"); return 1; } + + switch (Target) + { + case Targets.Plugins: + return await HandlePlugins(); + case Targets.Wizards: + return await HandleWizards(); + default: + throw new ArgumentOutOfRangeException(); + } + + return 0; + } + private async Task HandleWizards() + { + if (!ManifestPathOption?.Exists ?? true) + { + Console.WriteLine("Manifest does not exists"); + return 1; + } + + var t = documentLogic.ExtractWizardDocumentation(ManifestPathOption, new PluginInfo(RootPathOption, + AssemblyPathOption, ConfigurationOption, + FrameworkOption)); + + return 0; + } + + private async Task HandlePlugins() + { var plugins = documentLogic - .ExtractPluginDocumentation(new PluginInfo(RootPathOption, AssemblyPathOption, ConfigurationOption, FrameworkOption)) + .ExtractPluginDocumentation(new PluginInfo(RootPathOption, AssemblyPathOption, ConfigurationOption, + FrameworkOption)) .ToArray(); var jsonString = JsonSerializer.Serialize(plugins, new JsonSerializerOptions @@ -72,7 +121,7 @@ private async Task Run(ParseResult parseResult, IConsole console) WriteIndented = true }); await File.WriteAllTextAsync("docs.json", jsonString); - + var groups = plugins.GroupBy(x => x.Entity!.Name); Console.WriteLine("# Plugins "); @@ -85,7 +134,6 @@ private async Task Run(ParseResult parseResult, IConsole console) } } - return 0; } diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj index bf75144..d66cc9e 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj @@ -20,8 +20,8 @@ - + diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json index 7c30d12..0ba4c51 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json @@ -3,7 +3,8 @@ "EAVFW.Extensions.Manifest.ManifestEnricherTool": { "commandName": "Project", "workingDirectory": "/Users/thyge/dev/playground", - "commandLineArgs": "docs -c Release -f net6.0 -a \"/Users/thyge/dev/hafnia/Letter of Indemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/Letter of Indemnity\"" + "commandLineArgs": "docs -c Debug -t wizards -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Debug/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\" -m \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/manifest.loi.json\"" +// "commandLineArgs": "docs -c Debug -t plugins -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Debug/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\"" // "commandLineArgs": "binary --unzip 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" // "commandLineArgs": "binary --unzip 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" // "commandLineArgs": "binary --unzip --pretty-print 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" diff --git a/tests/EAVFW.Extensions.Manifest.Tests/EAVFW.Extensions.Manifest.Tests.csproj b/tests/EAVFW.Extensions.Manifest.Tests/EAVFW.Extensions.Manifest.Tests.csproj index 0fae815..dbad66c 100644 --- a/tests/EAVFW.Extensions.Manifest.Tests/EAVFW.Extensions.Manifest.Tests.csproj +++ b/tests/EAVFW.Extensions.Manifest.Tests/EAVFW.Extensions.Manifest.Tests.csproj @@ -10,6 +10,7 @@ + From 186dee657568fe9140ca1de662f7b4ce2c20e1d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thyge=20Sk=C3=B8dt=20Steffensen?= <31892312+thygesteffensen@users.noreply.github.com> Date: Thu, 9 Nov 2023 15:24:45 +0100 Subject: [PATCH 09/42] feat: Add plugin formatter --- ...tensions.Manifest.ManifestEnricherTool.sln | 7 ++ .../DocumentLogic.cs | 6 +- ...tensions.Docs.Extracter.csproj.DotSettings | 6 ++ .../PluginRegistrationAttributeConverter.cs | 34 +++++++ .../JsonConverters/TabConverter.cs | 30 +++++++ .../JsonConverters/TypeConverter.cs | 20 +++++ .../Plugin/PluginDocumentation.cs | 20 +---- .../ServiceCollectionExtension.cs | 14 +++ .../Wizard/Wizards.cs | 24 +---- .../EAVFW.Extensions.Docs.Generator.csproj | 12 +++ .../PluginDocumentationToReadMe.cs | 89 +++++++++++++++++++ .../Commands/DocumentCommand.cs | 24 ++--- ...sions.Manifest.ManifestEnricherTool.csproj | 1 + .../Program.cs | 2 +- .../Properties/launchSettings.json | 4 +- 15 files changed, 229 insertions(+), 64 deletions(-) create mode 100644 src/EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj.DotSettings create mode 100644 src/EAVFW.Extensions.Docs.Extracter/JsonConverters/PluginRegistrationAttributeConverter.cs create mode 100644 src/EAVFW.Extensions.Docs.Extracter/JsonConverters/TabConverter.cs create mode 100644 src/EAVFW.Extensions.Docs.Extracter/JsonConverters/TypeConverter.cs create mode 100644 src/EAVFW.Extensions.Docs.Extracter/ServiceCollectionExtension.cs create mode 100644 src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj create mode 100644 src/EAVFW.Extensions.Docs.Generator/PluginDocumentationToReadMe.cs diff --git a/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln b/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln index 283985b..1cb1253 100644 --- a/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln +++ b/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln @@ -46,6 +46,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EAVFW.Extensions.Manifest.S EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EAVFW.Extensions.Docs.Extracter", "src\EAVFW.Extensions.Docs.Extracter\EAVFW.Extensions.Docs.Extracter.csproj", "{432042AB-6A78-4ED7-B8AC-73B047F6630F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EAVFW.Extensions.Docs.Generator", "src\EAVFW.Extensions.Docs.Generator\EAVFW.Extensions.Docs.Generator.csproj", "{71FCB365-F4AE-4578-BF86-B4A3C278B6B1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -70,6 +72,10 @@ Global {432042AB-6A78-4ED7-B8AC-73B047F6630F}.Debug|Any CPU.Build.0 = Debug|Any CPU {432042AB-6A78-4ED7-B8AC-73B047F6630F}.Release|Any CPU.ActiveCfg = Release|Any CPU {432042AB-6A78-4ED7-B8AC-73B047F6630F}.Release|Any CPU.Build.0 = Release|Any CPU + {71FCB365-F4AE-4578-BF86-B4A3C278B6B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {71FCB365-F4AE-4578-BF86-B4A3C278B6B1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {71FCB365-F4AE-4578-BF86-B4A3C278B6B1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {71FCB365-F4AE-4578-BF86-B4A3C278B6B1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -82,6 +88,7 @@ Global {2F30C24A-421A-4309-9F07-99668EA70C25} = {CAE8FBC9-BDC3-4F45-81E1-57506D609011} {3BEF0769-ABD1-4D34-8004-C98DE9FB0339} = {CAE8FBC9-BDC3-4F45-81E1-57506D609011} {432042AB-6A78-4ED7-B8AC-73B047F6630F} = {0D61C87C-0809-4CD7-9200-D78AD11A1E22} + {71FCB365-F4AE-4578-BF86-B4A3C278B6B1} = {0D61C87C-0809-4CD7-9200-D78AD11A1E22} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {036D5D82-DDA4-4600-B190-739D512F1062} diff --git a/src/EAVFW.Extensions.Docs.Extracter/DocumentLogic.cs b/src/EAVFW.Extensions.Docs.Extracter/DocumentLogic.cs index ebefaec..0351759 100644 --- a/src/EAVFW.Extensions.Docs.Extracter/DocumentLogic.cs +++ b/src/EAVFW.Extensions.Docs.Extracter/DocumentLogic.cs @@ -145,11 +145,7 @@ private void ExtractEntitiesWithWizards(JsonElement element, IDictionary>(property.Value.GetRawText(), - new JsonSerializerOptions - { - Converters = { new TabConverter() } - }); + JsonSerializer.Deserialize>(property.Value.GetRawText()); if (localEntities == null) return; diff --git a/src/EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj.DotSettings b/src/EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj.DotSettings new file mode 100644 index 0000000..6ed5a98 --- /dev/null +++ b/src/EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj.DotSettings @@ -0,0 +1,6 @@ + + True diff --git a/src/EAVFW.Extensions.Docs.Extracter/JsonConverters/PluginRegistrationAttributeConverter.cs b/src/EAVFW.Extensions.Docs.Extracter/JsonConverters/PluginRegistrationAttributeConverter.cs new file mode 100644 index 0000000..bc70d3c --- /dev/null +++ b/src/EAVFW.Extensions.Docs.Extracter/JsonConverters/PluginRegistrationAttributeConverter.cs @@ -0,0 +1,34 @@ +using System; +using System.Text.Json; +using System.Text.Json.Nodes; +using System.Text.Json.Serialization; +using EAVFramework.Plugins; + +namespace EAVFW.Extensions.Docs.Extracter +{ + public class PluginRegistrationAttributeConverter : JsonConverter + { + public override PluginRegistrationAttribute? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options) + { + throw new NotImplementedException(); + } + + public override void Write( + Utf8JsonWriter writer, + PluginRegistrationAttribute value, + JsonSerializerOptions options) + { + var _object = new JsonObject + { + { nameof(value.Order), value.Order }, + { nameof(value.Operation), value.Operation.ToString() }, + { nameof(value.Execution), value.Execution.ToString() }, + { nameof(value.Mode), value.Mode.ToString() } + }; + _object.WriteTo(writer); + } + } +} diff --git a/src/EAVFW.Extensions.Docs.Extracter/JsonConverters/TabConverter.cs b/src/EAVFW.Extensions.Docs.Extracter/JsonConverters/TabConverter.cs new file mode 100644 index 0000000..b548a25 --- /dev/null +++ b/src/EAVFW.Extensions.Docs.Extracter/JsonConverters/TabConverter.cs @@ -0,0 +1,30 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace EAVFW.Extensions.Docs.Extracter +{ + public class TabConverter : JsonConverter + { + public override StringOrBoolean Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options) + { + return reader.TokenType switch + { + JsonTokenType.String => new StringOrBoolean(reader.GetString() ?? ""), + JsonTokenType.False => new StringOrBoolean(false), + JsonTokenType.True => new StringOrBoolean(true), + _ => new StringOrBoolean() + }; + } + + public override void Write(Utf8JsonWriter writer, StringOrBoolean value, JsonSerializerOptions options) + { + if (value.IsBool) + writer.WriteBooleanValue(value.BooleanValue); + writer.WriteStringValue(value.StringValue); + } + } +} diff --git a/src/EAVFW.Extensions.Docs.Extracter/JsonConverters/TypeConverter.cs b/src/EAVFW.Extensions.Docs.Extracter/JsonConverters/TypeConverter.cs new file mode 100644 index 0000000..2f40207 --- /dev/null +++ b/src/EAVFW.Extensions.Docs.Extracter/JsonConverters/TypeConverter.cs @@ -0,0 +1,20 @@ +using System; +using System.Text.Json; +using System.Text.Json.Nodes; +using System.Text.Json.Serialization; + +namespace EAVFW.Extensions.Docs.Extracter +{ + public class TypeConverter : JsonConverter + { + public override Type? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + throw new NotImplementedException(); + } + + public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) + { + JsonValue.Create(value.Name)?.WriteTo(writer, options); + } + } +} diff --git a/src/EAVFW.Extensions.Docs.Extracter/Plugin/PluginDocumentation.cs b/src/EAVFW.Extensions.Docs.Extracter/Plugin/PluginDocumentation.cs index b1830f2..e6ae712 100644 --- a/src/EAVFW.Extensions.Docs.Extracter/Plugin/PluginDocumentation.cs +++ b/src/EAVFW.Extensions.Docs.Extracter/Plugin/PluginDocumentation.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text.Json.Serialization; using EAVFramework.Plugins; @@ -8,27 +7,14 @@ namespace EAVFW.Extensions.Docs.Extracter { public class PluginDocumentation { - [JsonIgnore] public IEnumerable PluginRegistrations { get; set; } = Array.Empty(); public string? Name { get; set; } - - [JsonIgnore] - public Type? Context { get; set; } - [JsonIgnore] - public Type? Entity { get; set; } - public string Summary { get; set; } = ""; + [JsonConverter(typeof(TypeConverter))] public Type? Context { get; set; } - public override string ToString() - { - var summary = Summary?.Split("\n").Select(x => x.Trim()).ToArray() ?? Array.Empty(); - return $"Plugin: {Name} on {Entity.Name}\n* " - + string.Join("\n* ", PluginRegistrations.Select(x => $"{x.Operation} on {x.Execution} as {x.Order}")) - + '\n' - + string.Join('\n', summary) - + "\n\n"; - } + [JsonConverter(typeof(TypeConverter))] public Type? Entity { get; set; } + public string Summary { get; set; } = ""; } } diff --git a/src/EAVFW.Extensions.Docs.Extracter/ServiceCollectionExtension.cs b/src/EAVFW.Extensions.Docs.Extracter/ServiceCollectionExtension.cs new file mode 100644 index 0000000..9701d2c --- /dev/null +++ b/src/EAVFW.Extensions.Docs.Extracter/ServiceCollectionExtension.cs @@ -0,0 +1,14 @@ +using Microsoft.Extensions.DependencyInjection; + +namespace EAVFW.Extensions.Docs.Extracter +{ + public static class ServiceCollectionExtension + { + public static IServiceCollection AddDocument(this IServiceCollection serviceCollection) + { + serviceCollection.AddSingleton(); + + return serviceCollection; + } + } +} diff --git a/src/EAVFW.Extensions.Docs.Extracter/Wizard/Wizards.cs b/src/EAVFW.Extensions.Docs.Extracter/Wizard/Wizards.cs index 4204c2a..870b21d 100644 --- a/src/EAVFW.Extensions.Docs.Extracter/Wizard/Wizards.cs +++ b/src/EAVFW.Extensions.Docs.Extracter/Wizard/Wizards.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; @@ -26,6 +25,7 @@ public struct Trigger [JsonPropertyName("ribbon")] public string Ribbon { get; set; } } + [JsonConverter(typeof(TabConverter))] public class Tab { [JsonPropertyName("columns")] public JsonElement Columns { get; set; } @@ -63,28 +63,6 @@ public StringOrBoolean(bool booleanValue) } - public class TabConverter : JsonConverter - { - public override StringOrBoolean Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - return reader.TokenType switch - { - JsonTokenType.String => new StringOrBoolean(reader.GetString() ?? ""), - JsonTokenType.False => new StringOrBoolean(false), - JsonTokenType.True => new StringOrBoolean(true), - _ => new StringOrBoolean() - }; - } - - public override void Write(Utf8JsonWriter writer, StringOrBoolean value, JsonSerializerOptions options) - { - if (value.IsBool) - writer.WriteBooleanValue(value.BooleanValue); - writer.WriteStringValue(value.StringValue); - } - } - public class Transition { [JsonPropertyName("workflow")] public string? Workflow { get; set; } diff --git a/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj b/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj new file mode 100644 index 0000000..69e771f --- /dev/null +++ b/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj @@ -0,0 +1,12 @@ + + + + net6.0 + enable + + + + + + + diff --git a/src/EAVFW.Extensions.Docs.Generator/PluginDocumentationToReadMe.cs b/src/EAVFW.Extensions.Docs.Generator/PluginDocumentationToReadMe.cs new file mode 100644 index 0000000..2f79707 --- /dev/null +++ b/src/EAVFW.Extensions.Docs.Generator/PluginDocumentationToReadMe.cs @@ -0,0 +1,89 @@ +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using EAVFW.Extensions.Docs.Extracter; +using Microsoft.AspNetCore.DataProtection; +using Sprache; + +namespace EAVFW.Extensions.Docs.Generator +{ + public class PluginDocumentationToReadMe + { + public async Task WriteReadMe(IEnumerable pluginDocumentations) + { + await using var writer = new StreamWriter("documentation.md"); + + var groups = pluginDocumentations.GroupBy(x => x.Entity!.Name); + await writer.WriteLineAsync("# Plugins "); + foreach (var group in groups) + { + await writer.WriteLineAsync($"## {group.FirstOrDefault()?.Entity?.Name}"); + foreach (var pluginDocumentation in group) + { + await writer.WriteLineAsync($"### {pluginDocumentation.Name}"); + await writer.WriteLineAsync( + $"Entity:\t[{pluginDocumentation.Entity?.Name}](#{pluginDocumentation.Entity?.Name})"); + await writer.WriteLineAsync( + $"Context:\t[{pluginDocumentation.Entity?.Name}](#{pluginDocumentation.Entity?.Name})"); + await writer.WriteLineAsync("Triggers:"); + await writer.WriteLineAsync("| Operation | Execution | Mode | Order |"); + await writer.WriteLineAsync("|---|---|---|:-:|"); + foreach (var reg in pluginDocumentation.PluginRegistrations.OrderBy(x => x.Order)) + { + await writer.WriteLineAsync($"|{reg.Operation}|{reg.Execution}|{reg.Mode}|{reg.Order}|"); + } + + await writer.WriteLineAsync("\n**Summary:**"); + + await writer.WriteLineAsync(SanitizeSummary(pluginDocumentation.Summary)); + + await writer.WriteLineAsync(); + } + } + } + + private static string SanitizeSummary(string summary) + { + if (string.IsNullOrWhiteSpace(summary)) return summary; + + var lines = summary.Split("\n").Select(x => x); + + lines = lines.Where(x => !string.IsNullOrWhiteSpace(x)); + lines = lines.Select(x => x.Trim()); + lines = lines.Select(x => ToMarkDownLink.Parse(x)); + + + return string.Join("", lines); + } + + private static readonly Parser Text = Parse.CharExcept('<').Many().Text(); + + private static readonly Parser Value = + Parse.AnyChar.Except(Parse.Char('\"')).Many().Text(); + + private static readonly Parser> Property = + from key in Parse.LetterOrDigit.Or(Parse.Char('-')).Many().Text() + from eq in Parse.Char('=') + from value in Parse.AnyChar.Except(Parse.Char('\"')).Many().Contained(Parse.Char('\"'), Parse.Char('\"')).Text() + select new KeyValuePair(key, value); + + private static readonly Parser> Properties = + from properties in Property.DelimitedBy(Parse.Char(' ')) + select properties.ToDictionary(x => x.Key, x => x.Value); + + private static readonly Parser LinkReplace = + from s in Parse.String("") + select $"[{props["cref"]}](#{props["cref"]})"; + + private static readonly Parser ToMarkDownLink = + from s in Text.Or(LinkReplace).Many() + select string.Join("", s); + + + } +} diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/DocumentCommand.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/DocumentCommand.cs index 1384c3a..0277055 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/DocumentCommand.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/DocumentCommand.cs @@ -8,6 +8,7 @@ using System.Text.Json; using System.Threading.Tasks; using EAVFW.Extensions.Docs.Extracter; +using EAVFW.Extensions.Docs.Generator; namespace EAVFW.Extensions.Manifest.ManifestEnricherTool.Commands { @@ -20,7 +21,7 @@ public class DocumentCommand : Command [Alias("--assembly")] [Description("Path for the assembly")] public FileInfo AssemblyPathOption { get; set; } - + [Alias("-m")] [Alias("--manifest")] [Description("Path for the manifest")] @@ -40,8 +41,7 @@ public class DocumentCommand : Command [Alias("--framework")] [Description("Framework confugraiton for the built assembly")] public string FrameworkOption { get; set; } - - + [Alias("-t")] [Alias("--target")] @@ -80,7 +80,7 @@ private async Task Run(ParseResult parseResult, IConsole console) Console.WriteLine("Assembly does not exists"); return 1; } - + switch (Target) { case Targets.Plugins: @@ -90,7 +90,7 @@ private async Task Run(ParseResult parseResult, IConsole console) default: throw new ArgumentOutOfRangeException(); } - + return 0; } @@ -118,21 +118,13 @@ private async Task HandlePlugins() var jsonString = JsonSerializer.Serialize(plugins, new JsonSerializerOptions { + Converters = { new PluginRegistrationAttributeConverter() }, WriteIndented = true }); await File.WriteAllTextAsync("docs.json", jsonString); - var groups = plugins.GroupBy(x => x.Entity!.Name); - - Console.WriteLine("# Plugins "); - foreach (var group in groups) - { - Console.WriteLine($"## {group.FirstOrDefault()?.Entity?.Name}"); - foreach (var pluginDocumentation in group) - { - Console.WriteLine(pluginDocumentation.ToString()); - } - } + var writer = new PluginDocumentationToReadMe(); + await writer.WriteReadMe(plugins); return 0; } diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj index d66cc9e..999995a 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj @@ -50,5 +50,6 @@ + diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Program.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Program.cs index 81bfd86..f4e1b86 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Program.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Program.cs @@ -29,7 +29,7 @@ static IServiceCollection ConfigureServices(IServiceCollection serviceCollection .AddManifestSDK() .AddSingleton(); - serviceCollection.AddSingleton(); + serviceCollection.AddDocument(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json index 0ba4c51..108f59a 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json @@ -3,8 +3,8 @@ "EAVFW.Extensions.Manifest.ManifestEnricherTool": { "commandName": "Project", "workingDirectory": "/Users/thyge/dev/playground", - "commandLineArgs": "docs -c Debug -t wizards -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Debug/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\" -m \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/manifest.loi.json\"" -// "commandLineArgs": "docs -c Debug -t plugins -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Debug/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\"" +// "commandLineArgs": "docs -c Release -t wizards -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\" -m \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/manifest.loi.json\"" + "commandLineArgs": "docs -c Release -t plugins -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\"" // "commandLineArgs": "binary --unzip 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" // "commandLineArgs": "binary --unzip 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" // "commandLineArgs": "binary --unzip --pretty-print 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" From 275249cea66d79cb4c3d32a862dbb1095a79bd43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thyge=20Sk=C3=B8dt=20Steffensen?= <31892312+thygesteffensen@users.noreply.github.com> Date: Fri, 10 Nov 2023 15:23:25 +0100 Subject: [PATCH 10/42] Working version with generator --- global.json | 4 +- .../DocumentLogic.cs | 7 +- .../EAVFW.Extensions.Docs.Extracter.csproj | 2 +- .../JsonConverters/TabConverter.cs | 30 ---- .../Wizard/Wizards.cs | 79 ----------- .../EAVFW.Extensions.Docs.Generator.csproj | 2 +- .../PluginDocumentationToReadMe.cs | 129 +++++++++++------- .../TransformXmlTag.cs | 58 ++++++++ .../Commands/DocumentCommand.cs | 5 +- .../Commands/SQLCommand.cs | 7 - ...sions.Manifest.ManifestEnricherTool.csproj | 7 +- .../Properties/launchSettings.json | 2 +- .../EAVFW.Extensions.Manifest.Tests.csproj | 4 +- 13 files changed, 159 insertions(+), 177 deletions(-) delete mode 100644 src/EAVFW.Extensions.Docs.Extracter/JsonConverters/TabConverter.cs delete mode 100644 src/EAVFW.Extensions.Docs.Extracter/Wizard/Wizards.cs create mode 100644 src/EAVFW.Extensions.Docs.Generator/TransformXmlTag.cs diff --git a/global.json b/global.json index f9550e8..3ecc5db 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "6.0.414" + "version": "8.0.100-rc.2.23502.2" } -} \ No newline at end of file +} diff --git a/src/EAVFW.Extensions.Docs.Extracter/DocumentLogic.cs b/src/EAVFW.Extensions.Docs.Extracter/DocumentLogic.cs index 0351759..2b949e0 100644 --- a/src/EAVFW.Extensions.Docs.Extracter/DocumentLogic.cs +++ b/src/EAVFW.Extensions.Docs.Extracter/DocumentLogic.cs @@ -7,6 +7,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using EAVFramework.Plugins; +using EAVFW.Extensions.Manifest.SDK; namespace EAVFW.Extensions.Docs.Extracter { @@ -96,7 +97,7 @@ from type in assembly.GetTypes() var jsonManifest = JsonDocument.ParseAsync(openStream).Result; // Find Wizards - var simpleManifest = new Dictionary(); + var simpleManifest = new Dictionary(); ExtractEntitiesWithWizards(jsonManifest.RootElement, simpleManifest); @@ -136,7 +137,7 @@ from tabs in wizard.Value.Tabs return new List(); } - private void ExtractEntitiesWithWizards(JsonElement element, IDictionary entities) + private void ExtractEntitiesWithWizards(JsonElement element, IDictionary entities) { if (element.ValueKind != JsonValueKind.Object) return; @@ -145,7 +146,7 @@ private void ExtractEntitiesWithWizards(JsonElement element, IDictionary>(property.Value.GetRawText()); + JsonSerializer.Deserialize>(property.Value.GetRawText()); if (localEntities == null) return; diff --git a/src/EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj b/src/EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj index f7d8b2d..a3549d6 100644 --- a/src/EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj +++ b/src/EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj @@ -2,7 +2,7 @@ 9.0 - net6.0 + net8.0 enable diff --git a/src/EAVFW.Extensions.Docs.Extracter/JsonConverters/TabConverter.cs b/src/EAVFW.Extensions.Docs.Extracter/JsonConverters/TabConverter.cs deleted file mode 100644 index b548a25..0000000 --- a/src/EAVFW.Extensions.Docs.Extracter/JsonConverters/TabConverter.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace EAVFW.Extensions.Docs.Extracter -{ - public class TabConverter : JsonConverter - { - public override StringOrBoolean Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options) - { - return reader.TokenType switch - { - JsonTokenType.String => new StringOrBoolean(reader.GetString() ?? ""), - JsonTokenType.False => new StringOrBoolean(false), - JsonTokenType.True => new StringOrBoolean(true), - _ => new StringOrBoolean() - }; - } - - public override void Write(Utf8JsonWriter writer, StringOrBoolean value, JsonSerializerOptions options) - { - if (value.IsBool) - writer.WriteBooleanValue(value.BooleanValue); - writer.WriteStringValue(value.StringValue); - } - } -} diff --git a/src/EAVFW.Extensions.Docs.Extracter/Wizard/Wizards.cs b/src/EAVFW.Extensions.Docs.Extracter/Wizard/Wizards.cs deleted file mode 100644 index 870b21d..0000000 --- a/src/EAVFW.Extensions.Docs.Extracter/Wizard/Wizards.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System.Collections.Generic; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace EAVFW.Extensions.Docs.Extracter -{ - public class Entity - { - [JsonPropertyName("wizards")] public Dictionary Wizards { get; set; } - } - - public class Wizard - { - [JsonPropertyName("title")] public string Title { get; set; } - - [JsonPropertyName("triggers")] public JsonElement Triggers { get; set; } - - [JsonPropertyName("tabs")] public Dictionary Tabs { get; set; } - } - - public struct Trigger - { - [JsonPropertyName("form")] public string Form { get; set; } - - [JsonPropertyName("ribbon")] public string Ribbon { get; set; } - } - - [JsonConverter(typeof(TabConverter))] - public class Tab - { - [JsonPropertyName("columns")] public JsonElement Columns { get; set; } - - [JsonPropertyName("visible")] public StringOrBoolean StringOrBoolean { get; set; } - - [JsonPropertyName("onTransitionOut")] public Transition? OnTransitionOut { get; set; } - - [JsonPropertyName("onTransitionIn")] public Transition? OnTransitionIn { get; set; } - - [JsonPropertyName("actions")] public JsonElement? Actions { get; set; } // TODO: This also needs to be enriched - } - - public struct StringOrBoolean - { - public StringOrBoolean(string stringValue) - { - StringValue = stringValue; - IsBool = false; - BooleanValue = default; - } - - public StringOrBoolean(bool booleanValue) - { - StringValue = default; - IsBool = false; - BooleanValue = booleanValue; - } - - public string? StringValue { get; } - - public bool BooleanValue { get; } - - public bool IsBool { get; } - } - - - public class Transition - { - [JsonPropertyName("workflow")] public string? Workflow { get; set; } - - [JsonPropertyName("workflowSummary")] public string? WorkflowSummary { get; set; } - - [JsonPropertyName("message")] public Message? Message { get; set; } - } - - public class Message - { - [JsonPropertyName("title")] public string? Title { get; set; } - } -} diff --git a/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj b/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj index 69e771f..ae618e2 100644 --- a/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj +++ b/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable diff --git a/src/EAVFW.Extensions.Docs.Generator/PluginDocumentationToReadMe.cs b/src/EAVFW.Extensions.Docs.Generator/PluginDocumentationToReadMe.cs index 2f79707..8ff1ba4 100644 --- a/src/EAVFW.Extensions.Docs.Generator/PluginDocumentationToReadMe.cs +++ b/src/EAVFW.Extensions.Docs.Generator/PluginDocumentationToReadMe.cs @@ -1,49 +1,84 @@ +using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; using System.Threading.Tasks; using EAVFW.Extensions.Docs.Extracter; -using Microsoft.AspNetCore.DataProtection; -using Sprache; +using EAVFW.Extensions.Manifest.SDK; +using JsonSerializer = System.Text.Json.JsonSerializer; namespace EAVFW.Extensions.Docs.Generator { - public class PluginDocumentationToReadMe + public class PluginDocumentationToReadMe : IDisposable { - public async Task WriteReadMe(IEnumerable pluginDocumentations) + private readonly StreamWriter _writer; + private readonly Dictionary _logicalNameLookup = new(); + private readonly TransformXmlTag _transformXmlTag; + + public PluginDocumentationToReadMe( + string path = "/Users/thyge/Documents/Obsidian Vault/Delegate Lava-Stone/Delegate/documentation.md") + { + _transformXmlTag = new TransformXmlTag(); + _writer = new StreamWriter(path); + } + + public async Task WriteTables(FileInfo manifest) { - await using var writer = new StreamWriter("documentation.md"); + var manifestObject = await JsonSerializer.DeserializeAsync(manifest.OpenRead()); + + await _writer.WriteLineAsync("## Tables:\n"); + + var t = new DefaultSchemaNameManager(); + + Debug.Assert(manifestObject != null, nameof(manifestObject) + " != null"); + foreach (var (key, value) in manifestObject.Entities) + { + _logicalNameLookup[t.ToSchemaName(key)] = key; + + await _writer.WriteLineAsync($"### {key}"); + await _writer.WriteLineAsync($"Logical name: `{t.ToSchemaName(key)}`"); + await _writer.WriteLineAsync($"Plural name: {value.PluralName}"); + await _writer.WriteLineAsync($"Description: {value.Description}"); + await _writer.WriteLineAsync("Attributes:"); + } + } + public async Task WritePlugins(IEnumerable pluginDocumentations) + { var groups = pluginDocumentations.GroupBy(x => x.Entity!.Name); - await writer.WriteLineAsync("# Plugins "); + await _writer.WriteLineAsync("## Plugins "); foreach (var group in groups) { - await writer.WriteLineAsync($"## {group.FirstOrDefault()?.Entity?.Name}"); + await _writer.WriteLineAsync($"### {group.FirstOrDefault()?.Entity?.Name}"); foreach (var pluginDocumentation in group) { - await writer.WriteLineAsync($"### {pluginDocumentation.Name}"); - await writer.WriteLineAsync( + await _writer.WriteLineAsync($"#### {pluginDocumentation.Name}"); + await _writer.WriteLineAsync( $"Entity:\t[{pluginDocumentation.Entity?.Name}](#{pluginDocumentation.Entity?.Name})"); - await writer.WriteLineAsync( + await _writer.WriteLineAsync( $"Context:\t[{pluginDocumentation.Entity?.Name}](#{pluginDocumentation.Entity?.Name})"); - await writer.WriteLineAsync("Triggers:"); - await writer.WriteLineAsync("| Operation | Execution | Mode | Order |"); - await writer.WriteLineAsync("|---|---|---|:-:|"); + await _writer.WriteLineAsync("Triggers:\n"); + await _writer.WriteLineAsync("| Operation | Execution | Mode | Order |"); + await _writer.WriteLineAsync("|---|---|---|:-:|"); foreach (var reg in pluginDocumentation.PluginRegistrations.OrderBy(x => x.Order)) { - await writer.WriteLineAsync($"|{reg.Operation}|{reg.Execution}|{reg.Mode}|{reg.Order}|"); + await _writer.WriteLineAsync($"|{reg.Operation}|{reg.Execution}|{reg.Mode}|{reg.Order}|"); } - await writer.WriteLineAsync("\n**Summary:**"); + await _writer.WriteLineAsync("\n**Summary:**"); - await writer.WriteLineAsync(SanitizeSummary(pluginDocumentation.Summary)); + await _writer.WriteLineAsync(SanitizeSummary(pluginDocumentation.Summary)); - await writer.WriteLineAsync(); + await _writer.WriteLineAsync(); } } } + + // public async Task WriteWizards() + - private static string SanitizeSummary(string summary) + private string SanitizeSummary(string summary) { if (string.IsNullOrWhiteSpace(summary)) return summary; @@ -51,39 +86,37 @@ private static string SanitizeSummary(string summary) lines = lines.Where(x => !string.IsNullOrWhiteSpace(x)); lines = lines.Select(x => x.Trim()); - lines = lines.Select(x => ToMarkDownLink.Parse(x)); - + lines = lines.Select(x => _transformXmlTag.TransformString(x, TransformTag)); - return string.Join("", lines); + return string.Join(" ", lines); } - private static readonly Parser Text = Parse.CharExcept('<').Many().Text(); + /// + /// Function i expression motoren + /// + /// + /// + /// + private string TransformTag(string tag, Dictionary properties) + { + if (tag != "see") + return tag; - private static readonly Parser Value = - Parse.AnyChar.Except(Parse.Char('\"')).Many().Text(); - - private static readonly Parser> Property = - from key in Parse.LetterOrDigit.Or(Parse.Char('-')).Many().Text() - from eq in Parse.Char('=') - from value in Parse.AnyChar.Except(Parse.Char('\"')).Many().Contained(Parse.Char('\"'), Parse.Char('\"')).Text() - select new KeyValuePair(key, value); - - private static readonly Parser> Properties = - from properties in Property.DelimitedBy(Parse.Char(' ')) - select properties.ToDictionary(x => x.Key, x => x.Value); - - private static readonly Parser LinkReplace = - from s in Parse.String("") - select $"[{props["cref"]}](#{props["cref"]})"; - - private static readonly Parser ToMarkDownLink = - from s in Text.Or(LinkReplace).Many() - select string.Join("", s); - - + var target = properties["cref"]; + + var key = target.Split(':').Last().Split('.').Last(); + + _logicalNameLookup.TryGetValue(key, out var value); + + return $"[{value ?? key}](#{key})"; + } + + + public async void Dispose() + { + await _writer.FlushAsync(); + await _writer.DisposeAsync(); + GC.SuppressFinalize(this); + } } } diff --git a/src/EAVFW.Extensions.Docs.Generator/TransformXmlTag.cs b/src/EAVFW.Extensions.Docs.Generator/TransformXmlTag.cs new file mode 100644 index 0000000..24218c8 --- /dev/null +++ b/src/EAVFW.Extensions.Docs.Generator/TransformXmlTag.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Sprache; + +namespace EAVFW.Extensions.Docs.Generator +{ + public class TransformXmlTag + { + private Parser? _linkReplace; + + private readonly Parser? _toMarkDownLink; + + private readonly Parser>? _properties; + + public TransformXmlTag() + { + var text = + Parse.CharExcept('<').Many().Text(); + + var property = + from key in Parse.LetterOrDigit.Or(Parse.Char('-')).Many().Text() + from eq in Parse.Char('=') + from value in Parse.AnyChar.Except(Parse.Char('\"')).Many() + .Contained(Parse.Char('\"'), Parse.Char('\"')) + .Text() + select new KeyValuePair(key, value); + + _properties = + from properties in property.DelimitedBy(Parse.Char(' ')) + select properties.ToDictionary(x => x.Key, x => x.Value); + + _toMarkDownLink = + from s in text.Or(Parse.Ref(() => _linkReplace)).Many() + select string.Join("", s); + } + + /// + /// Transform a string with Xml tags using the tag string to locate the + /// + /// Input to transform + /// Transform function with access to the properties + /// + public string TransformString(string input, Func, string> transform) + { + _linkReplace = + from s in Parse.String("<") + from tag in Parse.LetterOrDigit.Many().Text() + from _ in Parse.WhiteSpace.Many() + from props in _properties + from __ in Parse.WhiteSpace.Many() + from e in Parse.String("/>") + select transform(tag, props); + + return _toMarkDownLink.Parse(input); + } + } +} diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/DocumentCommand.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/DocumentCommand.cs index 0277055..cc0154b 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/DocumentCommand.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/DocumentCommand.cs @@ -123,8 +123,9 @@ private async Task HandlePlugins() }); await File.WriteAllTextAsync("docs.json", jsonString); - var writer = new PluginDocumentationToReadMe(); - await writer.WriteReadMe(plugins); + using var writer = new PluginDocumentationToReadMe(); + await writer.WriteTables(ManifestPathOption); + await writer.WritePlugins(plugins); return 0; } diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLCommand.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLCommand.cs index 68d3720..5ad962c 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLCommand.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/SQLCommand.cs @@ -1,25 +1,18 @@ using EAVFramework; using EAVFW.Extensions.Manifest.SDK; -using Microsoft.Azure.Documents.Spatial; -using Microsoft.Data.SqlClient; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; -using NetTopologySuite.Geometries; using Newtonsoft.Json.Linq; using System; -using System.Collections.Generic; using System.CommandLine; using System.CommandLine.NamingConventionBinder; using System.CommandLine.Parsing; using System.IO; using System.Linq; -using System.Text; using System.Threading.Tasks; -using System.Xml.Linq; -using Point = NetTopologySuite.Geometries.Point; namespace EAVFW.Extensions.Manifest.ManifestEnricherTool.Commands { diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj index 999995a..89494e0 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj @@ -1,7 +1,7 @@  Exe - net6.0 + net8.0 true eavfw-manifest ./../../artifacts @@ -37,6 +37,11 @@ 6.0.11 + + + 7.0.13 + + diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json index 108f59a..7ec3e90 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json @@ -4,7 +4,7 @@ "commandName": "Project", "workingDirectory": "/Users/thyge/dev/playground", // "commandLineArgs": "docs -c Release -t wizards -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\" -m \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/manifest.loi.json\"" - "commandLineArgs": "docs -c Release -t plugins -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\"" + "commandLineArgs": "docs -c Release -t plugins -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\" -m \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/manifest.loi.json\"" // "commandLineArgs": "binary --unzip 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" // "commandLineArgs": "binary --unzip 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" // "commandLineArgs": "binary --unzip --pretty-print 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" diff --git a/tests/EAVFW.Extensions.Manifest.Tests/EAVFW.Extensions.Manifest.Tests.csproj b/tests/EAVFW.Extensions.Manifest.Tests/EAVFW.Extensions.Manifest.Tests.csproj index dbad66c..aee4d5c 100644 --- a/tests/EAVFW.Extensions.Manifest.Tests/EAVFW.Extensions.Manifest.Tests.csproj +++ b/tests/EAVFW.Extensions.Manifest.Tests/EAVFW.Extensions.Manifest.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 disable disable @@ -9,7 +9,7 @@ - + From 06c1b72dc272b0e8240a40ed36d4d0bef840005c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thyge=20Sk=C3=B8dt=20Steffensen?= <31892312+thygesteffensen@users.noreply.github.com> Date: Fri, 17 Nov 2023 07:19:09 +0100 Subject: [PATCH 11/42] wip: Add functionality to extract documentation --- Directory.Build.props | 4 +- external/EAVFW.Extensions.CommandLine | 2 +- .../DocumentLogic.cs | 68 +++++++++-------- .../EAVFW.Extensions.Docs.Extracter.csproj | 9 +++ .../IDocumentLogic.cs | 3 +- .../JsonConverters/TypeConverter.cs | 2 +- .../EAVFW.Extensions.Docs.Generator.csproj | 6 ++ .../PluginDocumentationToReadMe.cs | 11 ++- .../App.cs | 60 +++++---------- .../Commands/DocumentCommand.cs | 56 +++++++++++--- ...sions.Manifest.ManifestEnricherTool.csproj | 1 + .../IManifestMerger.cs | 15 ++++ .../IModuleMetadataEnricher.cs | 14 ++++ .../ManifestMerger.cs | 52 +++++++++++++ .../ModuleMetadataEnricher.cs | 74 +++++++++++++++++++ .../Program.cs | 3 + .../Properties/launchSettings.json | 9 ++- .../EAVFW.Extensions.Manifest.Tests.csproj | 8 +- .../Merge/AppTest.cs | 39 ++++++++++ .../Merge/expected.manifest.json | 67 +++++++++++++++++ .../Merge/manifest.component.json | 19 +++++ .../Merge/manifest.json | 33 +++++++++ .../TestLogger.cs | 31 ++++++++ 23 files changed, 487 insertions(+), 99 deletions(-) create mode 100644 src/EAVFW.Extensions.Manifest.ManifestEnricherTool/IManifestMerger.cs create mode 100644 src/EAVFW.Extensions.Manifest.ManifestEnricherTool/IModuleMetadataEnricher.cs create mode 100644 src/EAVFW.Extensions.Manifest.ManifestEnricherTool/ManifestMerger.cs create mode 100644 src/EAVFW.Extensions.Manifest.ManifestEnricherTool/ModuleMetadataEnricher.cs create mode 100644 tests/EAVFW.Extensions.Manifest.Tests/Merge/AppTest.cs create mode 100644 tests/EAVFW.Extensions.Manifest.Tests/Merge/expected.manifest.json create mode 100644 tests/EAVFW.Extensions.Manifest.Tests/Merge/manifest.component.json create mode 100644 tests/EAVFW.Extensions.Manifest.Tests/Merge/manifest.json create mode 100644 tests/EAVFW.Extensions.Manifest.Tests/TestLogger.cs diff --git a/Directory.Build.props b/Directory.Build.props index 7925b0d..bc28d4d 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,9 +2,9 @@ 9.0 4.0.2 - true + false $(MSBuildThisFileDirectory)/external/EAVFramework $(MSBuildThisFileDirectory)/external $(MSBuildThisFileDirectory) - \ No newline at end of file + diff --git a/external/EAVFW.Extensions.CommandLine b/external/EAVFW.Extensions.CommandLine index 0350081..e43af6a 160000 --- a/external/EAVFW.Extensions.CommandLine +++ b/external/EAVFW.Extensions.CommandLine @@ -1 +1 @@ -Subproject commit 03500817f0d20e753288c4937b1bc87ca1cc664a +Subproject commit e43af6ad852b921bc688208d423b2f6e243522f5 diff --git a/src/EAVFW.Extensions.Docs.Extracter/DocumentLogic.cs b/src/EAVFW.Extensions.Docs.Extracter/DocumentLogic.cs index 2b949e0..0da526c 100644 --- a/src/EAVFW.Extensions.Docs.Extracter/DocumentLogic.cs +++ b/src/EAVFW.Extensions.Docs.Extracter/DocumentLogic.cs @@ -4,10 +4,12 @@ using System.Linq; using System.Reflection; using System.Runtime.Loader; +using System.Security.Principal; using System.Text.Json; using System.Text.Json.Serialization; using EAVFramework.Plugins; using EAVFW.Extensions.Manifest.SDK; +using WorkflowEngine.Core; namespace EAVFW.Extensions.Docs.Extracter { @@ -80,19 +82,17 @@ where d.FullName.EndsWith($"bin/{pluginInfo.Configuration}/{pluginInfo.Framework } /// - public IEnumerable ExtractWizardDocumentation(FileInfo manifestFile, PluginInfo pluginInfo) + public Dictionary ExtractWizardDocumentation(FileInfo manifestFile, + PluginInfo pluginInfo) { var assembly = LoadAssembly(pluginInfo); // Preloading types to easily query for documentation - var workflows = - from type in assembly.GetTypes() - // where type.IsAbstract && typeof(Workflow).IsAssignableFrom(type) - select type; + var workflows = assembly.GetTypes() + .Where(type => !type.IsAbstract && !type.IsInterface && typeof(IWorkflow).IsAssignableFrom(type)) + .ToDictionary(x => x.Name, x => x); // Load manifest - - using var openStream = manifestFile.OpenRead(); var jsonManifest = JsonDocument.ParseAsync(openStream).Result; @@ -100,41 +100,47 @@ from type in assembly.GetTypes() var simpleManifest = new Dictionary(); ExtractEntitiesWithWizards(jsonManifest.RootElement, simpleManifest); + var tabs = + (from entity in simpleManifest + from wizard in entity.Value.Wizards + from _tabs in wizard.Value.Tabs + select _tabs).AsEnumerable(); // Glorified for loop? var tabsWithWorkflows = - from entity in simpleManifest - from wizard in entity.Value.Wizards - from tabs in wizard.Value.Tabs - where tabs.Value.OnTransitionOut?.Workflow != null && tabs.Value.OnTransitionIn?.Workflow != null - select tabs.Value; + from tab in tabs + where tab.Value.OnTransitionOut?.Workflow != null || tab.Value.OnTransitionIn?.Workflow != null + select tab; - foreach (var tabsWithWorkflow in tabsWithWorkflows) + foreach (var (key, value) in tabsWithWorkflows) { - if (!string.IsNullOrWhiteSpace(tabsWithWorkflow?.OnTransitionOut?.Workflow)) + if (!string.IsNullOrWhiteSpace(value?.OnTransitionIn?.Workflow) && + workflows.TryGetValue(value.OnTransitionIn.Workflow, out var type1)) { - var workflow = tabsWithWorkflow.OnTransitionOut.Workflow!; - // look for workflow in types? - Console.WriteLine(workflow); + value.OnTransitionIn.AdditionalData["x-workflowSummary"] = type1.GetDocumentation(); } - } - foreach (var (key, wizard) in simpleManifest) - { - var t = JsonSerializer.Serialize(wizard, new JsonSerializerOptions + if (!string.IsNullOrWhiteSpace(value?.OnTransitionOut?.Workflow) && + workflows.TryGetValue(value.OnTransitionOut.Workflow, out var type2)) { - WriteIndented = true, - DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull - }); - Console.WriteLine(t); + value.OnTransitionOut.AdditionalData["x-workflowSummary"] = type2.GetDocumentation(); + } + } + + var actionsWithWorkflows = + from tab in tabs + where tab.Value.Actions != null + from action in tab.Value.Actions + where action.Value.Workflow != null + select action; + + foreach (var (key, value) in actionsWithWorkflows) + { + if (workflows.TryGetValue(value.Workflow, out var type)) + value.AdditionalFields["x-workflowSummary"] = type.GetDocumentation(); } - - // Generate Wizard object - - - // Return Wizard object - return new List(); + return simpleManifest; } private void ExtractEntitiesWithWizards(JsonElement element, IDictionary entities) diff --git a/src/EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj b/src/EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj index a3549d6..c87d43c 100644 --- a/src/EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj +++ b/src/EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj @@ -14,4 +14,13 @@ + + + ..\EAVFW.Extensions.Manifest.ManifestEnricherTool\bin\Debug\net8.0\EAVFW.Extensions.Manifest.SDK.dll + + + ..\..\..\..\hafnia\LetterofIndemnity\Hafnia.Tests\bin\Release\net6.0\WorkflowEngine.Core.dll + + + diff --git a/src/EAVFW.Extensions.Docs.Extracter/IDocumentLogic.cs b/src/EAVFW.Extensions.Docs.Extracter/IDocumentLogic.cs index ff95e3a..bb70159 100644 --- a/src/EAVFW.Extensions.Docs.Extracter/IDocumentLogic.cs +++ b/src/EAVFW.Extensions.Docs.Extracter/IDocumentLogic.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.IO; +using EAVFW.Extensions.Manifest.SDK; namespace EAVFW.Extensions.Docs.Extracter { @@ -21,6 +22,6 @@ public interface IDocumentLogic /// /// /// - IEnumerable ExtractWizardDocumentation(FileInfo manifestFile, PluginInfo pluginInfo); + Dictionary ExtractWizardDocumentation(FileInfo manifestFile, PluginInfo pluginInfo); } } diff --git a/src/EAVFW.Extensions.Docs.Extracter/JsonConverters/TypeConverter.cs b/src/EAVFW.Extensions.Docs.Extracter/JsonConverters/TypeConverter.cs index 2f40207..3154860 100644 --- a/src/EAVFW.Extensions.Docs.Extracter/JsonConverters/TypeConverter.cs +++ b/src/EAVFW.Extensions.Docs.Extracter/JsonConverters/TypeConverter.cs @@ -14,7 +14,7 @@ public class TypeConverter : JsonConverter public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) { - JsonValue.Create(value.Name)?.WriteTo(writer, options); + JsonValue.Create(value.Name).WriteTo(writer, options); } } } diff --git a/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj b/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj index ae618e2..f4f75e8 100644 --- a/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj +++ b/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj @@ -9,4 +9,10 @@ + + + ..\EAVFW.Extensions.Manifest.ManifestEnricherTool\bin\Debug\net8.0\EAVFW.Extensions.Manifest.SDK.dll + + + diff --git a/src/EAVFW.Extensions.Docs.Generator/PluginDocumentationToReadMe.cs b/src/EAVFW.Extensions.Docs.Generator/PluginDocumentationToReadMe.cs index 8ff1ba4..c524be7 100644 --- a/src/EAVFW.Extensions.Docs.Generator/PluginDocumentationToReadMe.cs +++ b/src/EAVFW.Extensions.Docs.Generator/PluginDocumentationToReadMe.cs @@ -23,7 +23,7 @@ public PluginDocumentationToReadMe( _writer = new StreamWriter(path); } - public async Task WriteTables(FileInfo manifest) + public async Task WriteTables(FileInfo manifest, string component) { var manifestObject = await JsonSerializer.DeserializeAsync(manifest.OpenRead()); @@ -44,7 +44,7 @@ public async Task WriteTables(FileInfo manifest) } } - public async Task WritePlugins(IEnumerable pluginDocumentations) + public async Task WritePlugins(IEnumerable pluginDocumentations, string component) { var groups = pluginDocumentations.GroupBy(x => x.Entity!.Name); await _writer.WriteLineAsync("## Plugins "); @@ -74,8 +74,11 @@ await _writer.WriteLineAsync( } } } - - // public async Task WriteWizards() + + public async Task WriteWizards() + { + + } private string SanitizeSummary(string summary) diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/App.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/App.cs index 6176912..997a3c3 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/App.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/App.cs @@ -1,77 +1,53 @@ - +// See https://aka.ms/new-console-template for more information - -// See https://aka.ms/new-console-template for more information +using System; using EAVFW.Extensions.Manifest.ManifestEnricherTool; using EAVFW.Extensions.Manifest.SDK; using Microsoft.Extensions.Logging; -using Newtonsoft.Json.Linq; using System.Collections.Generic; using System.CommandLine; using System.CommandLine.NamingConventionBinder; using System.CommandLine.Parsing; using System.IO; -using System.Linq; using System.Reflection; using System.Text.Json; using System.Threading.Tasks; public class App : System.CommandLine.RootCommand { - public Option Path = new Option("--path", "The path"); + public Option Path = new Option("--path", "The path"); public Option Prefix = new Option(new string[] { "--customizationprefix" }, "The prefix"); private readonly ILogger logger; private readonly IManifestEnricher manifestEnricher; + private readonly IManifestMerger _manifestMerger; - public App(ILogger logger, IEnumerable commands, IManifestEnricher manifestEnricher) : base($"Generating Manifest: v{Assembly.GetExecutingAssembly().GetCustomAttribute()?.InformationalVersion}") + public App(ILogger logger, IEnumerable commands, IManifestEnricher manifestEnricher, IManifestMerger manifestMerger) : base( + $"Generating Manifest: v{Assembly.GetExecutingAssembly().GetCustomAttribute()?.InformationalVersion}") { - this.logger=logger; + this.logger = logger; this.manifestEnricher = manifestEnricher; - Path.IsRequired=true; - - Add(Path); + _manifestMerger = manifestMerger ?? throw new ArgumentNullException(nameof(manifestMerger)); + Path.IsRequired = true; + + Add(Path); Add(Prefix); foreach (var command in commands) Add(command); - Handler = CommandHandler.Create(Run); + Handler = CommandHandler.Create(Run); } - public async Task Run(ParseResult parseResult, IConsole console) //(string path, string customizationprefix) + public async Task Run(ParseResult parseResult, IConsole console) { var path = parseResult.GetValueForOption(Path); var customizationprefix = parseResult.GetValueForOption(Prefix); - console.Out.Write($"Generating Manifest: v{Assembly.GetExecutingAssembly().GetCustomAttribute()?.InformationalVersion} - {Assembly.GetExecutingAssembly().GetCustomAttribute()?.Version}"); - - // var cmd = new EAVFW.Extensions.Manifest.ManifestEnricherTool.RootCommand(); - - - - - using (var fs = File.OpenRead(path)) - { - - var jsonraw = Newtonsoft.Json.Linq.JToken.ReadFrom(new Newtonsoft.Json.JsonTextReader(new StreamReader(fs))) as JObject; - var others = Directory.GetFiles(System.IO.Path.GetDirectoryName(path), "manifest.*.json") - .Where(c => !string.Equals("manifest.schema.json", System.IO.Path.GetFileName(c), System.StringComparison.OrdinalIgnoreCase)); - foreach (var other in others) - { - jsonraw.Merge(JToken.Parse(File.ReadAllText(other)), new JsonMergeSettings - { - // union array values together to avoid duplicates - MergeArrayHandling = MergeArrayHandling.Union, - PropertyNameComparison = System.StringComparison.OrdinalIgnoreCase, - MergeNullValueHandling = MergeNullValueHandling.Ignore - }); - } - - JsonDocument json = await manifestEnricher.LoadJsonDocumentAsync(jsonraw, customizationprefix, logger); - } - - + console.Out.Write( + $"Generating Manifest: v{Assembly.GetExecutingAssembly().GetCustomAttribute()?.InformationalVersion} - {Assembly.GetExecutingAssembly().GetCustomAttribute()?.Version}"); + var t = await _manifestMerger.MergeManifests(path); + JsonDocument json = await manifestEnricher.LoadJsonDocumentAsync(t, customizationprefix, logger); } -} \ No newline at end of file +} diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/DocumentCommand.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/DocumentCommand.cs index cc0154b..e966be2 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/DocumentCommand.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/DocumentCommand.cs @@ -16,7 +16,6 @@ public class DocumentCommand : Command { private readonly IDocumentLogic documentLogic; - [Alias("-a")] [Alias("--assembly")] [Description("Path for the assembly")] @@ -24,7 +23,7 @@ public class DocumentCommand : Command [Alias("-m")] [Alias("--manifest")] - [Description("Path for the manifest")] + [Description("Path for the enriched manifest")] public FileInfo ManifestPathOption { get; set; } [Alias("-p")] @@ -37,11 +36,19 @@ public class DocumentCommand : Command [Description("Configuration for the built assembly")] public string ConfigurationOption { get; set; } + [Alias("--component")] + [Description("Component to generate documentation. E.g., `mainfest.component.json`")] + public string ComponentOption { get; set; } + [Alias("-f")] [Alias("--framework")] [Description("Framework confugraiton for the built assembly")] public string FrameworkOption { get; set; } + [Alias("-o")] + [Alias("--output")] + [Description("Output directory for genreated documentation source files")] + public DirectoryInfo OutputOption { get; set; } [Alias("-t")] [Alias("--target")] @@ -54,7 +61,6 @@ public enum Targets Wizards } - public DocumentCommand(IDocumentLogic documentLogic) : base("docs", "Generate documentation") { this.documentLogic = documentLogic ?? throw new ArgumentNullException(nameof(documentLogic)); @@ -90,8 +96,6 @@ private async Task Run(ParseResult parseResult, IConsole console) default: throw new ArgumentOutOfRangeException(); } - - return 0; } private async Task HandleWizards() @@ -102,9 +106,29 @@ private async Task HandleWizards() return 1; } - var t = documentLogic.ExtractWizardDocumentation(ManifestPathOption, new PluginInfo(RootPathOption, - AssemblyPathOption, ConfigurationOption, - FrameworkOption)); + var entityDefinitions = documentLogic.ExtractWizardDocumentation( + ManifestPathOption, + new PluginInfo(RootPathOption, + AssemblyPathOption, + ConfigurationOption, + FrameworkOption)); + + var basePath = new DirectoryInfo(CalculateFullPath("wizards")); + + if(!basePath.Exists) + basePath.Create(); + + foreach (var (key, value) in entityDefinitions) + { + var fileName = Path.Combine(basePath.FullName, $"{key}.json"); + + await using var createStream = File.Create(fileName); + await JsonSerializer.SerializeAsync(createStream, value, new JsonSerializerOptions + { + WriteIndented = true + }); + await createStream.DisposeAsync(); + } return 0; } @@ -121,15 +145,23 @@ private async Task HandlePlugins() Converters = { new PluginRegistrationAttributeConverter() }, WriteIndented = true }); - await File.WriteAllTextAsync("docs.json", jsonString); - using var writer = new PluginDocumentationToReadMe(); - await writer.WriteTables(ManifestPathOption); - await writer.WritePlugins(plugins); + var path = CalculateFullPath("plugins.json"); + await File.WriteAllTextAsync(path, jsonString); return 0; } + private string CalculateFullPath(string path) + { + if (OutputOption != null) + { + path = Path.Combine(OutputOption.FullName, path); + } + + return path; + } + private bool IsMissingOptions(out List missing) { missing = new List(); diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj index 89494e0..445e2a4 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj @@ -20,6 +20,7 @@ + diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/IManifestMerger.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/IManifestMerger.cs new file mode 100644 index 0000000..6b20534 --- /dev/null +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/IManifestMerger.cs @@ -0,0 +1,15 @@ +using System.IO; +using System.Threading.Tasks; +using Newtonsoft.Json.Linq; + +namespace EAVFW.Extensions.Manifest.ManifestEnricherTool +{ + public interface IManifestMerger + { + /// + /// Component Manifest files are loaded based on the . + /// + /// Path for the root manifest file, manifest.json + public Task MergeManifests(FileInfo path); + } +} diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/IModuleMetadataEnricher.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/IModuleMetadataEnricher.cs new file mode 100644 index 0000000..d467e92 --- /dev/null +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/IModuleMetadataEnricher.cs @@ -0,0 +1,14 @@ +using Newtonsoft.Json.Linq; + +namespace EAVFW.Extensions.Manifest.ManifestEnricherTool +{ + public interface IModuleMetadataEnricher + { + /// + /// Add metadata to each module before merging and enriching manifests. + /// + /// The module manifest + /// The module manifest json file name + public void AddSource(JToken manifest, string source); + } +} diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/ManifestMerger.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/ManifestMerger.cs new file mode 100644 index 0000000..48b56fd --- /dev/null +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/ManifestMerger.cs @@ -0,0 +1,52 @@ +using System; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Newtonsoft.Json.Linq; + +namespace EAVFW.Extensions.Manifest.ManifestEnricherTool +{ + public class ManifestMerger : IManifestMerger + { + private readonly IModuleMetadataEnricher _moduleMetadataEnricher; + + public ManifestMerger(IModuleMetadataEnricher moduleMetadataEnricher) + { + _moduleMetadataEnricher = + moduleMetadataEnricher ?? throw new ArgumentNullException(nameof(moduleMetadataEnricher)); + } + + /// + public async Task MergeManifests(FileInfo path) + { + await using var fs = File.OpenRead(path.FullName); + + var jtokenRaw = await JToken.ReadFromAsync(new Newtonsoft.Json.JsonTextReader(new StreamReader(fs))); + + _moduleMetadataEnricher.AddSource(jtokenRaw, path.Name); + var jsonRaw = jtokenRaw as JObject; + + var others = Directory.GetFiles(path.DirectoryName!, "manifest.*.json") + .Where(c => !string.Equals("manifest.schema.json", System.IO.Path.GetFileName(c), + StringComparison.OrdinalIgnoreCase)); + + foreach (var other in others) + { + var fileInfo = new FileInfo(other); + + var component = JToken.Parse(await File.ReadAllTextAsync(fileInfo.FullName)); + + _moduleMetadataEnricher.AddSource(component, fileInfo.Name); + jsonRaw.Merge(component, new JsonMergeSettings + { + // union array values together to avoid duplicates + MergeArrayHandling = MergeArrayHandling.Union, + PropertyNameComparison = System.StringComparison.OrdinalIgnoreCase, + MergeNullValueHandling = MergeNullValueHandling.Ignore + }); + } + + return jsonRaw; + } + } +} diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/ModuleMetadataEnricher.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/ModuleMetadataEnricher.cs new file mode 100644 index 0000000..1a58fe1 --- /dev/null +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/ModuleMetadataEnricher.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json.Linq; + +namespace EAVFW.Extensions.Manifest.ManifestEnricherTool +{ + public class ModuleMetadataEnricher : IModuleMetadataEnricher + { + /// + public void AddSource(JToken jToken, string source) + { + var entities = jToken.SelectToken("$.entities")?.Children(); + + if (entities == null) return; + + foreach (var entity in entities) + { + (entity.First as JObject)?.Add("moduleSource", source); + (entity.First as JObject)?.Add("moduleLocation", "manifest"); + + var attributes = entity.First?.SelectToken("$.attributes")?.Children(); + + if (attributes == null) continue; + + foreach (var attribute in attributes) + { + (attribute.First as JObject)?.Add("moduleSource", source); + (attribute.First as JObject)?.Add("moduleLocation", "entity"); + } + } + + var variables = jToken.SelectToken("$.variables"); + if (variables == null) + return; + + foreach (var child in variables.Children()) + { + WalkJToken(child, source); + } + } + + private void WalkJToken(JToken jToken, string source) + { + switch (jToken) + { + case JProperty jProperty: + // jp.Add("moduleSource", source); + // jp.Add("moduleLocation", "variables"); + foreach (var child in jProperty.Children()) + { + WalkJToken(child, source); + } + + break; + case JObject jObject: + jObject.Add("moduleSource", source); + jObject.Add("moduleLocation", "variables"); + foreach (var child in jObject.Children()) + { + WalkJToken(child, source); + } + + break; + case JArray jArray: + foreach (var child in jArray.Children()) + { + WalkJToken(child, source); + } + + break; + } + } + } +} diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Program.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Program.cs index f4e1b86..9535825 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Program.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Program.cs @@ -38,6 +38,9 @@ static IServiceCollection ConfigureServices(IServiceCollection serviceCollection serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddGPT(); + + serviceCollection.AddTransient(); + serviceCollection.AddTransient(); serviceCollection.AddHttpClient(); return serviceCollection; diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json index 7ec3e90..fcf09a0 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json @@ -3,8 +3,9 @@ "EAVFW.Extensions.Manifest.ManifestEnricherTool": { "commandName": "Project", "workingDirectory": "/Users/thyge/dev/playground", -// "commandLineArgs": "docs -c Release -t wizards -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\" -m \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/manifest.loi.json\"" - "commandLineArgs": "docs -c Release -t plugins -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\" -m \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/manifest.loi.json\"" +// "workingDirectory": "/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models", + "commandLineArgs": "docs -c Release -t wizards -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\" -m \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/manifest.loi.json\"" +// "commandLineArgs": "docs -c Release -t plugins -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\" -m \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/manifest.loi.json\"" // "commandLineArgs": "binary --unzip 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" // "commandLineArgs": "binary --unzip 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" // "commandLineArgs": "binary --unzip --pretty-print 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" @@ -22,9 +23,11 @@ // "commandLineArgs": "--path C:\\dev\\MedlemsCentralen\\src\\MC.Models\\manifest.json --customizationprefix MC" // "commandLineArgs": "sql ./src/Hafnia.Models", + // "commandLineArgs": "gpt review pr --project https://github.com/delegateas/WorkflowEngine.git --pr 15" // "commandLineArgs": "sql ./apps/KFST.Vanddata.ManagementPortal" - //"commandLineArgs": "--path C:\\dev\\hafnia\\loi\\src\\Hafnia.Models\\manifest.json --customizationprefix hafnia" +// "commandLineArgs": "--path C:\\dev\\hafnia\\loi\\src\\Hafnia.Models\\manifest.json --customizationprefix hafnia" +// "commandLineArgs": "--path /Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/manifest.json --customizationprefix hafnia" } } } diff --git a/tests/EAVFW.Extensions.Manifest.Tests/EAVFW.Extensions.Manifest.Tests.csproj b/tests/EAVFW.Extensions.Manifest.Tests/EAVFW.Extensions.Manifest.Tests.csproj index aee4d5c..bffa217 100644 --- a/tests/EAVFW.Extensions.Manifest.Tests/EAVFW.Extensions.Manifest.Tests.csproj +++ b/tests/EAVFW.Extensions.Manifest.Tests/EAVFW.Extensions.Manifest.Tests.csproj @@ -9,8 +9,9 @@ - - + + + @@ -31,6 +32,9 @@ PreserveNewest + + PreserveNewest + diff --git a/tests/EAVFW.Extensions.Manifest.Tests/Merge/AppTest.cs b/tests/EAVFW.Extensions.Manifest.Tests/Merge/AppTest.cs new file mode 100644 index 0000000..0fd0331 --- /dev/null +++ b/tests/EAVFW.Extensions.Manifest.Tests/Merge/AppTest.cs @@ -0,0 +1,39 @@ +using System.IO; +using System.Threading.Tasks; +using EAVFW.Extensions.Manifest.ManifestEnricherTool; +using JsonDiffPatchDotNet; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace EAVFW.Extensions.Manifest.Tests.Merge +{ + [TestClass] + public class AppTest + { + [TestMethod] + public async Task Test1() + { + // Arrange + var rootManifest = new FileInfo("Merge/manifest.json"); + var expectedManifestFileInfo = new FileInfo("Merge/expected.manifest.json"); + var expectedManifest = JToken.Parse(await File.ReadAllTextAsync(expectedManifestFileInfo.FullName)); + + var merger = new ManifestMerger(new ModuleMetadataEnricher()); + + // Act + var merged = await merger.MergeManifests(rootManifest); + + await using var fileStream = new FileStream("Merge/outpot.json", FileMode.Create); + var streamWriter = new StreamWriter(fileStream); + var jsonWriter = new JsonTextWriter(streamWriter); + await merged.WriteToAsync(jsonWriter); + await jsonWriter.FlushAsync(); + + // Assert + var diff = new JsonDiffPatch().Diff(merged, expectedManifest); + + Assert.IsNull(diff); + } + } +} diff --git a/tests/EAVFW.Extensions.Manifest.Tests/Merge/expected.manifest.json b/tests/EAVFW.Extensions.Manifest.Tests/Merge/expected.manifest.json new file mode 100644 index 0000000..d07c480 --- /dev/null +++ b/tests/EAVFW.Extensions.Manifest.Tests/Merge/expected.manifest.json @@ -0,0 +1,67 @@ +{ + "variables": { + "Audit": { + "moduleSource": "manifest.json", + "moduleLocation": "variables", + "CreatedOn": { + "moduleSource": "manifest.json", + "moduleLocation": "variables", + "type": "DateTime" + } + }, + "Administrative": { + "moduleSource": "manifest.json", + "moduleLocation": "variables", + "tab": "TAB_Administrative" + } + }, + "entities": { + "System User": { + "pluralName": "System Users", +// "moduleSource": "manifest.json", + "moduleSource": "manifest.component.json", + "moduleLocation": "manifest", + "attributes": { + "Email": { + "type": "Text", + "moduleSource": "manifest.json", + "moduleLocation": "entity" + }, + "Name": { + "type": "Text", + "moduleSource": "manifest.json", + "moduleLocation": "entity" + }, + "Organization": { + "type": "Text", + "moduleSource": "manifest.component.json", + "moduleLocation": "entity" + } + } + }, + "Identity": { + "pluralName": "Identities", + "moduleSource": "manifest.json", + "moduleLocation": "manifest", + "attributes": { + "Name": { + "type": "Text", + "moduleSource": "manifest.json", + "moduleLocation": "entity" + } + } + }, + "Component Table": { + "pluralName": "Component Tables", + "moduleSource": "manifest.component.json", + "moduleLocation": "manifest", + "attributes": { + "Name": { + "type": "Text", + "moduleSource": "manifest.component.json", + "moduleLocation": "entity" + } + } + } + } +} diff --git a/tests/EAVFW.Extensions.Manifest.Tests/Merge/manifest.component.json b/tests/EAVFW.Extensions.Manifest.Tests/Merge/manifest.component.json new file mode 100644 index 0000000..b9bb20b --- /dev/null +++ b/tests/EAVFW.Extensions.Manifest.Tests/Merge/manifest.component.json @@ -0,0 +1,19 @@ +{ + "entities": { + "System User": { + "attributes": { + "Organization": { + "type": "Text" + } + } + }, + "Component Table": { + "pluralName": "Component Tables", + "attributes": { + "Name": { + "type": "Text" + } + } + } + } +} diff --git a/tests/EAVFW.Extensions.Manifest.Tests/Merge/manifest.json b/tests/EAVFW.Extensions.Manifest.Tests/Merge/manifest.json new file mode 100644 index 0000000..e109781 --- /dev/null +++ b/tests/EAVFW.Extensions.Manifest.Tests/Merge/manifest.json @@ -0,0 +1,33 @@ +{ + "variables": { + "Audit": { + "CreatedOn": { + "type": "DateTime" + } + }, + "Administrative": { + "tab": "TAB_Administrative" + } + }, + "entities": { + "System User": { + "pluralName": "System Users", + "attributes": { + "Email": { + "type": "Text" + }, + "Name": { + "type": "Text" + } + } + }, + "Identity": { + "pluralName": "Identities", + "attributes": { + "Name": { + "type": "Text" + } + } + } + } +} diff --git a/tests/EAVFW.Extensions.Manifest.Tests/TestLogger.cs b/tests/EAVFW.Extensions.Manifest.Tests/TestLogger.cs new file mode 100644 index 0000000..789e5a4 --- /dev/null +++ b/tests/EAVFW.Extensions.Manifest.Tests/TestLogger.cs @@ -0,0 +1,31 @@ +using System; +using Microsoft.Extensions.Logging; + +namespace EAVFW.Extensions.Manifest.Tests +{ + // https://alastaircrabtree.com/using-logging-in-unit-tests-in-net-core/ + public static class TestLogger + { + public static ILogger Create() + { + var logger = new NUnitLogger(); + return logger; + } + + private class NUnitLogger : ILogger, IDisposable + { + private readonly Action _output = Console.WriteLine; + + public void Dispose() + { + } + + public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, + Func formatter) => _output(formatter(state, exception)); + + public bool IsEnabled(LogLevel logLevel) => true; + + public IDisposable BeginScope(TState state) => this; + } + } +} From 32ec6c1649a6f41ae622def6be43223cd7298149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thyge=20Sk=C3=B8dt=20Steffensen?= <31892312+thygesteffensen@users.noreply.github.com> Date: Wed, 22 Nov 2023 14:38:33 +0100 Subject: [PATCH 12/42] feat: Working version of documentation extractor and markdown generated --- ...tensions.Manifest.ManifestEnricherTool.sln | 2 +- external/EAVFramework | 2 +- ...tensions.Docs.Extracter.csproj.DotSettings | 6 - .../PluginRegistrationAttributeConverter.cs | 34 ---- .../JsonConverters/TypeConverter.cs | 20 --- .../Plugin/PluginDocumentation.cs | 20 --- .../CustomAssemblyResolver.cs | 2 +- .../DocumentLogic.cs | 13 +- .../EAVFW.Extensions.Docs.Extractor.csproj} | 1 + .../IDocumentLogic.cs | 2 +- .../Plugin/AssemblyInfo.cs | 2 +- .../Plugin/PluginDocumentation.cs | 20 +++ .../Plugin/PluginInfo.cs | 2 +- .../Plugin/PluginRegistrationAttributeData.cs | 12 ++ .../Plugin/TypeInformation.cs | 24 +++ .../Plugin/XmlDocumentationHelper.cs | 2 +- .../Plugin/XmlMemberElement.cs | 2 +- .../ServiceCollectionExtension.cs | 2 +- .../EAVFW.Extensions.Docs.Generator.csproj | 2 +- .../IDocumentationGenerator.cs | 16 ++ .../PluginDocumentationToReadMe.cs | 125 -------------- .../ReadMeDocumentationGenerator.cs | 155 ++++++++++++++++++ .../DocumentationGeneratorCommand.cs | 92 +++++++++++ .../DocumentationSourceCommand.cs | 24 +++ .../DocumentationSourceExtractorCommand.cs} | 50 +++--- ...sions.Manifest.ManifestEnricherTool.csproj | 2 +- .../Program.cs | 7 +- .../Properties/launchSettings.json | 5 +- 28 files changed, 394 insertions(+), 252 deletions(-) delete mode 100644 src/EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj.DotSettings delete mode 100644 src/EAVFW.Extensions.Docs.Extracter/JsonConverters/PluginRegistrationAttributeConverter.cs delete mode 100644 src/EAVFW.Extensions.Docs.Extracter/JsonConverters/TypeConverter.cs delete mode 100644 src/EAVFW.Extensions.Docs.Extracter/Plugin/PluginDocumentation.cs rename src/{EAVFW.Extensions.Docs.Extracter => EAVFW.Extensions.Docs.Extractor}/CustomAssemblyResolver.cs (96%) rename src/{EAVFW.Extensions.Docs.Extracter => EAVFW.Extensions.Docs.Extractor}/DocumentLogic.cs (92%) rename src/{EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj => EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj} (92%) rename src/{EAVFW.Extensions.Docs.Extracter => EAVFW.Extensions.Docs.Extractor}/IDocumentLogic.cs (95%) rename src/{EAVFW.Extensions.Docs.Extracter => EAVFW.Extensions.Docs.Extractor}/Plugin/AssemblyInfo.cs (81%) create mode 100644 src/EAVFW.Extensions.Docs.Extractor/Plugin/PluginDocumentation.cs rename src/{EAVFW.Extensions.Docs.Extracter => EAVFW.Extensions.Docs.Extractor}/Plugin/PluginInfo.cs (96%) create mode 100644 src/EAVFW.Extensions.Docs.Extractor/Plugin/PluginRegistrationAttributeData.cs create mode 100644 src/EAVFW.Extensions.Docs.Extractor/Plugin/TypeInformation.cs rename src/{EAVFW.Extensions.Docs.Extracter => EAVFW.Extensions.Docs.Extractor}/Plugin/XmlDocumentationHelper.cs (97%) rename src/{EAVFW.Extensions.Docs.Extracter => EAVFW.Extensions.Docs.Extractor}/Plugin/XmlMemberElement.cs (85%) rename src/{EAVFW.Extensions.Docs.Extracter => EAVFW.Extensions.Docs.Extractor}/ServiceCollectionExtension.cs (89%) create mode 100644 src/EAVFW.Extensions.Docs.Generator/IDocumentationGenerator.cs delete mode 100644 src/EAVFW.Extensions.Docs.Generator/PluginDocumentationToReadMe.cs create mode 100644 src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs create mode 100644 src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/DocumentationGeneratorCommand.cs create mode 100644 src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/DocumentationSourceCommand.cs rename src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/{DocumentCommand.cs => Documentation/DocumentationSourceExtractorCommand.cs} (75%) diff --git a/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln b/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln index 1cb1253..146db41 100644 --- a/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln +++ b/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln @@ -44,7 +44,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EAVFramework", "external\EA EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EAVFW.Extensions.Manifest.SDK", "external\EAVFramework\sdk\EAVFW.Extensions.Manifest.SDK.csproj", "{3BEF0769-ABD1-4D34-8004-C98DE9FB0339}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EAVFW.Extensions.Docs.Extracter", "src\EAVFW.Extensions.Docs.Extracter\EAVFW.Extensions.Docs.Extracter.csproj", "{432042AB-6A78-4ED7-B8AC-73B047F6630F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EAVFW.Extensions.Docs.Extractor", "src\EAVFW.Extensions.Docs.Extractor\EAVFW.Extensions.Docs.Extractor.csproj", "{432042AB-6A78-4ED7-B8AC-73B047F6630F}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EAVFW.Extensions.Docs.Generator", "src\EAVFW.Extensions.Docs.Generator\EAVFW.Extensions.Docs.Generator.csproj", "{71FCB365-F4AE-4578-BF86-B4A3C278B6B1}" EndProject diff --git a/external/EAVFramework b/external/EAVFramework index 65e40e2..f58d2ee 160000 --- a/external/EAVFramework +++ b/external/EAVFramework @@ -1 +1 @@ -Subproject commit 65e40e29208c746d0580ee123845df11f209d3b1 +Subproject commit f58d2eeef1ad7c24177e434fd093465c16e55094 diff --git a/src/EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj.DotSettings b/src/EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj.DotSettings deleted file mode 100644 index 6ed5a98..0000000 --- a/src/EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj.DotSettings +++ /dev/null @@ -1,6 +0,0 @@ - - True diff --git a/src/EAVFW.Extensions.Docs.Extracter/JsonConverters/PluginRegistrationAttributeConverter.cs b/src/EAVFW.Extensions.Docs.Extracter/JsonConverters/PluginRegistrationAttributeConverter.cs deleted file mode 100644 index bc70d3c..0000000 --- a/src/EAVFW.Extensions.Docs.Extracter/JsonConverters/PluginRegistrationAttributeConverter.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Nodes; -using System.Text.Json.Serialization; -using EAVFramework.Plugins; - -namespace EAVFW.Extensions.Docs.Extracter -{ - public class PluginRegistrationAttributeConverter : JsonConverter - { - public override PluginRegistrationAttribute? Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options) - { - throw new NotImplementedException(); - } - - public override void Write( - Utf8JsonWriter writer, - PluginRegistrationAttribute value, - JsonSerializerOptions options) - { - var _object = new JsonObject - { - { nameof(value.Order), value.Order }, - { nameof(value.Operation), value.Operation.ToString() }, - { nameof(value.Execution), value.Execution.ToString() }, - { nameof(value.Mode), value.Mode.ToString() } - }; - _object.WriteTo(writer); - } - } -} diff --git a/src/EAVFW.Extensions.Docs.Extracter/JsonConverters/TypeConverter.cs b/src/EAVFW.Extensions.Docs.Extracter/JsonConverters/TypeConverter.cs deleted file mode 100644 index 3154860..0000000 --- a/src/EAVFW.Extensions.Docs.Extracter/JsonConverters/TypeConverter.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Nodes; -using System.Text.Json.Serialization; - -namespace EAVFW.Extensions.Docs.Extracter -{ - public class TypeConverter : JsonConverter - { - public override Type? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - throw new NotImplementedException(); - } - - public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options) - { - JsonValue.Create(value.Name).WriteTo(writer, options); - } - } -} diff --git a/src/EAVFW.Extensions.Docs.Extracter/Plugin/PluginDocumentation.cs b/src/EAVFW.Extensions.Docs.Extracter/Plugin/PluginDocumentation.cs deleted file mode 100644 index e6ae712..0000000 --- a/src/EAVFW.Extensions.Docs.Extracter/Plugin/PluginDocumentation.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text.Json.Serialization; -using EAVFramework.Plugins; - -namespace EAVFW.Extensions.Docs.Extracter -{ - public class PluginDocumentation - { - public IEnumerable PluginRegistrations { get; set; } = - Array.Empty(); - - public string? Name { get; set; } - - [JsonConverter(typeof(TypeConverter))] public Type? Context { get; set; } - - [JsonConverter(typeof(TypeConverter))] public Type? Entity { get; set; } - public string Summary { get; set; } = ""; - } -} diff --git a/src/EAVFW.Extensions.Docs.Extracter/CustomAssemblyResolver.cs b/src/EAVFW.Extensions.Docs.Extractor/CustomAssemblyResolver.cs similarity index 96% rename from src/EAVFW.Extensions.Docs.Extracter/CustomAssemblyResolver.cs rename to src/EAVFW.Extensions.Docs.Extractor/CustomAssemblyResolver.cs index a2922f3..f0f8d67 100644 --- a/src/EAVFW.Extensions.Docs.Extracter/CustomAssemblyResolver.cs +++ b/src/EAVFW.Extensions.Docs.Extractor/CustomAssemblyResolver.cs @@ -3,7 +3,7 @@ using System.Linq; using System.Reflection; -namespace EAVFW.Extensions.Docs.Extracter +namespace EAVFW.Extensions.Docs.Extractor { public static class CustomAssemblyResolver { diff --git a/src/EAVFW.Extensions.Docs.Extracter/DocumentLogic.cs b/src/EAVFW.Extensions.Docs.Extractor/DocumentLogic.cs similarity index 92% rename from src/EAVFW.Extensions.Docs.Extracter/DocumentLogic.cs rename to src/EAVFW.Extensions.Docs.Extractor/DocumentLogic.cs index 0da526c..3ac7e5e 100644 --- a/src/EAVFW.Extensions.Docs.Extracter/DocumentLogic.cs +++ b/src/EAVFW.Extensions.Docs.Extractor/DocumentLogic.cs @@ -4,14 +4,12 @@ using System.Linq; using System.Reflection; using System.Runtime.Loader; -using System.Security.Principal; using System.Text.Json; -using System.Text.Json.Serialization; using EAVFramework.Plugins; using EAVFW.Extensions.Manifest.SDK; using WorkflowEngine.Core; -namespace EAVFW.Extensions.Docs.Extracter +namespace EAVFW.Extensions.Docs.Extractor { public class DocumentLogic : IDocumentLogic { @@ -53,11 +51,12 @@ from implementingType in implementingTypes .FirstOrDefault(i => i.GenericTypeArguments.Length == 2) select new PluginDocumentation { - PluginRegistrations = pluginRegistrations, + PluginRegistrations = pluginRegistrations.Select(x => new PluginRegistrationAttributeData + { Order = x.Order, Execution = x.Execution, Operation = x.Operation, Mode = x.Mode }), Name = implementingType.Name, Summary = implementingType.GetDocumentation(), - Context = _interface.GetGenericArguments().First(), - Entity = _interface.GetGenericArguments().Last() + Context = new TypeInformation(_interface.GetGenericArguments().First()), + Entity = new TypeInformation(_interface.GetGenericArguments().Last()) }; return plugins; @@ -106,7 +105,7 @@ from wizard in entity.Value.Wizards from _tabs in wizard.Value.Tabs select _tabs).AsEnumerable(); - // Glorified for loop? + // Glorified for loop?w var tabsWithWorkflows = from tab in tabs where tab.Value.OnTransitionOut?.Workflow != null || tab.Value.OnTransitionIn?.Workflow != null diff --git a/src/EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj b/src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj similarity index 92% rename from src/EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj rename to src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj index c87d43c..a3fecf8 100644 --- a/src/EAVFW.Extensions.Docs.Extracter/EAVFW.Extensions.Docs.Extracter.csproj +++ b/src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj @@ -4,6 +4,7 @@ 9.0 net8.0 enable + EAVFW.Extensions.Docs.Extracter diff --git a/src/EAVFW.Extensions.Docs.Extracter/IDocumentLogic.cs b/src/EAVFW.Extensions.Docs.Extractor/IDocumentLogic.cs similarity index 95% rename from src/EAVFW.Extensions.Docs.Extracter/IDocumentLogic.cs rename to src/EAVFW.Extensions.Docs.Extractor/IDocumentLogic.cs index bb70159..e74952c 100644 --- a/src/EAVFW.Extensions.Docs.Extracter/IDocumentLogic.cs +++ b/src/EAVFW.Extensions.Docs.Extractor/IDocumentLogic.cs @@ -2,7 +2,7 @@ using System.IO; using EAVFW.Extensions.Manifest.SDK; -namespace EAVFW.Extensions.Docs.Extracter +namespace EAVFW.Extensions.Docs.Extractor { public interface IDocumentLogic { diff --git a/src/EAVFW.Extensions.Docs.Extracter/Plugin/AssemblyInfo.cs b/src/EAVFW.Extensions.Docs.Extractor/Plugin/AssemblyInfo.cs similarity index 81% rename from src/EAVFW.Extensions.Docs.Extracter/Plugin/AssemblyInfo.cs rename to src/EAVFW.Extensions.Docs.Extractor/Plugin/AssemblyInfo.cs index d76edcc..6168edb 100644 --- a/src/EAVFW.Extensions.Docs.Extracter/Plugin/AssemblyInfo.cs +++ b/src/EAVFW.Extensions.Docs.Extractor/Plugin/AssemblyInfo.cs @@ -1,4 +1,4 @@ -namespace EAVFW.Extensions.Docs.Extracter +namespace EAVFW.Extensions.Docs.Extractor { public class AssemblyInfo { diff --git a/src/EAVFW.Extensions.Docs.Extractor/Plugin/PluginDocumentation.cs b/src/EAVFW.Extensions.Docs.Extractor/Plugin/PluginDocumentation.cs new file mode 100644 index 0000000..facc0f5 --- /dev/null +++ b/src/EAVFW.Extensions.Docs.Extractor/Plugin/PluginDocumentation.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace EAVFW.Extensions.Docs.Extractor +{ + public class PluginDocumentation + { + public IEnumerable PluginRegistrations { get; set; } = + Array.Empty(); + + public string? Name { get; set; } + + [JsonPropertyName("context")] public TypeInformation Context { get; set; } + + [JsonPropertyName("entity")] public TypeInformation Entity { get; set; } + + public string Summary { get; set; } = ""; + } +} diff --git a/src/EAVFW.Extensions.Docs.Extracter/Plugin/PluginInfo.cs b/src/EAVFW.Extensions.Docs.Extractor/Plugin/PluginInfo.cs similarity index 96% rename from src/EAVFW.Extensions.Docs.Extracter/Plugin/PluginInfo.cs rename to src/EAVFW.Extensions.Docs.Extractor/Plugin/PluginInfo.cs index f26bf60..344c615 100644 --- a/src/EAVFW.Extensions.Docs.Extracter/Plugin/PluginInfo.cs +++ b/src/EAVFW.Extensions.Docs.Extractor/Plugin/PluginInfo.cs @@ -1,7 +1,7 @@ using System; using System.IO; -namespace EAVFW.Extensions.Docs.Extracter +namespace EAVFW.Extensions.Docs.Extractor { public struct PluginInfo { diff --git a/src/EAVFW.Extensions.Docs.Extractor/Plugin/PluginRegistrationAttributeData.cs b/src/EAVFW.Extensions.Docs.Extractor/Plugin/PluginRegistrationAttributeData.cs new file mode 100644 index 0000000..84ec9b5 --- /dev/null +++ b/src/EAVFW.Extensions.Docs.Extractor/Plugin/PluginRegistrationAttributeData.cs @@ -0,0 +1,12 @@ +using EAVFramework.Plugins; + +namespace EAVFW.Extensions.Docs.Extractor +{ + public class PluginRegistrationAttributeData + { + public EntityPluginExecution Execution { get; set; } + public EntityPluginOperation Operation { get; set; } + public EntityPluginMode Mode { get; set; } + public int Order { get; set; } + } +} diff --git a/src/EAVFW.Extensions.Docs.Extractor/Plugin/TypeInformation.cs b/src/EAVFW.Extensions.Docs.Extractor/Plugin/TypeInformation.cs new file mode 100644 index 0000000..1f6c4fb --- /dev/null +++ b/src/EAVFW.Extensions.Docs.Extractor/Plugin/TypeInformation.cs @@ -0,0 +1,24 @@ +using System; +using System.Linq; +using System.Text.Json.Serialization; + +namespace EAVFW.Extensions.Docs.Extractor +{ + public class TypeInformation + { + [JsonPropertyName("AssemblyQualifiedName")] + public string AssemblyQualifiedName { get; set; } + + [JsonIgnore] + public string Name => AssemblyQualifiedName.Split(',').First().Split('.').Last().Trim(); + + public TypeInformation() + { + } + + public TypeInformation(Type type) + { + AssemblyQualifiedName = type.AssemblyQualifiedName; + } + } +} diff --git a/src/EAVFW.Extensions.Docs.Extracter/Plugin/XmlDocumentationHelper.cs b/src/EAVFW.Extensions.Docs.Extractor/Plugin/XmlDocumentationHelper.cs similarity index 97% rename from src/EAVFW.Extensions.Docs.Extracter/Plugin/XmlDocumentationHelper.cs rename to src/EAVFW.Extensions.Docs.Extractor/Plugin/XmlDocumentationHelper.cs index 1ae0044..9aefe99 100644 --- a/src/EAVFW.Extensions.Docs.Extracter/Plugin/XmlDocumentationHelper.cs +++ b/src/EAVFW.Extensions.Docs.Extractor/Plugin/XmlDocumentationHelper.cs @@ -4,7 +4,7 @@ using System.Reflection; using System.Xml; -namespace EAVFW.Extensions.Docs.Extracter +namespace EAVFW.Extensions.Docs.Extractor { public static class XmlDocumentationHelper { diff --git a/src/EAVFW.Extensions.Docs.Extracter/Plugin/XmlMemberElement.cs b/src/EAVFW.Extensions.Docs.Extractor/Plugin/XmlMemberElement.cs similarity index 85% rename from src/EAVFW.Extensions.Docs.Extracter/Plugin/XmlMemberElement.cs rename to src/EAVFW.Extensions.Docs.Extractor/Plugin/XmlMemberElement.cs index ce53ecf..03eba34 100644 --- a/src/EAVFW.Extensions.Docs.Extracter/Plugin/XmlMemberElement.cs +++ b/src/EAVFW.Extensions.Docs.Extractor/Plugin/XmlMemberElement.cs @@ -1,6 +1,6 @@ using System.Xml.Serialization; -namespace EAVFW.Extensions.Docs.Extracter +namespace EAVFW.Extensions.Docs.Extractor { [XmlRoot("member")] public class XmlMemberElement diff --git a/src/EAVFW.Extensions.Docs.Extracter/ServiceCollectionExtension.cs b/src/EAVFW.Extensions.Docs.Extractor/ServiceCollectionExtension.cs similarity index 89% rename from src/EAVFW.Extensions.Docs.Extracter/ServiceCollectionExtension.cs rename to src/EAVFW.Extensions.Docs.Extractor/ServiceCollectionExtension.cs index 9701d2c..f690cc4 100644 --- a/src/EAVFW.Extensions.Docs.Extracter/ServiceCollectionExtension.cs +++ b/src/EAVFW.Extensions.Docs.Extractor/ServiceCollectionExtension.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.DependencyInjection; -namespace EAVFW.Extensions.Docs.Extracter +namespace EAVFW.Extensions.Docs.Extractor { public static class ServiceCollectionExtension { diff --git a/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj b/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj index f4f75e8..07bae44 100644 --- a/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj +++ b/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj @@ -6,7 +6,7 @@ - + diff --git a/src/EAVFW.Extensions.Docs.Generator/IDocumentationGenerator.cs b/src/EAVFW.Extensions.Docs.Generator/IDocumentationGenerator.cs new file mode 100644 index 0000000..b3daecd --- /dev/null +++ b/src/EAVFW.Extensions.Docs.Generator/IDocumentationGenerator.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using EAVFW.Extensions.Docs.Extractor; +using EAVFW.Extensions.Manifest.SDK; + +namespace EAVFW.Extensions.Docs.Generator +{ + public interface IDocumentationGenerator + { + public void AddPluginSource(IEnumerable pluginDocumentations); + public void AddWizardSource(Dictionary entitiesWithWizards); + public void AddGeneratedManifest(ManifestDefinition generatedManifest); + public Task Write(FileInfo outputLocation, string component); + } +} diff --git a/src/EAVFW.Extensions.Docs.Generator/PluginDocumentationToReadMe.cs b/src/EAVFW.Extensions.Docs.Generator/PluginDocumentationToReadMe.cs deleted file mode 100644 index c524be7..0000000 --- a/src/EAVFW.Extensions.Docs.Generator/PluginDocumentationToReadMe.cs +++ /dev/null @@ -1,125 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using EAVFW.Extensions.Docs.Extracter; -using EAVFW.Extensions.Manifest.SDK; -using JsonSerializer = System.Text.Json.JsonSerializer; - -namespace EAVFW.Extensions.Docs.Generator -{ - public class PluginDocumentationToReadMe : IDisposable - { - private readonly StreamWriter _writer; - private readonly Dictionary _logicalNameLookup = new(); - private readonly TransformXmlTag _transformXmlTag; - - public PluginDocumentationToReadMe( - string path = "/Users/thyge/Documents/Obsidian Vault/Delegate Lava-Stone/Delegate/documentation.md") - { - _transformXmlTag = new TransformXmlTag(); - _writer = new StreamWriter(path); - } - - public async Task WriteTables(FileInfo manifest, string component) - { - var manifestObject = await JsonSerializer.DeserializeAsync(manifest.OpenRead()); - - await _writer.WriteLineAsync("## Tables:\n"); - - var t = new DefaultSchemaNameManager(); - - Debug.Assert(manifestObject != null, nameof(manifestObject) + " != null"); - foreach (var (key, value) in manifestObject.Entities) - { - _logicalNameLookup[t.ToSchemaName(key)] = key; - - await _writer.WriteLineAsync($"### {key}"); - await _writer.WriteLineAsync($"Logical name: `{t.ToSchemaName(key)}`"); - await _writer.WriteLineAsync($"Plural name: {value.PluralName}"); - await _writer.WriteLineAsync($"Description: {value.Description}"); - await _writer.WriteLineAsync("Attributes:"); - } - } - - public async Task WritePlugins(IEnumerable pluginDocumentations, string component) - { - var groups = pluginDocumentations.GroupBy(x => x.Entity!.Name); - await _writer.WriteLineAsync("## Plugins "); - foreach (var group in groups) - { - await _writer.WriteLineAsync($"### {group.FirstOrDefault()?.Entity?.Name}"); - foreach (var pluginDocumentation in group) - { - await _writer.WriteLineAsync($"#### {pluginDocumentation.Name}"); - await _writer.WriteLineAsync( - $"Entity:\t[{pluginDocumentation.Entity?.Name}](#{pluginDocumentation.Entity?.Name})"); - await _writer.WriteLineAsync( - $"Context:\t[{pluginDocumentation.Entity?.Name}](#{pluginDocumentation.Entity?.Name})"); - await _writer.WriteLineAsync("Triggers:\n"); - await _writer.WriteLineAsync("| Operation | Execution | Mode | Order |"); - await _writer.WriteLineAsync("|---|---|---|:-:|"); - foreach (var reg in pluginDocumentation.PluginRegistrations.OrderBy(x => x.Order)) - { - await _writer.WriteLineAsync($"|{reg.Operation}|{reg.Execution}|{reg.Mode}|{reg.Order}|"); - } - - await _writer.WriteLineAsync("\n**Summary:**"); - - await _writer.WriteLineAsync(SanitizeSummary(pluginDocumentation.Summary)); - - await _writer.WriteLineAsync(); - } - } - } - - public async Task WriteWizards() - { - - } - - - private string SanitizeSummary(string summary) - { - if (string.IsNullOrWhiteSpace(summary)) return summary; - - var lines = summary.Split("\n").Select(x => x); - - lines = lines.Where(x => !string.IsNullOrWhiteSpace(x)); - lines = lines.Select(x => x.Trim()); - lines = lines.Select(x => _transformXmlTag.TransformString(x, TransformTag)); - - return string.Join(" ", lines); - } - - /// - /// Function i expression motoren - /// - /// - /// - /// - private string TransformTag(string tag, Dictionary properties) - { - if (tag != "see") - return tag; - - var target = properties["cref"]; - - var key = target.Split(':').Last().Split('.').Last(); - - _logicalNameLookup.TryGetValue(key, out var value); - - return $"[{value ?? key}](#{key})"; - } - - - public async void Dispose() - { - await _writer.FlushAsync(); - await _writer.DisposeAsync(); - GC.SuppressFinalize(this); - } - } -} diff --git a/src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs b/src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs new file mode 100644 index 0000000..7a92899 --- /dev/null +++ b/src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs @@ -0,0 +1,155 @@ +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using EAVFW.Extensions.Docs.Extractor; +using EAVFW.Extensions.Manifest.SDK; + +namespace EAVFW.Extensions.Docs.Generator +{ + public class ReadMeDocumentationGenerator : IDocumentationGenerator + { + private readonly TransformXmlTag _transformXmlTag = new(); + private readonly Dictionary _logicalNameLookup = new(); + private Dictionary _wizards; + private IEnumerable _pluginDocumentations; + private ManifestDefinition _manifestObject; + + + public void AddPluginSource(IEnumerable pluginDocumentations) + { + _pluginDocumentations = pluginDocumentations; + } + + + public void AddWizardSource(Dictionary entitiesWithWizards) + { + _wizards = entitiesWithWizards; + } + + public void AddGeneratedManifest(ManifestDefinition generatedManifest) + { + _manifestObject = generatedManifest; + } + + public async Task Write(FileInfo outputLocation, string component) + { + var writer = new StreamWriter(outputLocation.FullName); + + await WriteTables(writer, component); + await WriteWizards(writer); + await WritePlugins(writer); + + await writer.FlushAsync(); + } + + + private async Task WriteTables(TextWriter writer, string component) + { + await writer.WriteLineAsync("## Tables:\n"); + + var t = new DefaultSchemaNameManager(); + + var entitiesToWrite = _manifestObject.Entities; + + if (!string.IsNullOrWhiteSpace(component)) + { + entitiesToWrite = entitiesToWrite.Where(entity => + entity.Value.AdditionalFields.ContainsKey("moduleSource") && + entity.Value.AdditionalFields["moduleSource"].ToString() == component) + .ToDictionary(x => x.Key, x => x.Value); + } + + foreach (var (key, value) in entitiesToWrite) + { + _logicalNameLookup[t.ToSchemaName(key)] = key; + + await writer.WriteLineAsync($"### {key}"); + await writer.WriteLineAsync($"Logical name: `{t.ToSchemaName(key)}`"); + await writer.WriteLineAsync($"Plural name: {value.PluralName}"); + await writer.WriteLineAsync($"Description: {value.Description}"); + await writer.WriteLineAsync("Attributes:"); + } + } + + private async Task WritePlugins(TextWriter writer) + { + var groups = _pluginDocumentations.GroupBy(x => x.Entity!.Name); + await writer.WriteLineAsync("## Plugins: "); + foreach (var group in groups) + { + await writer.WriteLineAsync($"### {group.FirstOrDefault()?.Entity?.Name}"); + foreach (var pluginDocumentation in group) + { + await writer.WriteLineAsync($"#### {pluginDocumentation.Name}"); + await writer.WriteLineAsync( + $"Entity:\t[{pluginDocumentation.Entity?.Name}](#{pluginDocumentation.Entity?.Name})"); + await writer.WriteLineAsync( + $"Context:\t[{pluginDocumentation.Entity?.Name}](#{pluginDocumentation.Entity?.Name})"); + await writer.WriteLineAsync("Triggers:\n"); + await writer.WriteLineAsync("| Operation | Execution | Mode | Order |"); + await writer.WriteLineAsync("|---|---|---|:-:|"); + foreach (var reg in pluginDocumentation.PluginRegistrations.OrderBy(x => x.Order)) + { + await writer.WriteLineAsync($"|{reg.Operation}|{reg.Execution}|{reg.Mode}|{reg.Order}|"); + } + + await writer.WriteLineAsync("\n**Summary:**"); + + await writer.WriteLineAsync(SanitizeSummary(pluginDocumentation.Summary)); + + await writer.WriteLineAsync(); + } + } + } + + private async Task WriteWizards(TextWriter writer) + { + await writer.WriteLineAsync("## Wizards:"); + + foreach (var (key, value) in _wizards.Where(x => x.Value.Wizards.Count > 0)) + { + await writer.WriteLineAsync($"### {key}"); + + foreach (var (wizardKey, wizardDefinition) in value.Wizards) + { + await writer.WriteLineAsync($"#### {wizardKey}"); + } + } + } + + + private string SanitizeSummary(string summary) + { + if (string.IsNullOrWhiteSpace(summary)) return summary; + + var lines = summary.Split("\n").Select(x => x); + + lines = lines.Where(x => !string.IsNullOrWhiteSpace(x)); + lines = lines.Select(x => x.Trim()); + lines = lines.Select(x => _transformXmlTag.TransformString(x, TransformTag)); + + return string.Join(" ", lines); + } + + /// + /// Function i expression motoren + /// + /// + /// + /// + private string TransformTag(string tag, Dictionary properties) + { + if (tag != "see") + return tag; + + var target = properties["cref"]; + + var key = target.Split(':').Last().Split('.').Last(); + + _logicalNameLookup.TryGetValue(key, out var value); + + return $"[{value ?? key}](#{key})"; + } + } +} diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/DocumentationGeneratorCommand.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/DocumentationGeneratorCommand.cs new file mode 100644 index 0000000..f1cc919 --- /dev/null +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/DocumentationGeneratorCommand.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.CommandLine.Parsing; +using System.ComponentModel; +using System.IO; +using System.Text.Json; +using System.Threading.Tasks; +using EAVFW.Extensions.Docs.Extractor; +using EAVFW.Extensions.Docs.Generator; +using EAVFW.Extensions.Manifest.SDK; + +namespace EAVFW.Extensions.Manifest.ManifestEnricherTool.Commands.Documentation +{ + public class DocumentationGeneratorCommand : Command + { + [Alias("-gm")] + [Description("Path to the generate manifest")] + public FileInfo GeneratedManifestPath { get; set; } + + [Alias("-p")] + [Description("Path to plugin source")] + public FileInfo PluginSourcePath { get; set; } + + [Alias("-w")] + [Description("Path to wizard source directory")] + public DirectoryInfo WizardSourcePath { get; set; } + + [Alias("-c")] + [Description("Component")] + public string Component { get; set; } + + [Alias("-o")] [Description("Output")] public FileInfo Output { get; set; } + + public DocumentationGeneratorCommand() : base("generate", "Generate") + { + Handler = COmmandExtensions.Create(this, Array.Empty(), Run); + } + + private async Task Run(ParseResult parseResult, IConsole console) + { + if (IsFilesAndFoldersMissing(out var missing)) + { + console.WriteLine($"The following file(s)/folder(s) are missing: {string.Join(", ", missing)}"); + return 1; + } + + var documentationGenerator = new ReadMeDocumentationGenerator(); + + await using var pluginStream = PluginSourcePath.OpenRead(); + documentationGenerator.AddPluginSource( + await JsonSerializer.DeserializeAsync>(pluginStream)); + + + var wizards = new Dictionary(); + var files = Directory.GetFiles(WizardSourcePath.FullName, "*.json"); + foreach (var file in files) + { + var fileInfo = new FileInfo(file); + await using var openStream = fileInfo.OpenRead(); + var w = await JsonSerializer.DeserializeAsync(openStream); + wizards[Path.GetFileNameWithoutExtension(fileInfo.Name)] = w; + } + + documentationGenerator.AddWizardSource(wizards); + + await using var manifestStream = GeneratedManifestPath.OpenRead(); + documentationGenerator.AddGeneratedManifest( + await JsonSerializer.DeserializeAsync(manifestStream)); + + await documentationGenerator.Write(Output, Component); + + return 0; + } + + private bool IsFilesAndFoldersMissing(out List missing) + { + missing = new List(); + + if (!GeneratedManifestPath.Exists) + missing.Add(GeneratedManifestPath.Name); + + if (!PluginSourcePath.Exists) + missing.Add(PluginSourcePath.Name); + + if (!WizardSourcePath.Exists) + missing.Add(WizardSourcePath.Name); + + return missing.Count > 0; + } + } +} diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/DocumentationSourceCommand.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/DocumentationSourceCommand.cs new file mode 100644 index 0000000..a24158f --- /dev/null +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/DocumentationSourceCommand.cs @@ -0,0 +1,24 @@ +using System; +using System.CommandLine; +using System.CommandLine.Parsing; +using System.Threading.Tasks; +using EAVFW.Extensions.Docs.Extractor; + +namespace EAVFW.Extensions.Manifest.ManifestEnricherTool.Commands.Documentation +{ + public class DocumentationSourceCommand : Command + { + public DocumentationSourceCommand(IDocumentLogic documentLogic) : base("docs", "Work with documentation") + { + Handler = COmmandExtensions.Create(this, Array.Empty(), Run); + + AddCommand(new DocumentationSourceExtractorCommand(documentLogic)); + AddCommand(new DocumentationGeneratorCommand()); + } + + private Task Run(ParseResult parseResult, IConsole console) + { + return Task.FromResult(0); + } + } +} diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/DocumentCommand.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/DocumentationSourceExtractorCommand.cs similarity index 75% rename from src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/DocumentCommand.cs rename to src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/DocumentationSourceExtractorCommand.cs index e966be2..5d01223 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/DocumentCommand.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/DocumentationSourceExtractorCommand.cs @@ -7,14 +7,19 @@ using System.Linq; using System.Text.Json; using System.Threading.Tasks; -using EAVFW.Extensions.Docs.Extracter; -using EAVFW.Extensions.Docs.Generator; +using EAVFW.Extensions.Docs.Extractor; -namespace EAVFW.Extensions.Manifest.ManifestEnricherTool.Commands +namespace EAVFW.Extensions.Manifest.ManifestEnricherTool.Commands.Documentation { - public class DocumentCommand : Command + /* + * There are many parameters to the command and generating source for both plugin and wizard requires the tool to be + * executed twice. Alternatively, the "configuration" could be done using a configuration, which would provide all + * necessary parameters. Both it would be more rigid and could not easily be changed in a pipeline or other. + */ + + public class DocumentationSourceExtractorCommand : Command { - private readonly IDocumentLogic documentLogic; + private readonly IDocumentLogic _documentLogic; [Alias("-a")] [Alias("--assembly")] @@ -29,15 +34,15 @@ public class DocumentCommand : Command [Alias("-p")] [Alias("--probing-path")] [Description("Path to probe for dependent assemblies")] - public DirectoryInfo RootPathOption { get; set; } + public DirectoryInfo ProbePathOption { get; set; } [Alias("-c")] [Alias("--configuration")] [Description("Configuration for the built assembly")] public string ConfigurationOption { get; set; } - + [Alias("--component")] - [Description("Component to generate documentation. E.g., `mainfest.component.json`")] + [Description("Component to generate documentation. E.g., `manifest.component.json`")] public string ComponentOption { get; set; } [Alias("-f")] @@ -61,9 +66,9 @@ public enum Targets Wizards } - public DocumentCommand(IDocumentLogic documentLogic) : base("docs", "Generate documentation") + public DocumentationSourceExtractorCommand(IDocumentLogic documentLogic) : base("extract", "Extract documentation source") { - this.documentLogic = documentLogic ?? throw new ArgumentNullException(nameof(documentLogic)); + _documentLogic = documentLogic ?? throw new ArgumentNullException(nameof(documentLogic)); Handler = COmmandExtensions.Create(this, Array.Empty(), Run); } @@ -75,7 +80,7 @@ private async Task Run(ParseResult parseResult, IConsole console) return 126; } - if (!RootPathOption.Exists) + if (!ProbePathOption.Exists) { Console.WriteLine("Probing path does not exists"); return 1; @@ -90,15 +95,15 @@ private async Task Run(ParseResult parseResult, IConsole console) switch (Target) { case Targets.Plugins: - return await HandlePlugins(); + return await GeneratePluginSource(); case Targets.Wizards: - return await HandleWizards(); + return await GenerateWizardSource(); default: throw new ArgumentOutOfRangeException(); } } - private async Task HandleWizards() + private async Task GenerateWizardSource() { if (!ManifestPathOption?.Exists ?? true) { @@ -106,9 +111,9 @@ private async Task HandleWizards() return 1; } - var entityDefinitions = documentLogic.ExtractWizardDocumentation( + var entityDefinitions = _documentLogic.ExtractWizardDocumentation( ManifestPathOption, - new PluginInfo(RootPathOption, + new PluginInfo(ProbePathOption, AssemblyPathOption, ConfigurationOption, FrameworkOption)); @@ -133,16 +138,15 @@ private async Task HandleWizards() return 0; } - private async Task HandlePlugins() + private async Task GeneratePluginSource() { - var plugins = documentLogic - .ExtractPluginDocumentation(new PluginInfo(RootPathOption, AssemblyPathOption, ConfigurationOption, + var plugins = _documentLogic + .ExtractPluginDocumentation(new PluginInfo(ProbePathOption, AssemblyPathOption, ConfigurationOption, FrameworkOption)) .ToArray(); - + var jsonString = JsonSerializer.Serialize(plugins, new JsonSerializerOptions { - Converters = { new PluginRegistrationAttributeConverter() }, WriteIndented = true }); @@ -169,8 +173,8 @@ private bool IsMissingOptions(out List missing) if (AssemblyPathOption == null) missing.Add(nameof(AssemblyPathOption)); - if (RootPathOption == null) - missing.Add(nameof(RootPathOption)); + if (ProbePathOption == null) + missing.Add(nameof(ProbePathOption)); if (string.IsNullOrWhiteSpace(ConfigurationOption)) missing.Add(nameof(ConfigurationOption)); diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj index 445e2a4..bd60682 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj @@ -55,7 +55,7 @@ - + diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Program.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Program.cs index 9535825..0b0153f 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Program.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Program.cs @@ -1,6 +1,4 @@  - - // See https://aka.ms/new-console-template for more information using EAVFW.Extensions.Manifest.ManifestEnricherTool.Commands; using EAVFW.Extensions.Manifest.ManifestEnricherTool.Commands.GPT; @@ -9,7 +7,8 @@ using Microsoft.Extensions.Logging; using System.CommandLine; using System.Threading.Tasks; -using EAVFW.Extensions.Docs.Extracter; +using EAVFW.Extensions.Docs.Extractor; +using EAVFW.Extensions.Manifest.ManifestEnricherTool.Commands.Documentation; using EAVFW.Extensions.Manifest.ManifestEnricherTool.Commands.Gzip; namespace EAVFW.Extensions.Manifest.ManifestEnricherTool @@ -36,7 +35,7 @@ static IServiceCollection ConfigureServices(IServiceCollection serviceCollection serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); - serviceCollection.AddSingleton(); + serviceCollection.AddSingleton(); serviceCollection.AddGPT(); serviceCollection.AddTransient(); diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json index fcf09a0..48460f1 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json @@ -4,8 +4,9 @@ "commandName": "Project", "workingDirectory": "/Users/thyge/dev/playground", // "workingDirectory": "/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models", - "commandLineArgs": "docs -c Release -t wizards -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\" -m \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/manifest.loi.json\"" -// "commandLineArgs": "docs -c Release -t plugins -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\" -m \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/manifest.loi.json\"" +// "commandLineArgs": "docs extract -c Release -t wizards -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\" -m \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/manifest.loi.json\"" +// "commandLineArgs": "docs extract -c Release -t plugins -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\" -m \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/manifest.loi.json\"" + "commandLineArgs": "docs generate -c manifest.loi.json -p /Users/thyge/dev/playground/plugins.json -w /Users/thyge/dev/playground/wizards -o \"/Users/thyge/Documents/Obsidian Vault/Delegate Lava-Stone/Delegate/documentation.md\" -gm /Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/obj/manifest.g.json" // "commandLineArgs": "binary --unzip 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" // "commandLineArgs": "binary --unzip 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" // "commandLineArgs": "binary --unzip --pretty-print 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" From 7e58cf83b1eb22b080f0866fbcc71222fd004675 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thyge=20Sk=C3=B8dt=20Steffensen?= <31892312+thygesteffensen@users.noreply.github.com> Date: Thu, 23 Nov 2023 18:10:11 +0100 Subject: [PATCH 13/42] feat: Finishing version of documentation generator --- .../ReadMeDocumentationGenerator.cs | 261 +++++++++++++++--- .../Commands/Documentation/README.md | 25 ++ 2 files changed, 245 insertions(+), 41 deletions(-) create mode 100644 src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/README.md diff --git a/src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs b/src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs index 7a92899..bae36e2 100644 --- a/src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs +++ b/src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text; using System.Threading.Tasks; using EAVFW.Extensions.Docs.Extractor; using EAVFW.Extensions.Manifest.SDK; @@ -15,6 +16,8 @@ public class ReadMeDocumentationGenerator : IDocumentationGenerator private IEnumerable _pluginDocumentations; private ManifestDefinition _manifestObject; + private ISchemaNameManager _schemaNameManager = new DefaultSchemaNameManager(); + public void AddPluginSource(IEnumerable pluginDocumentations) { @@ -32,23 +35,59 @@ public void AddGeneratedManifest(ManifestDefinition generatedManifest) _manifestObject = generatedManifest; } - public async Task Write(FileInfo outputLocation, string component) + private string BuildAttributeDescription(AttributeObjectDefinition attribute, string key) { - var writer = new StreamWriter(outputLocation.FullName); + var s = ""; + var _component = "manifest.loi.json"; + if (attribute.AttributeType.Type == "lookup") + { + var lookup = attribute.AttributeType.ReferenceType; + _manifestObject.Entities.FirstOrDefault(x => x.Key == lookup).Value.AdditionalFields + .TryGetValue("moduleSource", out var source); - await WriteTables(writer, component); - await WriteWizards(writer); - await WritePlugins(writer); + if (source.ToString() == _component) + { + s += + $"Lookup: [{attribute.AttributeType.ReferenceType}](#{_schemaNameManager.ToSchemaName(attribute.AttributeType.ReferenceType)})
"; + } + else + { + s += $"Lookup: {attribute.AttributeType.ReferenceType} ({source})
"; + } + } - await writer.FlushAsync(); - } + if (attribute.AttributeType.Type == "Choice") + { + var defaultOption = attribute.AdditionalFields.TryGetValue("default", out var _default); + var defaultValue = 0; + if (defaultOption) + { + // defaultValue = _default.GetInt32(); + } + + + s += "Options:
"; + foreach (var (key1, value) in attribute.AttributeType.Options) + { + s += $"- {value}: {key1}"; + + if (defaultOption && value.GetInt32() == defaultValue) + { + s += " (default)"; + } + + s += "
"; + } + } + return s + $"_Display name:_ {key}"; + } - private async Task WriteTables(TextWriter writer, string component) + public async Task Write(FileInfo outputLocation, string component) { - await writer.WriteLineAsync("## Tables:\n"); + var writer = new StreamWriter(outputLocation.FullName); - var t = new DefaultSchemaNameManager(); + await writer.WriteLineAsync($"# Documentation for {component}"); var entitiesToWrite = _manifestObject.Entities; @@ -60,64 +99,145 @@ private async Task WriteTables(TextWriter writer, string component) .ToDictionary(x => x.Key, x => x.Value); } + await writer.WriteLineAsync("## Table of contents"); + + var index = 2; + await writer.WriteLineAsync("1. [Class diagram](#class-diagram)"); + foreach (var (key, value) in entitiesToWrite) + { + await writer.WriteLineAsync($"{index++}. [{key}](#{_schemaNameManager.ToSchemaName(key)})"); + } + + await writer.WriteLineAsync("# Class diagram "); + await writer.WriteAsync(EntitiesToClassDiagram(_manifestObject, component)); + + var ignored = new List + { "Modified On", "Modified By", "Created By", "Created On", "Row Version", "Owner" }; + foreach (var (key, value) in entitiesToWrite) { - _logicalNameLookup[t.ToSchemaName(key)] = key; + await writer.WriteLineAsync($"## {key} "); + + await writer.WriteLineAsync(value.Description); + + await WriteAttributes(writer, value, ignored); + + await WritePlugins(writer, key); - await writer.WriteLineAsync($"### {key}"); - await writer.WriteLineAsync($"Logical name: `{t.ToSchemaName(key)}`"); - await writer.WriteLineAsync($"Plural name: {value.PluralName}"); - await writer.WriteLineAsync($"Description: {value.Description}"); - await writer.WriteLineAsync("Attributes:"); + + await WriteWizards(writer, key); } + + await writer.FlushAsync(); } - private async Task WritePlugins(TextWriter writer) + private async Task WriteWizards(StreamWriter writer, string key) { - var groups = _pluginDocumentations.GroupBy(x => x.Entity!.Name); - await writer.WriteLineAsync("## Plugins: "); - foreach (var group in groups) + await writer.WriteLineAsync("### Wizards"); + + if (_wizards.TryGetValue(key, out var wizard)) { - await writer.WriteLineAsync($"### {group.FirstOrDefault()?.Entity?.Name}"); - foreach (var pluginDocumentation in group) + foreach (var (s, wizardDefinition) in wizard.Wizards) { - await writer.WriteLineAsync($"#### {pluginDocumentation.Name}"); - await writer.WriteLineAsync( - $"Entity:\t[{pluginDocumentation.Entity?.Name}](#{pluginDocumentation.Entity?.Name})"); - await writer.WriteLineAsync( - $"Context:\t[{pluginDocumentation.Entity?.Name}](#{pluginDocumentation.Entity?.Name})"); - await writer.WriteLineAsync("Triggers:\n"); - await writer.WriteLineAsync("| Operation | Execution | Mode | Order |"); - await writer.WriteLineAsync("|---|---|---|:-:|"); - foreach (var reg in pluginDocumentation.PluginRegistrations.OrderBy(x => x.Order)) + await writer.WriteLineAsync($"#### {wizardDefinition.Title}"); + + await writer.WriteLineAsync("\nTriggers:\n"); + await writer.WriteLineAsync("| Type | Value |"); + await writer.WriteLineAsync("|------|-------|"); + + foreach (var (k, triggerDefinition) in wizardDefinition.Triggers) { - await writer.WriteLineAsync($"|{reg.Operation}|{reg.Execution}|{reg.Mode}|{reg.Order}|"); + if (string.IsNullOrWhiteSpace(triggerDefinition.Form)) + await writer.WriteLineAsync($"| Ribbon | {triggerDefinition.Ribbon} |"); + else + await writer.WriteLineAsync($"| Form | {triggerDefinition.Form} |"); } - await writer.WriteLineAsync("\n**Summary:**"); + await writer.WriteLineAsync("\nTabs:\n"); + await writer.WriteLineAsync("| Tab | Visible | OnTransitionIn | OnTransitionOut |"); + await writer.WriteLineAsync("| -- | -- | -- | -- |"); + + foreach (var (key1, tabDefinition) in wizardDefinition.Tabs) + { + await writer.WriteLineAsync( + $"| {key1} | {GetVisibleString(tabDefinition.Visible.ToString())} | {GetTransitionString(tabDefinition.OnTransitionIn)} | {GetTransitionString(tabDefinition.OnTransitionOut)} |"); + } + } + } + else + { + await writer.WriteLineAsync("_No wizards_"); + } + } - await writer.WriteLineAsync(SanitizeSummary(pluginDocumentation.Summary)); + private string GetVisibleString(string visible) + { + return string.IsNullOrWhiteSpace(visible) ? "" : $"`{visible}`"; + } - await writer.WriteLineAsync(); + private string GetTransitionString(TransitionDefinition transitionDefinition) + { + if (!string.IsNullOrWhiteSpace(transitionDefinition?.Workflow)) + { + var summaryString = ""; + if (transitionDefinition.AdditionalData.TryGetValue("x-workflowSummary", out var summary) && + summary != null) + { + summaryString = $"
Summary: {SanitizeSummary(summary.ToString())}"; } + + return $"{transitionDefinition.Workflow} {summaryString}"; } + + return ""; } - private async Task WriteWizards(TextWriter writer) + private async Task WritePlugins(StreamWriter writer, string key) { - await writer.WriteLineAsync("## Wizards:"); + await writer.WriteLineAsync("### Plugins"); - foreach (var (key, value) in _wizards.Where(x => x.Value.Wizards.Count > 0)) + var plugins = _pluginDocumentations.Where(x => x.Entity.Name == _schemaNameManager.ToSchemaName(key)) + .ToList(); + if (!plugins.Any()) await writer.WriteLineAsync("_No plugins_"); + foreach (var pluginDocumentation in plugins) { - await writer.WriteLineAsync($"### {key}"); + await writer.WriteLineAsync($"#### {pluginDocumentation.Name}"); + + await writer.WriteLineAsync(SanitizeSummary(pluginDocumentation.Summary)); + + await writer.WriteLineAsync(); - foreach (var (wizardKey, wizardDefinition) in value.Wizards) + await writer.WriteLineAsync( + $"Entity:\t[{pluginDocumentation.Entity?.Name}](#{pluginDocumentation.Entity?.Name})"); + await writer.WriteLineAsync( + $"Context:\t[{pluginDocumentation.Entity?.Name}](#{pluginDocumentation.Entity?.Name})"); + + await writer.WriteLineAsync(); + await writer.WriteLineAsync("| Operation | Execution | Mode | Order |"); + await writer.WriteLineAsync("|---|---|---|:-:|"); + foreach (var reg in pluginDocumentation.PluginRegistrations.OrderBy(x => x.Order)) { - await writer.WriteLineAsync($"#### {wizardKey}"); + await writer.WriteLineAsync($"|{reg.Operation}|{reg.Execution}|{reg.Mode}|{reg.Order}|"); } } } + private async Task WriteAttributes(StreamWriter writer, EntityDefinition value, List ignored) + { + await writer.WriteLineAsync("### Attributes"); + + await writer.WriteLineAsync("| Name | Type | Details |"); + await writer.WriteLineAsync("|------|------|---------|"); + + foreach (var (s, attributeBase) in value.Attributes.Where(x => !ignored.Contains(x.Key))) + { + if (attributeBase is AttributeObjectDefinition attributeDefinition) + { + await writer.WriteLineAsync( + $"| {_schemaNameManager.ToSchemaName(s)} | {attributeDefinition.AttributeType.Type} | {BuildAttributeDescription(attributeDefinition, s)} |"); + } + } + } private string SanitizeSummary(string summary) { @@ -151,5 +271,64 @@ private string TransformTag(string tag, Dictionary properties) return $"[{value ?? key}](#{key})"; } + + private string EntitiesToClassDiagram(ManifestDefinition manifest, string component) + { + var diagramBuilder = new StringBuilder(); + + diagramBuilder.AppendLine("```mermaid"); + diagramBuilder.AppendLine("classDiagram"); + diagramBuilder.AppendLine($"\tnote \"Class diagram for {component}\""); + + var t = new DefaultSchemaNameManager(); + + var entities = manifest.Entities.Where(entity => + entity.Value.AdditionalFields.ContainsKey("moduleSource") && + entity.Value.AdditionalFields["moduleSource"].ToString() == component); + + var ignored = new List + { "Modified On", "Modified By", "Created By", "Created On", "Row Version", "Owner" }; + + foreach (var (key, value) in entities) + { + var attributes = value.Attributes.Where(x => !ignored.Contains(x.Key)).ToList(); + + diagramBuilder.AppendLine($"\tclass {t.ToSchemaName(key)}[\"{key}\"]{{"); + foreach (var (s, attributeDefinitionBase) in attributes) + { + if (attributeDefinitionBase is AttributeObjectDefinition o) + { + // Argmunt + if (o.AttributeType.Type == "lookup") + { + diagramBuilder.AppendLine($"\t\t+{t.ToSchemaName(o.AttributeType.ReferenceType)} {s}"); + } + else + { + diagramBuilder.AppendLine($"\t\t+{o.AttributeType.Type} {s}"); + } + } + } + + diagramBuilder.AppendLine("\t}"); + + var relations = new HashSet(); + foreach (var (_, attributeDefinitionBase) in attributes) + { + if (attributeDefinitionBase is AttributeObjectDefinition o && o.AttributeType.Type == "lookup") + { + relations.Add($"\t{o.AttributeType.ReferenceType} <-- {key}"); + } + } + + foreach (var relation in relations) + { + diagramBuilder.AppendLine(relation); + } + } + + diagramBuilder.AppendLine("```"); + return diagramBuilder.ToString(); + } } } diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/README.md b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/README.md new file mode 100644 index 0000000..91c1f45 --- /dev/null +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/README.md @@ -0,0 +1,25 @@ +# EAVFW Documentation Generator + +The process of generating documentation for EAVFW is a two step process. + +1. Extract information from metadata and code +2. Generate documentation from sources. + +The process is divided in two steps and seperated by JSON files. The makes it possible to enrich the source files and to create a custom generator without extracting information twice. + +## Extract information + +`eavfw docs extract -h` + +The metadata extract for both plugins and wizards are saved as JSON files. + +Plugins is a single file and `PluginDocumentation` can be used to deserialize the document. +Wizards are saved in a directory `wizards` where each JSON file is a `EntityDefinition` enrich with extracted documentation from Workflow. + +OnTransitionIn, OnTransitionOut and Actions with workflows are enriched with `x-workflowSummary` with the doc-string for the given class. + +## Generate information + +The interface `IDocumentationGenerator` depicts how the source can be loaded and at the end written. `EAVFW.Extensions.Docs.Generator` implement a simple markdown generator, that writes all the content to a single markdown file. + +This is the default invoked in `eavfw docs generate`. From 6149963720afc8d13204c01cb9d296ffb6c1c142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thyge=20Sk=C3=B8dt=20Steffensen?= <31892312+thygesteffensen@users.noreply.github.com> Date: Fri, 24 Nov 2023 15:44:09 +0100 Subject: [PATCH 14/42] fix: Operating on generated manifest --- src/EAVFW.Extensions.Docs.Extractor/DocumentLogic.cs | 2 +- .../Documentation/DocumentationSourceExtractorCommand.cs | 8 ++------ .../Properties/launchSettings.json | 6 +++--- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/EAVFW.Extensions.Docs.Extractor/DocumentLogic.cs b/src/EAVFW.Extensions.Docs.Extractor/DocumentLogic.cs index 3ac7e5e..b189836 100644 --- a/src/EAVFW.Extensions.Docs.Extractor/DocumentLogic.cs +++ b/src/EAVFW.Extensions.Docs.Extractor/DocumentLogic.cs @@ -105,7 +105,7 @@ from wizard in entity.Value.Wizards from _tabs in wizard.Value.Tabs select _tabs).AsEnumerable(); - // Glorified for loop?w + // Glorified for loop? var tabsWithWorkflows = from tab in tabs where tab.Value.OnTransitionOut?.Workflow != null || tab.Value.OnTransitionIn?.Workflow != null diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/DocumentationSourceExtractorCommand.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/DocumentationSourceExtractorCommand.cs index 5d01223..3f7d10b 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/DocumentationSourceExtractorCommand.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/DocumentationSourceExtractorCommand.cs @@ -26,8 +26,8 @@ public class DocumentationSourceExtractorCommand : Command [Description("Path for the assembly")] public FileInfo AssemblyPathOption { get; set; } - [Alias("-m")] - [Alias("--manifest")] + [Alias("-gm")] + [Alias("--generated-manifest")] [Description("Path for the enriched manifest")] public FileInfo ManifestPathOption { get; set; } @@ -40,10 +40,6 @@ public class DocumentationSourceExtractorCommand : Command [Alias("--configuration")] [Description("Configuration for the built assembly")] public string ConfigurationOption { get; set; } - - [Alias("--component")] - [Description("Component to generate documentation. E.g., `manifest.component.json`")] - public string ComponentOption { get; set; } [Alias("-f")] [Alias("--framework")] diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json index 48460f1..0cede8f 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json @@ -4,9 +4,9 @@ "commandName": "Project", "workingDirectory": "/Users/thyge/dev/playground", // "workingDirectory": "/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models", -// "commandLineArgs": "docs extract -c Release -t wizards -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\" -m \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/manifest.loi.json\"" -// "commandLineArgs": "docs extract -c Release -t plugins -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\" -m \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/manifest.loi.json\"" - "commandLineArgs": "docs generate -c manifest.loi.json -p /Users/thyge/dev/playground/plugins.json -w /Users/thyge/dev/playground/wizards -o \"/Users/thyge/Documents/Obsidian Vault/Delegate Lava-Stone/Delegate/documentation.md\" -gm /Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/obj/manifest.g.json" + "commandLineArgs": "docs extract -c Release -t wizards -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\" -gm /Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/obj/manifest.g.json" +// "commandLineArgs": "docs extract -c Release -t plugins -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\" -gm /Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/obj/manifest.g.json" +// "commandLineArgs": "docs generate -c manifest.loi.json -p /Users/thyge/dev/playground/plugins.json -w /Users/thyge/dev/playground/wizards -o \"/Users/thyge/Documents/Obsidian Vault/Delegate Lava-Stone/Delegate/documentation.md\" -gm /Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/obj/manifest.g.json" // "commandLineArgs": "binary --unzip 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" // "commandLineArgs": "binary --unzip 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" // "commandLineArgs": "binary --unzip --pretty-print 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" From eb346ad01c154d4ff6617c219d805fbf9e0912bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thyge=20Sk=C3=B8dt=20Steffensen?= <31892312+thygesteffensen@users.noreply.github.com> Date: Fri, 24 Nov 2023 17:25:21 +0100 Subject: [PATCH 15/42] fix: References and NuGet packages --- .../EAVFW.Extensions.Docs.Extractor.csproj | 15 ++++++++------- .../EAVFW.Extensions.Docs.Generator.csproj | 14 +++++++++----- ...xtensions.Manifest.ManifestEnricherTool.csproj | 5 +++-- .../Properties/launchSettings.json | 4 ++-- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj b/src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj index a3fecf8..a4747ac 100644 --- a/src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj +++ b/src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj @@ -15,13 +15,14 @@
- - - ..\EAVFW.Extensions.Manifest.ManifestEnricherTool\bin\Debug\net8.0\EAVFW.Extensions.Manifest.SDK.dll - - - ..\..\..\..\hafnia\LetterofIndemnity\Hafnia.Tests\bin\Release\net6.0\WorkflowEngine.Core.dll - + + + + + + + + diff --git a/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj b/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj index 07bae44..3c06e14 100644 --- a/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj +++ b/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj @@ -6,13 +6,17 @@ - + - - - ..\EAVFW.Extensions.Manifest.ManifestEnricherTool\bin\Debug\net8.0\EAVFW.Extensions.Manifest.SDK.dll - + + + + + + + + diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj index bd60682..5603ed0 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj @@ -48,12 +48,13 @@ - + - + + diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json index 0cede8f..f04303c 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json @@ -4,8 +4,8 @@ "commandName": "Project", "workingDirectory": "/Users/thyge/dev/playground", // "workingDirectory": "/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models", - "commandLineArgs": "docs extract -c Release -t wizards -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\" -gm /Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/obj/manifest.g.json" -// "commandLineArgs": "docs extract -c Release -t plugins -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\" -gm /Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/obj/manifest.g.json" +// "commandLineArgs": "docs extract -c Release -t wizards -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\" -gm /Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/obj/manifest.g.json" + "commandLineArgs": "docs extract -c Release -t plugins -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\" -gm /Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/obj/manifest.g.json" // "commandLineArgs": "docs generate -c manifest.loi.json -p /Users/thyge/dev/playground/plugins.json -w /Users/thyge/dev/playground/wizards -o \"/Users/thyge/Documents/Obsidian Vault/Delegate Lava-Stone/Delegate/documentation.md\" -gm /Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/obj/manifest.g.json" // "commandLineArgs": "binary --unzip 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" // "commandLineArgs": "binary --unzip 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" From a109a5f4c2698c0c37a255c77e8c3da619a13707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thyge=20Sk=C3=B8dt=20Steffensen?= <31892312+thygesteffensen@users.noreply.github.com> Date: Fri, 24 Nov 2023 17:25:54 +0100 Subject: [PATCH 16/42] Use nuget --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index bc28d4d..2d08e79 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ 9.0 4.0.2 - false + true $(MSBuildThisFileDirectory)/external/EAVFramework $(MSBuildThisFileDirectory)/external $(MSBuildThisFileDirectory) From 525b9d4dc2a1b97d8cad7eb7e8484f507269e752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thyge=20Sk=C3=B8dt=20Steffensen?= <31892312+thygesteffensen@users.noreply.github.com> Date: Sun, 26 Nov 2023 15:16:35 +0100 Subject: [PATCH 17/42] fix: Target net6.0 and net8.0 --- .../EAVFW.Extensions.Docs.Extractor.csproj | 2 +- .../EAVFW.Extensions.Docs.Generator.csproj | 2 +- .../EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj b/src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj index a4747ac..84f8803 100644 --- a/src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj +++ b/src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj @@ -2,7 +2,7 @@ 9.0 - net8.0 + net6.0;net8.0 enable EAVFW.Extensions.Docs.Extracter diff --git a/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj b/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj index 3c06e14..7e62241 100644 --- a/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj +++ b/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj @@ -1,7 +1,7 @@ - net8.0 + net6.0;net8.0 enable diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj index 5603ed0..c50eb0f 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj @@ -1,7 +1,7 @@  Exe - net8.0 + net6.0;net8.0 true eavfw-manifest ./../../artifacts From f77d677619bfbdf383875fbd89e42b37b8ca5f31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thyge=20Sk=C3=B8dt=20Steffensen?= <31892312+thygesteffensen@users.noreply.github.com> Date: Wed, 29 Nov 2023 10:26:39 +0100 Subject: [PATCH 18/42] feat: Utilize path globbing to find assemblies Instead of using framework and configuration path globbing is used. Here the old use case for probing bin folders is still possible, but it is also possible to use a single folder with all assemblies, such as publish generates --- .../DocumentLogic.cs | 45 +++++++------------ .../Plugin/PluginInfo.cs | 32 ++++++++----- .../DocumentationSourceExtractorCommand.cs | 35 +++------------ .../Properties/launchSettings.json | 3 +- 4 files changed, 44 insertions(+), 71 deletions(-) diff --git a/src/EAVFW.Extensions.Docs.Extractor/DocumentLogic.cs b/src/EAVFW.Extensions.Docs.Extractor/DocumentLogic.cs index b189836..289e801 100644 --- a/src/EAVFW.Extensions.Docs.Extractor/DocumentLogic.cs +++ b/src/EAVFW.Extensions.Docs.Extractor/DocumentLogic.cs @@ -7,35 +7,13 @@ using System.Text.Json; using EAVFramework.Plugins; using EAVFW.Extensions.Manifest.SDK; +using Microsoft.Extensions.FileSystemGlobbing; using WorkflowEngine.Core; namespace EAVFW.Extensions.Docs.Extractor { public class DocumentLogic : IDocumentLogic { - private static Dictionary BuildAssemblyDictionary(IEnumerable binDirectories) - { - var dictionary = new Dictionary(); - - foreach (var directory in binDirectories) - { - var dlls = Directory.GetFiles(directory, "*.dll"); - foreach (var dll in dlls) - { - var assemblyName = AssemblyName.GetAssemblyName(dll); - - dictionary.TryAdd(assemblyName.Name!, new AssemblyInfo - { - Name = assemblyName.Name!, - Version = assemblyName.Version!.ToString(), - Path = dll - }); - } - } - - return dictionary; - } - /// public IEnumerable ExtractPluginDocumentation(PluginInfo pluginInfo) { @@ -64,14 +42,23 @@ from implementingType in implementingTypes private static Assembly LoadAssembly(PluginInfo pluginInfo) { - var subDirectories = pluginInfo.RootPath.EnumerateDirectories("*", SearchOption.AllDirectories); + var matcher = new Matcher(); + matcher.AddInclude(pluginInfo.Search); - var directoriesWithBin = - from d in subDirectories - where d.FullName.EndsWith($"bin/{pluginInfo.Configuration}/{pluginInfo.Framework}") - select d.FullName; + var dictionary = new Dictionary(); + foreach (var file in matcher.GetResultsInFullPath(pluginInfo.RootPath.FullName)) + { + var assemblyName = AssemblyName.GetAssemblyName(file); + + dictionary.TryAdd(assemblyName.Name!, new AssemblyInfo + { + Name = assemblyName.Name!, + Version = assemblyName.Version!.ToString(), + Path = file + }); + } - CustomAssemblyResolver.Dictionary = BuildAssemblyDictionary(directoriesWithBin.AsQueryable()); + CustomAssemblyResolver.Dictionary = dictionary; var currentDomain = AppDomain.CurrentDomain; currentDomain.AssemblyResolve += CustomAssemblyResolver.CustomAssemblyResolverEventHandler; diff --git a/src/EAVFW.Extensions.Docs.Extractor/Plugin/PluginInfo.cs b/src/EAVFW.Extensions.Docs.Extractor/Plugin/PluginInfo.cs index 344c615..a4d694e 100644 --- a/src/EAVFW.Extensions.Docs.Extractor/Plugin/PluginInfo.cs +++ b/src/EAVFW.Extensions.Docs.Extractor/Plugin/PluginInfo.cs @@ -1,28 +1,38 @@ using System; using System.IO; +using System.Linq; namespace EAVFW.Extensions.Docs.Extractor { public struct PluginInfo { - public PluginInfo(DirectoryInfo rootPath, FileInfo assemblyPath, string configuration, string framework) + public PluginInfo(DirectoryInfo rootPath, FileInfo assemblyPath) { - RootPath = !rootPath.Exists - ? throw new ArgumentException($"Directory {nameof(rootPath)} does not exists") - : rootPath; + var basePath = rootPath.Parent; + var search = rootPath.Name; + + if (rootPath.FullName.Contains("**")) + { + basePath = new DirectoryInfo(rootPath.FullName.Split("**").First()); + search = rootPath.FullName[basePath.FullName.Length..]; + } + else if (!rootPath.FullName.Contains('*')) + { + throw new ArgumentException("Probing path mu"); + } + + Search = search; + RootPath = !(basePath?.Exists ?? false) + ? throw new ArgumentException($"Directory {basePath.FullName} does not exists") + : basePath; + AssemblyPath = !assemblyPath.Exists ? throw new ArgumentException($"File {nameof(assemblyPath)} does not exists") : assemblyPath; - - Configuration = string.IsNullOrWhiteSpace(configuration) - ? throw new ArgumentNullException(configuration) - : configuration; - Framework = string.IsNullOrWhiteSpace(framework) ? throw new ArgumentNullException(framework) : framework; } public DirectoryInfo RootPath { get; } + public string Search { get; } public FileInfo AssemblyPath { get; } - public string Configuration { get; } - public string Framework { get; } } } diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/DocumentationSourceExtractorCommand.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/DocumentationSourceExtractorCommand.cs index 3f7d10b..3769c3a 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/DocumentationSourceExtractorCommand.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/DocumentationSourceExtractorCommand.cs @@ -32,20 +32,10 @@ public class DocumentationSourceExtractorCommand : Command public FileInfo ManifestPathOption { get; set; } [Alias("-p")] - [Alias("--probing-path")] - [Description("Path to probe for dependent assemblies")] + [Alias("--probing-pattern")] + [Description("Path pattern used to probe for assemblies, supporting glob patterns")] public DirectoryInfo ProbePathOption { get; set; } - [Alias("-c")] - [Alias("--configuration")] - [Description("Configuration for the built assembly")] - public string ConfigurationOption { get; set; } - - [Alias("-f")] - [Alias("--framework")] - [Description("Framework confugraiton for the built assembly")] - public string FrameworkOption { get; set; } - [Alias("-o")] [Alias("--output")] [Description("Output directory for genreated documentation source files")] @@ -53,7 +43,7 @@ public class DocumentationSourceExtractorCommand : Command [Alias("-t")] [Alias("--target")] - [Description("Target?")] + [Description("What kind of documentation source should be extracted")] public Targets Target { get; set; } public enum Targets @@ -76,12 +66,6 @@ private async Task Run(ParseResult parseResult, IConsole console) return 126; } - if (!ProbePathOption.Exists) - { - Console.WriteLine("Probing path does not exists"); - return 1; - } - if (!AssemblyPathOption.Exists) { Console.WriteLine("Assembly does not exists"); @@ -110,9 +94,7 @@ private async Task GenerateWizardSource() var entityDefinitions = _documentLogic.ExtractWizardDocumentation( ManifestPathOption, new PluginInfo(ProbePathOption, - AssemblyPathOption, - ConfigurationOption, - FrameworkOption)); + AssemblyPathOption)); var basePath = new DirectoryInfo(CalculateFullPath("wizards")); @@ -137,8 +119,7 @@ private async Task GenerateWizardSource() private async Task GeneratePluginSource() { var plugins = _documentLogic - .ExtractPluginDocumentation(new PluginInfo(ProbePathOption, AssemblyPathOption, ConfigurationOption, - FrameworkOption)) + .ExtractPluginDocumentation(new PluginInfo(ProbePathOption, AssemblyPathOption)) .ToArray(); var jsonString = JsonSerializer.Serialize(plugins, new JsonSerializerOptions @@ -172,12 +153,6 @@ private bool IsMissingOptions(out List missing) if (ProbePathOption == null) missing.Add(nameof(ProbePathOption)); - if (string.IsNullOrWhiteSpace(ConfigurationOption)) - missing.Add(nameof(ConfigurationOption)); - - if (string.IsNullOrWhiteSpace(FrameworkOption)) - missing.Add(nameof(FrameworkOption)); - return false; } } diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json index f04303c..99ec44f 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json @@ -5,7 +5,8 @@ "workingDirectory": "/Users/thyge/dev/playground", // "workingDirectory": "/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models", // "commandLineArgs": "docs extract -c Release -t wizards -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\" -gm /Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/obj/manifest.g.json" - "commandLineArgs": "docs extract -c Release -t plugins -f net6.0 -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity\" -gm /Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/obj/manifest.g.json" +// "commandLineArgs": "docs extract -t plugins -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity/**/bin/Release/net6.0/*.dll\" -gm /Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/obj/manifest.g.json" + "commandLineArgs": "docs extract -t plugins -a \"/Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.BusinessLogic/bin/Release/net6.0/Hafnia.BusinessLogic.dll\" -p \"/Users/thyge/dev/hafnia/LetterofIndemnity/obj/publish/*.dll\" -gm /Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/obj/manifest.g.json" // "commandLineArgs": "docs generate -c manifest.loi.json -p /Users/thyge/dev/playground/plugins.json -w /Users/thyge/dev/playground/wizards -o \"/Users/thyge/Documents/Obsidian Vault/Delegate Lava-Stone/Delegate/documentation.md\" -gm /Users/thyge/dev/hafnia/LetterofIndemnity/src/Hafnia.Models/obj/manifest.g.json" // "commandLineArgs": "binary --unzip 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" // "commandLineArgs": "binary --unzip 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" From eb98cbba640687fb2d3015a602ca27313390f795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thyge=20Sk=C3=B8dt=20Steffensen?= <31892312+thygesteffensen@users.noreply.github.com> Date: Wed, 29 Nov 2023 13:59:38 +0100 Subject: [PATCH 19/42] feat: ProbePattern or list of assemblies replace configuration and dotnet version to find assemblies --- .../DocumentLogic.cs | 18 ++- .../IDocumentLogic.cs | 4 +- .../DocumentationSourceExtractorCommand.cs | 64 ++++++++-- ...sions.Manifest.ManifestEnricherTool.csproj | 116 +++++++++--------- 4 files changed, 120 insertions(+), 82 deletions(-) diff --git a/src/EAVFW.Extensions.Docs.Extractor/DocumentLogic.cs b/src/EAVFW.Extensions.Docs.Extractor/DocumentLogic.cs index 289e801..452e6b8 100644 --- a/src/EAVFW.Extensions.Docs.Extractor/DocumentLogic.cs +++ b/src/EAVFW.Extensions.Docs.Extractor/DocumentLogic.cs @@ -7,7 +7,6 @@ using System.Text.Json; using EAVFramework.Plugins; using EAVFW.Extensions.Manifest.SDK; -using Microsoft.Extensions.FileSystemGlobbing; using WorkflowEngine.Core; namespace EAVFW.Extensions.Docs.Extractor @@ -15,9 +14,9 @@ namespace EAVFW.Extensions.Docs.Extractor public class DocumentLogic : IDocumentLogic { /// - public IEnumerable ExtractPluginDocumentation(PluginInfo pluginInfo) + public IEnumerable ExtractPluginDocumentation(FileInfo assemblyInfo, string[] assemblies) { - var assembly = LoadAssembly(pluginInfo); + var assembly = LoadAssembly(assemblyInfo, assemblies); var implementingTypes = assembly.GetTypes() .Where(t => typeof(IPlugin).IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract); @@ -40,13 +39,10 @@ from implementingType in implementingTypes return plugins; } - private static Assembly LoadAssembly(PluginInfo pluginInfo) + private static Assembly LoadAssembly(FileInfo assemblyInfo, string [] assemblies) { - var matcher = new Matcher(); - matcher.AddInclude(pluginInfo.Search); - var dictionary = new Dictionary(); - foreach (var file in matcher.GetResultsInFullPath(pluginInfo.RootPath.FullName)) + foreach (var file in assemblies) { var assemblyName = AssemblyName.GetAssemblyName(file); @@ -63,15 +59,15 @@ private static Assembly LoadAssembly(PluginInfo pluginInfo) var currentDomain = AppDomain.CurrentDomain; currentDomain.AssemblyResolve += CustomAssemblyResolver.CustomAssemblyResolverEventHandler; - var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(pluginInfo.AssemblyPath.FullName); + var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(assemblyInfo.FullName); return assembly; } /// public Dictionary ExtractWizardDocumentation(FileInfo manifestFile, - PluginInfo pluginInfo) + FileInfo assemblyInfo, string[] assemblies) { - var assembly = LoadAssembly(pluginInfo); + var assembly = LoadAssembly(assemblyInfo, assemblies); // Preloading types to easily query for documentation var workflows = assembly.GetTypes() diff --git a/src/EAVFW.Extensions.Docs.Extractor/IDocumentLogic.cs b/src/EAVFW.Extensions.Docs.Extractor/IDocumentLogic.cs index e74952c..6263a3f 100644 --- a/src/EAVFW.Extensions.Docs.Extractor/IDocumentLogic.cs +++ b/src/EAVFW.Extensions.Docs.Extractor/IDocumentLogic.cs @@ -13,7 +13,7 @@ public interface IDocumentLogic /// Remember to enable GenerateDocumentationFile for the project. /// /// - IEnumerable ExtractPluginDocumentation(PluginInfo pluginInfo); + IEnumerable ExtractPluginDocumentation(FileInfo assemblyInfo, string[] assemblies); /// /// Extract Wizards from the given Manifest and generate documentation based on manifest metadata and workflow @@ -22,6 +22,6 @@ public interface IDocumentLogic /// /// /// - Dictionary ExtractWizardDocumentation(FileInfo manifestFile, PluginInfo pluginInfo); + Dictionary ExtractWizardDocumentation(FileInfo manifestFile, FileInfo assemblyInfo, string[] assemblies); } } diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/DocumentationSourceExtractorCommand.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/DocumentationSourceExtractorCommand.cs index 3769c3a..0d80c74 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/DocumentationSourceExtractorCommand.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Documentation/DocumentationSourceExtractorCommand.cs @@ -8,15 +8,16 @@ using System.Text.Json; using System.Threading.Tasks; using EAVFW.Extensions.Docs.Extractor; +using Microsoft.Extensions.FileSystemGlobbing; namespace EAVFW.Extensions.Manifest.ManifestEnricherTool.Commands.Documentation { /* * There are many parameters to the command and generating source for both plugin and wizard requires the tool to be * executed twice. Alternatively, the "configuration" could be done using a configuration, which would provide all - * necessary parameters. Both it would be more rigid and could not easily be changed in a pipeline or other. + * necessary parameters. Both it would be more rigid and could not easily be changed in a pipeline or other. */ - + public class DocumentationSourceExtractorCommand : Command { private readonly IDocumentLogic _documentLogic; @@ -34,7 +35,7 @@ public class DocumentationSourceExtractorCommand : Command [Alias("-p")] [Alias("--probing-pattern")] [Description("Path pattern used to probe for assemblies, supporting glob patterns")] - public DirectoryInfo ProbePathOption { get; set; } + public IEnumerable ProbePathOption { get; set; } [Alias("-o")] [Alias("--output")] @@ -46,13 +47,19 @@ public class DocumentationSourceExtractorCommand : Command [Description("What kind of documentation source should be extracted")] public Targets Target { get; set; } + [Alias("-d")] + [Alias("--debug")] + [Description("Enable debug output")] + public bool Debug { get; set; } = false; + public enum Targets { Plugins, Wizards } - public DocumentationSourceExtractorCommand(IDocumentLogic documentLogic) : base("extract", "Extract documentation source") + public DocumentationSourceExtractorCommand(IDocumentLogic documentLogic) : base("extract", + "Extract documentation source") { _documentLogic = documentLogic ?? throw new ArgumentNullException(nameof(documentLogic)); Handler = COmmandExtensions.Create(this, Array.Empty(), Run); @@ -72,6 +79,37 @@ private async Task Run(ParseResult parseResult, IConsole console) return 1; } + if (ProbePathOption.Count() == 1 && ProbePathOption.First().Contains('*')) + { + DebugMsg("No assemblies in list, probing..."); + + var probePath = new DirectoryInfo(ProbePathOption.First()); + + var matcher = new Matcher(); + var basePath = probePath.Parent; + + if (probePath.FullName.Contains("**")) + { + basePath = new DirectoryInfo(probePath.FullName.Split("**").First()); + matcher.AddInclude(probePath.FullName[basePath.FullName.Length..]); + } + else if (probePath.Name.Contains(".")) + { + matcher.AddInclude(probePath.Name); + } + + ProbePathOption = matcher.GetResultsInFullPath(basePath.FullName).ToList(); + + } + + DebugMsg($"Found {ProbePathOption.Count()} assemblies"); + + if (!ProbePathOption.Any()) + { + Console.WriteLine("Did not find any assemblies"); + return 1; + } + switch (Target) { case Targets.Plugins: @@ -92,15 +130,13 @@ private async Task GenerateWizardSource() } var entityDefinitions = _documentLogic.ExtractWizardDocumentation( - ManifestPathOption, - new PluginInfo(ProbePathOption, - AssemblyPathOption)); + ManifestPathOption, AssemblyPathOption, ProbePathOption.ToArray()); var basePath = new DirectoryInfo(CalculateFullPath("wizards")); - if(!basePath.Exists) + if (!basePath.Exists) basePath.Create(); - + foreach (var (key, value) in entityDefinitions) { var fileName = Path.Combine(basePath.FullName, $"{key}.json"); @@ -119,9 +155,9 @@ private async Task GenerateWizardSource() private async Task GeneratePluginSource() { var plugins = _documentLogic - .ExtractPluginDocumentation(new PluginInfo(ProbePathOption, AssemblyPathOption)) + .ExtractPluginDocumentation(AssemblyPathOption, ProbePathOption.ToArray()) .ToArray(); - + var jsonString = JsonSerializer.Serialize(plugins, new JsonSerializerOptions { WriteIndented = true @@ -155,5 +191,11 @@ private bool IsMissingOptions(out List missing) return false; } + + private void DebugMsg(string msg) + { + if (Debug) + Console.WriteLine(msg); + } } } diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj index c50eb0f..dfa4622 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj @@ -1,62 +1,62 @@  - - Exe - net6.0;net8.0 - true - eavfw-manifest - ./../../artifacts - ManifestEnricherTool - Poul Kjeldager - A tool to enrich and transform manifest.json to manifest.g.json - README.md - https://github.com/EAVFW/EAVFW.Extensions.Manifest.ManifestEnricherTool - - - - - - - - - - - - - - - - - - - - - 3.1.31 - - - - - 6.0.11 - - - - - 7.0.13 - - + + Exe + net6.0;net8.0 + true + eavfw-manifest + ./../../artifacts + ManifestEnricherTool + Poul Kjeldager + A tool to enrich and transform manifest.json to manifest.g.json + README.md + https://github.com/EAVFW/EAVFW.Extensions.Manifest.ManifestEnricherTool - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + 3.1.31 + + + + + 6.0.11 + + + + + 7.0.13 + + + + + + + + + + + + + + + + + + From 1035e1a4e3017dd76cf2564483854584068eb176 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thyge=20Sk=C3=B8dt=20Steffensen?= <31892312+thygesteffensen@users.noreply.github.com> Date: Thu, 30 Nov 2023 12:23:38 +0100 Subject: [PATCH 20/42] feat: Remove module location and source from unwanted places --- .../ManifestMerger.cs | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/ManifestMerger.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/ManifestMerger.cs index 48b56fd..c707653 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/ManifestMerger.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/ManifestMerger.cs @@ -2,6 +2,7 @@ using System.IO; using System.Linq; using System.Threading.Tasks; +using Microsoft.Extensions.FileSystemGlobbing; using Newtonsoft.Json.Linq; namespace EAVFW.Extensions.Manifest.ManifestEnricherTool @@ -15,7 +16,7 @@ public ManifestMerger(IModuleMetadataEnricher moduleMetadataEnricher) _moduleMetadataEnricher = moduleMetadataEnricher ?? throw new ArgumentNullException(nameof(moduleMetadataEnricher)); } - + /// public async Task MergeManifests(FileInfo path) { @@ -41,12 +42,44 @@ public async Task MergeManifests(FileInfo path) { // union array values together to avoid duplicates MergeArrayHandling = MergeArrayHandling.Union, - PropertyNameComparison = System.StringComparison.OrdinalIgnoreCase, + PropertyNameComparison = StringComparison.OrdinalIgnoreCase, MergeNullValueHandling = MergeNullValueHandling.Ignore }); } + var matcher = new Matcher(); + matcher.AddInclude("**/entities/*"); + matcher.AddInclude("**/attributes/*"); + matcher.AddInclude("**/wizards/*"); + + CleanModuleLocationSource(jtokenRaw, matcher, "root"); + return jsonRaw; } + + private static void CleanModuleLocationSource(JToken jToken, Matcher matcher, string path) + { + switch (jToken) + { + case JObject jObject: + { + if (!matcher.Match(path).HasMatches) + { + jObject.Remove("moduleSource"); + jObject.Remove("moduleLocation"); + } + + foreach (var (key, value) in jObject) + CleanModuleLocationSource(value, matcher, $"{path}/{key}"); + break; + } + case JArray jArray: + { + foreach (var child in jArray.Children()) + CleanModuleLocationSource(child, matcher, path); + break; + } + } + } } } From 33ab1d8f2c2b161ea35a9a6319626f6c114b394a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thyge=20Sk=C3=B8dt=20Steffensen?= <31892312+thygesteffensen@users.noreply.github.com> Date: Thu, 30 Nov 2023 12:34:17 +0100 Subject: [PATCH 21/42] fix: donet version to 8.0.100 --- global.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/global.json b/global.json index 3ecc5db..9da8d87 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,6 @@ { "sdk": { - "version": "8.0.100-rc.2.23502.2" + "version": "8.0.100" } } + From c5fe8586007ac21968de743bd5ba2cb78d542df0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thyge=20Sk=C3=B8dt=20Steffensen?= <31892312+thygesteffensen@users.noreply.github.com> Date: Thu, 30 Nov 2023 15:26:55 +0100 Subject: [PATCH 22/42] fix: Change mermaid to ADO support --- .../ReadMeDocumentationGenerator.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs b/src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs index bae36e2..2e9ae87 100644 --- a/src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs +++ b/src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs @@ -276,7 +276,7 @@ private string EntitiesToClassDiagram(ManifestDefinition manifest, string compon { var diagramBuilder = new StringBuilder(); - diagramBuilder.AppendLine("```mermaid"); + diagramBuilder.AppendLine("::: mermaid"); diagramBuilder.AppendLine("classDiagram"); diagramBuilder.AppendLine($"\tnote \"Class diagram for {component}\""); @@ -293,7 +293,7 @@ private string EntitiesToClassDiagram(ManifestDefinition manifest, string compon { var attributes = value.Attributes.Where(x => !ignored.Contains(x.Key)).ToList(); - diagramBuilder.AppendLine($"\tclass {t.ToSchemaName(key)}[\"{key}\"]{{"); + diagramBuilder.AppendLine($"\tclass {t.ToSchemaName(key)}{{"); foreach (var (s, attributeDefinitionBase) in attributes) { if (attributeDefinitionBase is AttributeObjectDefinition o) @@ -327,7 +327,7 @@ private string EntitiesToClassDiagram(ManifestDefinition manifest, string compon } } - diagramBuilder.AppendLine("```"); + diagramBuilder.AppendLine(":::"); return diagramBuilder.ToString(); } } From 8b761d7e828a8102b1ddb5d924b643b64af5eacf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thyge=20Sk=C3=B8dt=20Steffensen?= <31892312+thygesteffensen@users.noreply.github.com> Date: Thu, 30 Nov 2023 15:34:31 +0100 Subject: [PATCH 23/42] fix: Ado hyperlinks support --- .../ReadMeDocumentationGenerator.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs b/src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs index 2e9ae87..2993fc1 100644 --- a/src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs +++ b/src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs @@ -102,13 +102,13 @@ public async Task Write(FileInfo outputLocation, string component) await writer.WriteLineAsync("## Table of contents"); var index = 2; - await writer.WriteLineAsync("1. [Class diagram](#class-diagram)"); + await writer.WriteLineAsync("1. [Class diagram](#Class-diagram)"); foreach (var (key, value) in entitiesToWrite) { - await writer.WriteLineAsync($"{index++}. [{key}](#{_schemaNameManager.ToSchemaName(key)})"); + await writer.WriteLineAsync($"{index++}. [{key}](#{key.Replace(' ', '-')})"); } - await writer.WriteLineAsync("# Class diagram "); + await writer.WriteLineAsync("# Class diagram"); await writer.WriteAsync(EntitiesToClassDiagram(_manifestObject, component)); var ignored = new List @@ -116,7 +116,7 @@ public async Task Write(FileInfo outputLocation, string component) foreach (var (key, value) in entitiesToWrite) { - await writer.WriteLineAsync($"## {key} "); + await writer.WriteLineAsync($"## {key}"); await writer.WriteLineAsync(value.Description); From a8418ecdc151e8977b6fc56cc94d26fc63a0806f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thyge=20Sk=C3=B8dt=20Steffensen?= <31892312+thygesteffensen@users.noreply.github.com> Date: Thu, 30 Nov 2023 15:46:04 +0100 Subject: [PATCH 24/42] fix: Add component support for class diagram --- .../ReadMeDocumentationGenerator.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs b/src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs index 2993fc1..7f55d74 100644 --- a/src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs +++ b/src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs @@ -282,9 +282,14 @@ private string EntitiesToClassDiagram(ManifestDefinition manifest, string compon var t = new DefaultSchemaNameManager(); - var entities = manifest.Entities.Where(entity => - entity.Value.AdditionalFields.ContainsKey("moduleSource") && - entity.Value.AdditionalFields["moduleSource"].ToString() == component); + var entities = manifest.Entities; + if (!string.IsNullOrWhiteSpace(component)) + { + entities = manifest.Entities.Where(entity => + entity.Value.AdditionalFields.ContainsKey("moduleSource") && + entity.Value.AdditionalFields["moduleSource"].ToString() == component) + .ToDictionary(x => x.Key, x => x.Value); + } var ignored = new List { "Modified On", "Modified By", "Created By", "Created On", "Row Version", "Owner" }; From fdb06568c15fdf8b037cb0169c5657954a0e6063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thyge=20Sk=C3=B8dt=20Steffensen?= <31892312+thygesteffensen@users.noreply.github.com> Date: Thu, 30 Nov 2023 16:24:32 +0100 Subject: [PATCH 25/42] fix: Remove note --- .../ReadMeDocumentationGenerator.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs b/src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs index 7f55d74..b2f8486 100644 --- a/src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs +++ b/src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs @@ -278,7 +278,6 @@ private string EntitiesToClassDiagram(ManifestDefinition manifest, string compon diagramBuilder.AppendLine("::: mermaid"); diagramBuilder.AppendLine("classDiagram"); - diagramBuilder.AppendLine($"\tnote \"Class diagram for {component}\""); var t = new DefaultSchemaNameManager(); From b42c28b5b271eca7f945305d042377c999e76125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thyge=20Sk=C3=B8dt=20Steffensen?= <31892312+thygesteffensen@users.noreply.github.com> Date: Thu, 30 Nov 2023 16:33:52 +0100 Subject: [PATCH 26/42] dotnet tool update --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 281b87c..baa1cb6 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -9,4 +9,4 @@ ] } } -} \ No newline at end of file +} From 5bec76d0a8c3e1443eb37b49d7d006ce215ea45b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Fri, 2 Feb 2024 22:20:26 +0100 Subject: [PATCH 27/42] fix: made cert command take --subject parameter --- Directory.Build.props | 10 ++++++ ...tensions.Manifest.ManifestEnricherTool.sln | 18 +++++++++++ global.json | 2 +- .../Commands/CertCommand.cs | 7 +++-- ...sions.Manifest.ManifestEnricherTool.csproj | 6 ++-- .../Properties/launchSettings.json | 31 +++++++++++++++++++ 6 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 Directory.Build.props create mode 100644 src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..171edd0 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,10 @@ + + + 9.0 + 4.2.1 + false + $(MSBuildThisFileDirectory)/external/EAVFramework + $(MSBuildThisFileDirectory)/external + $(MSBuildThisFileDirectory) + + \ No newline at end of file diff --git a/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln b/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln index 572e4a5..02b101b 100644 --- a/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln +++ b/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln @@ -6,6 +6,8 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5250CA28-EB3D-4DF8-8B5B-68D520CADDEE}" ProjectSection(SolutionItems) = preProject .gitignore = .gitignore + Directory.Build.props = Directory.Build.props + global.json = global.json README.md = README.md EndProjectSection EndProject @@ -55,6 +57,22 @@ Global {C472564C-38FE-4465-BC62-FDCF45339C36}.Debug|Any CPU.Build.0 = Debug|Any CPU {C472564C-38FE-4465-BC62-FDCF45339C36}.Release|Any CPU.ActiveCfg = Release|Any CPU {C472564C-38FE-4465-BC62-FDCF45339C36}.Release|Any CPU.Build.0 = Release|Any CPU + {856357CE-BB26-4E6C-BAA2-B74FF8DC5734}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {856357CE-BB26-4E6C-BAA2-B74FF8DC5734}.Debug|Any CPU.Build.0 = Debug|Any CPU + {856357CE-BB26-4E6C-BAA2-B74FF8DC5734}.Release|Any CPU.ActiveCfg = Release|Any CPU + {856357CE-BB26-4E6C-BAA2-B74FF8DC5734}.Release|Any CPU.Build.0 = Release|Any CPU + {79505337-2855-4CC7-8FD3-D5AF31B18278}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {79505337-2855-4CC7-8FD3-D5AF31B18278}.Debug|Any CPU.Build.0 = Debug|Any CPU + {79505337-2855-4CC7-8FD3-D5AF31B18278}.Release|Any CPU.ActiveCfg = Release|Any CPU + {79505337-2855-4CC7-8FD3-D5AF31B18278}.Release|Any CPU.Build.0 = Release|Any CPU + {2F30C24A-421A-4309-9F07-99668EA70C25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2F30C24A-421A-4309-9F07-99668EA70C25}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F30C24A-421A-4309-9F07-99668EA70C25}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F30C24A-421A-4309-9F07-99668EA70C25}.Release|Any CPU.Build.0 = Release|Any CPU + {3BEF0769-ABD1-4D34-8004-C98DE9FB0339}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3BEF0769-ABD1-4D34-8004-C98DE9FB0339}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3BEF0769-ABD1-4D34-8004-C98DE9FB0339}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3BEF0769-ABD1-4D34-8004-C98DE9FB0339}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/global.json b/global.json index 6c7fbc9..f3365c4 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "6.0.308" + "version": "8.0.100" } } \ No newline at end of file diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/CertCommand.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/CertCommand.cs index 50f04ac..e754eb4 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/CertCommand.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/CertCommand.cs @@ -12,16 +12,19 @@ namespace EAVFW.Extensions.Manifest.ManifestEnricherTool.Commands { public class CertCommand : Command { + public Option Subject = new Option("Subject", ""); + public CertCommand() : base("certs", "generalte certs files") { - + Subject.AddAlias("--subject"); + Add(Subject); Handler = CommandHandler.Create(Run); } private async Task Run(ParseResult parseResult, IConsole console) { - var subject = "CN=MCOIDC"; + var subject = parseResult.GetValueForOption(Subject);// "CN=MCOIDC"; { using var algorithm = RSA.Create(keySizeInBits: 2048); diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj index 9869183..3dde808 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj @@ -60,9 +60,9 @@ - - - + + + diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json new file mode 100644 index 0000000..ad47e94 --- /dev/null +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "profiles": { + "EAVFW.Extensions.Manifest.ManifestEnricherTool": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\hafnia\\loi\\obj\\dbinit", + // "workingDirectory": "/Users/thyge/dev/playground", + // "commandLineArgs": "binary --unzip 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" + // "commandLineArgs": "binary --unzip --pretty-print 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" + // "commandLineArgs": "binary --unzip --pretty-print --output myjsonfile.json 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" + // "commandLineArgs": "binary --zip {\"actions\":{\"CreateLOIDataRequestMessageAction\":{\"input\":{\"loirequest\":\"a4dd227a-efab-4cb5-3e2a-08dbcaf45591\",\"recipients\":[\"1504bf2f-cf6e-49c9-df39-08dbcaf6aa88\"]},\"status\":\"Succeded\",\"body\":\"a4dd227a-efab-4cb5-3e2a-08dbcaf45591\",\"failedReason\":null}},\"triggers\":{\"Trigger\":{\"time\":\"2023-10-12T07:41:42.311509+00:00\",\"body\":{\"entityName\":\"LetterofindemnityRequests\",\"recordId\":\"a4dd227a-efab-4cb5-3e2a-08dbcaf45591\",\"data\":{\"recipients\":[\"1504bf2f-cf6e-49c9-df39-08dbcaf6aa88\"]}}}}}" + //"workingDirectory": "C:\\dev\\kfst_vanddata", + //"commandLineArgs": "--path c:\\dev\\kfst_vanddata\\apps\\KFST.Vanddata.ManagementPortal\\manifest.json --customizationprefix kfst", + //"commandLineArgs": "install EAVFW.Extensions.SecurityModel", + //"commandLineArgs": "sql C:/dev/eavfwdemo/src/EAVApp.Models" + + //"commandLineArgs": "sql C:/dev/kfst_vanddata/apps/KFST.Vanddata.ManagementPortal/" + + //"commandLineArgs": "manifest fix-migration --project-path c:\\dev\\kfst_vanddata\\apps\\KFST.Vanddata.ManagementPortal -v 1.0.45 --schema KFST --prefix KFST --database VandData2" + + // "commandLineArgs": "--path C:\\dev\\MedlemsCentralen\\src\\MC.Models\\manifest.json --customizationprefix MC" + + // "commandLineArgs": "sql ./src/Hafnia.Models", + // "commandLineArgs": "gpt review pr --project https://github.com/delegateas/WorkflowEngine.git --pr 15" + // "commandLineArgs": "sql ./apps/KFST.Vanddata.ManagementPortal" + //"commandLineArgs": "--path C:\\dev\\hafnia\\loi\\src\\Hafnia.Models\\manifest.json --customizationprefix hafnia" + //"commandLineArgs": "sql apply -S sql-loi-tst.database.windows.net -d db-loi-tst -v DBSchema=dbo -v DBName=db-loi-tst -v SystemAdminSecurityGroupId=1b714972-8d0a-4feb-b166-08d93c6ae328 -v UserGuid=1F3EE206-2B94-4017-8EC1-F983E3E24BDE -v UserName=\"Poul Kjeldager\" -v UserEmail=x_pks@hafniabw.com -i init.sql -i init-systemadmin.sql" + // "commandLineArgs": "sql add-user -S sql-loi-tst.database.windows.net -d db-loi-tst --external-user-name app-loi-management-tst --external-user-objid 785062c9-a28a-4f65-9a8c-cf671d58fe7f --token eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjlHbW55RlBraGMzaE91UjIybXZTdmduTG83WSIsImtpZCI6IjlHbW55RlBraGMzaE91UjIybXZTdmduTG83WSJ9.eyJhdWQiOiJodHRwczovL2RhdGFiYXNlLndpbmRvd3MubmV0IiwiaXNzIjoiaHR0cHM6Ly9zdHMud2luZG93cy5uZXQvYTM2NGViMjgtZTk1Yi00YWQwLWE0ZmItNWI0Zjc3NjdhZDg0LyIsImlhdCI6MTY5OTUyNjI4MiwibmJmIjoxNjk5NTI2MjgyLCJleHAiOjE2OTk1MzAxODIsImFpbyI6IkUyVmdZQkJlNzNqaUc5czl2NUNpUlNreTAyWWNBZ0E9IiwiYXBwaWQiOiJlMWVmMmM5Mi1mZTFiLTQwZGItODAzYi0xM2Y0MzA3ZGIzNzQiLCJhcHBpZGFjciI6IjEiLCJpZHAiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9hMzY0ZWIyOC1lOTViLTRhZDAtYTRmYi01YjRmNzc2N2FkODQvIiwiaWR0eXAiOiJhcHAiLCJvaWQiOiIyMDNhMWUwOS1iMTUyLTQ5NjgtOTdlZS1hMzgyZTBmNDJkMmUiLCJyaCI6IjAuQVM4QUtPdGtvMXZwMEVxay0xdFBkMmV0aE5NSEtRSWJEX2RJdXR3YnBxdXJiV2F3QUFBLiIsInN1YiI6IjIwM2ExZTA5LWIxNTItNDk2OC05N2VlLWEzODJlMGY0MmQyZSIsInRpZCI6ImEzNjRlYjI4LWU5NWItNGFkMC1hNGZiLTViNGY3NzY3YWQ4NCIsInV0aSI6Ilo0cVFHMXo5b0VDRDd2eUJUVjhOQUEiLCJ2ZXIiOiIxLjAifQ.bLG9-5aDAkO3CPcNRyBTjDOPL4vvahjSB3UvDF1lRFbjEL-j9bgXDlJfI29M1MSjz_wgAiUoKcIsM6TTtnK2tMYrZYKvZeo9SDh6vrX-UqZgQVxibuVNrOKpRCkDOEl34LIn1b2Qy8UH7Nvf7TFpwImiJ8oW7KHDFYCTTbEoEQsurtl8R_KX4MX803eo6PP2bXi2_LApi6r8xEj0Lb8xI3v81TEhovrDDI8wwy5IrfhpCNyi6Hryu9K_AaB3r3rMdQYdsJM7MVMbcWzzL4yCILi8uLlJnHBGC7W8gylD8LUa9KDnvyMSPiZn6MOXP2X6dBXVaR9oG-SI-MdaBJVsiA" + "commandLineArgs": "certs --subject CN=HAFNIA-PRD-OIDC" + } + } +} \ No newline at end of file From 7ba69ae28d4d245013e2427d2b6e332c50199a7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Fri, 2 Feb 2024 22:41:06 +0100 Subject: [PATCH 28/42] fix: fixed build --- ...tensions.Manifest.ManifestEnricherTool.sln | 30 +++++++++++-------- .../EAVFW.Extensions.Docs.Extractor.csproj | 8 ++--- .../EAVFW.Extensions.Docs.Generator.csproj | 2 +- ...sions.Manifest.ManifestEnricherTool.csproj | 1 - 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln b/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln index 7640684..4456d31 100644 --- a/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln +++ b/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln @@ -45,9 +45,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EAVFramework", "external\EA EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EAVFW.Extensions.Manifest.SDK", "external\EAVFramework\sdk\EAVFW.Extensions.Manifest.SDK.csproj", "{3BEF0769-ABD1-4D34-8004-C98DE9FB0339}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EAVFW.Extensions.Docs.Extractor", "src\EAVFW.Extensions.Docs.Extractor\EAVFW.Extensions.Docs.Extractor.csproj", "{432042AB-6A78-4ED7-B8AC-73B047F6630F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EAVFW.Extensions.Docs.Extractor", "src\EAVFW.Extensions.Docs.Extractor\EAVFW.Extensions.Docs.Extractor.csproj", "{2D8E1682-53DD-4533-95BF-00376B321D5B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EAVFW.Extensions.Docs.Generator", "src\EAVFW.Extensions.Docs.Generator\EAVFW.Extensions.Docs.Generator.csproj", "{71FCB365-F4AE-4578-BF86-B4A3C278B6B1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EAVFW.Extensions.Docs.Generator", "src\EAVFW.Extensions.Docs.Generator\EAVFW.Extensions.Docs.Generator.csproj", "{CC413F9F-F79E-4996-8572-636F6F01ED09}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -65,18 +65,24 @@ Global {856357CE-BB26-4E6C-BAA2-B74FF8DC5734}.Release|Any CPU.Build.0 = Release|Any CPU {79505337-2855-4CC7-8FD3-D5AF31B18278}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {79505337-2855-4CC7-8FD3-D5AF31B18278}.Debug|Any CPU.Build.0 = Debug|Any CPU + {79505337-2855-4CC7-8FD3-D5AF31B18278}.Release|Any CPU.ActiveCfg = Release|Any CPU + {79505337-2855-4CC7-8FD3-D5AF31B18278}.Release|Any CPU.Build.0 = Release|Any CPU {2F30C24A-421A-4309-9F07-99668EA70C25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2F30C24A-421A-4309-9F07-99668EA70C25}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F30C24A-421A-4309-9F07-99668EA70C25}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F30C24A-421A-4309-9F07-99668EA70C25}.Release|Any CPU.Build.0 = Release|Any CPU {3BEF0769-ABD1-4D34-8004-C98DE9FB0339}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3BEF0769-ABD1-4D34-8004-C98DE9FB0339}.Debug|Any CPU.Build.0 = Debug|Any CPU - {432042AB-6A78-4ED7-B8AC-73B047F6630F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {432042AB-6A78-4ED7-B8AC-73B047F6630F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {432042AB-6A78-4ED7-B8AC-73B047F6630F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {432042AB-6A78-4ED7-B8AC-73B047F6630F}.Release|Any CPU.Build.0 = Release|Any CPU - {71FCB365-F4AE-4578-BF86-B4A3C278B6B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {71FCB365-F4AE-4578-BF86-B4A3C278B6B1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {71FCB365-F4AE-4578-BF86-B4A3C278B6B1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {71FCB365-F4AE-4578-BF86-B4A3C278B6B1}.Release|Any CPU.Build.0 = Release|Any CPU + {3BEF0769-ABD1-4D34-8004-C98DE9FB0339}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3BEF0769-ABD1-4D34-8004-C98DE9FB0339}.Release|Any CPU.Build.0 = Release|Any CPU + {2D8E1682-53DD-4533-95BF-00376B321D5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2D8E1682-53DD-4533-95BF-00376B321D5B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2D8E1682-53DD-4533-95BF-00376B321D5B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2D8E1682-53DD-4533-95BF-00376B321D5B}.Release|Any CPU.Build.0 = Release|Any CPU + {CC413F9F-F79E-4996-8572-636F6F01ED09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CC413F9F-F79E-4996-8572-636F6F01ED09}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CC413F9F-F79E-4996-8572-636F6F01ED09}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CC413F9F-F79E-4996-8572-636F6F01ED09}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -88,8 +94,8 @@ Global {79505337-2855-4CC7-8FD3-D5AF31B18278} = {CAE8FBC9-BDC3-4F45-81E1-57506D609011} {2F30C24A-421A-4309-9F07-99668EA70C25} = {CAE8FBC9-BDC3-4F45-81E1-57506D609011} {3BEF0769-ABD1-4D34-8004-C98DE9FB0339} = {CAE8FBC9-BDC3-4F45-81E1-57506D609011} - {432042AB-6A78-4ED7-B8AC-73B047F6630F} = {0D61C87C-0809-4CD7-9200-D78AD11A1E22} - {71FCB365-F4AE-4578-BF86-B4A3C278B6B1} = {0D61C87C-0809-4CD7-9200-D78AD11A1E22} + {2D8E1682-53DD-4533-95BF-00376B321D5B} = {0D61C87C-0809-4CD7-9200-D78AD11A1E22} + {CC413F9F-F79E-4996-8572-636F6F01ED09} = {0D61C87C-0809-4CD7-9200-D78AD11A1E22} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {036D5D82-DDA4-4600-B190-739D512F1062} diff --git a/src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj b/src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj index 84f8803..20b1b39 100644 --- a/src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj +++ b/src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj @@ -1,15 +1,13 @@ - + 9.0 net6.0;net8.0 - enable + disable EAVFW.Extensions.Docs.Extracter - - - + diff --git a/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj b/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj index 7e62241..bdeba74 100644 --- a/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj +++ b/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj @@ -2,7 +2,7 @@ net6.0;net8.0 - enable + disable diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj index dfa4622..b891c4f 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj @@ -22,7 +22,6 @@ - From 4147b8fbf6fc5f3b7d8c19814c6e5a3b7374af4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Fri, 2 Feb 2024 22:48:37 +0100 Subject: [PATCH 29/42] fix: use latest node as part of build --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f0f410b..a90ad4a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/setup-node@v2 with: - node-version: '18' + node-version: 'latest' - name: Add plugin for conventional commits run: npm install conventional-changelog-conventionalcommits @@ -58,4 +58,4 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GIT_AUTHOR_NAME: pksorensen GIT_AUTHOR_EMAIL: poul@kjeldager.com - run: npx semantic-release \ No newline at end of file + run: npx semantic-release From 9974d3b1183d02809b7724739cec131d4fcfd68f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Fri, 2 Feb 2024 22:51:50 +0100 Subject: [PATCH 30/42] fix: trying * for node version --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a90ad4a..fa99ea6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,9 +18,9 @@ jobs: with: global-json-file: ./global.json - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: - node-version: 'latest' + node-version: '*' - name: Add plugin for conventional commits run: npm install conventional-changelog-conventionalcommits From 01c187175d9c8ec4123ffa09954cfbbb8a9e617a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Fri, 2 Feb 2024 23:18:50 +0100 Subject: [PATCH 31/42] fix: exlude from release build --- EAVFW.Extensions.Manifest.ManifestEnricherTool.sln | 3 --- 1 file changed, 3 deletions(-) diff --git a/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln b/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln index 4456d31..d191a69 100644 --- a/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln +++ b/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln @@ -66,15 +66,12 @@ Global {79505337-2855-4CC7-8FD3-D5AF31B18278}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {79505337-2855-4CC7-8FD3-D5AF31B18278}.Debug|Any CPU.Build.0 = Debug|Any CPU {79505337-2855-4CC7-8FD3-D5AF31B18278}.Release|Any CPU.ActiveCfg = Release|Any CPU - {79505337-2855-4CC7-8FD3-D5AF31B18278}.Release|Any CPU.Build.0 = Release|Any CPU {2F30C24A-421A-4309-9F07-99668EA70C25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2F30C24A-421A-4309-9F07-99668EA70C25}.Debug|Any CPU.Build.0 = Debug|Any CPU {2F30C24A-421A-4309-9F07-99668EA70C25}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2F30C24A-421A-4309-9F07-99668EA70C25}.Release|Any CPU.Build.0 = Release|Any CPU {3BEF0769-ABD1-4D34-8004-C98DE9FB0339}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3BEF0769-ABD1-4D34-8004-C98DE9FB0339}.Debug|Any CPU.Build.0 = Debug|Any CPU {3BEF0769-ABD1-4D34-8004-C98DE9FB0339}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3BEF0769-ABD1-4D34-8004-C98DE9FB0339}.Release|Any CPU.Build.0 = Release|Any CPU {2D8E1682-53DD-4533-95BF-00376B321D5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2D8E1682-53DD-4533-95BF-00376B321D5B}.Debug|Any CPU.Build.0 = Debug|Any CPU {2D8E1682-53DD-4533-95BF-00376B321D5B}.Release|Any CPU.ActiveCfg = Release|Any CPU From be6032d376df6771a3f771b6ba28546e5a12ca5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Fri, 22 Mar 2024 10:37:47 +0100 Subject: [PATCH 32/42] fix: added submodules and updated deps to include fix for index in generation --- .gitmodules | 9 +++++++ Directory.Build.props | 2 +- ...tensions.Manifest.ManifestEnricherTool.sln | 24 +++++++++++++++++++ external/EAVFW.Extensions.Documents | 1 + external/EAVFW.Extensions.WorkflowEngine | 1 + external/EAVFramework | 2 +- external/WorkflowEngine | 1 + .../EAVFW.Extensions.Docs.Extractor.csproj | 2 ++ .../EAVFW.Extensions.Docs.Generator.csproj | 2 +- .../Commands/Gzip/GzipCommand.cs | 5 ++++ .../Properties/launchSettings.json | 24 +++++++++++-------- 11 files changed, 60 insertions(+), 13 deletions(-) create mode 160000 external/EAVFW.Extensions.Documents create mode 160000 external/EAVFW.Extensions.WorkflowEngine create mode 160000 external/WorkflowEngine diff --git a/.gitmodules b/.gitmodules index b210976..b03397b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,12 @@ [submodule "external/EAVFramework"] path = external/EAVFramework url = https://github.com/EAVFW/EAVFramework.git +[submodule "external/EAVFW.Extensions.WorkflowEngine"] + path = external/EAVFW.Extensions.WorkflowEngine + url = https://github.com/EAVFW/EAVFW.Extensions.WorkflowEngine.git +[submodule "external/EAVFW.Extensions.Documents"] + path = external/EAVFW.Extensions.Documents + url = https://github.com/EAVFW/EAVFW.Extensions.Documents.git +[submodule "external/WorkflowEngine"] + path = external/WorkflowEngine + url = https://github.com/Delegateas/WorkflowEngine.git diff --git a/Directory.Build.props b/Directory.Build.props index 1fdb4a7..a14617c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ 9.0 true - 4.2.1 + 4.2.3 $(MSBuildThisFileDirectory)/external/EAVFramework $(MSBuildThisFileDirectory)/external $(MSBuildThisFileDirectory) diff --git a/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln b/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln index d191a69..655e539 100644 --- a/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln +++ b/EAVFW.Extensions.Manifest.ManifestEnricherTool.sln @@ -49,6 +49,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EAVFW.Extensions.Docs.Extra EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EAVFW.Extensions.Docs.Generator", "src\EAVFW.Extensions.Docs.Generator\EAVFW.Extensions.Docs.Generator.csproj", "{CC413F9F-F79E-4996-8572-636F6F01ED09}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EAVFW.Extensions.WorkflowEngine", "external\EAVFW.Extensions.WorkflowEngine\src\EAVFW.Extensions.WorkflowEngine\EAVFW.Extensions.WorkflowEngine.csproj", "{3C3AC1C6-95EE-404E-8FC1-C95BDC00B4A5}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EAVFW.Extensions.Documents", "external\EAVFW.Extensions.Documents\src\EAVFW.Extensions.Documents\EAVFW.Extensions.Documents.csproj", "{1A7EAF0B-3736-4C7C-99AC-60042AA0821A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkflowEngine.Hangfire", "external\WorkflowEngine\src\WorkflowEngine.Hangfire\WorkflowEngine.Hangfire.csproj", "{934C1036-25B0-43FE-BE53-D9FB7171C327}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkflowEngine.Core", "external\WorkflowEngine\src\WorkflowEngine.Core\WorkflowEngine.Core.csproj", "{CB068DAB-01F8-4C4C-BD14-94AC94DB6F36}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -80,6 +88,18 @@ Global {CC413F9F-F79E-4996-8572-636F6F01ED09}.Debug|Any CPU.Build.0 = Debug|Any CPU {CC413F9F-F79E-4996-8572-636F6F01ED09}.Release|Any CPU.ActiveCfg = Release|Any CPU {CC413F9F-F79E-4996-8572-636F6F01ED09}.Release|Any CPU.Build.0 = Release|Any CPU + {3C3AC1C6-95EE-404E-8FC1-C95BDC00B4A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3C3AC1C6-95EE-404E-8FC1-C95BDC00B4A5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C3AC1C6-95EE-404E-8FC1-C95BDC00B4A5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1A7EAF0B-3736-4C7C-99AC-60042AA0821A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1A7EAF0B-3736-4C7C-99AC-60042AA0821A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1A7EAF0B-3736-4C7C-99AC-60042AA0821A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {934C1036-25B0-43FE-BE53-D9FB7171C327}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {934C1036-25B0-43FE-BE53-D9FB7171C327}.Debug|Any CPU.Build.0 = Debug|Any CPU + {934C1036-25B0-43FE-BE53-D9FB7171C327}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CB068DAB-01F8-4C4C-BD14-94AC94DB6F36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CB068DAB-01F8-4C4C-BD14-94AC94DB6F36}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CB068DAB-01F8-4C4C-BD14-94AC94DB6F36}.Release|Any CPU.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -93,6 +113,10 @@ Global {3BEF0769-ABD1-4D34-8004-C98DE9FB0339} = {CAE8FBC9-BDC3-4F45-81E1-57506D609011} {2D8E1682-53DD-4533-95BF-00376B321D5B} = {0D61C87C-0809-4CD7-9200-D78AD11A1E22} {CC413F9F-F79E-4996-8572-636F6F01ED09} = {0D61C87C-0809-4CD7-9200-D78AD11A1E22} + {3C3AC1C6-95EE-404E-8FC1-C95BDC00B4A5} = {CAE8FBC9-BDC3-4F45-81E1-57506D609011} + {1A7EAF0B-3736-4C7C-99AC-60042AA0821A} = {CAE8FBC9-BDC3-4F45-81E1-57506D609011} + {934C1036-25B0-43FE-BE53-D9FB7171C327} = {CAE8FBC9-BDC3-4F45-81E1-57506D609011} + {CB068DAB-01F8-4C4C-BD14-94AC94DB6F36} = {CAE8FBC9-BDC3-4F45-81E1-57506D609011} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {036D5D82-DDA4-4600-B190-739D512F1062} diff --git a/external/EAVFW.Extensions.Documents b/external/EAVFW.Extensions.Documents new file mode 160000 index 0000000..0190dd4 --- /dev/null +++ b/external/EAVFW.Extensions.Documents @@ -0,0 +1 @@ +Subproject commit 0190dd48b3a9c36e0742e59e897c18b83373abf1 diff --git a/external/EAVFW.Extensions.WorkflowEngine b/external/EAVFW.Extensions.WorkflowEngine new file mode 160000 index 0000000..6b9b265 --- /dev/null +++ b/external/EAVFW.Extensions.WorkflowEngine @@ -0,0 +1 @@ +Subproject commit 6b9b265fa9b33517eea5931a5c82c9cd6fd7ed44 diff --git a/external/EAVFramework b/external/EAVFramework index 2640f04..4679c24 160000 --- a/external/EAVFramework +++ b/external/EAVFramework @@ -1 +1 @@ -Subproject commit 2640f049b1f94d704e3ac4feb3a5bf2603535151 +Subproject commit 4679c24ae8080106f0dfa5f37b4056141d468f6a diff --git a/external/WorkflowEngine b/external/WorkflowEngine new file mode 160000 index 0000000..04ccdc1 --- /dev/null +++ b/external/WorkflowEngine @@ -0,0 +1 @@ +Subproject commit 04ccdc125a7172805f4425a4b4daceecd942c5c7 diff --git a/src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj b/src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj index 20b1b39..f7177c4 100644 --- a/src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj +++ b/src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj @@ -19,7 +19,9 @@ + + diff --git a/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj b/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj index bdeba74..cf66ecc 100644 --- a/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj +++ b/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Gzip/GzipCommand.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Gzip/GzipCommand.cs index dd54a22..abbb7c6 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Gzip/GzipCommand.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/Gzip/GzipCommand.cs @@ -41,6 +41,11 @@ public GzipCommand() : base("binary", "Work with binary gunzipped data used in E private async Task Run(ParseResult parseResult, IConsole console) { + var input = Input; + if (input.EndsWith(".gz")) + { + Input = File.ReadAllText(Input); + } var (statusCode, output) = await GzipLogic.ConstructString(Input, UnzipOption, ZipOption, PrettyPrintOption); if (statusCode != 0 || OutputOption == null) diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json index 754497e..3aa2ece 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json @@ -2,12 +2,12 @@ "profiles": { "EAVFW.Extensions.Manifest.ManifestEnricherTool": { "commandName": "Project", - "workingDirectory": "C:\\dev\\hafnia\\loi\\obj\\dbinit", - // "workingDirectory": "/Users/thyge/dev/playground", - // "commandLineArgs": "binary --unzip 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" -// "commandLineArgs": "binary --unzip --pretty-print 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" -// "commandLineArgs": "binary --unzip --pretty-print --output myjsonfile.json 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" -// "commandLineArgs": "binary --zip {\"actions\":{\"CreateLOIDataRequestMessageAction\":{\"input\":{\"loirequest\":\"a4dd227a-efab-4cb5-3e2a-08dbcaf45591\",\"recipients\":[\"1504bf2f-cf6e-49c9-df39-08dbcaf6aa88\"]},\"status\":\"Succeded\",\"body\":\"a4dd227a-efab-4cb5-3e2a-08dbcaf45591\",\"failedReason\":null}},\"triggers\":{\"Trigger\":{\"time\":\"2023-10-12T07:41:42.311509+00:00\",\"body\":{\"entityName\":\"LetterofindemnityRequests\",\"recordId\":\"a4dd227a-efab-4cb5-3e2a-08dbcaf45591\",\"data\":{\"recipients\":[\"1504bf2f-cf6e-49c9-df39-08dbcaf6aa88\"]}}}}}" + // "workingDirectory": "C:\\dev\\hafnia\\loi\\obj\\dbinit", + // "workingDirectory": "C:\\Users\\pks\\Downloads", + // "commandLineArgs": "binary -o 1.0.4.sql --unzip 1.0.4.gz" + // "commandLineArgs": "binary --unzip --pretty-print 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" + // "commandLineArgs": "binary --unzip --pretty-print --output myjsonfile.json 0x1F8B08000000000000139C51414EC33010FC8BAFD4C8719C36C9AD824BA50252E90D71D8D8EBC852EA147B73A8A2FE1D3B05CE153E8DAC99D99DD999812637FAC8DA993D0504C2FDDBEE19080EF83561A4178C117ADC2EAC4C72FE3C5106C3E8C28DC35A06CA182937C0D142C795EE2A5EA2042E6AD369B0AAAA9A82AD5840EDCE0E3DA5791FACA884EAACB45CDB3572D5E8861B5B36BFA235405DB3CFEB8A45029A9284BD4F5AA34193ACBAD15CEE1F6CC10D680E0831A7F0D3305C932F05D7F71896F0C71BCE90DC0993B514B2E485E0853C8A4DAB8A56C9C7B2484B370F42B442FC2D31B394C8D1E51516DD1E89308CD67983279FFE7FAA8CB702C66076E6FECD4DBA451EF1AFEAF2FB060000FFFF" + // "commandLineArgs": "binary --zip {\"actions\":{\"CreateLOIDataRequestMessageAction\":{\"input\":{\"loirequest\":\"a4dd227a-efab-4cb5-3e2a-08dbcaf45591\",\"recipients\":[\"1504bf2f-cf6e-49c9-df39-08dbcaf6aa88\"]},\"status\":\"Succeded\",\"body\":\"a4dd227a-efab-4cb5-3e2a-08dbcaf45591\",\"failedReason\":null}},\"triggers\":{\"Trigger\":{\"time\":\"2023-10-12T07:41:42.311509+00:00\",\"body\":{\"entityName\":\"LetterofindemnityRequests\",\"recordId\":\"a4dd227a-efab-4cb5-3e2a-08dbcaf45591\",\"data\":{\"recipients\":[\"1504bf2f-cf6e-49c9-df39-08dbcaf6aa88\"]}}}}}" //"workingDirectory": "C:\\dev\\kfst_vanddata", //"commandLineArgs": "--path c:\\dev\\kfst_vanddata\\apps\\KFST.Vanddata.ManagementPortal\\manifest.json --customizationprefix kfst", //"commandLineArgs": "install EAVFW.Extensions.SecurityModel", @@ -20,13 +20,17 @@ // "commandLineArgs": "--path C:\\dev\\MedlemsCentralen\\src\\MC.Models\\manifest.json --customizationprefix MC" // "commandLineArgs": "sql ./src/Hafnia.Models", - -// "commandLineArgs": "gpt review pr --project https://github.com/delegateas/WorkflowEngine.git --pr 15" + + // "commandLineArgs": "gpt review pr --project https://github.com/delegateas/WorkflowEngine.git --pr 15" // "commandLineArgs": "sql ./apps/KFST.Vanddata.ManagementPortal" //"commandLineArgs": "--path C:\\dev\\hafnia\\loi\\src\\Hafnia.Models\\manifest.json --customizationprefix hafnia" //"commandLineArgs": "sql apply -S sql-loi-tst.database.windows.net -d db-loi-tst -v DBSchema=dbo -v DBName=db-loi-tst -v SystemAdminSecurityGroupId=1b714972-8d0a-4feb-b166-08d93c6ae328 -v UserGuid=1F3EE206-2B94-4017-8EC1-F983E3E24BDE -v UserName=\"Poul Kjeldager\" -v UserEmail=x_pks@hafniabw.com -i init.sql -i init-systemadmin.sql" - // "commandLineArgs": "sql add-user -S sql-loi-tst.database.windows.net -d db-loi-tst --external-user-name app-loi-management-tst --external-user-objid 785062c9-a28a-4f65-9a8c-cf671d58fe7f --token eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjlHbW55RlBraGMzaE91UjIybXZTdmduTG83WSIsImtpZCI6IjlHbW55RlBraGMzaE91UjIybXZTdmduTG83WSJ9.eyJhdWQiOiJodHRwczovL2RhdGFiYXNlLndpbmRvd3MubmV0IiwiaXNzIjoiaHR0cHM6Ly9zdHMud2luZG93cy5uZXQvYTM2NGViMjgtZTk1Yi00YWQwLWE0ZmItNWI0Zjc3NjdhZDg0LyIsImlhdCI6MTY5OTUyNjI4MiwibmJmIjoxNjk5NTI2MjgyLCJleHAiOjE2OTk1MzAxODIsImFpbyI6IkUyVmdZQkJlNzNqaUc5czl2NUNpUlNreTAyWWNBZ0E9IiwiYXBwaWQiOiJlMWVmMmM5Mi1mZTFiLTQwZGItODAzYi0xM2Y0MzA3ZGIzNzQiLCJhcHBpZGFjciI6IjEiLCJpZHAiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9hMzY0ZWIyOC1lOTViLTRhZDAtYTRmYi01YjRmNzc2N2FkODQvIiwiaWR0eXAiOiJhcHAiLCJvaWQiOiIyMDNhMWUwOS1iMTUyLTQ5NjgtOTdlZS1hMzgyZTBmNDJkMmUiLCJyaCI6IjAuQVM4QUtPdGtvMXZwMEVxay0xdFBkMmV0aE5NSEtRSWJEX2RJdXR3YnBxdXJiV2F3QUFBLiIsInN1YiI6IjIwM2ExZTA5LWIxNTItNDk2OC05N2VlLWEzODJlMGY0MmQyZSIsInRpZCI6ImEzNjRlYjI4LWU5NWItNGFkMC1hNGZiLTViNGY3NzY3YWQ4NCIsInV0aSI6Ilo0cVFHMXo5b0VDRDd2eUJUVjhOQUEiLCJ2ZXIiOiIxLjAifQ.bLG9-5aDAkO3CPcNRyBTjDOPL4vvahjSB3UvDF1lRFbjEL-j9bgXDlJfI29M1MSjz_wgAiUoKcIsM6TTtnK2tMYrZYKvZeo9SDh6vrX-UqZgQVxibuVNrOKpRCkDOEl34LIn1b2Qy8UH7Nvf7TFpwImiJ8oW7KHDFYCTTbEoEQsurtl8R_KX4MX803eo6PP2bXi2_LApi6r8xEj0Lb8xI3v81TEhovrDDI8wwy5IrfhpCNyi6Hryu9K_AaB3r3rMdQYdsJM7MVMbcWzzL4yCILi8uLlJnHBGC7W8gylD8LUa9KDnvyMSPiZn6MOXP2X6dBXVaR9oG-SI-MdaBJVsiA" - "commandLineArgs": "certs --subject CN=HAFNIA-PRD-OIDC" + // "commandLineArgs": "sql add-user -S sql-loi-tst.database.windows.net -d db-loi-tst --external-user-name app-loi-management-tst --external-user-objid 785062c9-a28a-4f65-9a8c-cf671d58fe7f --token eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjlHbW55RlBraGMzaE91UjIybXZTdmduTG83WSIsImtpZCI6IjlHbW55RlBraGMzaE91UjIybXZTdmduTG83WSJ9.eyJhdWQiOiJodHRwczovL2RhdGFiYXNlLndpbmRvd3MubmV0IiwiaXNzIjoiaHR0cHM6Ly9zdHMud2luZG93cy5uZXQvYTM2NGViMjgtZTk1Yi00YWQwLWE0ZmItNWI0Zjc3NjdhZDg0LyIsImlhdCI6MTY5OTUyNjI4MiwibmJmIjoxNjk5NTI2MjgyLCJleHAiOjE2OTk1MzAxODIsImFpbyI6IkUyVmdZQkJlNzNqaUc5czl2NUNpUlNreTAyWWNBZ0E9IiwiYXBwaWQiOiJlMWVmMmM5Mi1mZTFiLTQwZGItODAzYi0xM2Y0MzA3ZGIzNzQiLCJhcHBpZGFjciI6IjEiLCJpZHAiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9hMzY0ZWIyOC1lOTViLTRhZDAtYTRmYi01YjRmNzc2N2FkODQvIiwiaWR0eXAiOiJhcHAiLCJvaWQiOiIyMDNhMWUwOS1iMTUyLTQ5NjgtOTdlZS1hMzgyZTBmNDJkMmUiLCJyaCI6IjAuQVM4QUtPdGtvMXZwMEVxay0xdFBkMmV0aE5NSEtRSWJEX2RJdXR3YnBxdXJiV2F3QUFBLiIsInN1YiI6IjIwM2ExZTA5LWIxNTItNDk2OC05N2VlLWEzODJlMGY0MmQyZSIsInRpZCI6ImEzNjRlYjI4LWU5NWItNGFkMC1hNGZiLTViNGY3NzY3YWQ4NCIsInV0aSI6Ilo0cVFHMXo5b0VDRDd2eUJUVjhOQUEiLCJ2ZXIiOiIxLjAifQ.bLG9-5aDAkO3CPcNRyBTjDOPL4vvahjSB3UvDF1lRFbjEL-j9bgXDlJfI29M1MSjz_wgAiUoKcIsM6TTtnK2tMYrZYKvZeo9SDh6vrX-UqZgQVxibuVNrOKpRCkDOEl34LIn1b2Qy8UH7Nvf7TFpwImiJ8oW7KHDFYCTTbEoEQsurtl8R_KX4MX803eo6PP2bXi2_LApi6r8xEj0Lb8xI3v81TEhovrDDI8wwy5IrfhpCNyi6Hryu9K_AaB3r3rMdQYdsJM7MVMbcWzzL4yCILi8uLlJnHBGC7W8gylD8LUa9KDnvyMSPiZn6MOXP2X6dBXVaR9oG-SI-MdaBJVsiA" + // "commandLineArgs": "certs --subject CN=HAFNIA-PRD-OIDC" + + "workingDirectory": "C:\\dev\\GroupOnline\\QuotationPlatform", + "commandLineArgs": "sql ./src/GroupOnline.Models" + } } } From 2a7b2055b49dee2c08a1d5f8221670852605a0ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Fri, 22 Mar 2024 12:22:07 +0100 Subject: [PATCH 33/42] fix: updated version to use msbuild pprops --- .../EAVFW.Extensions.Docs.Generator.csproj | 4 ++-- .../EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj b/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj index cf66ecc..f49b6b1 100644 --- a/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj +++ b/src/EAVFW.Extensions.Docs.Generator/EAVFW.Extensions.Docs.Generator.csproj @@ -15,8 +15,8 @@ - - + + diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj index b891c4f..02062af 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj @@ -50,7 +50,7 @@ - + From 558a78348da11455ac3e625b146c88719f4dee1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Thu, 25 Apr 2024 21:39:29 +0200 Subject: [PATCH 34/42] fix: updated to latest .net8 fixes of eavfw --- Directory.Build.props | 2 +- external/EAVFramework | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index a14617c..6983faa 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ 9.0 true - 4.2.3 + 4.2.6 $(MSBuildThisFileDirectory)/external/EAVFramework $(MSBuildThisFileDirectory)/external $(MSBuildThisFileDirectory) diff --git a/external/EAVFramework b/external/EAVFramework index 4679c24..fd81cea 160000 --- a/external/EAVFramework +++ b/external/EAVFramework @@ -1 +1 @@ -Subproject commit 4679c24ae8080106f0dfa5f37b4056141d468f6a +Subproject commit fd81cea5b56fe868d1d4eabb780696499a914ace From fc4f47c0e5b2932a0ac7bdd19465eedc46ed1f3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Thu, 25 Apr 2024 21:54:42 +0200 Subject: [PATCH 35/42] fix: build issues fixed for .net 8 --- .../Commands/ManifestFixMigrationCommand.cs | 7 +------ .../EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj | 1 - 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/ManifestFixMigrationCommand.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/ManifestFixMigrationCommand.cs index 301a5b2..b0da2c4 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/ManifestFixMigrationCommand.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/ManifestFixMigrationCommand.cs @@ -1,24 +1,19 @@ using LibGit2Sharp; -using Microsoft.AspNetCore.Hosting.Server; -using Microsoft.Azure.Documents; using Microsoft.Data.SqlClient; using Microsoft.Extensions.Logging; -using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Semver; using System; -using System.Collections.Generic; using System.CommandLine; using System.CommandLine.NamingConventionBinder; using System.CommandLine.Parsing; using System.IO; using System.Linq; using System.Threading.Tasks; -using System.Xml.Linq; namespace EAVFW.Extensions.Manifest.ManifestEnricherTool.Commands { - + public class ManifestFixMigrationCommand : Command { public Option ProjectPath = new Option("--project-path", "The project path to EAV Model Project"); diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj index 02062af..96a67cf 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj @@ -21,7 +21,6 @@ - From 83ce0da263df895f0c2f0e16181b7ccd0ef7d403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Thu, 25 Apr 2024 22:52:11 +0200 Subject: [PATCH 36/42] fix: updated deps for net8 that works --- .../EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj index 96a67cf..cbca24d 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj @@ -38,7 +38,7 @@ - 7.0.13 + 8.0.4 From 72e4b4c307bee1f64a2f2fb90f94fdf8fd1dd1ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Thu, 25 Apr 2024 23:35:13 +0200 Subject: [PATCH 37/42] fix: updated with working deps for .net 8 --- Directory.Build.props | 2 +- external/EAVFW.Extensions.Documents | 2 +- external/EAVFW.Extensions.WorkflowEngine | 2 +- external/EAVFramework | 2 +- external/WorkflowEngine | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 6983faa..19e8b90 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ 9.0 true - 4.2.6 + 4.2.7 $(MSBuildThisFileDirectory)/external/EAVFramework $(MSBuildThisFileDirectory)/external $(MSBuildThisFileDirectory) diff --git a/external/EAVFW.Extensions.Documents b/external/EAVFW.Extensions.Documents index 0190dd4..ae1b9f1 160000 --- a/external/EAVFW.Extensions.Documents +++ b/external/EAVFW.Extensions.Documents @@ -1 +1 @@ -Subproject commit 0190dd48b3a9c36e0742e59e897c18b83373abf1 +Subproject commit ae1b9f12684b16bd4371b6841b1bbfb2caf33d1d diff --git a/external/EAVFW.Extensions.WorkflowEngine b/external/EAVFW.Extensions.WorkflowEngine index 6b9b265..5e7d5e4 160000 --- a/external/EAVFW.Extensions.WorkflowEngine +++ b/external/EAVFW.Extensions.WorkflowEngine @@ -1 +1 @@ -Subproject commit 6b9b265fa9b33517eea5931a5c82c9cd6fd7ed44 +Subproject commit 5e7d5e451d2445a1bf98e31c19d9fe82a747086b diff --git a/external/EAVFramework b/external/EAVFramework index fd81cea..a4a0d7e 160000 --- a/external/EAVFramework +++ b/external/EAVFramework @@ -1 +1 @@ -Subproject commit fd81cea5b56fe868d1d4eabb780696499a914ace +Subproject commit a4a0d7eeb7f7c8f66edcb2a47c3187184af45a87 diff --git a/external/WorkflowEngine b/external/WorkflowEngine index 04ccdc1..f3ca426 160000 --- a/external/WorkflowEngine +++ b/external/WorkflowEngine @@ -1 +1 @@ -Subproject commit 04ccdc125a7172805f4425a4b4daceecd942c5c7 +Subproject commit f3ca4265067ee4cc6aed917655b7bf4458e12935 From 6dd0fc8d53175daaf2470390dfdd8ca5da365b1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Thu, 16 May 2024 07:30:29 +0200 Subject: [PATCH 38/42] fix: updated version that includes sql up dates in manifest. --- Directory.Build.props | 2 +- external/EAVFramework | 2 +- .../EAVFW.Extensions.Docs.Extractor.csproj | 6 ++-- ...sions.Manifest.ManifestEnricherTool.csproj | 28 +++++++++---------- .../EAVFW.Extensions.Manifest.Tests.csproj | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 19e8b90..afc8757 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ 9.0 true - 4.2.7 + 4.2.8 $(MSBuildThisFileDirectory)/external/EAVFramework $(MSBuildThisFileDirectory)/external $(MSBuildThisFileDirectory) diff --git a/external/EAVFramework b/external/EAVFramework index a4a0d7e..cf5f714 160000 --- a/external/EAVFramework +++ b/external/EAVFramework @@ -1 +1 @@ -Subproject commit a4a0d7eeb7f7c8f66edcb2a47c3187184af45a87 +Subproject commit cf5f7143eb253ae62d7f559c726ec852f0a60312 diff --git a/src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj b/src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj index f7177c4..2fdeb57 100644 --- a/src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj +++ b/src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj @@ -14,12 +14,12 @@ - - + + - + diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj index cbca24d..a92d504 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj @@ -14,19 +14,19 @@ - + - + - - - - + + + + - - + + 3.1.31 @@ -44,17 +44,17 @@ - - + + - - + + - - + + diff --git a/tests/EAVFW.Extensions.Manifest.Tests/EAVFW.Extensions.Manifest.Tests.csproj b/tests/EAVFW.Extensions.Manifest.Tests/EAVFW.Extensions.Manifest.Tests.csproj index bffa217..2a81ff3 100644 --- a/tests/EAVFW.Extensions.Manifest.Tests/EAVFW.Extensions.Manifest.Tests.csproj +++ b/tests/EAVFW.Extensions.Manifest.Tests/EAVFW.Extensions.Manifest.Tests.csproj @@ -15,7 +15,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive From 8ad3930a6eabfd8ee3f09ced09264a51196d24bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Thu, 16 May 2024 07:36:39 +0200 Subject: [PATCH 39/42] rolled back version to unblock bug --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fa99ea6..5b76297 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,7 +23,7 @@ jobs: node-version: '*' - name: Add plugin for conventional commits - run: npm install conventional-changelog-conventionalcommits + run: npm install conventional-changelog-conventionalcommits@7.0.0 working-directory: ./.github/workflows - name: Add plugin for executing bash commands From 324a5f2a2df44d70908cf44f44e6d1af0b8420b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Fri, 17 May 2024 04:56:34 +0200 Subject: [PATCH 40/42] fix: dependency update had breaking change --- .../Commands/GPT/GPTCommand.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/GPT/GPTCommand.cs b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/GPT/GPTCommand.cs index 4c582e2..e196015 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/GPT/GPTCommand.cs +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Commands/GPT/GPTCommand.cs @@ -39,7 +39,7 @@ private async Task Run(ParseResult parseResult, IConsole console) } Directory.CreateDirectory(folder); - var repoPath = LibGit2Sharp.Repository.Clone(Project, folder, new CloneOptions { Checkout = true, FetchOptions = new FetchOptions { } }); + var repoPath = LibGit2Sharp.Repository.Clone(Project, folder, new CloneOptions { Checkout = true, FetchOptions = { } }); try { console.WriteLine(repoPath); From 1beed96d71175671d15189c57748bb0bd123fbe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Fri, 17 May 2024 05:41:40 +0200 Subject: [PATCH 41/42] regression, try 7.0.2 --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5b76297..746eb75 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,7 +23,7 @@ jobs: node-version: '*' - name: Add plugin for conventional commits - run: npm install conventional-changelog-conventionalcommits@7.0.0 + run: npm install conventional-changelog-conventionalcommits@7.0.2 working-directory: ./.github/workflows - name: Add plugin for executing bash commands From 9d878ac60321e9305f5e422e63d7f748bee0b296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Tue, 28 May 2024 11:59:35 +0200 Subject: [PATCH 42/42] fix: updated deps with new poly lookup implementation --- Directory.Build.props | 2 +- external/EAVFramework | 2 +- .../Properties/launchSettings.json | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index afc8757..a193d7c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ 9.0 true - 4.2.8 + 4.3.0 $(MSBuildThisFileDirectory)/external/EAVFramework $(MSBuildThisFileDirectory)/external $(MSBuildThisFileDirectory) diff --git a/external/EAVFramework b/external/EAVFramework index cf5f714..24a2c31 160000 --- a/external/EAVFramework +++ b/external/EAVFramework @@ -1 +1 @@ -Subproject commit cf5f7143eb253ae62d7f559c726ec852f0a60312 +Subproject commit 24a2c312b11b9e67eb9f99a4cbaf20baf0ded44d diff --git a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json index 3aa2ece..40020af 100644 --- a/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json +++ b/src/EAVFW.Extensions.Manifest.ManifestEnricherTool/Properties/launchSettings.json @@ -30,6 +30,8 @@ "workingDirectory": "C:\\dev\\GroupOnline\\QuotationPlatform", "commandLineArgs": "sql ./src/GroupOnline.Models" + //"workingDirectory": "C:\\dev\\GroupOnline\\QuotationPlatform\\src\\GroupOnline.Models", + // "commandLineArgs": "--path C:\\dev\\GroupOnline\\QuotationPlatform\\src\\GroupOnline.Models\\manifest.json --customizationprefix GroupOnline" } }