Skip to content

Commit

Permalink
merged stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
pksorensen committed Feb 2, 2024
2 parents 5bec76d + b42c28b commit 72b72e5
Show file tree
Hide file tree
Showing 66 changed files with 15,724 additions and 2,039 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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
global-json-file: ./global.json

- name: Cleaning
run: dotnet clean
run: dotnet clean -c Release

#- name: Restore NuGet packages
# run: dotnet restore EAVFW.Extensions.Manifest.ManifestEnricherTool.sln
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ jobs:
- name: Cleaning
run: dotnet clean --configuration Release

- name: Restore NuGet packages
run: dotnet restore EAVFW.Extensions.Manifest.ManifestEnricherTool.sln
# - name: Restore NuGet packages
# run: dotnet restore EAVFW.Extensions.Manifest.ManifestEnricherTool.sln

- name: Package Parser
run: dotnet pack -c Release -p:PackageVersion=${env:RELEASE_VERSION} -o ./artifacts
Expand Down
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
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "external/EAVFW.Extensions.CommandLine"]
path = external/EAVFW.Extensions.CommandLine
url = https://github.com/EAVFW/EAVFW.Extensions.CommandLine.git
[submodule "external/EAVFramework"]
path = external/EAVFramework
url = https://github.com/EAVFW/EAVFramework.git
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project>
<PropertyGroup>
<LangVersion>9.0</LangVersion>
<UseEAVFromNuget>true</UseEAVFromNuget>
<EAVFrameworkVersion>4.2.1</EAVFrameworkVersion>
<UseEAVFromNuget>false</UseEAVFromNuget>
<LocalEAVFrameworkPath>$(MSBuildThisFileDirectory)/external/EAVFramework</LocalEAVFrameworkPath>
<LocalExternalpath>$(MSBuildThisFileDirectory)/external</LocalExternalpath>
<ManifestSDKPath>$(MSBuildThisFileDirectory)</ManifestSDKPath>
</PropertyGroup>
</Project>
</Project>
46 changes: 27 additions & 19 deletions EAVFW.Extensions.Manifest.ManifestEnricherTool.sln
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,30 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".config", ".config", "{4AFE
.config\dotnet-tools.json = .config\dotnet-tools.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "eavfw", "eavfw", "{99FD28D4-904E-4601-8B15-BAE281F48576}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{0343EA18-1645-4DFB-9A9C-2D10BBA2A2CB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EAVFW.Extensions.Manifest.SDK", "src\EAVFW.Extensions.Manifest.SDK\EAVFW.Extensions.Manifest.SDK.csproj", "{A69F8562-BDDF-4DE9-8768-E51B1FFFD368}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EAVFW.Extensions.Manifest.ManifestEnricherTool", "src\EAVFW.Extensions.Manifest.ManifestEnricherTool\EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj", "{C472564C-38FE-4465-BC62-FDCF45339C36}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EAVFramework", "..\..\EAVFramework\src\EAVFramework.csproj", "{B8E00220-CF68-4B02-831C-15E16D61E996}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EAVFW.Extensions.Manifest.Tests", "tests\EAVFW.Extensions.Manifest.Tests\EAVFW.Extensions.Manifest.Tests.csproj", "{856357CE-BB26-4E6C-BAA2-B74FF8DC5734}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{0343EA18-1645-4DFB-9A9C-2D10BBA2A2CB}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "external", "external", "{CAE8FBC9-BDC3-4F45-81E1-57506D609011}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EAVFW.Extensions.Manifest.ManifestEnricherTool", "src\EAVFW.Extensions.Manifest.ManifestEnricherTool\EAVFW.Extensions.Manifest.ManifestEnricherTool.csproj", "{C472564C-38FE-4465-BC62-FDCF45339C36}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EAVFW.Extensions.CommandLine", "external\EAVFW.Extensions.CommandLine\src\EAVFW.Extensions.CommandLine\EAVFW.Extensions.CommandLine.csproj", "{79505337-2855-4CC7-8FD3-D5AF31B18278}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EAVFramework", "external\EAVFramework\src\EAVFramework.csproj", "{2F30C24A-421A-4309-9F07-99668EA70C25}"
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}"
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
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A69F8562-BDDF-4DE9-8768-E51B1FFFD368}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A69F8562-BDDF-4DE9-8768-E51B1FFFD368}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A69F8562-BDDF-4DE9-8768-E51B1FFFD368}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A69F8562-BDDF-4DE9-8768-E51B1FFFD368}.Release|Any CPU.Build.0 = Release|Any CPU
{B8E00220-CF68-4B02-831C-15E16D61E996}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B8E00220-CF68-4B02-831C-15E16D61E996}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C472564C-38FE-4465-BC62-FDCF45339C36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{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
Expand All @@ -63,25 +65,31 @@ 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
{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
{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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{E8050101-10D8-4B0E-B081-8A45BA2E4A61} = {C88FCAB5-AE8A-44CD-9195-2B085A6CD560}
{A69F8562-BDDF-4DE9-8768-E51B1FFFD368} = {0D61C87C-0809-4CD7-9200-D78AD11A1E22}
{B8E00220-CF68-4B02-831C-15E16D61E996} = {99FD28D4-904E-4601-8B15-BAE281F48576}
{C472564C-38FE-4465-BC62-FDCF45339C36} = {0D61C87C-0809-4CD7-9200-D78AD11A1E22}
{856357CE-BB26-4E6C-BAA2-B74FF8DC5734} = {0343EA18-1645-4DFB-9A9C-2D10BBA2A2CB}
{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}
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>
1 change: 1 addition & 0 deletions external/EAVFW.Extensions.CommandLine
1 change: 1 addition & 0 deletions external/EAVFramework
Submodule EAVFramework added at 2640f0
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.100"
}
}
}

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>enable</Nullable>
<RootNamespace>EAVFW.Extensions.Docs.Extracter</RootNamespace>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\external\EAVFramework\src\EAVFramework.csproj" />
</ItemGroup>

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

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

<ItemGroup Condition="$(UseEAVFromNuget) == 'false'">
<ProjectReference Include="$(LocalExternalpath)/EAVFramework/src/EAVFramework.csproj" />
</ItemGroup>


</Project>
Loading

0 comments on commit 72b72e5

Please sign in to comment.