diff --git a/.github/workflows/nugetci.yml b/.github/workflows/nugetci.yml index 8e4a8359..906f1733 100644 --- a/.github/workflows/nugetci.yml +++ b/.github/workflows/nugetci.yml @@ -25,12 +25,17 @@ jobs: - name: dotnet pack run: dotnet pack RulesEngineEditor.sln -c Release --no-build --include-source --include-symbols -o nupkg - - name: Publish NuGet packages + - name: setup nuget if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: NuGet/setup-nuget@v1.0.6 env: - NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} - shell: pwsh - run: | - echo "Packing results:" - Get-ChildItem -Recurse nupkg | Format-List -Property FullName,Length - dotnet nuget push "nupkg/*.nupkg" -s https://api.nuget.org/v3/index.json -k $env:NUGET_API_KEY --skip-duplicate \ No newline at end of file + ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' + with: + nuget-version: latest + + - name: Publish NuGet + uses: brandedoutcast/publish-nuget@v2 + with: + PROJECT_FILE_PATH: src/RulesEngineEditor/RulesEngineEditor.csproj + NUGET_KEY: ${{ secrets.NUGET_API_KEY }} + PACKAGE_NAME: RulesEngineEditor \ No newline at end of file diff --git a/src/RulesEngineEditor/Pages/RulesEngineEditorPage.razor.cs b/src/RulesEngineEditor/Pages/RulesEngineEditorPage.razor.cs index 507f1658..ce44e1bd 100644 --- a/src/RulesEngineEditor/Pages/RulesEngineEditorPage.razor.cs +++ b/src/RulesEngineEditor/Pages/RulesEngineEditorPage.razor.cs @@ -80,12 +80,9 @@ partial class RulesEngineEditorPage : ComponentBase protected override async Task OnInitializedAsync() { - jsonOptions = new JsonSerializerOptions { - DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + jsonOptions = new JsonSerializerOptions(RulesEngineJsonSourceContext.Default.Options) { IncludeFields = true, - WriteIndented = true, Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping, - PropertyNameCaseInsensitive = true, Converters = { new JsonStringEnumConverter() } }; @@ -207,7 +204,12 @@ private void InputUpdate() private void UpdateInputs() { - var serializationOptions = new JsonSerializerOptions { Converters = { new JsonStringEnumConverter() } }; + var serializationOptions = new JsonSerializerOptions { + Converters = { new JsonStringEnumConverter() }, + WriteIndented = true, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping + }; inputJSONErrors = ""; List newInputs = new List(); @@ -233,7 +235,7 @@ private void UpdateInputs() if (inputJSONErrors == "") { - InputJSON = JsonNormalizer.Normalize(JsonSerializer.Serialize(newInputs, jsonOptions)); + InputJSON = JsonNormalizer.Normalize(JsonSerializer.Serialize(newInputs, serializationOptions)); } } diff --git a/src/RulesEngineEditor/RulesEngineEditor.csproj b/src/RulesEngineEditor/RulesEngineEditor.csproj index d0d4d3d2..f14b7e82 100644 --- a/src/RulesEngineEditor/RulesEngineEditor.csproj +++ b/src/RulesEngineEditor/RulesEngineEditor.csproj @@ -13,9 +13,9 @@ https://github.com/alexreich/RulesEngineEditor/blob/main/CHANGELOG.md RulesEngineEditor.png - 1.4.5 - 1.4.5.0 - 1.4.5.0 + 1.4.6 + 1.4.6.0 + 1.4.6.0 README.md diff --git a/src/RulesEngineEditor/Shared/RulesEngineJsonSourceContext.cs b/src/RulesEngineEditor/Shared/RulesEngineJsonSourceContext.cs index 36de0da1..5e7b9f72 100644 --- a/src/RulesEngineEditor/Shared/RulesEngineJsonSourceContext.cs +++ b/src/RulesEngineEditor/Shared/RulesEngineJsonSourceContext.cs @@ -10,6 +10,8 @@ namespace RulesEngineEditor.Shared { [JsonSourceGenerationOptions( WriteIndented = true, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + PropertyNameCaseInsensitive = true, GenerationMode = JsonSourceGenerationMode.Default)] [JsonSerializable(typeof(Workflow[]))] [JsonSerializable(typeof(RuleData))] @@ -17,6 +19,15 @@ namespace RulesEngineEditor.Shared [JsonSerializable(typeof(List))] // Added for WorkflowData list [JsonSerializable(typeof(InputRuleParameterDictionary))] // Added for InputRuleParameterDictionary [JsonSerializable(typeof(List))] // Added for list of InputRuleParameterDictionary + [JsonSerializable(typeof(JsonElement))] // Added for dynamic JSON deserialization + // Primitive types for Dictionary values in InputRuleParameterDictionary + [JsonSerializable(typeof(string))] + [JsonSerializable(typeof(int))] + [JsonSerializable(typeof(long))] + [JsonSerializable(typeof(double))] + [JsonSerializable(typeof(bool))] + [JsonSerializable(typeof(decimal))] + [JsonSerializable(typeof(object))] public partial class RulesEngineJsonSourceContext : JsonSerializerContext { // Removed manually implemented members.