Skip to content

Commit

Permalink
merged main
Browse files Browse the repository at this point in the history
  • Loading branch information
pksorensen committed Aug 6, 2024
2 parents cb8be7c + 9d878ac commit 5f28b49
Show file tree
Hide file tree
Showing 52 changed files with 1,885 additions and 80 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
]
}
}
}
}
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
root = true

[*]
insert_final_newline = true
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ jobs:
with:
global-json-file: ./global.json

- uses: actions/setup-node@v2
- uses: actions/setup-node@v4
with:
node-version: '18'
node-version: '*'

- name: Add plugin for conventional commits
run: npm install conventional-changelog-conventionalcommits
run: npm install conventional-changelog-conventionalcommits@7.0.2
working-directory: ./.github/workflows

- name: Add plugin for executing bash commands
Expand Down Expand Up @@ -58,4 +58,4 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: pksorensen
GIT_AUTHOR_EMAIL: [email protected]
run: npx semantic-release
run: npx semantic-release
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ node_modules
/.github/workflows/package-lock.json
/artifacts
*.csproj.user
.idea
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
<LocalExternalpath>$(MSBuildThisFileDirectory)/external</LocalExternalpath>
<ManifestSDKPath>$(MSBuildThisFileDirectory)</ManifestSDKPath>
</PropertyGroup>
</Project>
</Project>
14 changes: 14 additions & 0 deletions EAVFW.Extensions.Manifest.ManifestEnricherTool.sln
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ 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("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EAVFW.Extensions.Docs.Extractor", "src\EAVFW.Extensions.Docs.Extractor\EAVFW.Extensions.Docs.Extractor.csproj", "{28A8781C-D30A-4589-9D96-399ED8D2A6B4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EAVFW.Extensions.Docs.Generator", "src\EAVFW.Extensions.Docs.Generator\EAVFW.Extensions.Docs.Generator.csproj", "{D03D5862-7B6F-4E46-83E1-D24CF0038D1C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -70,6 +74,14 @@ Global
{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
{28A8781C-D30A-4589-9D96-399ED8D2A6B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{28A8781C-D30A-4589-9D96-399ED8D2A6B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{28A8781C-D30A-4589-9D96-399ED8D2A6B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{28A8781C-D30A-4589-9D96-399ED8D2A6B4}.Release|Any CPU.Build.0 = Release|Any CPU
{D03D5862-7B6F-4E46-83E1-D24CF0038D1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D03D5862-7B6F-4E46-83E1-D24CF0038D1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D03D5862-7B6F-4E46-83E1-D24CF0038D1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D03D5862-7B6F-4E46-83E1-D24CF0038D1C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -81,6 +93,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}
{28A8781C-D30A-4589-9D96-399ED8D2A6B4} = {0D61C87C-0809-4CD7-9200-D78AD11A1E22}
{D03D5862-7B6F-4E46-83E1-D24CF0038D1C} = {0D61C87C-0809-4CD7-9200-D78AD11A1E22}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {036D5D82-DDA4-4600-B190-739D512F1062}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=7ff53623_002D25f7_002D4650_002D83cc_002Da1cf7cca21fd/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="ZipAndUnZipTests" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
&lt;Solution /&gt;
&lt;/SessionState&gt;</s:String></wpf:ResourceDictionary>
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Empty file added artifacts/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions external/EAVFW.Extensions.Documents
1 change: 1 addition & 0 deletions external/EAVFW.Extensions.WorkflowEngine
1 change: 1 addition & 0 deletions external/WorkflowEngine
Submodule WorkflowEngine added at f3ca42
3 changes: 2 additions & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
"sdk": {
"version": "8.0.303"
}
}
}

36 changes: 36 additions & 0 deletions src/EAVFW.Extensions.Docs.Extractor/CustomAssemblyResolver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace EAVFW.Extensions.Docs.Extractor
{
public static class CustomAssemblyResolver
{
public static Dictionary<string, AssemblyInfo> 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;
}
}
}
}
148 changes: 148 additions & 0 deletions src/EAVFW.Extensions.Docs.Extractor/DocumentLogic.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Loader;
using System.Text.Json;
using EAVFramework.Plugins;
using EAVFW.Extensions.Manifest.SDK;
using WorkflowEngine.Core;

namespace EAVFW.Extensions.Docs.Extractor
{
public class DocumentLogic : IDocumentLogic
{
/// <inheritdoc />
public IEnumerable<PluginDocumentation> ExtractPluginDocumentation(FileInfo assemblyInfo, string[] assemblies)
{
var assembly = LoadAssembly(assemblyInfo, assemblies);

var implementingTypes = assembly.GetTypes()
.Where(t => typeof(IPlugin).IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract);

var plugins =
from implementingType in implementingTypes
let pluginRegistrations = implementingType.GetCustomAttributes<PluginRegistrationAttribute>()
let _interface = implementingType.GetInterfaces()
.FirstOrDefault(i => i.GenericTypeArguments.Length == 2)
select new PluginDocumentation
{
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 = new TypeInformation(_interface.GetGenericArguments().First()),
Entity = new TypeInformation(_interface.GetGenericArguments().Last())
};

return plugins;
}

private static Assembly LoadAssembly(FileInfo assemblyInfo, string [] assemblies)
{
var dictionary = new Dictionary<string, AssemblyInfo>();
foreach (var file in assemblies)
{
var assemblyName = AssemblyName.GetAssemblyName(file);

dictionary.TryAdd(assemblyName.Name!, new AssemblyInfo
{
Name = assemblyName.Name!,
Version = assemblyName.Version!.ToString(),
Path = file
});
}

CustomAssemblyResolver.Dictionary = dictionary;

var currentDomain = AppDomain.CurrentDomain;
currentDomain.AssemblyResolve += CustomAssemblyResolver.CustomAssemblyResolverEventHandler;

var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(assemblyInfo.FullName);
return assembly;
}

/// <inheritdoc/>
public Dictionary<string, EntityDefinition> ExtractWizardDocumentation(FileInfo manifestFile,
FileInfo assemblyInfo, string[] assemblies)
{
var assembly = LoadAssembly(assemblyInfo, assemblies);

// Preloading types to easily query for documentation
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;

// Find Wizards
var simpleManifest = new Dictionary<string, EntityDefinition>();
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 tab in tabs
where tab.Value.OnTransitionOut?.Workflow != null || tab.Value.OnTransitionIn?.Workflow != null
select tab;

foreach (var (key, value) in tabsWithWorkflows)
{
if (!string.IsNullOrWhiteSpace(value?.OnTransitionIn?.Workflow) &&
workflows.TryGetValue(value.OnTransitionIn.Workflow, out var type1))
{
value.OnTransitionIn.AdditionalData["x-workflowSummary"] = type1.GetDocumentation();
}

if (!string.IsNullOrWhiteSpace(value?.OnTransitionOut?.Workflow) &&
workflows.TryGetValue(value.OnTransitionOut.Workflow, out var type2))
{
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();
}

return simpleManifest;
}

private void ExtractEntitiesWithWizards(JsonElement element, IDictionary<string, EntityDefinition> 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<Dictionary<string, EntityDefinition>>(property.Value.GetRawText());

if (localEntities == null) return;

foreach (var (key, value) in localEntities.Where(x => x.Value?.Wizards?.Any() ?? false))
{
entities[key] = value;
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<LangVersion>9.0</LangVersion>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<Nullable>disable</Nullable>
<RootNamespace>EAVFW.Extensions.Docs.Extracter</RootNamespace>
</PropertyGroup>



<ItemGroup>
<PackageReference Include="System.ComponentModel.Composition" Version="6.0.0" />
</ItemGroup>

<ItemGroup Condition="$(UseEAVFromNuget) != 'false'">
<PackageReference Include="EAVFW.Extensions.Manifest.SDK" Version="$(EAVFrameworkVersion)" />
<PackageReference Include="EAVFW.Extensions.WorkflowEngine" Version="3.1.7" />
</ItemGroup>

<ItemGroup Condition="$(UseEAVFromNuget) == 'false'">
<ProjectReference Include="$(LocalExternalpath)/EAVFramework/sdk/EAVFW.Extensions.Manifest.SDK.csproj" />
<ProjectReference Include="$(LocalExternalpath)/EAVFramework/src/EAVFramework.csproj" />
<ProjectReference Include="$(LocalExternalpath)/EAVFW.Extensions.WorkflowEngine/src/EAVFW.Extensions.WorkflowEngine/EAVFW.Extensions.WorkflowEngine.csproj" />
</ItemGroup>


</Project>
27 changes: 27 additions & 0 deletions src/EAVFW.Extensions.Docs.Extractor/IDocumentLogic.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Collections.Generic;
using System.IO;
using EAVFW.Extensions.Manifest.SDK;

namespace EAVFW.Extensions.Docs.Extractor
{
public interface IDocumentLogic
{
/// <summary>
/// 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.
/// <param name="pluginInfo"></param>
/// </summary>
IEnumerable<PluginDocumentation> ExtractPluginDocumentation(FileInfo assemblyInfo, string[] assemblies);

/// <summary>
/// Extract Wizards from the given Manifest and generate documentation based on manifest metadata and workflow
/// CLR types and Actions
/// </summary>
/// <param name="manifestFile"></param>
/// <param name="pluginInfo"></param>
/// <returns></returns>
Dictionary<string, EntityDefinition> ExtractWizardDocumentation(FileInfo manifestFile, FileInfo assemblyInfo, string[] assemblies);
}
}
Loading

0 comments on commit 5f28b49

Please sign in to comment.