diff --git a/build/NewtonsoftJson.props b/build/NewtonsoftJson.props new file mode 100644 index 00000000000..da775538fbf --- /dev/null +++ b/build/NewtonsoftJson.props @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj b/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj index a9a49e05e19..2e8dc1c4e53 100644 --- a/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj +++ b/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj @@ -1,5 +1,6 @@ + $(TgsNugetNetFramework) @@ -28,8 +29,6 @@ - - diff --git a/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj b/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj index ef5a83c7a37..d76561899ce 100644 --- a/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj +++ b/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj @@ -18,7 +18,8 @@ - + + diff --git a/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs b/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs index 7386e856691..edaf3e408e0 100644 --- a/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs +++ b/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs @@ -5,6 +5,7 @@ using Tgstation.Server.Host.Extensions.Converters; using Tgstation.Server.Host.Properties; +using Tgstation.Server.Shared; namespace Tgstation.Server.Host.Components.Interop { diff --git a/src/Tgstation.Server.Host/Core/Application.cs b/src/Tgstation.Server.Host/Core/Application.cs index 9569d2510b7..36970000c59 100644 --- a/src/Tgstation.Server.Host/Core/Application.cs +++ b/src/Tgstation.Server.Host/Core/Application.cs @@ -50,7 +50,6 @@ using Tgstation.Server.Host.Controllers.Results; using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Extensions; -using Tgstation.Server.Host.Extensions.Converters; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Properties; @@ -61,6 +60,7 @@ using Tgstation.Server.Host.System; using Tgstation.Server.Host.Transfer; using Tgstation.Server.Host.Utils; +using Tgstation.Server.Shared; namespace Tgstation.Server.Host.Core { diff --git a/src/Tgstation.Server.Host/Setup/SetupWizard.cs b/src/Tgstation.Server.Host/Setup/SetupWizard.cs index c8007f16b50..04cc54a3bfd 100644 --- a/src/Tgstation.Server.Host/Setup/SetupWizard.cs +++ b/src/Tgstation.Server.Host/Setup/SetupWizard.cs @@ -23,11 +23,11 @@ using Tgstation.Server.Common; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Database; -using Tgstation.Server.Host.Extensions.Converters; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Properties; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; +using Tgstation.Server.Shared; using YamlDotNet.Serialization; @@ -986,14 +986,15 @@ async ValueTask SaveConfiguration( { SwarmConfiguration.Section, swarmConfiguration }, }; + var versionConverter = new VersionConverter(); var builder = new SerializerBuilder() - .WithTypeConverter(new VersionConverter()); + .WithTypeConverter(versionConverter); if (userConfigFileName.EndsWith(".json", StringComparison.OrdinalIgnoreCase)) builder.JsonCompatible(); var serializer = new SerializerBuilder() - .WithTypeConverter(new VersionConverter()) + .WithTypeConverter(versionConverter) .Build(); var serializedYaml = serializer.Serialize(map); diff --git a/src/Tgstation.Server.Host/Swarm/SwarmConstants.cs b/src/Tgstation.Server.Host/Swarm/SwarmConstants.cs index 988c60243ef..834b6718cf2 100644 --- a/src/Tgstation.Server.Host/Swarm/SwarmConstants.cs +++ b/src/Tgstation.Server.Host/Swarm/SwarmConstants.cs @@ -3,6 +3,7 @@ using Tgstation.Server.Api; using Tgstation.Server.Host.Extensions.Converters; +using Tgstation.Server.Shared; namespace Tgstation.Server.Host.Swarm { diff --git a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj index 9c5dbd6fefa..de23f6f7d8b 100644 --- a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj +++ b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj @@ -1,4 +1,4 @@ - + @@ -77,8 +77,6 @@ - - @@ -102,8 +100,6 @@ - - @@ -135,6 +131,7 @@ + diff --git a/src/Tgstation.Server.Shared/Tgstation.Server.Shared.csproj b/src/Tgstation.Server.Shared/Tgstation.Server.Shared.csproj new file mode 100644 index 00000000000..57442b94dcd --- /dev/null +++ b/src/Tgstation.Server.Shared/Tgstation.Server.Shared.csproj @@ -0,0 +1,23 @@ + + + + + net8.0 + enable + enable + + + + + + + + + + + + + + + + diff --git a/src/Tgstation.Server.Host/Extensions/Converters/VersionConverter.cs b/src/Tgstation.Server.Shared/VersionConverter.cs similarity index 90% rename from src/Tgstation.Server.Host/Extensions/Converters/VersionConverter.cs rename to src/Tgstation.Server.Shared/VersionConverter.cs index 48c593d72fb..b9766210e36 100644 --- a/src/Tgstation.Server.Host/Extensions/Converters/VersionConverter.cs +++ b/src/Tgstation.Server.Shared/VersionConverter.cs @@ -1,6 +1,4 @@ -using System; - -using Newtonsoft.Json; +using Newtonsoft.Json; using Tgstation.Server.Common.Extensions; @@ -8,7 +6,7 @@ using YamlDotNet.Core.Events; using YamlDotNet.Serialization; -namespace Tgstation.Server.Host.Extensions.Converters +namespace Tgstation.Server.Shared { /// /// and for serializing s in semver format. @@ -85,10 +83,10 @@ public override void WriteJson(JsonWriter? writer, object? value, JsonSerializer public bool Accepts(Type type) => CheckSupportsType(type, false); /// - public object ReadYaml(IParser parser, Type type) => throw new NotSupportedException("Deserialization not supported!"); // The default implementation is fine at handling this + public object ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeserializer) => throw new NotSupportedException("Deserialization not supported!"); // The default implementation is fine at handling this /// - public void WriteYaml(IEmitter? emitter, object? value, Type type) + public void WriteYaml(IEmitter? emitter, object? value, Type type, ObjectSerializer serializer) { ArgumentNullException.ThrowIfNull(emitter); diff --git a/tests/Tgstation.Server.Host.Tests/Extensions/Converters/TestVersionConverter.cs b/tests/Tgstation.Server.Shared.Tests/TestVersionConverter.cs similarity index 85% rename from tests/Tgstation.Server.Host.Tests/Extensions/Converters/TestVersionConverter.cs rename to tests/Tgstation.Server.Shared.Tests/TestVersionConverter.cs index deb2fc1760a..c5f8e26a370 100644 --- a/tests/Tgstation.Server.Host.Tests/Extensions/Converters/TestVersionConverter.cs +++ b/tests/Tgstation.Server.Shared.Tests/TestVersionConverter.cs @@ -1,11 +1,12 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; +using System; + +using Microsoft.VisualStudio.TestTools.UnitTesting; using Tgstation.Server.Common.Extensions; using YamlDotNet.Serialization; -namespace Tgstation.Server.Host.Extensions.Converters.Tests +namespace Tgstation.Server.Shared.Tests { [TestClass] public sealed class TestVersionConverter diff --git a/tests/Tgstation.Server.Shared.Tests/Tgstation.Server.Shared.Tests.csproj b/tests/Tgstation.Server.Shared.Tests/Tgstation.Server.Shared.Tests.csproj new file mode 100644 index 00000000000..a10b4c149e0 --- /dev/null +++ b/tests/Tgstation.Server.Shared.Tests/Tgstation.Server.Shared.Tests.csproj @@ -0,0 +1,12 @@ + + + + + $(TgsFrameworkVersion) + + + + + + + diff --git a/tgstation-server.sln b/tgstation-server.sln index a8b1f999bfa..81bcb0fb81d 100644 --- a/tgstation-server.sln +++ b/tgstation-server.sln @@ -29,6 +29,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{6FF654E6 build\Dockerfile = build\Dockerfile build\GenerateMigrations.sh = build\GenerateMigrations.sh build\logo.svg = build\logo.svg + build\NewtonsoftJson.props = build\NewtonsoftJson.props build\NugetCommon.props = build\NugetCommon.props build\OpenApiValidationSettings.json = build\OpenApiValidationSettings.json build\SrcCommon.props = build\SrcCommon.props @@ -261,7 +262,11 @@ Project("{B7DD6F7E-DEF8-4E67-B5B7-07EF123DB6F0}") = "Tgstation.Server.Host.Servi EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tgstation.Server.ReleaseNotes", "tools\Tgstation.Server.ReleaseNotes\Tgstation.Server.ReleaseNotes.csproj", "{69944039-65C2-40E1-9D86-0608FA0C2D70}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tgstation.Server.LogoGenerator", "tools\Tgstation.Server.LogoGenerator\Tgstation.Server.LogoGenerator.csproj", "{7F7FCFDF-271D-45C2-830C-BCCB19C57077}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tgstation.Server.LogoGenerator", "tools\Tgstation.Server.LogoGenerator\Tgstation.Server.LogoGenerator.csproj", "{7F7FCFDF-271D-45C2-830C-BCCB19C57077}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tgstation.Server.Shared", "src\Tgstation.Server.Shared\Tgstation.Server.Shared.csproj", "{74B9AC97-DEEC-49F4-B3B3-E07126A52B47}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tgstation.Server.Shared.Tests", "tests\Tgstation.Server.Shared.Tests\Tgstation.Server.Shared.Tests.csproj", "{EAB84FD0-5514-4254-B188-7D90ACB7284D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -533,6 +538,30 @@ Global {7F7FCFDF-271D-45C2-830C-BCCB19C57077}.ReleaseNoWindows|Any CPU.Build.0 = Release|Any CPU {7F7FCFDF-271D-45C2-830C-BCCB19C57077}.ReleaseNoWix|Any CPU.ActiveCfg = Release|Any CPU {7F7FCFDF-271D-45C2-830C-BCCB19C57077}.ReleaseNoWix|Any CPU.Build.0 = Release|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.Debug|Any CPU.Build.0 = Debug|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.DebugNoWindows|Any CPU.ActiveCfg = Debug|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.DebugNoWindows|Any CPU.Build.0 = Debug|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.DebugNoWix|Any CPU.ActiveCfg = Debug|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.DebugNoWix|Any CPU.Build.0 = Debug|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.Release|Any CPU.ActiveCfg = Release|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.Release|Any CPU.Build.0 = Release|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.ReleaseNoWindows|Any CPU.ActiveCfg = Release|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.ReleaseNoWindows|Any CPU.Build.0 = Release|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.ReleaseNoWix|Any CPU.ActiveCfg = Release|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.ReleaseNoWix|Any CPU.Build.0 = Release|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.DebugNoWindows|Any CPU.ActiveCfg = Debug|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.DebugNoWindows|Any CPU.Build.0 = Debug|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.DebugNoWix|Any CPU.ActiveCfg = Debug|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.DebugNoWix|Any CPU.Build.0 = Debug|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.Release|Any CPU.Build.0 = Release|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.ReleaseNoWindows|Any CPU.ActiveCfg = Release|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.ReleaseNoWindows|Any CPU.Build.0 = Release|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.ReleaseNoWix|Any CPU.ActiveCfg = Release|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.ReleaseNoWix|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -571,6 +600,7 @@ Global {9E66C6F1-E235-4979-83B5-C2B3FDAD6E01} = {506B9092-AF88-4DA2-84FD-C11646B695B0} {69944039-65C2-40E1-9D86-0608FA0C2D70} = {A55C1117-5808-4AB2-BEA6-4D4A3E66A2F2} {7F7FCFDF-271D-45C2-830C-BCCB19C57077} = {A55C1117-5808-4AB2-BEA6-4D4A3E66A2F2} + {EAB84FD0-5514-4254-B188-7D90ACB7284D} = {316141B0-CD21-4769-A013-D53DA9B9EC09} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {DFD36C95-3E49-41C7-ACDB-86BAF5B18A79} diff --git a/tools/Tgstation.Server.ReleaseNotes/Program.cs b/tools/Tgstation.Server.ReleaseNotes/Program.cs index 388eafe6cb2..d65432f591b 100644 --- a/tools/Tgstation.Server.ReleaseNotes/Program.cs +++ b/tools/Tgstation.Server.ReleaseNotes/Program.cs @@ -25,7 +25,7 @@ using Octokit; using Octokit.GraphQL; -using Tgstation.Server.Host.Extensions.Converters; +using Tgstation.Server.Shared; using YamlDotNet.Serialization; diff --git a/tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj b/tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj index 4c87963970b..772bc7c7174 100644 --- a/tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj +++ b/tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj @@ -12,7 +12,7 @@ - +