From ec7bc64ed3be2d938ea40fef1291d38636ef8793 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 16 Nov 2024 19:46:50 -0500 Subject: [PATCH] Undo the DRYness for CanonicalPackageName as it causes VS havoc --- .../InstallationExtensions.cs | 21 ++++++++++++------- ....Server.Host.Service.Wix.Extensions.csproj | 1 - .../Extensions/ValueTaskExtensions.cs | 4 +--- .../Extensions/VersionExtensions.cs | 4 +--- .../Http/CachedResponseStream.cs | 4 +--- .../Http/HttpClient.cs | 4 +--- .../Http/HttpClientFactory.cs | 4 +--- .../Http/IAbstractHttpClientFactory.cs | 4 +--- .../Http/IHttpClient.cs | 4 +--- .../Tgstation.Server.Common.csproj | 11 ++-------- 10 files changed, 22 insertions(+), 39 deletions(-) diff --git a/build/package/winget/Tgstation.Server.Host.Service.Wix.Extensions/InstallationExtensions.cs b/build/package/winget/Tgstation.Server.Host.Service.Wix.Extensions/InstallationExtensions.cs index 6747b1c764..ddecf51c9a 100644 --- a/build/package/winget/Tgstation.Server.Host.Service.Wix.Extensions/InstallationExtensions.cs +++ b/build/package/winget/Tgstation.Server.Host.Service.Wix.Extensions/InstallationExtensions.cs @@ -4,7 +4,6 @@ using System.IO; using System.ServiceProcess; - using Tgstation.Server.Common; using Tgstation.Server.Host.Common; using WixToolset.Dtf.WindowsInstaller; @@ -14,6 +13,12 @@ /// public static class InstallationExtensions { + /// + /// Package name + /// + /// As much as I'd like to use Tgstation.Server.Common.Constants.CanonicalPackageName here, attempting to reference it makes VS go crazy with fake errors. + const string CanonicalPackageName = "tgstation-server"; + /// /// Attempts to detach stop the existing tgstation-server service if it exists. /// @@ -30,18 +35,18 @@ session.Log("Begin DetachStopTgsServiceIfRunning"); ServiceController serviceController = null; - session.Log($"Searching for {Constants.CanonicalPackageName} service..."); + session.Log($"Searching for {CanonicalPackageName} service..."); try { foreach (var controller in ServiceController.GetServices()) - if (controller.ServiceName == Constants.CanonicalPackageName) + if (controller.ServiceName == CanonicalPackageName) serviceController = controller; else controller.Dispose(); if (serviceController == null || serviceController.Status != ServiceControllerStatus.Running) { - session.Log($"{Constants.CanonicalPackageName} service not found. Continuing."); + session.Log($"{CanonicalPackageName} service not found. Continuing."); return ActionResult.Success; } @@ -49,16 +54,16 @@ PipeCommands.CommandDetachingShutdown) .Value; - session.Log($"{Constants.CanonicalPackageName} service found. Sending command \"{PipeCommands.CommandDetachingShutdown}\" ({commandId})..."); + session.Log($"{CanonicalPackageName} service found. Sending command \"{PipeCommands.CommandDetachingShutdown}\" ({commandId})..."); serviceController.ExecuteCommand(commandId); - session.Log($"Command sent. Waiting for {Constants.CanonicalPackageName} service to stop..."); + session.Log($"Command sent. Waiting for {CanonicalPackageName} service to stop..."); serviceController.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromMinutes(1)); var stopped = serviceController.Status == ServiceControllerStatus.Stopped; - session.Log($"{Constants.CanonicalPackageName} stopped {(stopped ? String.Empty : "un")}successfully."); + session.Log($"{CanonicalPackageName} stopped {(stopped ? String.Empty : "un")}successfully."); return stopped ? ActionResult.Success @@ -92,7 +97,7 @@ session.Log("Begin ApplyProductionAppsettingsIfNonExistant"); var programDataDirectory = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), - Constants.CanonicalPackageName); + CanonicalPackageName); var initialAppSettingsPath = Path.Combine(programDataDirectory, "appsettings.Initial.yml"); var productionAppSettingsPath = Path.Combine(programDataDirectory, "appsettings.Production.yml"); diff --git a/build/package/winget/Tgstation.Server.Host.Service.Wix.Extensions/Tgstation.Server.Host.Service.Wix.Extensions.csproj b/build/package/winget/Tgstation.Server.Host.Service.Wix.Extensions/Tgstation.Server.Host.Service.Wix.Extensions.csproj index ad57e5fbd5..fcdbd512a6 100644 --- a/build/package/winget/Tgstation.Server.Host.Service.Wix.Extensions/Tgstation.Server.Host.Service.Wix.Extensions.csproj +++ b/build/package/winget/Tgstation.Server.Host.Service.Wix.Extensions/Tgstation.Server.Host.Service.Wix.Extensions.csproj @@ -11,7 +11,6 @@ - True diff --git a/src/Tgstation.Server.Common/Extensions/ValueTaskExtensions.cs b/src/Tgstation.Server.Common/Extensions/ValueTaskExtensions.cs index a01da554c0..1dead09d93 100644 --- a/src/Tgstation.Server.Common/Extensions/ValueTaskExtensions.cs +++ b/src/Tgstation.Server.Common/Extensions/ValueTaskExtensions.cs @@ -1,5 +1,4 @@ -#if NETSTANDARD2_0_OR_GREATER -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Threading.Tasks; @@ -156,4 +155,3 @@ namespace Tgstation.Server.Common.Extensions public static ValueTask WhenAll(params ValueTask[] tasks) => WhenAll((IReadOnlyList)tasks); } } -#endif diff --git a/src/Tgstation.Server.Common/Extensions/VersionExtensions.cs b/src/Tgstation.Server.Common/Extensions/VersionExtensions.cs index c67a4a096d..3e6b3102bd 100644 --- a/src/Tgstation.Server.Common/Extensions/VersionExtensions.cs +++ b/src/Tgstation.Server.Common/Extensions/VersionExtensions.cs @@ -1,5 +1,4 @@ -#if NETSTANDARD2_0_OR_GREATER -using System; +using System; namespace Tgstation.Server.Common.Extensions { @@ -25,4 +24,3 @@ namespace Tgstation.Server.Common.Extensions } } } -#endif diff --git a/src/Tgstation.Server.Common/Http/CachedResponseStream.cs b/src/Tgstation.Server.Common/Http/CachedResponseStream.cs index 77dd7b1ccb..eb007b54a5 100644 --- a/src/Tgstation.Server.Common/Http/CachedResponseStream.cs +++ b/src/Tgstation.Server.Common/Http/CachedResponseStream.cs @@ -1,5 +1,4 @@ -#if NETSTANDARD2_0_OR_GREATER -using System; +using System; using System.IO; using System.Net.Http; using System.Threading.Tasks; @@ -106,4 +105,3 @@ namespace Tgstation.Server.Common.Http } } } -#endif diff --git a/src/Tgstation.Server.Common/Http/HttpClient.cs b/src/Tgstation.Server.Common/Http/HttpClient.cs index 67431fef9d..692c10a304 100644 --- a/src/Tgstation.Server.Common/Http/HttpClient.cs +++ b/src/Tgstation.Server.Common/Http/HttpClient.cs @@ -1,5 +1,4 @@ -#if NETSTANDARD2_0_OR_GREATER -using System; +using System; using System.Net.Http; using System.Net.Http.Headers; using System.Threading; @@ -50,4 +49,3 @@ namespace Tgstation.Server.Common.Http => httpClient.SendAsync(request, completionOption, cancellationToken); } } -#endif diff --git a/src/Tgstation.Server.Common/Http/HttpClientFactory.cs b/src/Tgstation.Server.Common/Http/HttpClientFactory.cs index 02ab8cc00b..93659471b5 100644 --- a/src/Tgstation.Server.Common/Http/HttpClientFactory.cs +++ b/src/Tgstation.Server.Common/Http/HttpClientFactory.cs @@ -1,5 +1,4 @@ -#if NETSTANDARD2_0_OR_GREATER -using System; +using System; using System.Net.Http.Headers; namespace Tgstation.Server.Common.Http @@ -40,4 +39,3 @@ namespace Tgstation.Server.Common.Http } } } -#endif diff --git a/src/Tgstation.Server.Common/Http/IAbstractHttpClientFactory.cs b/src/Tgstation.Server.Common/Http/IAbstractHttpClientFactory.cs index 8bff723798..120712f2bb 100644 --- a/src/Tgstation.Server.Common/Http/IAbstractHttpClientFactory.cs +++ b/src/Tgstation.Server.Common/Http/IAbstractHttpClientFactory.cs @@ -1,5 +1,4 @@ -#if NETSTANDARD2_0_OR_GREATER -namespace Tgstation.Server.Common.Http +namespace Tgstation.Server.Common.Http { /// /// Creates s. @@ -13,4 +12,3 @@ namespace Tgstation.Server.Common.Http IHttpClient CreateClient(); } } -#endif diff --git a/src/Tgstation.Server.Common/Http/IHttpClient.cs b/src/Tgstation.Server.Common/Http/IHttpClient.cs index 537a7bcd77..d0ade7050d 100644 --- a/src/Tgstation.Server.Common/Http/IHttpClient.cs +++ b/src/Tgstation.Server.Common/Http/IHttpClient.cs @@ -1,5 +1,4 @@ -#if NETSTANDARD2_0_OR_GREATER -using System; +using System; using System.Net.Http; using System.Net.Http.Headers; using System.Threading; @@ -32,4 +31,3 @@ namespace Tgstation.Server.Common.Http Task SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken); } } -#endif diff --git a/src/Tgstation.Server.Common/Tgstation.Server.Common.csproj b/src/Tgstation.Server.Common/Tgstation.Server.Common.csproj index 4ec30e8da0..4b119caf8b 100644 --- a/src/Tgstation.Server.Common/Tgstation.Server.Common.csproj +++ b/src/Tgstation.Server.Common/Tgstation.Server.Common.csproj @@ -2,7 +2,7 @@ - $(TgsNugetNetFramework);net2.0 + $(TgsNugetNetFramework) $(TgsCommonLibraryVersion) enable Common functions for tgstation-server. @@ -10,7 +10,7 @@ $(TGS_NUGET_RELEASE_NOTES_COMMON) - + @@ -24,11 +24,4 @@ - - - - - - -