From a7f87579902b029b11261918592aedfb0d4adee2 Mon Sep 17 00:00:00 2001 From: allisterb Date: Sun, 24 Nov 2024 19:14:26 -0400 Subject: [PATCH] Use CompactJson dependency in build task. Can run build task from VS. --- .../CompileContracts.cs | 4 ++-- .../SolidityCompilerIO.cs | 12 ++++++------ .../Stratis.VS.SolidityProjectBuildTasks.csproj | 5 ++++- src/Stratis.VS.StratisEVM/StratisEVMPackage.cs | 1 + 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Stratis.VS.SolidityProjectBuildTasks/CompileContracts.cs b/src/Stratis.VS.SolidityProjectBuildTasks/CompileContracts.cs index bdb40b2..9818fc1 100644 --- a/src/Stratis.VS.SolidityProjectBuildTasks/CompileContracts.cs +++ b/src/Stratis.VS.SolidityProjectBuildTasks/CompileContracts.cs @@ -64,8 +64,8 @@ public override bool Execute() Log.LogError("Could not start npm process", psi.FileName + " " + psi.Arguments); return false; } - var ser = new Newtonsoft.Json.JsonSerializer(); - ser.Serialize(p.StandardInput, i); + + CompactJson.Serializer.Write(i, p.StandardInput, false); p.StandardInput.WriteLine(Environment.NewLine); p.StandardInput.Close(); Log.LogMessage(MessageImportance.High, p.StandardOutput.ReadToEnd()); diff --git a/src/Stratis.VS.SolidityProjectBuildTasks/SolidityCompilerIO.cs b/src/Stratis.VS.SolidityProjectBuildTasks/SolidityCompilerIO.cs index ef24272..0720d32 100644 --- a/src/Stratis.VS.SolidityProjectBuildTasks/SolidityCompilerIO.cs +++ b/src/Stratis.VS.SolidityProjectBuildTasks/SolidityCompilerIO.cs @@ -2,10 +2,12 @@ { using System; using System.Collections.Generic; + using System.Runtime.Serialization; - using System.Globalization; - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; + using CompactJson; + + using System.ComponentModel; + public partial class SolidityCompilerInput { @@ -15,12 +17,10 @@ public partial class SolidityCompilerInput [JsonProperty("sources")] public Dictionary Sources { get; set; } - [JsonProperty("settings", NullValueHandling = NullValueHandling.Ignore)] - + [JsonProperty("settings")] public Settings Settings { get; set; } } - [JsonObject(MissingMemberHandling = MissingMemberHandling.Ignore, ItemNullValueHandling = NullValueHandling.Ignore)] public partial class Settings { [JsonProperty("remappings")] diff --git a/src/Stratis.VS.SolidityProjectBuildTasks/Stratis.VS.SolidityProjectBuildTasks.csproj b/src/Stratis.VS.SolidityProjectBuildTasks/Stratis.VS.SolidityProjectBuildTasks.csproj index 237be4f..d91b508 100644 --- a/src/Stratis.VS.SolidityProjectBuildTasks/Stratis.VS.SolidityProjectBuildTasks.csproj +++ b/src/Stratis.VS.SolidityProjectBuildTasks/Stratis.VS.SolidityProjectBuildTasks.csproj @@ -11,7 +11,10 @@ - + + + + diff --git a/src/Stratis.VS.StratisEVM/StratisEVMPackage.cs b/src/Stratis.VS.StratisEVM/StratisEVMPackage.cs index 29a9eb8..a01b769 100644 --- a/src/Stratis.VS.StratisEVM/StratisEVMPackage.cs +++ b/src/Stratis.VS.StratisEVM/StratisEVMPackage.cs @@ -137,6 +137,7 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke Directory.CreateDirectory(Runtime.LocalAppDataDir.CombinePath("CustomProjectSystems", "Solidity", "Tools")); } await Runtime.CopyFileAsync(Runtime.AssemblyLocation.CombinePath("Stratis.VS.SolidityProjectBuildTasks.dll"), Runtime.LocalAppDataDir.CombinePath("CustomProjectSystems", "Solidity", "Tools", "Stratis.VS.SolidityProjectBuildTasks.dll")); + await Runtime.CopyFileAsync(Runtime.AssemblyLocation.CombinePath("CompactJson.dll"), Runtime.LocalAppDataDir.CombinePath("CustomProjectSystems", "Solidity", "Tools", "CompactJson.dll")); await File.WriteAllTextAsync(Runtime.LocalAppDataDir.CombinePath("CustomProjectSystems", "Solidity", "extdir.txt"), Runtime.AssemblyLocation); if (!Directory.Exists(Path.Combine(Runtime.AssemblyLocation, "node_modules")) || !File.Exists(Path.Combine(Runtime.AssemblyLocation, "node_modules", "solidity", "dist", "cli", "server.js")))