Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tst/documentation generation upgrade #13

Merged
merged 8 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
dotnet-version: |
3.1.x
6.0.x
8.0.x

- name: Cleaning
run: dotnet clean
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
dotnet-version: |
3.1.x
6.0.x
8.0.x

- name: Cleaning
run: dotnet clean
Expand Down
17 changes: 17 additions & 0 deletions sdk/DTO/ActionDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace EAVFW.Extensions.Manifest.SDK
{
public class ActionDefinition
{
[JsonPropertyName("text")] public string Text { get; set; }
[JsonPropertyName("workflow")] public string Workflow { get; set; }

/// <summary>
/// Exclusively used to capture non-spec items
/// </summary>
[JsonExtensionData]
public Dictionary<string, object> AdditionalFields { get; set; }
}
}
85 changes: 85 additions & 0 deletions sdk/DTO/AttributeDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;

namespace EAVFW.Extensions.Manifest.SDK
{
public class AttributeConverter : JsonConverter<AttributeDefinitionBase>
{
public override AttributeDefinitionBase Read(
ref Utf8JsonReader reader,
Type typeToConvert,
JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case JsonTokenType.String:
return new AttributeStringDefinition { Value = reader.GetString() ?? "" };
case JsonTokenType.StartObject:
var node = JsonNode.Parse(ref reader);
var t = node.Deserialize<AttributeObjectDefinition>();
return t;
default:
throw new Exception($"{reader.TokenType} is not supported as AttributeDefinition");
}
}

public override void Write(Utf8JsonWriter writer, AttributeDefinitionBase value, JsonSerializerOptions options)
{
var jsonString = value switch
{
AttributeObjectDefinition attributeObjectDefinition =>
JsonSerializer.Serialize(attributeObjectDefinition),
AttributeStringDefinition attributeStringDefinition =>
JsonSerializer.Serialize(attributeStringDefinition),
_ => throw new ArgumentException($"{value.GetType()} is not supported")
};

var jsonNode = JsonNode.Parse(jsonString);
jsonNode?.WriteTo(writer, options);
}
}

[JsonConverter(typeof(AttributeConverter))]
public abstract class AttributeDefinitionBase
{
}

public class AttributeStringDefinition : AttributeDefinitionBase
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What case do we have where attribute is not an object?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"attributes": {
  "[merge()]": "[variables('audit')]",
  "Title": {
    "isPrimaryField": true
  },

Then the merge property is a string.

I build the first iteration on the non enriched version :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the moduleSource and moduleLocation is a part of attributes if they are merged from a variable

{
public string Value { get; set; }
}

public class AttributeObjectDefinition : AttributeDefinitionBase
{
[JsonPropertyName("isPrimaryField")] public bool IsPrimaryField { get; set; }

[JsonPropertyName("moduleSource")] public string ModuleSource { get; set; }

[JsonPropertyName("moduleLocation")] public string ModuleLocation { get; set; }

[JsonPropertyName("type")] public TypeDefinition AttributeType { get; set; }

/// <summary>
/// Exclusively used to capture non-spec items
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalFields { get; set; }
}

public class TypeDefinition
{
[JsonPropertyName("type")] public string Type { get; set; }
[JsonPropertyName("referenceType")] public string ReferenceType { get; set; }

[JsonPropertyName("options")] public Dictionary<string, JsonElement> Options { get; set; }

/// <summary>
/// Exclusively used to capture non-spec items
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalFields { get; set; }
}
}
19 changes: 19 additions & 0 deletions sdk/DTO/EntityDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace EAVFW.Extensions.Manifest.SDK
{
public class EntityDefinition
{
[JsonPropertyName("pluralName")] public string PluralName { get; set; }
[JsonPropertyName("description")] public string Description { get; set; }
[JsonPropertyName("attributes")] public Dictionary<string, AttributeDefinitionBase> Attributes { get; set; }
[JsonPropertyName("wizards")] public Dictionary<string, WizardDefinition> Wizards { get; set; }

/// <summary>
/// Exclusively used to capture non-spec items
/// </summary>
[JsonExtensionData]
public Dictionary<string, object> AdditionalFields { get; set; }
}
}
10 changes: 10 additions & 0 deletions sdk/DTO/ManifestDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace EAVFW.Extensions.Manifest.SDK
{
public class ManifestDefinition
{
[JsonPropertyName("entities")] public Dictionary<string, EntityDefinition> Entities { get; set; }
}
}
9 changes: 9 additions & 0 deletions sdk/DTO/MessageDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Text.Json.Serialization;

