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

Pks/polylookup split #15

Merged
merged 8 commits into from
May 28, 2024
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Build

on:
pull_request:
Expand Down Expand Up @@ -63,10 +63,10 @@ jobs:
run: dotnet build -o ../build/net6.0/ -f net6.0 -c Release --no-restore -m:1

- name: Restore NuGet packages
run: dotnet restore EAVFramework.sln -p:TargetFramework=netcoreapp3.1
run: dotnet restore EAVFramework.sln -p:TargetFramework=net8.0

- name: Build solution
run: dotnet build -o ../build/netcoreapp3.1/ -f netcoreapp3.1 -c Release --no-restore -m:1
run: dotnet build -o ../build/net8.0/ -f net8.0 -c Release --no-restore -m:1

- name: Archive build to artifacts
uses: actions/upload-artifact@v2
Expand Down
54 changes: 51 additions & 3 deletions sdk/DTO/AttributeDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ public override AttributeDefinitionBase Read(
return new AttributeStringDefinition { Value = reader.GetString() ?? "" };
case JsonTokenType.StartObject:
var node = JsonNode.Parse(ref reader);
var t = node.Deserialize<AttributeObjectDefinition>();
return t;

var t = node.Deserialize<AttributeObjectDefinition>(new JsonSerializerOptions { Converters={ new TypeDefinitionConverter()} });
return t;


default:
throw new Exception($"{reader.TokenType} is not supported as AttributeDefinition");
}
Expand Down Expand Up @@ -51,10 +54,12 @@ public class AttributeStringDefinition : AttributeDefinitionBase
{
public string Value { get; set; }
}


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

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

Expand All @@ -69,9 +74,52 @@ public class AttributeObjectDefinition : AttributeDefinitionBase
public Dictionary<string, JsonElement> AdditionalFields { get; set; }
}

public class TypeDefinition

public class TypeDefinitionConverter : JsonConverter<TypeDefinition>
{
public override TypeDefinition Read(
ref Utf8JsonReader reader,
Type typeToConvert,
JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case JsonTokenType.String:
return new TypeDefinition { Type = reader.GetString() ?? "" };
case JsonTokenType.StartObject:
var node = JsonNode.Parse(ref reader);

var t = node.Deserialize<TypeDefinition>();
return t;


default:
throw new Exception($"{reader.TokenType} is not supported as AttributeDefinition");
}
}

public override void Write(Utf8JsonWriter writer, TypeDefinition value, JsonSerializerOptions options)
{
var jsonString = value switch
{
TypeDefinition attributeObjectDefinition =>
JsonSerializer.Serialize(attributeObjectDefinition),

_ => throw new ArgumentException($"{value.GetType()} is not supported")
};

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

// [JsonConverter(typeof(TypeDefinitionConverter))]

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

[JsonPropertyName("split")] public bool Split { get; set; }
[JsonPropertyName("referenceType")] public string ReferenceType { get; set; }

[JsonPropertyName("options")] public Dictionary<string, JsonElement> Options { get; set; }
Expand Down
32 changes: 27 additions & 5 deletions sdk/DTO/EntityDefinition.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
using Newtonsoft.Json;
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; }
[JsonProperty("pluralName")]
[JsonPropertyName("pluralName")]
public string PluralName { get; set; }

[JsonProperty("collectionSchemaName")]
[JsonPropertyName("collectionSchemaName")]
public string CollectionSchemaName { get; set; }

[JsonProperty("logicalName")]
[JsonPropertyName("logicalName")]
public string LogicalName { get; set; }


[JsonPropertyName("description")]
[JsonProperty("description")]
public string Description { get; set; }

[JsonPropertyName("attributes")]
[JsonProperty("attributes")]
public Dictionary<string, AttributeDefinitionBase> Attributes { get; set; }

[JsonPropertyName("wizards")]
[JsonProperty("wizards")]
public Dictionary<string, WizardDefinition> Wizards { get; set; }

/// <summary>
/// Exclusively used to capture non-spec items
/// </summary>
[JsonExtensionData]
[System.Text.Json.Serialization.JsonExtensionData]
[Newtonsoft.Json.JsonExtensionData]
public Dictionary<string, object> AdditionalFields { get; set; }
}
}
2 changes: 1 addition & 1 deletion sdk/DTO/MessageDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ namespace EAVFW.Extensions.Manifest.SDK
{
public class MessageDefinition
{
[JsonPropertyName("title")] public string? Title { get; set; }
[JsonPropertyName("title")] public string Title { get; set; }
}
}
12 changes: 4 additions & 8 deletions sdk/DefaultManifestReplacementRunner.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using DotNETDevOps.JsonFunctions;
using DotNETDevOps.JsonFunctions;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Newtonsoft.Json.Linq;
Expand Down Expand Up @@ -211,14 +211,10 @@ public async Task RunReplacements(JToken jsonraw, string customizationprefix, IL
}
else
{
try
{

parentObj.Add(childProp);
q.Enqueue(childProp);
}catch(Exception ex)
{
throw;
}

}

// parentObj.Add(childProp.Name, childProp.Value);
Expand Down Expand Up @@ -284,7 +280,7 @@ public async Task RunReplacements(JToken jsonraw, string customizationprefix, IL
}

}
catch (Exception ex)
catch (Exception)
{
Console.WriteLine($"{entityPath}| {attributePath}");
throw;
Expand Down
4 changes: 2 additions & 2 deletions sdk/EAVFW.Extensions.Manifest.SDK.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>

Expand Down
Loading
Loading