-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
1,885 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ | |
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
root = true | ||
|
||
[*] | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ node_modules | |
/.github/workflows/package-lock.json | ||
/artifacts | ||
*.csproj.user | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
EAVFW.Extensions.Manifest.ManifestEnricherTool.sln.DotSettings.user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"><SessionState ContinuousTestingMode="0" IsActive="True" Name="ZipAndUnZipTests" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> | ||
<Solution /> | ||
</SessionState></s:String></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Submodule EAVFW.Extensions.Documents
added at
ae1b9f
Submodule EAVFW.Extensions.WorkflowEngine
added at
5e7d5e
Submodule WorkflowEngine
added at
f3ca42
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
"sdk": { | ||
"version": "8.0.303" | ||
} | ||
} | ||
} | ||
|
36 changes: 36 additions & 0 deletions
36
src/EAVFW.Extensions.Docs.Extractor/CustomAssemblyResolver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/EAVFW.Extensions.Docs.Extractor/EAVFW.Extensions.Docs.Extractor.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.