namespace EAVFW.Extensions.Manifest.SDK
{
public class MessageDefinition
{
[JsonPropertyName("title")] public string? Title { get; set; }

Check warning on line 7 in sdk/DTO/MessageDefinition.cs

View workflow job for this annotation

GitHub Actions / Building

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 7 in sdk/DTO/MessageDefinition.cs

View workflow job for this annotation

GitHub Actions / Building

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 7 in sdk/DTO/MessageDefinition.cs

View workflow job for this annotation

GitHub Actions / Building

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 7 in sdk/DTO/MessageDefinition.cs

View workflow job for this annotation

GitHub Actions / Building

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 7 in sdk/DTO/MessageDefinition.cs

View workflow job for this annotation

GitHub Actions / Building

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 7 in sdk/DTO/MessageDefinition.cs

View workflow job for this annotation

GitHub Actions / Building

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 7 in sdk/DTO/MessageDefinition.cs

View workflow job for this annotation

GitHub Actions / Building

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 7 in sdk/DTO/MessageDefinition.cs

View workflow job for this annotation

GitHub Actions / Building

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
}
}
30 changes: 30 additions & 0 deletions sdk/DTO/StringOrBoolean.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
namespace EAVFW.Extensions.Manifest.SDK
{
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 override string ToString()
{
return IsBool ? BooleanValue.ToString() : StringValue;
}
}
}
21 changes: 21 additions & 0 deletions sdk/DTO/TabDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace EAVFW.Extensions.Manifest.SDK
{
public class TabDefinition
{
[JsonPropertyName("columns")] public JsonElement Columns { get; set; }

[JsonConverter(typeof(StringOrBooleanTabConverter))]
[JsonPropertyName("visible")]
public StringOrBoolean Visible { get; set; }

[JsonPropertyName("onTransitionOut")] public TransitionDefinition OnTransitionOut { get; set; }

[JsonPropertyName("onTransitionIn")] public TransitionDefinition OnTransitionIn { get; set; }

[JsonPropertyName("actions")] public Dictionary<string, ActionDefinition> Actions { get; set; }
}
}
14 changes: 14 additions & 0 deletions sdk/DTO/TransitionDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace EAVFW.Extensions.Manifest.SDK
{
public class TransitionDefinition
{
[JsonPropertyName("workflow")] public string Workflow { get; set; }

[JsonPropertyName("message")] public MessageDefinition Message { get; set; }

[JsonExtensionData] public Dictionary<string, object> AdditionalData { get; set; } = new Dictionary<string, object>();
}
}
11 changes: 11 additions & 0 deletions sdk/DTO/TriggerDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Text.Json.Serialization;

namespace EAVFW.Extensions.Manifest.SDK
{
public struct TriggerDefinition
{
[JsonPropertyName("form")] public string Form { get; set; }

[JsonPropertyName("ribbon")] public string Ribbon { get; set; }
}
}
14 changes: 14 additions & 0 deletions sdk/DTO/WizardDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace EAVFW.Extensions.Manifest.SDK
{
public class WizardDefinition
{
[JsonPropertyName("title")] public string Title { get; set; }

[JsonPropertyName("triggers")] public Dictionary<string, TriggerDefinition> Triggers { get; set; }

[JsonPropertyName("tabs")] public Dictionary<string, TabDefinition> Tabs { get; set; }
}
}
1 change: 1 addition & 0 deletions sdk/EAVFW.Extensions.Manifest.SDK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@


<ItemGroup>
<PackageReference Include="System.Text.Json" Version="8.0.0"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="DotNETDevOps.JsonFunctions" Version="3.0.26" />
</ItemGroup>
Expand Down
30 changes: 30 additions & 0 deletions sdk/JsonConverters/StringOrBooleanTabConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace EAVFW.Extensions.Manifest.SDK
{
public class StringOrBooleanTabConverter : JsonConverter<StringOrBoolean>
{
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);
}
}
}
7 changes: 3 additions & 4 deletions src/EAVFramework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Microsoft.Azure.Cosmos.Table" Version="1.0.8" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' != 'net6.0' ">

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.17" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.17" />
</ItemGroup>
Expand All @@ -49,5 +48,5 @@
<ItemGroup>
<ProjectReference Include="..\sdk\EAVFW.Extensions.Manifest.SDK.csproj" />
</ItemGroup>
</Project>

</Project>
Loading