From f036d3a959f3215dacc4db5ad90ccfd596e3b919 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Thu, 11 May 2023 20:04:58 +0200 Subject: [PATCH 01/41] update deps --- Directory.Build.props | 2 +- sample/SampleApplication/SampleApplication.csproj | 2 +- ...roGlyph.Games.EawFoc.Clients.Steam.Windows.csproj | 12 ++++++------ ...ph.Games.EawFoc.Clients.Steam.Windows.Test.csproj | 6 +++--- ...PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj | 6 +++--- .../test/Arguments/ArgumentCollectionTest.cs | 1 - .../test/PetroGlyph.Games.EawFoc.Clients.Test.csproj | 6 +++--- src/PetroGlyph.Games.EawFoc/src/Mods/ModBase.cs | 1 - .../src/Mods/ModDependencyEntry.cs | 2 +- .../src/PetroGlyph.Games.EawFoc.csproj | 12 ++++++------ .../test/ModDependencyEntryTest.cs | 2 +- .../test/ModEqualityComparerTest.cs | 1 - .../ModDependencyResolverIntegrationTest.cs | 2 +- .../test/ModServices/ModIdentifierBuilderTest.cs | 2 +- .../test/PetroGlyph.Games.EawFoc.Test.csproj | 6 +++--- version.json | 2 +- 16 files changed, 31 insertions(+), 34 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 8fd7dede..2d1293c6 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -19,7 +19,7 @@ all - 3.5.119 + 3.6.128 diff --git a/sample/SampleApplication/SampleApplication.csproj b/sample/SampleApplication/SampleApplication.csproj index 17b61e09..17deeae8 100644 --- a/sample/SampleApplication/SampleApplication.csproj +++ b/sample/SampleApplication/SampleApplication.csproj @@ -17,7 +17,7 @@ - + diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj index 2445024e..6172a16e 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj @@ -22,12 +22,12 @@ - - - - - - + + + + + + diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj index a71fa913..97e77836 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj @@ -8,14 +8,14 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj index 159dd62a..44c8d9c2 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj @@ -9,14 +9,14 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCollectionTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCollectionTest.cs index 86344046..320eaaae 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCollectionTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCollectionTest.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using Castle.DynamicProxy.Generators; using PetroGlyph.Games.EawFoc.Clients.Arguments; using PetroGlyph.Games.EawFoc.Clients.Arguments.GameArguments; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/PetroGlyph.Games.EawFoc.Clients.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients/test/PetroGlyph.Games.EawFoc.Clients.Test.csproj index 46d49cff..d902765a 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/PetroGlyph.Games.EawFoc.Clients.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/PetroGlyph.Games.EawFoc.Clients.Test.csproj @@ -9,14 +9,14 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/PetroGlyph.Games.EawFoc/src/Mods/ModBase.cs b/src/PetroGlyph.Games.EawFoc/src/Mods/ModBase.cs index e56d253b..c9fd6cf8 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Mods/ModBase.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Mods/ModBase.cs @@ -12,7 +12,6 @@ using PetroGlyph.Games.EawFoc.Services.Icon; using PetroGlyph.Games.EawFoc.Services.Language; using Semver; -using Semver.Ranges; using Validation; namespace PetroGlyph.Games.EawFoc.Mods; diff --git a/src/PetroGlyph.Games.EawFoc/src/Mods/ModDependencyEntry.cs b/src/PetroGlyph.Games.EawFoc/src/Mods/ModDependencyEntry.cs index f95c2e58..c4fd35aa 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Mods/ModDependencyEntry.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Mods/ModDependencyEntry.cs @@ -1,6 +1,6 @@ using System; using EawModinfo.Spec; -using Semver.Ranges; +using Semver; using Validation; namespace PetroGlyph.Games.EawFoc.Mods; diff --git a/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj b/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj index a8300708..adaf35a3 100644 --- a/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj +++ b/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj @@ -19,17 +19,17 @@ - - - - + + + + - - + + \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/test/ModDependencyEntryTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModDependencyEntryTest.cs index fb440c95..8b367f1a 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModDependencyEntryTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModDependencyEntryTest.cs @@ -1,7 +1,7 @@ using System; using Moq; using PetroGlyph.Games.EawFoc.Mods; -using Semver.Ranges; +using Semver; using Xunit; namespace PetroGlyph.Games.EawFoc.Test; diff --git a/src/PetroGlyph.Games.EawFoc/test/ModEqualityComparerTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModEqualityComparerTest.cs index a805f735..0eaf7e51 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModEqualityComparerTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModEqualityComparerTest.cs @@ -4,7 +4,6 @@ using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Mods; using Semver; -using Semver.Ranges; using Xunit; namespace PetroGlyph.Games.EawFoc.Test; diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverIntegrationTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverIntegrationTest.cs index 24308eb8..04bff57f 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverIntegrationTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverIntegrationTest.cs @@ -9,7 +9,7 @@ using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Mods; using PetroGlyph.Games.EawFoc.Services.Dependencies; -using Semver.Ranges; +using Semver; using Xunit; namespace PetroGlyph.Games.EawFoc.Test.ModServices; diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModIdentifierBuilderTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModIdentifierBuilderTest.cs index bc9d80fc..90341837 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModIdentifierBuilderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModIdentifierBuilderTest.cs @@ -7,7 +7,7 @@ using Moq; using PetroGlyph.Games.EawFoc.Mods; using PetroGlyph.Games.EawFoc.Services.Detection; -using Semver.Ranges; +using Semver; using Xunit; namespace PetroGlyph.Games.EawFoc.Test.ModServices; diff --git a/src/PetroGlyph.Games.EawFoc/test/PetroGlyph.Games.EawFoc.Test.csproj b/src/PetroGlyph.Games.EawFoc/test/PetroGlyph.Games.EawFoc.Test.csproj index dfade1ed..7a172a40 100644 --- a/src/PetroGlyph.Games.EawFoc/test/PetroGlyph.Games.EawFoc.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc/test/PetroGlyph.Games.EawFoc.Test.csproj @@ -10,15 +10,15 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/version.json b/version.json index c81df559..c5b97804 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "2.0-beta", + "version": "2.0", "publicReleaseRefSpec": [ "^refs/heads/main" ], From f144437bd54ff6b80c90f0274d7c399ed867c9c2 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Mon, 15 May 2023 17:04:05 +0200 Subject: [PATCH 02/41] updates --- Directory.Build.props | 2 +- .../SampleApplication.csproj | 1 - ....Games.EawFoc.Clients.Steam.Windows.csproj | 5 +- .../src/SteamRegistry.cs | 5 +- ...s.EawFoc.Clients.Steam.Windows.Test.csproj | 2 +- ...yph.Games.EawFoc.Clients.Steam.Test.csproj | 2 +- ...etroGlyph.Games.EawFoc.Clients.Test.csproj | 2 +- .../src/IWindowsRegistry.cs | 141 ------------------ .../src/PetroGlyph.Games.EawFoc.csproj | 3 +- .../test/PetroGlyph.Games.EawFoc.Test.csproj | 2 +- 10 files changed, 10 insertions(+), 155 deletions(-) delete mode 100644 src/PetroGlyph.Games.EawFoc/src/IWindowsRegistry.cs diff --git a/Directory.Build.props b/Directory.Build.props index 2d1293c6..16b45899 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -19,7 +19,7 @@ all - 3.6.128 + 3.6.132 diff --git a/sample/SampleApplication/SampleApplication.csproj b/sample/SampleApplication/SampleApplication.csproj index 17deeae8..bc11be91 100644 --- a/sample/SampleApplication/SampleApplication.csproj +++ b/sample/SampleApplication/SampleApplication.csproj @@ -17,7 +17,6 @@ - diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj index 6172a16e..26e87a7f 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj @@ -20,11 +20,10 @@ + - - - + diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamRegistry.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamRegistry.cs index 2759fd36..522ab99e 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamRegistry.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamRegistry.cs @@ -3,7 +3,6 @@ using System.IO.Abstractions; using System.Linq; using AnakinRaW.CommonUtilities.Registry; -using AnakinRaW.CommonUtilities.Registry.Windows; using Microsoft.Extensions.DependencyInjection; #if NET using System.Diagnostics.CodeAnalysis; @@ -98,10 +97,10 @@ public ISet? InstalledApps public SteamRegistry(IServiceProvider serviceProvider) { - _registryKey = new WindowsRegistry() + _registryKey = serviceProvider.GetRequiredService() .OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default) .CreateSubKey("Software\\Valve\\Steam"); - _fileSystem = serviceProvider.GetService() ?? new FileSystem(); + _fileSystem = serviceProvider.GetRequiredService(); } diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj index 97e77836..77eba874 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj @@ -15,7 +15,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj index 44c8d9c2..3ff855d5 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj @@ -16,7 +16,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/PetroGlyph.Games.EawFoc.Clients.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients/test/PetroGlyph.Games.EawFoc.Clients.Test.csproj index d902765a..264d05f2 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/PetroGlyph.Games.EawFoc.Clients.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/PetroGlyph.Games.EawFoc.Clients.Test.csproj @@ -16,7 +16,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/PetroGlyph.Games.EawFoc/src/IWindowsRegistry.cs b/src/PetroGlyph.Games.EawFoc/src/IWindowsRegistry.cs deleted file mode 100644 index ab155b69..00000000 --- a/src/PetroGlyph.Games.EawFoc/src/IWindowsRegistry.cs +++ /dev/null @@ -1,141 +0,0 @@ -using System; -using Microsoft.Win32; - -namespace PetroGlyph.Games.EawFoc; - -/// -/// High-Level abstraction layer for the Windows Registry. -/// Each method is scoped to a the instance's . -/// This service supports read and write operations. -/// -public interface IWindowsRegistry : IDisposable -{ - /// - /// The root key of this instance. - /// All methods use this key as a base and subpath are built based on this key. - /// It also holds the registry view (32bit/64bit). - /// - RegistryKey RootKey { get; } - - /// - /// Tries to get a value from a registry key. - /// - /// The requested type of the key's value. - /// The name of the key. - /// The sub path of the key. - /// The returned value or if no value could be found. - /// - bool GetValueOrDefault(string name, string subPath, out T? result, T? defaultValue); - - /// - /// Tries to get a value from a registry key. - /// - /// The requested type of the key's value. - /// The name of the key. - /// The returned value or if no value could be found. - /// if a value was found; otherwise. - /// if a value was found; otherwise. - bool GetValueOrDefault(string name, out T? result, T? defaultValue); - - /// - /// Checks whether a given path exists in the registry. - /// - /// The requested path. - /// if a path exists; otherwise. - bool HasPath(string path); - - /// - /// Checks whether a given key exists in the registry. - /// - /// The requested key. - /// if a key exists; otherwise. - bool HasValue(string name); - - /// - /// Gets the value of a given key. - /// - /// The requested type of the key's value. - /// The name of the key. - /// The sub path of the key. - /// The returned value or default value if no value could be found. - /// if a value was found; otherwise. - bool GetValue(string name, string subPath, out T? value); - - /// - /// Gets the value of a given key. - /// - /// The requested type of the key's value. - /// The name of the key. - /// The returned value or default value if no value could be found. - /// if a value was found; otherwise. - bool GetValue(string name, out T? value); - - /// - /// Gets the of a given path. - /// - /// The sub-path. - /// Set to if write access is required. Default is . - /// The registry key or if the operation failed. - RegistryKey? GetKey(string subPath, bool writable = false); - - /// - /// Tries to get a value from a registry key. If the key did not exist, a key with a given default value gets created. - /// - /// The requested type of the key's value. - /// The name of the key. - /// The default value which shall be set - /// Gets set to if was set; otherwise. - /// The actual or default value of the key. - T? GetValueOrSetDefault(string name, T? defaultValue, out bool defaultValueUsed); - - /// - /// Tries to get a value from a registry key. If the key did not exist, a key with a given default value gets created. - /// - /// The requested type of the key's value. - /// The name of the key. - /// The sub-path. - /// The default value which shall be set. - /// Gets set to if was set; otherwise. - /// The actual or default value of the key. - /// If the requested registry key could not be found. - T? GetValueOrSetDefault(string name, string subPath, T? defaultValue, out bool defaultValueUsed); - - /// - /// Tries to write a value from a registry key. - /// - /// The name of the key. - /// The value which shall be set. - /// if a value was set successfully; otherwise. - bool WriteValue(string name, object value); - - /// - /// Tries to write a value from a registry key. - /// - /// The name of the key. - /// The sub-path. - /// The value which shall be set. - /// if a value was set successfully; otherwise. - bool WriteValue(string name, string subPath, object value); - - /// - /// Tries to delete a value from a registry key. - /// - /// The name of the key. - /// if a value was deleted successfully; otherwise. - bool DeleteValue(string name); - - /// - /// Tries to delete a value from a registry key. - /// - /// The name of the key. - /// The sub-path. - /// if a value was deleted successfully; otherwise. - bool DeleteValue(string name, string subPath); - - /// - /// Retrieves an array of strings that contains all the subkey names or if the operation failed. - /// - /// The sub-path. - /// An array of strings that contains the names of the subkeys for the given . - string[]? GetSubKeyNames(string subPath); -} \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj b/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj index adaf35a3..7a2770bb 100644 --- a/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj +++ b/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj @@ -26,9 +26,8 @@ - - + diff --git a/src/PetroGlyph.Games.EawFoc/test/PetroGlyph.Games.EawFoc.Test.csproj b/src/PetroGlyph.Games.EawFoc/test/PetroGlyph.Games.EawFoc.Test.csproj index 7a172a40..96013ad2 100644 --- a/src/PetroGlyph.Games.EawFoc/test/PetroGlyph.Games.EawFoc.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc/test/PetroGlyph.Games.EawFoc.Test.csproj @@ -18,7 +18,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive From 99e3286be1514fd668a56f8375680dda31a711d3 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Tue, 12 Mar 2024 21:29:10 +0100 Subject: [PATCH 03/41] update workflows --- .github/workflows/codeql-analysis.yml | 4 ++-- .github/workflows/release.yml | 16 ++++++++-------- .github/workflows/test.yml | 12 ++++-------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index ba0e021b..35b0ca2e 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -18,9 +18,9 @@ jobs: with: fetch-depth: 0 - name: Setup .NET Core SDK - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: - dotnet-version: '6.0.x' + dotnet-version: '8.0.x' - name: Initialize CodeQL uses: github/codeql-action/init@v2 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f9e62f5f..a165cfbd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,15 +18,15 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout sources - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 - name: Create packages run: dotnet pack --configuration Release --output ./packages - name: Upload a Build Artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: NuGet packages path: packages/*.* @@ -39,21 +39,21 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout sources - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup .NET - uses: actions/setup-dotnet@v3 - - uses: actions/download-artifact@v3 + uses: actions/setup-dotnet@v4 + - uses: actions/download-artifact@v4 with: name: NuGet packages path: packages - name: Push packages run: dotnet nuget push "packages/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json - - uses: dotnet/nbgv@v0.4.0 + - uses: dotnet/nbgv@v0.4.2 id: nbgv - name: Create GitHub release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: name: v${{ steps.nbgv.outputs.SemVer2 }} tag_name: v${{ steps.nbgv.outputs.SemVer2 }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 60ebf8b2..83e26e38 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,16 +18,12 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-dotnet@v3 + - uses: actions/setup-dotnet@v4 with: - dotnet-version: '6.0.x' + dotnet-version: '8.0.x' - name: Build & Test in Release Mode - run: dotnet test --configuration Release --logger "GitHubActions" - - - name: Build & Test .NET Framework - if: matrix.os == 'windows-latest' - run: dotnet test --configuration Release -f net48 --logger "GitHubActions" \ No newline at end of file + run: dotnet test --configuration Release --logger "GitHubActions" \ No newline at end of file From 5f2944ddcffaec78e20cf559026c143bd10e4c73 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Thu, 14 Mar 2024 10:47:19 +0100 Subject: [PATCH 04/41] update deps --- AlamoEngineTools.snk | Bin 596 -> 0 bytes Directory.Build.props | 10 +- PetroGlyphGameInfrastructure.sln | 9 +- global.json | 8 - .../SampleApplication.csproj | 4 +- .../src/AssemblyInfo.cs | 9 - ....Games.EawFoc.Clients.Steam.Windows.csproj | 11 +- .../src/Properties/AssemblyInfo.cs | 4 + .../src/SteamGameFinder.cs | 5 +- .../src/SteamLibrary.cs | 31 +- .../src/SteamLibraryFinder.cs | 6 +- .../src/SteamVdfReader.cs | 18 +- .../src/SteamWrapper.cs | 8 +- .../src/Threading/AwaitExtensions.cs | 14 +- .../src/Threading/NoMessagePumpSyncContext.cs | 4 +- .../src/Threading/SpecializedSyncContext.cs | 3 +- .../src/Threading/TplExtensions.cs | 4 +- ...s.EawFoc.Clients.Steam.Windows.Test.csproj | 19 +- .../test/Steam/SteamGameFinderTest.cs | 2 +- .../test/Steam/SteamLibraryFinderTest.cs | 31 +- .../test/Steam/SteamLibraryTest.cs | 29 +- .../test/Steam/SteamVdfReaderTest.cs | 41 +-- .../test/Steam/SteamWrapperTest.cs | 18 +- .../src/AssemblyInfo.cs | 9 - ...troGlyph.Games.EawFoc.Clients.Steam.csproj | 4 - .../src/Properties/AssemblyInfo.cs | 4 + .../src/SteamAppManifest.cs | 19 +- .../src/SteamGameClient.cs | 6 +- .../src/SteamGameLanguageFinder.cs | 4 +- ...yph.Games.EawFoc.Clients.Steam.Test.csproj | 18 +- .../test/SteamGameClientTest.cs | 4 +- .../test/SteamGameLanguageFinderTest.cs | 10 +- ...SteamPetroglyphStarWarsGameDetectorTest.cs | 18 +- .../Arguments/ArgumentCommandLineBuilder.cs | 6 +- .../src/Arguments/ArgumentValueSerializer.cs | 42 +-- .../src/Arguments/GameArgument.cs | 6 +- .../Arguments/GameArguments/GameArguments.cs | 198 +++--------- .../KeyBasedArgumentCollectionBuilder.cs | 12 +- .../src/Arguments/ModArgumentListFactory.cs | 4 +- .../Arguments/SerializeEnumNameAttribute.cs | 9 + .../Arguments/SerializeEnumValueAttribute.cs | 9 + .../src/AssemblyInfo.cs | 17 -- .../src/ClientBase.cs | 14 +- .../src/DefaultClient.cs | 2 +- .../src/GameExecutableFileService.cs | 11 +- .../PetroGlyph.Games.EawFoc.Clients.csproj | 1 - .../Processes/DefaultGameProcessLauncher.cs | 11 +- .../src/Processes/GameProcess.cs | 9 +- .../src/Processes/GameProcessInfo.cs | 10 +- .../src/Properties/AssemblyInfo.cs | 8 + .../src/Threading/AwaitExtensions.cs | 103 +++---- .../Arguments/ArgumentValueSerializerTest.cs | 21 +- .../Arguments/ModArgumentListFactoryTest.cs | 6 +- .../test/ClientBaseTest.cs | 10 +- .../test/DebugableClientBaseTest.cs | 17 +- .../test/DefaultClientTest.cs | 4 +- .../test/GameExecutableFileServiceTest.cs | 13 +- ...etroGlyph.Games.EawFoc.Clients.Test.csproj | 19 +- .../DefaultGameProcessLauncherTest.cs | 11 +- .../src/AssemblyInfo.cs | 11 - .../src/Games/PetroglyphStarWarsGame.cs | 47 +-- .../src/Games/Registry/GameRegistryBase.cs | 6 +- .../src/Games/Registry/GameRegistryFactory.cs | 5 +- src/PetroGlyph.Games.EawFoc/src/Mods/Mod.cs | 42 +-- .../src/Mods/ModBase.cs | 26 +- .../src/Mods/ModDependencyEntry.cs | 4 +- .../src/Mods/VirtualMod.cs | 6 +- .../src/PetroGlyph.Games.EawFoc.csproj | 26 +- .../src/Properties/AssemblyInfo.cs | 5 + .../Games/Detection/CompositeGameDetector.cs | 6 +- .../Games/Detection/DirectoryGameDetector.cs | 4 +- .../Games/Detection/GameDetectionResult.cs | 4 +- .../Services/Games/Detection/GameDetector.cs | 4 +- .../Games/Detection/GameDetectorOptions.cs | 10 +- .../Platform/GamePlatformIdentifier.cs | 12 +- .../Games/Detection/RegistryGameDetector.cs | 7 +- .../src/Services/Games/GameFactory.cs | 16 +- .../Games/Icon/CompositeGameIconFinder.cs | 9 +- .../Games/Icon/FallbackGameIconFinder.cs | 4 +- .../Games/Language/GameLanguageFinder.cs | 4 +- .../Games/Name/EnglishGameNameResolver.cs | 7 +- .../Services/Games/Steam/SteamGameHelpers.cs | 18 +- .../Dependencies/ModDependencyGraphBuilder.cs | 20 +- .../Dependencies/ModDependencyResolver.cs | 12 +- .../Dependencies/ModDependencyTraverser.cs | 4 +- .../MultiModDependencyResolver.cs | 15 +- .../Mods/Detection/FileSystemModFinder.cs | 21 +- .../Mods/Detection/IModIdentiferNormalizer.cs | 5 +- .../Mods/Detection/ModIdentifierBuilder.cs | 18 +- .../Detection/ModReferenceLocationResolver.cs | 12 +- .../Mods/Icon/CompositeModIconFinder.cs | 10 +- .../Services/Mods/Icon/SimpleModIconFinder.cs | 5 +- .../Mods/Language/ModLanguageFinderBase.cs | 4 +- .../src/Services/Mods/ModFactory.cs | 11 +- .../Mods/Name/CompositeModNameResolver.cs | 15 +- .../Mods/Name/DirectoryModNameResolver.cs | 2 +- .../Services/Mods/Name/ModNameResolverBase.cs | 11 +- .../Mods/Name/OnlineWorkshopNameResolver.cs | 5 +- .../Shared/FileService/DefaultFileService.cs | 7 +- .../FileService/IPhysicalFileService.cs | 1 + .../FileService/IPhysicalFileServiceTest.cs | 5 - .../Language/FileBasedLanguageFinder.cs | 1 - .../src/ThrowHelper.cs | 36 +++ .../CallerArgumentExpressionAttribute.cs | 9 + .../test/FileBasedLanguageFinderTest.cs | 28 +- .../test/GameRegistryFactoryTest.cs | 14 +- .../Detection/CompositeDetectorTest.cs | 8 +- .../Detection/DirectoryGameDetectorTest.cs | 57 +--- .../Detection/GameDetectorTest.cs | 14 +- .../Detection/GamePlatformIdentifierTest.cs | 83 ++--- .../Detection/RegistryGameDetectorTest.cs | 2 +- .../GameServices/FallbackIconFinderTest.cs | 6 +- .../test/GameServices/GameFactoryTest.cs | 12 +- .../test/GameServices/GameHelperTest.cs | 28 +- .../GameServices/GameLanguageFinderTest.cs | 6 +- src/PetroGlyph.Games.EawFoc/test/GameTest.cs | 8 +- .../CompositeModNameResolverTest.cs | 2 +- .../DirectoryModNameResolverTest.cs | 6 + .../ModServices/FileSystemModFinderTest.cs | 71 ++++- ...odDependencyGraphBuilderIntegrationTest.cs | 60 ++-- .../ModDependencyResolverIntegrationTest.cs | 283 ++++++------------ .../ModDependencyTraverserIntegrationTest.cs | 16 +- .../test/ModServices/ModFactoryTest.cs | 20 +- .../ModServices/ModIdentifierBuilderTest.cs | 45 ++- src/PetroGlyph.Games.EawFoc/test/ModTest.cs | 16 +- .../test/PetroGlyph.Games.EawFoc.Test.csproj | 19 +- src/PetroGlyph.Games.EawFoc/test/TestUtils.cs | 8 - .../test/VirtualModTest.cs | 3 + .../ConditionalFactAttribute.cs | 35 +++ .../PG.TestingUtilities.csproj | 33 ++ testEnvironments.json | 2 +- 131 files changed, 1123 insertions(+), 1231 deletions(-) delete mode 100644 AlamoEngineTools.snk delete mode 100644 global.json delete mode 100644 src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/AssemblyInfo.cs create mode 100644 src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Properties/AssemblyInfo.cs delete mode 100644 src/PetroGlyph.Games.EawFoc.Clients.Steam/src/AssemblyInfo.cs create mode 100644 src/PetroGlyph.Games.EawFoc.Clients.Steam/src/Properties/AssemblyInfo.cs create mode 100644 src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/SerializeEnumNameAttribute.cs create mode 100644 src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/SerializeEnumValueAttribute.cs delete mode 100644 src/PetroGlyph.Games.EawFoc.Clients/src/AssemblyInfo.cs create mode 100644 src/PetroGlyph.Games.EawFoc.Clients/src/Properties/AssemblyInfo.cs delete mode 100644 src/PetroGlyph.Games.EawFoc/src/AssemblyInfo.cs create mode 100644 src/PetroGlyph.Games.EawFoc/src/Properties/AssemblyInfo.cs delete mode 100644 src/PetroGlyph.Games.EawFoc/src/Services/Shared/FileService/IPhysicalFileServiceTest.cs create mode 100644 src/PetroGlyph.Games.EawFoc/src/ThrowHelper.cs create mode 100644 src/PetroGlyph.Games.EawFoc/src/Utilities/CompilerServices/CallerArgumentExpressionAttribute.cs delete mode 100644 src/PetroGlyph.Games.EawFoc/test/TestUtils.cs create mode 100644 src/Testing/PG.TestingUtilities/ConditionalFactAttribute.cs create mode 100644 src/Testing/PG.TestingUtilities/PG.TestingUtilities.csproj diff --git a/AlamoEngineTools.snk b/AlamoEngineTools.snk deleted file mode 100644 index ecf27190420c6a03d548cdecf9ec6e94e2ca7d83..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa500980q*lUQ23x@vjBLBtmuW9HW)qn`@K^WT z+BnxQeu>ECpPtw`yguw@Om=VIncqJV*mAud@nL5zmOD%&yrZr;DAh}{PVW{7brm0x zxMpv^F1eQBXh$UL&W1Rz3v3Eqm5sQ@ZO{h^eUaHOdhxIDR{*D-F6P|o&EztrhYWZGp`SflBtrH zmlS5d=Tw8pB)f%`1R`D2B!JF?=NYw=GT57PWl>1ewtpHy`LU0;aL;miiod@^!&3J+ z2HgrxaeH+}vn?8@j$l8zyeO*{Mg(yLOUc^s{m8pzV;|I8YjG%5TmZ9`2yZgym09<{ zgOxgW i`true - False - $(MSBuildThisFileDirectory)AlamoEngineTools.snk - 10.0 + latest disable all - 3.6.132 + 3.6.133 - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/PetroGlyphGameInfrastructure.sln b/PetroGlyphGameInfrastructure.sln index 37dac53f..37a2ac1e 100644 --- a/PetroGlyphGameInfrastructure.sln +++ b/PetroGlyphGameInfrastructure.sln @@ -23,7 +23,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PetroGlyph.Games.EawFoc.Cli EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PetroGlyph.Games.EawFoc.Clients.Steam.Test", "src\PetroGlyph.Games.EawFoc.Clients.Steam\test\PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj", "{69666FB7-7F44-451B-8ABF-7F18DEC3AD45}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleApplication", "sample\SampleApplication\SampleApplication.csproj", "{8F295344-3D7B-4983-88FD-D0E5C692CBAB}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleApplication", "sample\SampleApplication\SampleApplication.csproj", "{8F295344-3D7B-4983-88FD-D0E5C692CBAB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PG.TestingUtilities", "src\Testing\PG.TestingUtilities\PG.TestingUtilities.csproj", "{C8F51821-F25D-4C4E-8050-5C559ADD39DB}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -67,6 +69,10 @@ Global {8F295344-3D7B-4983-88FD-D0E5C692CBAB}.Debug|Any CPU.Build.0 = Debug|Any CPU {8F295344-3D7B-4983-88FD-D0E5C692CBAB}.Release|Any CPU.ActiveCfg = Release|Any CPU {8F295344-3D7B-4983-88FD-D0E5C692CBAB}.Release|Any CPU.Build.0 = Release|Any CPU + {C8F51821-F25D-4C4E-8050-5C559ADD39DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C8F51821-F25D-4C4E-8050-5C559ADD39DB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C8F51821-F25D-4C4E-8050-5C559ADD39DB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C8F51821-F25D-4C4E-8050-5C559ADD39DB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -80,6 +86,7 @@ Global {0D5DAC91-BB5F-46F4-9145-4296E9151DC3} = {91EC3980-0C87-484F-91E5-0FE684C1D2E0} {179786D1-8C85-46B3-9943-30A1902D92B4} = {DDF4836A-1257-4323-A288-B5F277242010} {69666FB7-7F44-451B-8ABF-7F18DEC3AD45} = {91EC3980-0C87-484F-91E5-0FE684C1D2E0} + {C8F51821-F25D-4C4E-8050-5C559ADD39DB} = {91EC3980-0C87-484F-91E5-0FE684C1D2E0} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {76D00646-2467-4997-A19B-8299D8724D38} diff --git a/global.json b/global.json deleted file mode 100644 index 870d1d1c..00000000 --- a/global.json +++ /dev/null @@ -1,8 +0,0 @@ - -{ - "sdk": { - "version": "6.0.405", - "rollForward": "patch", - "allowPrerelease": false - } - } \ No newline at end of file diff --git a/sample/SampleApplication/SampleApplication.csproj b/sample/SampleApplication/SampleApplication.csproj index bc11be91..a5fee1fa 100644 --- a/sample/SampleApplication/SampleApplication.csproj +++ b/sample/SampleApplication/SampleApplication.csproj @@ -3,7 +3,7 @@ Exe 10.0 - net6.0-windows + net8.0-windows disable enable false @@ -16,7 +16,7 @@ - + diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/AssemblyInfo.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/AssemblyInfo.cs deleted file mode 100644 index cd8a61ec..00000000 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/AssemblyInfo.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Runtime.CompilerServices; - -//#if DEBUG -[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test")] -[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] -//#else -//[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a9a456c25c065bc1168c6cbbd797692f366613993df057f7dcda38d72f7e89c8e59f9ed839bc3eec654c766fdf99df3f11d872bd1ef161672d963b4c24bca3ae3928d54bb24eef160875151f91b8666fbf2eb996e1684724ebce8638af0b6c0a5de503d9e911432fb29ce0948bb2372cfc5076a41ba12dd0d37dfd578b9418db")] -//[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] -//#endif diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj index 26e87a7f..ab51c4a5 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj @@ -5,7 +5,7 @@ - net6.0-windows;net48 + net8.0-windows;net48 PetroGlyph.Games.EawFoc.Clients.Steam enable true @@ -20,11 +20,10 @@ - - - - - + + + + diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Properties/AssemblyInfo.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..f72f245c --- /dev/null +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Properties/AssemblyInfo.cs @@ -0,0 +1,4 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test")] +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamGameFinder.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamGameFinder.cs index ed1cc18d..58842823 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamGameFinder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamGameFinder.cs @@ -1,7 +1,6 @@ using System; using System.Linq; using Microsoft.Extensions.DependencyInjection; -using Validation; namespace PetroGlyph.Games.EawFoc.Clients.Steam; @@ -11,7 +10,9 @@ internal class SteamGameFinder : ISteamGameFinder public SteamGameFinder(IServiceProvider serviceProvider) { - Requires.NotNull(serviceProvider, nameof(serviceProvider)); + if (serviceProvider == null) + throw new ArgumentNullException(nameof(serviceProvider)); + _libraryFinder = serviceProvider.GetRequiredService(); } diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibrary.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibrary.cs index 4da1b7b1..f1677159 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibrary.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibrary.cs @@ -3,9 +3,8 @@ using System.Collections.Generic; using System.IO; using System.IO.Abstractions; -using AnakinRaW.CommonUtilities.FileSystem; +using AnakinRaW.CommonUtilities.FileSystem.Normalization; using Microsoft.Extensions.DependencyInjection; -using Validation; namespace PetroGlyph.Games.EawFoc.Clients.Steam; @@ -21,8 +20,8 @@ internal class SteamLibrary : ISteamLibrary { KnownLibraryLocations.Workshops, new[] { "steamapps", "workshop" } } }; - private readonly IPathHelperService _pathHelper; private readonly string _normalizedLocation; + private readonly IFileSystem _fileSystem; public IDirectoryInfo LibraryLocation { get; } @@ -34,12 +33,15 @@ internal class SteamLibrary : ISteamLibrary public SteamLibrary(IDirectoryInfo libraryLocation, IServiceProvider serviceProvider) { - Requires.NotNull(libraryLocation, nameof(libraryLocation)); - Requires.NotNull(serviceProvider, nameof(serviceProvider)); - _serviceProvider = serviceProvider; - _pathHelper = serviceProvider.GetService() ?? - new PathHelperService(libraryLocation.FileSystem); - _normalizedLocation = _pathHelper.NormalizePath(libraryLocation.FullName, PathNormalizeOptions.Full); + if (libraryLocation == null) + throw new ArgumentNullException(nameof(libraryLocation)); + _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); + _fileSystem = serviceProvider.GetRequiredService(); + _normalizedLocation = PathNormalizer.Normalize(_fileSystem.Path.GetFullPath(libraryLocation.FullName), new PathNormalizeOptions + { + UnifyCase = UnifyCasingKind.UpperCase, + TrailingDirectorySeparatorBehavior = TrailingDirectorySeparatorBehavior.Trim + }); LibraryLocation = libraryLocation; } @@ -72,8 +74,15 @@ public bool Equals(ISteamLibrary? other) return false; if (ReferenceEquals(this, other)) return true; - return _normalizedLocation.Equals(_pathHelper.NormalizePath(other.LibraryLocation.FullName, - PathNormalizeOptions.Full)); + + var normalizedOtherPath = PathNormalizer.Normalize(_fileSystem.Path.GetFullPath(other.LibraryLocation.FullName), + new PathNormalizeOptions + { + UnifyCase = UnifyCasingKind.UpperCase, + TrailingDirectorySeparatorBehavior = TrailingDirectorySeparatorBehavior.Trim + }); + + return _normalizedLocation.Equals(normalizedOtherPath); } public override string ToString() diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibraryFinder.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibraryFinder.cs index 2a09d156..d8dbb010 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibraryFinder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibraryFinder.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; -using Validation; namespace PetroGlyph.Games.EawFoc.Clients.Steam; @@ -15,10 +14,9 @@ internal class SteamLibraryFinder : ISteamLibraryFinder public SteamLibraryFinder(IServiceProvider serviceProvider) { - Requires.NotNull(serviceProvider, nameof(serviceProvider)); - _serviceProvider = serviceProvider; + _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); _registry = serviceProvider.GetRequiredService(); - _fileSystem = serviceProvider.GetService() ?? new FileSystem(); + _fileSystem = serviceProvider.GetRequiredService(); _configReader = serviceProvider.GetRequiredService(); } diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamVdfReader.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamVdfReader.cs index 60b97b03..60e12a57 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamVdfReader.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamVdfReader.cs @@ -7,28 +7,30 @@ using Gameloop.Vdf.JsonConverter; using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json.Linq; -using Validation; namespace PetroGlyph.Games.EawFoc.Clients.Steam; internal class SteamVdfReader : ISteamAppManifestReader, ILibraryConfigReader { private readonly IFileSystem _fileSystem; - private readonly IPathHelperService _pathHelper; public SteamVdfReader(IServiceProvider serviceProvider) { - Requires.NotNull(serviceProvider, nameof(serviceProvider)); - _fileSystem = serviceProvider.GetService() ?? new FileSystem(); - _pathHelper = serviceProvider.GetService() ?? new PathHelperService(_fileSystem); + if (serviceProvider == null) + throw new ArgumentNullException(nameof(serviceProvider)); + + _fileSystem = serviceProvider.GetRequiredService(); } public SteamAppManifest ReadManifest(IFileInfo manifestFile, ISteamLibrary library) { - Requires.NotNull(manifestFile, nameof(manifestFile)); - Requires.NotNull(library, nameof(library)); + if (manifestFile == null) + throw new ArgumentNullException(nameof(manifestFile)); + if (library == null) + throw new ArgumentNullException(nameof(library)); + var directory = manifestFile.Directory; - if (directory is null || !_pathHelper.IsChildOf(library.LibraryLocation.FullName, directory.FullName)) + if (directory is null || !_fileSystem.Path.IsChildOf(library.LibraryLocation.FullName, directory.FullName)) throw new SteamException("The game's manifest is not part of the given library"); var manifestData = ReadFileAsJson(manifestFile); if (manifestData.Name != "AppState") diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamWrapper.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamWrapper.cs index 9df2f8f1..2481fed5 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamWrapper.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamWrapper.cs @@ -11,7 +11,6 @@ using PetroGlyph.Games.EawFoc.Clients.Processes; using PetroGlyph.Games.EawFoc.Clients.Steam.NativeMethods; using PetroGlyph.Games.EawFoc.Clients.Steam.Threading; -using Validation; #if NET using System.Diagnostics.CodeAnalysis; #endif @@ -81,11 +80,10 @@ internal bool IsUserLoggedIn public SteamWrapper(IServiceProvider serviceProvider) { - Requires.NotNull(serviceProvider, nameof(serviceProvider)); - _serviceProvider = serviceProvider; + _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); _registry = serviceProvider.GetRequiredService(); - _processHelper = serviceProvider.GetService() ?? new ProcessHelper(); - _fileSystem = serviceProvider.GetService() ?? new FileSystem(); + _processHelper = serviceProvider.GetRequiredService(); + _fileSystem = serviceProvider.GetRequiredService(); } #if NET diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/AwaitExtensions.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/AwaitExtensions.cs index ee55d8d7..a9fdeb24 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/AwaitExtensions.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/AwaitExtensions.cs @@ -6,7 +6,6 @@ using Microsoft.Win32; using Microsoft.Win32.SafeHandles; using PetroGlyph.Games.EawFoc.Clients.Steam.NativeMethods; -using Validation; namespace PetroGlyph.Games.EawFoc.Clients.Steam.Threading; @@ -34,7 +33,8 @@ public static Task WaitForChangeAsync(this RegistryKey registryKey, bool watchSu RegistryChangeNotificationFilters.Value | RegistryChangeNotificationFilters.Subkey, CancellationToken cancellationToken = default) { - Requires.NotNull(registryKey, nameof(registryKey)); + if (registryKey == null) + throw new ArgumentNullException(nameof(registryKey)); return WaitForRegistryChangeAsync(registryKey.Handle, watchSubtree, change, cancellationToken); } @@ -94,7 +94,8 @@ private static class DownlevelRegistryWatcherSupport internal static async Task ExecuteOnDedicatedThreadAsync(Action action) { - Requires.NotNull(action, nameof(action)); + if (action == null) + throw new ArgumentNullException(nameof(action)); var tcs = new TaskCompletionSource(); var keepAliveCountIncremented = false; @@ -119,7 +120,9 @@ internal static async Task ExecuteOnDedicatedThreadAsync(Action act if (_keepAliveCount == 1) { - Assumes.Null(_liveThread); + if (_liveThread is not null) + throw new InvalidOperationException("Internal error."); + _liveThread = new Thread(Worker, SmallThreadStackSize) { IsBackground = true, @@ -179,7 +182,8 @@ private static void Worker() // This happens when keepAliveCount (at least temporarily) // hits 0, so this thread must be assumed to be on its exit path, // and another thread will be spawned to process new requests. - Assumes.True(_liveThread is object || (_keepAliveCount == 0 && PendingWork.Count == 0)); + if (_liveThread is null && (_keepAliveCount != 0 || PendingWork.Count != 0)) + throw new InvalidOperationException(); return; } diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/NoMessagePumpSyncContext.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/NoMessagePumpSyncContext.cs index 9eb8d99f..1988f723 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/NoMessagePumpSyncContext.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/NoMessagePumpSyncContext.cs @@ -2,7 +2,6 @@ using System.Runtime.InteropServices; using System.Threading; using PetroGlyph.Games.EawFoc.Clients.Steam.NativeMethods; -using Validation; namespace PetroGlyph.Games.EawFoc.Clients.Steam.Threading; @@ -19,7 +18,8 @@ public NoMessagePumpSyncContext() public override int Wait(IntPtr[] waitHandles, bool waitAll, int millisecondsTimeout) { - Requires.NotNull(waitHandles, nameof(waitHandles)); + if (waitHandles == null) + throw new ArgumentNullException(nameof(waitHandles)); // On .NET Framework we must take special care to NOT end up in a call to CoWait (which lets in RPC calls). // Off Windows, we can't p/invoke to kernel32, but it appears that .NET Core never calls CoWait, so we can rely on default behavior. diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/SpecializedSyncContext.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/SpecializedSyncContext.cs index bc723b3e..73c2fa05 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/SpecializedSyncContext.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/SpecializedSyncContext.cs @@ -1,6 +1,5 @@ using System; using System.Threading; -using Validation; namespace PetroGlyph.Games.EawFoc.Clients.Steam.Threading; @@ -30,7 +29,7 @@ public void Dispose() { if (!_initialized) return; - Report.If(_checkForChangesOnRevert && SynchronizationContext.Current != _appliedContext); + // TODO Report.If(_checkForChangesOnRevert && SynchronizationContext.Current != _appliedContext); SynchronizationContext.SetSynchronizationContext(_prior); } } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/TplExtensions.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/TplExtensions.cs index 68a3f334..05e0989c 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/TplExtensions.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/TplExtensions.cs @@ -1,7 +1,6 @@ using System; using System.Threading; using System.Threading.Tasks; -using Validation; namespace PetroGlyph.Games.EawFoc.Clients.Steam.Threading; @@ -15,7 +14,8 @@ internal static class TplExtensions internal static Task ToTask(this WaitHandle handle, int timeout = Timeout.Infinite, CancellationToken cancellationToken = default) { - Requires.NotNull(handle, nameof(handle)); + if (handle == null) + throw new ArgumentNullException(nameof(handle)); // Check whether the handle is already signaled as an optimization. // But even for WaitOne(0) the CLR can pump messages if called on the UI thread, which the caller may not diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj index 77eba874..ea61534e 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj @@ -1,27 +1,27 @@  - net6.0-windows;net48 + net8.0-windows;net48 enable false true - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -29,6 +29,7 @@ + diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamGameFinderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamGameFinderTest.cs index e4591499..c42d91b9 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamGameFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamGameFinderTest.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using System.IO.Abstractions; -using System.IO.Abstractions.TestingHelpers; using Microsoft.Extensions.DependencyInjection; using Moq; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.Steam diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryFinderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryFinderTest.cs index 328d147d..a5c4d1e9 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryFinderTest.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using System.IO.Abstractions; -using System.IO.Abstractions.TestingHelpers; using System.Linq; using Microsoft.Extensions.DependencyInjection; using Moq; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.Steam @@ -15,7 +15,6 @@ public class SteamLibraryFinderTest private readonly Mock _registry; private readonly MockFileSystem _fileSystem; - public SteamLibraryFinderTest() { var sc = new ServiceCollection(); @@ -38,7 +37,7 @@ public void TestNoSteam_Throws() [Fact] public void TestNoLibrariesFound() { - _fileSystem.AddDirectory("Steam"); + _fileSystem.Initialize().WithSubdirectory("Steam"); _registry.Setup(r => r.InstallationDirectory) .Returns(_fileSystem.DirectoryInfo.New("Steam")); @@ -50,8 +49,8 @@ public void TestNoLibrariesFound() [Fact] public void TestNoLibrary_MissingSteamDll() { + _fileSystem.Initialize().WithFile("Steam/steamapps/libraryfolders.vdf"); var libraryLocation = _fileSystem.DirectoryInfo.New("Steam"); - _fileSystem.AddFile("Steam/steamapps/libraryfolders.vdf", new MockFileData(string.Empty)); _registry.Setup(r => r.InstallationDirectory) .Returns(_fileSystem.DirectoryInfo.New("Steam")); _reader.Setup(r => r.ReadLibraryLocationsFromConfig(It.IsAny())) @@ -65,9 +64,11 @@ public void TestNoLibrary_MissingSteamDll() [Fact] public void TestNoLibrary_NoConfigFile() { + _fileSystem.Initialize() + .WithFile("Steam/noValidConfigPath/libraryfolders.vdf") + .WithFile("Steam/steam.dll"); + var libraryLocation = _fileSystem.DirectoryInfo.New("Steam"); - _fileSystem.AddFile("Steam/noValidConfigPath/libraryfolders.vdf", new MockFileData(string.Empty)); - _fileSystem.AddFile("Steam/steam.dll", new MockFileData(string.Empty)); _registry.Setup(r => r.InstallationDirectory) .Returns(_fileSystem.DirectoryInfo.New("Steam")); _reader.Setup(r => r.ReadLibraryLocationsFromConfig(It.IsAny())) @@ -81,9 +82,11 @@ public void TestNoLibrary_NoConfigFile() [Fact] public void TestSingleLibrary() { + _fileSystem.Initialize() + .WithFile("Steam/steamapps/libraryfolders.vdf") + .WithFile("Steam/steam.dll"); + var libraryLocation = _fileSystem.DirectoryInfo.New("Steam"); - _fileSystem.AddFile("Steam/steamapps/libraryfolders.vdf", new MockFileData(string.Empty)); - _fileSystem.AddFile("Steam/steam.dll", new MockFileData(string.Empty)); _registry.Setup(r => r.InstallationDirectory) .Returns(_fileSystem.DirectoryInfo.New("Steam")); _reader.Setup(r => r.ReadLibraryLocationsFromConfig(It.IsAny())) @@ -98,9 +101,11 @@ public void TestSingleLibrary() [Fact] public void TestSingleAlternateConfig() { + _fileSystem.Initialize() + .WithFile("Steam/config/libraryfolders.vdf") + .WithFile("Steam/steam.dll"); + var libraryLocation = _fileSystem.DirectoryInfo.New("Steam"); - _fileSystem.AddFile("Steam/config/libraryfolders.vdf", new MockFileData(string.Empty)); - _fileSystem.AddFile("Steam/steam.dll", new MockFileData(string.Empty)); _registry.Setup(r => r.InstallationDirectory) .Returns(_fileSystem.DirectoryInfo.New("Steam")); _reader.Setup(r => r.ReadLibraryLocationsFromConfig(It.IsAny())) @@ -115,9 +120,11 @@ public void TestSingleAlternateConfig() [Fact] public void TestUniqueResult() { + _fileSystem.Initialize() + .WithFile("Steam/config/libraryfolders.vdf") + .WithFile("Steam/steam.dll"); + var libraryLocation = _fileSystem.DirectoryInfo.New("Steam"); - _fileSystem.AddFile("Steam/config/libraryfolders.vdf", new MockFileData(string.Empty)); - _fileSystem.AddFile("Steam/steam.dll", new MockFileData(string.Empty)); _registry.Setup(r => r.InstallationDirectory) .Returns(_fileSystem.DirectoryInfo.New("Steam")); _reader.Setup(r => r.ReadLibraryLocationsFromConfig(It.IsAny())) diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryTest.cs index 5f48b5e2..dfb06dd3 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryTest.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; using System.IO.Abstractions; -using System.IO.Abstractions.TestingHelpers; -using System.Runtime.InteropServices; using Microsoft.Extensions.DependencyInjection; using Moq; +using PG.TestingUtilities; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.Steam @@ -71,7 +71,7 @@ public void TestNoApps1() [Fact] public void TestNoApps2() { - _fileSystem.AddDirectory("Library/steamapps"); + _fileSystem.Initialize().WithSubdirectory("Library/steamapps"); var lib = new SteamLibrary(_fileSystem.DirectoryInfo.New("Library"), _serviceProvider); var app = new SteamAppManifest(lib, _fileSystem.FileInfo.New("file"), 123, "name", @@ -89,7 +89,7 @@ public void TestNoApps2() [Fact] public void TestApps() { - _fileSystem.AddFile("Library/steamapps/test.acf", new MockFileData(string.Empty)); + _fileSystem.Initialize().WithFile("Library/steamapps/test.acf"); var lib = new SteamLibrary(_fileSystem.DirectoryInfo.New("Library"), _serviceProvider); var app = new SteamAppManifest(lib, _fileSystem.FileInfo.New("file"), 123, "name", @@ -107,8 +107,10 @@ public void TestApps() [Fact] public void TestNoDuplicatesApps() { - _fileSystem.AddFile("Library/steamapps/test1.acf", new MockFileData(string.Empty)); - _fileSystem.AddFile("Library/steamapps/test2.acf", new MockFileData(string.Empty)); + _fileSystem.Initialize() + .WithFile("Library/steamapps/test1.acf") + .WithFile("Library/steamapps/test2.acf"); + var lib = new SteamLibrary(_fileSystem.DirectoryInfo.New("Library"), _serviceProvider); var app = new SteamAppManifest(lib, _fileSystem.FileInfo.New("file"), 123, "name", @@ -123,15 +125,18 @@ public void TestNoDuplicatesApps() Assert.Same(app, result); } - [Fact] - public void TestLocations() + [PlatformSpecificFact(TestPlatformIdentifier.Windows)] + public void TestLocations_Windows() { var lib = new SteamLibrary(_fileSystem.DirectoryInfo.New("Library"), _serviceProvider); + Assert.Equal("C:\\Library\\steamapps\\common", lib.CommonLocation.FullName); + } - Assert.Equal( - RuntimeInformation.IsOSPlatform(OSPlatform.Linux) - ? "/Library/steamapps/common" - : "C:\\Library\\steamapps\\common", lib.CommonLocation.FullName); + [PlatformSpecificFact(TestPlatformIdentifier.Linux)] + public void TestLocations_Linux() + { + var lib = new SteamLibrary(_fileSystem.DirectoryInfo.New("Library"), _serviceProvider); + Assert.Equal("/Library/steamapps/common", lib.CommonLocation.FullName); } } } diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamVdfReaderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamVdfReaderTest.cs index e9e73f88..e07b70b7 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamVdfReaderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamVdfReaderTest.cs @@ -1,14 +1,9 @@ using System.IO.Abstractions; -using System.IO.Abstractions.TestingHelpers; using System.Linq; -using System.Runtime.InteropServices; -using AnakinRaW.CommonUtilities.FileSystem; using Microsoft.Extensions.DependencyInjection; using Moq; +using Testably.Abstractions.Testing; using Xunit; -#if NET -using System; -#endif namespace PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.Steam; @@ -16,14 +11,11 @@ public class SteamVdfReaderTest { private readonly SteamVdfReader _service; private readonly MockFileSystem _fileSystem; - private readonly Mock _pathHelper; public SteamVdfReaderTest() { var sc = new ServiceCollection(); _fileSystem = new MockFileSystem(); - _pathHelper = new Mock(); - sc.AddTransient(_ => _pathHelper.Object); sc.AddTransient(_ => _fileSystem); _service = new SteamVdfReader(sc.BuildServiceProvider()); } @@ -31,7 +23,7 @@ public SteamVdfReaderTest() [Fact] public void TestInvalidData_Throws() { - _fileSystem.AddFile("input.vdf", new MockFileData(string.Empty)); + _fileSystem.Initialize().WithFile("input.vdf"); var input = _fileSystem.FileInfo.New("input.vdf"); Assert.Throws(() => _service.ReadLibraryLocationsFromConfig(input)); } @@ -59,7 +51,9 @@ public void ReadLibraryLocations() var expected1 = _fileSystem.DirectoryInfo.New("C:\\Lib1").FullName; var expected2 = _fileSystem.DirectoryInfo.New("C:\\Lib2").FullName; var expected3 = _fileSystem.DirectoryInfo.New("C:\\Lib3").FullName; - _fileSystem.AddFile("input.vdf", new MockFileData(data)); + + _fileSystem.Initialize().WithFile("input.vdf").Which(d => d.HasStringContent(data)); + var input = _fileSystem.FileInfo.New("input.vdf"); var locations = _service.ReadLibraryLocationsFromConfig(input).Select(l => l.FullName).ToList(); @@ -77,7 +71,8 @@ public void ReadLibraryLocationsInvalidData_Throws() ""contentstatsid"" ""-6588270118365286089"" } "; - _fileSystem.AddFile("input.vdf", new MockFileData(data)); + _fileSystem.Initialize().WithFile("input.vdf").Which(d => d.HasStringContent(data)); + var input = _fileSystem.FileInfo.New("input.vdf"); Assert.Throws(() => _service.ReadLibraryLocationsFromConfig(input)); @@ -91,7 +86,8 @@ public void ReadLibraryLocationsNoLibraries() ""contentstatsid"" ""-6588270118365286089"" } "; - _fileSystem.AddFile("input.vdf", new MockFileData(data)); + _fileSystem.Initialize().WithFile("input.vdf").Which(d => d.HasStringContent(data)); + var input = _fileSystem.FileInfo.New("input.vdf"); var libs = _service.ReadLibraryLocationsFromConfig(input); Assert.Empty(libs); @@ -100,8 +96,6 @@ public void ReadLibraryLocationsNoLibraries() [Fact] public void TestReadAppManifest() { - - var data = @"""AppState"" { ""appid"" ""1230"" @@ -117,12 +111,11 @@ public void TestReadAppManifest() } "; var lib = new Mock(); - lib.Setup(l => l.LibraryLocation).Returns(_fileSystem.DirectoryInfo.New("./")); - lib.Setup(l => l.CommonLocation).Returns(_fileSystem.DirectoryInfo.New("./steamapps/common")); + lib.Setup(l => l.LibraryLocation).Returns(_fileSystem.DirectoryInfo.New(".")); + lib.Setup(l => l.CommonLocation).Returns(_fileSystem.DirectoryInfo.New("steamapps/common")); - _pathHelper.Setup(h => h.IsChildOf(It.IsAny(), It.IsAny())).Returns(true); + _fileSystem.Initialize().WithFile("steamapps/input.vdf").Which(d => d.HasStringContent(data)); - _fileSystem.AddFile("steamapps/input.vdf", new MockFileData(data)); var input = _fileSystem.FileInfo.New("steamapps/input.vdf"); var app = _service.ReadManifest(input, lib.Object); @@ -130,10 +123,9 @@ public void TestReadAppManifest() Assert.Equal("GameName", app.Name); Assert.Equal(SteamAppState.StateFullyInstalled | SteamAppState.StateUpdatePaused, app.State); - Assert.Equal( - RuntimeInformation.IsOSPlatform(OSPlatform.Linux) - ? "/steamapps/common/GamePath" - : "C:\\steamapps\\common\\GamePath", app.InstallDir.FullName); + var expectedGameFullPath = _fileSystem.Path.GetFullPath("steamapps/common/GamePath"); + + Assert.Equal(expectedGameFullPath, app.InstallDir.FullName); Assert.Contains(1231u, app.Depots); Assert.Contains(1232u, app.Depots); @@ -160,9 +152,8 @@ public void TestReadInvalidAppManifest_Throws() lib.Setup(l => l.LibraryLocation).Returns(_fileSystem.DirectoryInfo.New("./")); lib.Setup(l => l.CommonLocation).Returns(_fileSystem.DirectoryInfo.New("./steamapps/common")); - _pathHelper.Setup(h => h.IsChildOf(It.IsAny(), It.IsAny())).Returns(true); + _fileSystem.Initialize().WithFile("steamapps/input.vdf").Which(d => d.HasStringContent(data)); - _fileSystem.AddFile("steamapps/input.vdf", new MockFileData(data)); var input = _fileSystem.FileInfo.New("steamapps/input.vdf"); Assert.Throws(() => _service.ReadManifest(input, lib.Object)); } diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperTest.cs index 4e0f5e0c..5e3e0b8e 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperTest.cs @@ -2,10 +2,10 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO.Abstractions; -using System.IO.Abstractions.TestingHelpers; using Microsoft.Extensions.DependencyInjection; using Moq; using PetroGlyph.Games.EawFoc.Clients.Processes; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.Steam @@ -67,7 +67,7 @@ public void TestInstalled() Assert.False(_service.Installed); Assert.False(_service.Installed); - _fileSystem.AddFile("steam.exe", new MockFileData(string.Empty)); + _fileSystem.Initialize().WithFile("steam.exe"); Assert.True(_service.Installed); } @@ -88,6 +88,8 @@ public void TestUserLoggedIn() [Fact] public void TestGameInstalled() { + _fileSystem.Initialize(); + SetupInstalledRegistry(); var mFile = _fileSystem.FileInfo.New("manifest.acf"); @@ -110,24 +112,24 @@ public void TestGameInstalled() public void TestWantsOffline() { SetupInstalledRegistry(); - + _steamRegistry.Setup(r => r.InstallationDirectory).Returns(_fileSystem.DirectoryInfo.New(".")); Assert.Null(_service.WantOfflineMode); - _fileSystem.AddFile("config/loginusers.vdf", new MockFileData(string.Empty)); + _fileSystem.Initialize().WithFile("config/loginusers.vdf"); Assert.Null(_service.WantOfflineMode); - _fileSystem.AddFile("config/loginusers.vdf", WantsNotOffline()); + _fileSystem.File.WriteAllText("config/loginusers.vdf", WantsNotOffline()); Assert.False(_service.WantOfflineMode); - _fileSystem.AddFile("config/loginusers.vdf", WantsOffline()); + _fileSystem.File.WriteAllText("config/loginusers.vdf", WantsOffline()); Assert.True(_service.WantOfflineMode); } - + private void SetupInstalledRegistry() { - _fileSystem.AddFile("steam.exe", new MockFileData(string.Empty)); + _fileSystem.Initialize().WithFile("steam.exe"); _steamRegistry.Setup(r => r.ExeFile).Returns(_fileSystem.FileInfo.New("steam.exe")); } diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/AssemblyInfo.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/AssemblyInfo.cs deleted file mode 100644 index d700e952..00000000 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/AssemblyInfo.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Runtime.CompilerServices; - -//#if DEBUG -[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Test")] -[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] -//#else -//[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a9a456c25c065bc1168c6cbbd797692f366613993df057f7dcda38d72f7e89c8e59f9ed839bc3eec654c766fdf99df3f11d872bd1ef161672d963b4c24bca3ae3928d54bb24eef160875151f91b8666fbf2eb996e1684724ebce8638af0b6c0a5de503d9e911432fb29ce0948bb2372cfc5076a41ba12dd0d37dfd578b9418db")] -//[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] -//#endif \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/PetroGlyph.Games.EawFoc.Clients.Steam.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/PetroGlyph.Games.EawFoc.Clients.Steam.csproj index fe1b62ba..47595b9b 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/PetroGlyph.Games.EawFoc.Clients.Steam.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/PetroGlyph.Games.EawFoc.Clients.Steam.csproj @@ -22,10 +22,6 @@ - - - - diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/Properties/AssemblyInfo.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..b7dda2ee --- /dev/null +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/Properties/AssemblyInfo.cs @@ -0,0 +1,4 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Test")] +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamAppManifest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamAppManifest.cs index 78656806..17c232fa 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamAppManifest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamAppManifest.cs @@ -1,7 +1,7 @@ -using System; +using AnakinRaW.CommonUtilities; +using System; using System.Collections.Generic; using System.IO.Abstractions; -using Validation; namespace PetroGlyph.Games.EawFoc.Clients.Steam; @@ -66,11 +66,16 @@ public SteamAppManifest( SteamAppState state, ISet depots) { - Requires.NotNull(library, nameof(library)); - Requires.NotNull(manifestFile, nameof(manifestFile)); - Requires.NotNullOrEmpty(name, nameof(name)); - Requires.NotNull(installDir, nameof(installDir)); - Requires.NotNull(depots, nameof(depots)); + if (library == null) + throw new ArgumentNullException(nameof(library)); + if (manifestFile == null) + throw new ArgumentNullException(nameof(manifestFile)); + if (installDir == null) + throw new ArgumentNullException(nameof(installDir)); + if (depots == null) + throw new ArgumentNullException(nameof(depots)); + ThrowHelper.ThrowIfNullOrEmpty(name); + Library = library; ManifestFile = manifestFile; Id = id; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameClient.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameClient.cs index 11364c87..f35b9847 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameClient.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameClient.cs @@ -4,7 +4,6 @@ using Microsoft.Extensions.DependencyInjection; using PetroGlyph.Games.EawFoc.Clients.Processes; using PetroGlyph.Games.EawFoc.Games; -using Validation; namespace PetroGlyph.Games.EawFoc.Clients.Steam; @@ -42,9 +41,10 @@ private class SteamGameLauncher : IGameProcessLauncher public SteamGameLauncher(IServiceProvider serviceProvider) { - Requires.NotNull(serviceProvider, nameof(serviceProvider)); + if (serviceProvider == null) + throw new ArgumentNullException(nameof(serviceProvider)); _steamWrapper = serviceProvider.GetRequiredService(); - _internalLauncher = serviceProvider.GetService() ?? new DefaultGameProcessLauncher(serviceProvider); + _internalLauncher = serviceProvider.GetRequiredService(); } public IGameProcess StartGameProcess(IFileInfo executable, GameProcessInfo processInfo) diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameLanguageFinder.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameLanguageFinder.cs index c80e3e4a..44954557 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameLanguageFinder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameLanguageFinder.cs @@ -5,7 +5,6 @@ using Microsoft.Extensions.DependencyInjection; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Services.Language; -using Validation; namespace PetroGlyph.Games.EawFoc.Clients.Steam; @@ -30,7 +29,8 @@ public sealed class SteamGameLanguageFinder : IGameLanguageFinder /// The service provider. public SteamGameLanguageFinder(IServiceProvider serviceProvider) { - Requires.NotNull(serviceProvider, nameof(serviceProvider)); + if (serviceProvider == null) + throw new ArgumentNullException(nameof(serviceProvider)); _steamWrapper = serviceProvider.GetRequiredService(); } diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj index 3ff855d5..798b5829 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 $(TargetFrameworks);net48 enable false @@ -9,20 +9,20 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameClientTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameClientTest.cs index 0f0ebd46..c27f4213 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameClientTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameClientTest.cs @@ -1,9 +1,9 @@ using System.IO.Abstractions; -using System.IO.Abstractions.TestingHelpers; using Microsoft.Extensions.DependencyInjection; using Moq; using PetroGlyph.Games.EawFoc.Clients.Processes; using PetroGlyph.Games.EawFoc.Games; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Clients.Steam.Test; @@ -19,7 +19,7 @@ public class SteamGameClientTest public SteamGameClientTest() { var fs = new MockFileSystem(); - fs.AddFile("test.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("test.exe"); var sc = new ServiceCollection(); _steam = new Mock(); sc.AddTransient(_ => _steam.Object); diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameLanguageFinderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameLanguageFinderTest.cs index e9db554c..cb697eeb 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameLanguageFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameLanguageFinderTest.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; -using System.IO.Abstractions.TestingHelpers; using EawModinfo.Model; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; using Moq; using PetroGlyph.Games.EawFoc.Games; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Clients.Steam.Test; @@ -55,8 +55,8 @@ public void TestNoOtherInstalledLanguages() var fs = new MockFileSystem(); - var manifest = new SteamAppManifest(new Mock().Object, new MockFileInfo(fs, "test.path"), 123, - "name", new MockDirectoryInfo(fs, "path"), SteamAppState.StateFullyInstalled, new HashSet()); + var manifest = new SteamAppManifest(new Mock().Object, fs.FileInfo.New("test.path"), 123, + "name", fs.DirectoryInfo.New("path"), SteamAppState.StateFullyInstalled, new HashSet()); _steam.Setup(s => s.IsGameInstalled(32470u, out manifest)).Returns(true); @@ -73,8 +73,8 @@ public void TestOtherInstalledLanguages() var fs = new MockFileSystem(); - var manifest = new SteamAppManifest(new Mock().Object, new MockFileInfo(fs, "test.path"), 123, - "name", new MockDirectoryInfo(fs, "path"), SteamAppState.StateFullyInstalled, new HashSet + var manifest = new SteamAppManifest(new Mock().Object, fs.FileInfo.New("test.path"), 123, + "name", fs.DirectoryInfo.New("path"), SteamAppState.StateFullyInstalled, new HashSet { 32473, 32474, 32475, 32476 }); diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamPetroglyphStarWarsGameDetectorTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamPetroglyphStarWarsGameDetectorTest.cs index e32d9ea1..11289150 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamPetroglyphStarWarsGameDetectorTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamPetroglyphStarWarsGameDetectorTest.cs @@ -1,12 +1,12 @@ using System; using System.Collections.Generic; using System.IO.Abstractions; -using System.IO.Abstractions.TestingHelpers; using Microsoft.Extensions.DependencyInjection; using Moq; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Games.Registry; using PetroGlyph.Games.EawFoc.Services.Detection; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Clients.Steam.Test; @@ -70,7 +70,7 @@ public void TestNoGame2() public void TestNoGame3() { var installLocation = _fileSystem.DirectoryInfo.New("Game"); - _fileSystem.AddFile("Game/swfoc.exe", new MockFileData(string.Empty)); + _fileSystem.Initialize().WithFile("Game/swfoc.exe"); var mFile = _fileSystem.FileInfo.New("manifest.acf"); var app = new SteamAppManifest(_gameLib.Object, mFile, 1234, "name", installLocation, SteamAppState.StateInvalid, new HashSet { 32472 }); @@ -86,7 +86,7 @@ public void TestNoGame3() public void TestNoGame4() { var installLocation = _fileSystem.DirectoryInfo.New("Game"); - _fileSystem.AddFile("Game/swfoc.exe", new MockFileData(string.Empty)); + _fileSystem.Initialize().WithFile("Game/swfoc.exe"); var mFile = _fileSystem.FileInfo.New("manifest.acf"); var app = new SteamAppManifest(_gameLib.Object, mFile, 1234, "name", installLocation, SteamAppState.StateInvalid, new HashSet()); @@ -102,7 +102,7 @@ public void TestNoGame4() public void TestNoGame5() { var installLocation = _fileSystem.DirectoryInfo.New("Game"); - _fileSystem.AddFile("Game/swfoc.exe", new MockFileData(string.Empty)); + _fileSystem.Initialize().WithFile("Game/swfoc.exe"); var mFile = _fileSystem.FileInfo.New("manifest.acf"); var app = new SteamAppManifest(_gameLib.Object, mFile, 1234, "name", installLocation, SteamAppState.StateFullyInstalled, new HashSet { 32472 }); @@ -118,7 +118,7 @@ public void TestNoGame5() public void TestGameExists1() { var installLocation = _fileSystem.DirectoryInfo.New("Game"); - _fileSystem.AddFile("Game/corruption/swfoc.exe", new MockFileData(string.Empty)); + _fileSystem.Initialize().WithFile("Game/corruption/swfoc.exe"); var mFile = _fileSystem.FileInfo.New("manifest.acf"); var app = new SteamAppManifest(_gameLib.Object, mFile, 1234, "name", installLocation, SteamAppState.StateFullyInstalled, new HashSet { 32472 }); @@ -140,7 +140,7 @@ public void TestGameExists1() public void TestGameExists3() { var installLocation = _fileSystem.DirectoryInfo.New("Game"); - _fileSystem.AddFile("Game/corruption/swfoc.exe", new MockFileData(string.Empty)); + _fileSystem.Initialize().WithFile("Game/corruption/swfoc.exe"); var mFile = _fileSystem.FileInfo.New("manifest.acf"); var app = new SteamAppManifest(_gameLib.Object, mFile, 1234, "name", installLocation, SteamAppState.StateFullyInstalled | SteamAppState.StateAppRunning, new HashSet { 32472 }); @@ -162,7 +162,7 @@ public void TestGameExists3() public void TestGameExists4() { var installLocation = _fileSystem.DirectoryInfo.New("Game"); - _fileSystem.AddFile("Game/GameData/sweaw.exe", new MockFileData(string.Empty)); + _fileSystem.Initialize().WithFile("Game/GameData/sweaw.exe"); var mFile = _fileSystem.FileInfo.New("manifest.acf"); var app = new SteamAppManifest(_gameLib.Object, mFile, 1234, "name", installLocation, SteamAppState.StateFullyInstalled, new HashSet { 32472 }); @@ -184,7 +184,7 @@ public void TestGameExists4() public void TestInvalidRegistry() { var installLocation = _fileSystem.DirectoryInfo.New("Game"); - _fileSystem.AddFile("Game/swfoc.exe", new MockFileData(string.Empty)); + _fileSystem.Initialize().WithFile("Game/swfoc.exe"); var mFile = _fileSystem.FileInfo.New("manifest.acf"); var app = new SteamAppManifest(_gameLib.Object, mFile, 1234, "name", installLocation, SteamAppState.StateFullyInstalled, new HashSet { 32472 }); @@ -207,7 +207,7 @@ public void TestInvalidRegistry() public void TestGameRequiresInit() { var installLocation = _fileSystem.DirectoryInfo.New("Game"); - _fileSystem.AddFile("Game/swfoc.exe", new MockFileData(string.Empty)); + _fileSystem.Initialize().WithFile("Game/swfoc.exe"); var mFile = _fileSystem.FileInfo.New("manifest.acf"); var app = new SteamAppManifest(_gameLib.Object, mFile, 1234, "name", installLocation, SteamAppState.StateFullyInstalled, new HashSet { 32472 }); diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentCommandLineBuilder.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentCommandLineBuilder.cs index 1cdc32da..5a3d8136 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentCommandLineBuilder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentCommandLineBuilder.cs @@ -3,7 +3,6 @@ using System.Linq; using System.Text; using Microsoft.Extensions.DependencyInjection; -using Validation; namespace PetroGlyph.Games.EawFoc.Clients.Arguments; @@ -13,8 +12,9 @@ internal class ArgumentCommandLineBuilder : IArgumentCommandLineBuilder public ArgumentCommandLineBuilder(IServiceProvider serviceProvider) { - Requires.NotNull(serviceProvider, nameof(serviceProvider)); - _validator = serviceProvider.GetService() ?? new ArgumentValidator(); + if (serviceProvider == null) + throw new ArgumentNullException(nameof(serviceProvider)); + _validator = serviceProvider.GetRequiredService(); } /// diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentValueSerializer.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentValueSerializer.cs index da0511d4..df68b3df 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentValueSerializer.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentValueSerializer.cs @@ -3,36 +3,14 @@ using System.ComponentModel; using System.IO.Abstractions; using AnakinRaW.CommonUtilities.FileSystem; +using AnakinRaW.CommonUtilities.FileSystem.Normalization; namespace PetroGlyph.Games.EawFoc.Clients.Arguments; -/// -/// Attribute to indicate that an enum shall be serialized by its name. -/// -[AttributeUsage(AttributeTargets.Enum)] -public class SerializeEnumNameAttribute : Attribute { } - -/// -/// Attribute to indicate that an enum shall be serialized by its underlying value. -/// -[AttributeUsage(AttributeTargets.Enum)] -public class SerializeEnumValueAttribute : Attribute { } - internal class ArgumentValueSerializer { - private readonly IPathHelperService? _pathHelper; - private static readonly Dictionary SpecialTypes; - public ArgumentValueSerializer() - { - } - - internal ArgumentValueSerializer(IPathHelperService pathHelper) - { - _pathHelper = pathHelper; - } - static ArgumentValueSerializer() { SpecialTypes = new Dictionary(); @@ -70,15 +48,21 @@ public string Serialize(object value) public string ShortenPath(IFileSystemInfo target, IDirectoryInfo gameDir) { - var pathHelper = _pathHelper ?? new PathHelperService(gameDir.FileSystem); + var fileSystem = target.FileSystem; - var gamePath = pathHelper.EnsureTrailingSeparator( - pathHelper.NormalizePath(gameDir.FullName, PathNormalizeOptions.Full)); - var targetPath = pathHelper.EnsureTrailingSeparator( - pathHelper.NormalizePath(target.FullName, PathNormalizeOptions.Full)); + var gamePath = PathNormalizer.Normalize(fileSystem.Path.GetFullPath(gameDir.FullName), + PathNormalizeOptions.EnsureTrailingSeparator); + + var targetPath = PathNormalizer.Normalize(fileSystem.Path.GetFullPath(target.FullName), + PathNormalizeOptions.EnsureTrailingSeparator); // It's important not to resolve, as that would give us an absolute path again. - return pathHelper.NormalizePath(pathHelper.GetRelativePath(gamePath, targetPath), PathNormalizeOptions.FullNoResolve); + return PathNormalizer.Normalize(fileSystem.Path.GetRelativePathEx(gamePath, targetPath), new PathNormalizeOptions + { + TrailingDirectorySeparatorBehavior = TrailingDirectorySeparatorBehavior.Trim, + UnifyCase = UnifyCasingKind.UpperCase, + UnifyDirectorySeparators = true + }); } private static TypeConverter? GetConverter(string typeName) diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArgument.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArgument.cs index 595a4110..fcea4649 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArgument.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArgument.cs @@ -1,5 +1,4 @@ using System; -using Validation; namespace PetroGlyph.Games.EawFoc.Clients.Arguments; @@ -30,7 +29,8 @@ public abstract class GameArgument : IGameArgument where T : notnull /// Indicates whether this instance if for debug mode only. protected GameArgument(T value, bool isDebug = false) { - Requires.NotNullAllowStructs(value, nameof(value)); + if (value is null) + throw new ArgumentNullException(nameof(value)); Value = value; DebugArgument = isDebug; } @@ -43,7 +43,7 @@ protected GameArgument(T value, bool isDebug = false) /// If this method returns , /// with return with reason . /// - /// This methods gets called in the sequence of . Returns by default. + /// This method gets called in the sequence of . Returns by default. /// /// /// if the data is valid; otherwise. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArguments/GameArguments.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArguments/GameArguments.cs index e3e59368..0499823e 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArguments/GameArguments.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArguments/GameArguments.cs @@ -22,32 +22,17 @@ public WindowedArgument() : base(ArgumentNameCatalog.WindowedArg, true) /// /// UNKNOWN BEHAVIOR! /// -internal sealed class SafeMode : FlagArgument -{ - public SafeMode() : base(ArgumentNameCatalog.SafeModeArg, true) - { - } -} +internal sealed class SafeMode() : FlagArgument(ArgumentNameCatalog.SafeModeArg, true); /// /// UNKNOWN BEHAVIOR! /// -internal sealed class LowRamArgument : FlagArgument -{ - public LowRamArgument() : base(ArgumentNameCatalog.LowRamArg, true) - { - } -} +internal sealed class LowRamArgument() : FlagArgument(ArgumentNameCatalog.LowRamArg, true); /// /// UNKNOWN BEHAVIOR! /// -internal sealed class MCEArgument : FlagArgument -{ - public MCEArgument() : base(ArgumentNameCatalog.LowRamArg, true, true) - { - } -} +internal sealed class MCEArgument() : FlagArgument(ArgumentNameCatalog.LowRamArg, true, true); #endregion @@ -82,12 +67,7 @@ public NoArtProcessArgument() : base(ArgumentNameCatalog.NoArtProcessArg, true) /// /// UNKNOWN BEHAVIOR! /// -internal sealed class RecordingArgument : FlagArgument -{ - public RecordingArgument() : base(ArgumentNameCatalog.RecordingArg, true) - { - } -} +internal sealed class RecordingArgument() : FlagArgument(ArgumentNameCatalog.RecordingArg, true); /// /// Indicates the game runs in multiple instances. @@ -118,12 +98,7 @@ public PersistAssertsArgument() : base(ArgumentNameCatalog.PersistAssertsArg, tr /// /// UNKNOWN BEHAVIOR! No Timeout when waiting for synchronization?! /// -internal sealed class NoTimeoutArgument : FlagArgument -{ - public NoTimeoutArgument() : base(ArgumentNameCatalog.NoTimeoutArg, true) - { - } -} +internal sealed class NoTimeoutArgument() : FlagArgument(ArgumentNameCatalog.NoTimeoutArg, true); /// /// Skips logging to files. @@ -141,22 +116,13 @@ public SuppressLogArgument() : base(ArgumentNameCatalog.SuppressLogArg, true) /// /// UNKNOWN BEHAVIOR! /// -internal sealed class PreValidateAudioMessagesArgument : FlagArgument -{ - public PreValidateAudioMessagesArgument() : base(ArgumentNameCatalog.PreValidateAudioMessagesArg, true) - { - } -} +internal sealed class PreValidateAudioMessagesArgument() + : FlagArgument(ArgumentNameCatalog.PreValidateAudioMessagesArg, true); /// /// UNKNOWN BEHAVIOR! /// -internal sealed class LeftLeftArgument : FlagArgument -{ - public LeftLeftArgument() : base(ArgumentNameCatalog.LeftLeftArg, true) - { - } -} +internal sealed class LeftLeftArgument() : FlagArgument(ArgumentNameCatalog.LeftLeftArg, true); /// /// Game uses deep synchronization. @@ -200,22 +166,12 @@ public NoIntroArgument() : base(ArgumentNameCatalog.NoIntroArg, true) /// /// UNKNOWN BEHAVIOR! /// -internal sealed class SaveLoadDebugArgument : FlagArgument -{ - public SaveLoadDebugArgument() : base(ArgumentNameCatalog.SaveLoadDebugArg, true) - { - } -} +internal sealed class SaveLoadDebugArgument() : FlagArgument(ArgumentNameCatalog.SaveLoadDebugArg, true); /// /// UNKNOWN BEHAVIOR! /// -internal sealed class RefCountTrackingArgument : FlagArgument -{ - public RefCountTrackingArgument() : base(ArgumentNameCatalog.RefCountTrackingArg, true) - { - } -} +internal sealed class RefCountTrackingArgument() : FlagArgument(ArgumentNameCatalog.RefCountTrackingArg, true); /// /// Indicates that no physical mouse device is used. @@ -233,42 +189,23 @@ public NoHardwareMouseArgument() : base(ArgumentNameCatalog.NoHardwareMouseArg, /// /// UNKNOWN BEHAVIOR! /// -internal sealed class ProcessEnglishAssetsAndExitArgument : FlagArgument -{ - public ProcessEnglishAssetsAndExitArgument() : base(ArgumentNameCatalog.ProcessEnglishAssetsAndExitArg, true) - { - } -} +internal sealed class ProcessEnglishAssetsAndExitArgument() + : FlagArgument(ArgumentNameCatalog.ProcessEnglishAssetsAndExitArg, true); /// /// UNKNOWN BEHAVIOR! /// -internal sealed class ProcessAssetsAndExitArgument : FlagArgument -{ - public ProcessAssetsAndExitArgument() : base(ArgumentNameCatalog.ProcessAssetsAndExitArg, true) - { - } -} +internal sealed class ProcessAssetsAndExitArgument() : FlagArgument(ArgumentNameCatalog.ProcessAssetsAndExitArg, true); /// /// UNKNOWN BEHAVIOR! /// -internal sealed class AttractArgument : FlagArgument -{ - public AttractArgument() : base(ArgumentNameCatalog.AttractArg, true) - { - } -} +internal sealed class AttractArgument() : FlagArgument(ArgumentNameCatalog.AttractArg, true); /// /// UNKNOWN BEHAVIOR! /// -internal sealed class DebugUnitsArgument : FlagArgument -{ - public DebugUnitsArgument() : base(ArgumentNameCatalog.DebugUnitsArg, true) - { - } -} +internal sealed class DebugUnitsArgument() : FlagArgument(ArgumentNameCatalog.DebugUnitsArg, true); /// /// Completely disables the user interface from the game. @@ -286,12 +223,7 @@ public NoMenuArgument() : base(ArgumentNameCatalog.NoMenuArg, true) /// /// UNKNOWN BEHAVIOR! /// -internal sealed class FullScreenArgument : FlagArgument -{ - public FullScreenArgument() : base(ArgumentNameCatalog.FullScreenArg, true) - { - } -} +internal sealed class FullScreenArgument() : FlagArgument(ArgumentNameCatalog.FullScreenArg, true); #endregion @@ -430,19 +362,12 @@ public override string ValueToCommandLine() /// /// UNKNOWN BEHAVIOR! /// -internal sealed class OriginalAssetPathArgument : NamedArgument +internal sealed class OriginalAssetPathArgument(IDirectoryInfo value, IDirectoryInfo gameDirectory) + : NamedArgument(ArgumentNameCatalog.OriginalAssetPathArg, value, true) { - private readonly IDirectoryInfo _gameDirectory; - - public OriginalAssetPathArgument(IDirectoryInfo value, IDirectoryInfo gameDirectory) : - base(ArgumentNameCatalog.OriginalAssetPathArg, value, true) - { - _gameDirectory = gameDirectory; - } - public override string ValueToCommandLine() { - return new ArgumentValueSerializer().ShortenPath(Value, _gameDirectory); + return new ArgumentValueSerializer().ShortenPath(Value, gameDirectory); } } @@ -469,12 +394,9 @@ public override string ValueToCommandLine() /// /// UNKNOWN BEHAVIOR! /// -internal sealed class ExpCDKeyArgument : NamedArgument +internal sealed class ExpCDKeyArgument(string value) + : NamedArgument(ArgumentNameCatalog.ExpCDKeyArg, value, true) { - public ExpCDKeyArgument(string value) : base(ArgumentNameCatalog.ExpCDKeyArg, value, true) - { - } - public override string ValueToCommandLine() { return Value; @@ -484,12 +406,8 @@ public override string ValueToCommandLine() /// /// UNKNOWN BEHAVIOR! /// -internal sealed class CDKeyArgument : NamedArgument +internal sealed class CDKeyArgument(string value) : NamedArgument(ArgumentNameCatalog.CDKeyArg, value, true) { - public CDKeyArgument(string value) : base(ArgumentNameCatalog.CDKeyArg, value, true) - { - } - public override string ValueToCommandLine() { return Value; @@ -499,19 +417,12 @@ public override string ValueToCommandLine() /// /// UNKNOWN BEHAVIOR! /// -internal sealed class MpPlaybackFileArgument : NamedArgument +internal sealed class MpPlaybackFileArgument(IFileInfo value, IDirectoryInfo gameDir) + : NamedArgument(ArgumentNameCatalog.MPPlaybackFileArg, value, true) { - private readonly IDirectoryInfo _gameDir; - - public MpPlaybackFileArgument(IFileInfo value, IDirectoryInfo gameDir) : - base(ArgumentNameCatalog.MPPlaybackFileArg, value, true) - { - _gameDir = gameDir; - } - public override string ValueToCommandLine() { - return new ArgumentValueSerializer().ShortenPath(Value, _gameDir); + return new ArgumentValueSerializer().ShortenPath(Value, gameDir); } } @@ -568,12 +479,9 @@ public override string ValueToCommandLine() /// /// UNKNOWN BEHAVIOR! /// -internal sealed class QuickLoadRecordingArgument : NamedArgument +internal sealed class QuickLoadRecordingArgument(string value) + : NamedArgument(ArgumentNameCatalog.QuickLoadRecordingArg, value, true) { - public QuickLoadRecordingArgument(string value) : base(ArgumentNameCatalog.QuickLoadRecordingArg, value, true) - { - } - public override string ValueToCommandLine() { return Value; @@ -583,12 +491,9 @@ public override string ValueToCommandLine() /// /// UNKNOWN BEHAVIOR! /// -internal sealed class QuickLoadArgument : NamedArgument +internal sealed class QuickLoadArgument(string value) + : NamedArgument(ArgumentNameCatalog.QuickLoadArg, value, true) { - public QuickLoadArgument(string value) : base(ArgumentNameCatalog.QuickLoadArg, value, true) - { - } - public override string ValueToCommandLine() { return Value; @@ -598,12 +503,8 @@ public override string ValueToCommandLine() /// /// UNKNOWN BEHAVIOR! /// -internal sealed class ConfigArgument : NamedArgument +internal sealed class ConfigArgument(string value) : NamedArgument(ArgumentNameCatalog.ConfigArg, value, true) { - public ConfigArgument(string value) : base(ArgumentNameCatalog.ConfigArg, value, true) - { - } - public override string ValueToCommandLine() { return Value; @@ -659,12 +560,8 @@ public override string ValueToCommandLine() /// /// UNKNOWN BEHAVIOR! /// -internal sealed class BCast3Argument : NamedArgument +internal sealed class BCast3Argument(uint value) : NamedArgument(ArgumentNameCatalog.BCast3Arg, value, true) { - public BCast3Argument(uint value) : base(ArgumentNameCatalog.BCast3Arg, value, true) - { - } - public override string ValueToCommandLine() { return new ArgumentValueSerializer().Serialize(Value); @@ -674,12 +571,8 @@ public override string ValueToCommandLine() /// /// UNKNOWN BEHAVIOR! /// -internal sealed class BCast4Argument : NamedArgument +internal sealed class BCast4Argument(uint value) : NamedArgument(ArgumentNameCatalog.BCast4Arg, value, true) { - public BCast4Argument(uint value) : base(ArgumentNameCatalog.BCast4Arg, value, true) - { - } - public override string ValueToCommandLine() { return new ArgumentValueSerializer().Serialize(Value); @@ -810,19 +703,12 @@ public override string ValueToCommandLine() /// /// UNKNOWN BEHAVIOR! /// -internal sealed class ConsoleCommandFileArgument : NamedArgument +internal sealed class ConsoleCommandFileArgument(IFileInfo value, IDirectoryInfo gameDir) + : NamedArgument(ArgumentNameCatalog.ConsoleCommandFileArg, value, true) { - private readonly IDirectoryInfo _gameDir; - - public ConsoleCommandFileArgument(IFileInfo value, IDirectoryInfo gameDir) : - base(ArgumentNameCatalog.ConsoleCommandFileArg, value, true) - { - _gameDir = gameDir; - } - public override string ValueToCommandLine() { - return new ArgumentValueSerializer().ShortenPath(Value, _gameDir); + return new ArgumentValueSerializer().ShortenPath(Value, gameDir); } } @@ -850,12 +736,9 @@ public override string ValueToCommandLine() /// /// UNKNOWN BEHAVIOR! Not sure it 'connects' to. /// -internal sealed class ConnectPortArgument : NamedArgument +internal sealed class ConnectPortArgument(uint value) + : NamedArgument(ArgumentNameCatalog.ConnectPortArg, value, true) { - public ConnectPortArgument(uint value) : base(ArgumentNameCatalog.ConnectPortArg, value, true) - { - } - public override string ValueToCommandLine() { return new ArgumentValueSerializer().Serialize(Value); @@ -865,12 +748,9 @@ public override string ValueToCommandLine() /// /// UNKNOWN BEHAVIOR! Not sure it 'connects' to. /// -internal sealed class ConnectIPArgument : NamedArgument +internal sealed class ConnectIPArgument(string value) + : NamedArgument(ArgumentNameCatalog.ConnectIPArg, value, true) { - public ConnectIPArgument(string value) : base(ArgumentNameCatalog.ConnectIPArg, value, true) - { - } - public override string ValueToCommandLine() { return new ArgumentValueSerializer().Serialize(Value); diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/KeyBasedArgumentCollectionBuilder.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/KeyBasedArgumentCollectionBuilder.cs index 9c053769..8b11ccaf 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/KeyBasedArgumentCollectionBuilder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/KeyBasedArgumentCollectionBuilder.cs @@ -1,6 +1,6 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; -using Validation; namespace PetroGlyph.Games.EawFoc.Clients.Arguments; @@ -34,7 +34,9 @@ public KeyBasedArgumentCollectionBuilder(IArgumentCollection argumentCollection) /// This instance. public IArgumentCollectionBuilder Add(IGameArgument argument) { - Requires.NotNull(argument, nameof(argument)); + if (argument == null) + throw new ArgumentNullException(nameof(argument)); + _argumentDict[argument.Name] = argument; return this; } @@ -42,7 +44,9 @@ public IArgumentCollectionBuilder Add(IGameArgument argument) /// public IArgumentCollectionBuilder Remove(IGameArgument argument) { - Requires.NotNull(argument, nameof(argument)); + if (argument == null) + throw new ArgumentNullException(nameof(argument)); + return Remove(argument.Name); } diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ModArgumentListFactory.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ModArgumentListFactory.cs index 7e9a1a26..640c5b7d 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ModArgumentListFactory.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ModArgumentListFactory.cs @@ -7,7 +7,6 @@ using PetroGlyph.Games.EawFoc.Mods; using PetroGlyph.Games.EawFoc.Services.Dependencies; using PetroGlyph.Games.EawFoc.Services.Steam; -using Validation; namespace PetroGlyph.Games.EawFoc.Clients.Arguments; @@ -26,8 +25,7 @@ public class ModArgumentListFactory : IModArgumentListFactory /// The service provider. public ModArgumentListFactory(IServiceProvider serviceProvider) { - Requires.NotNull(serviceProvider, nameof(serviceProvider)); - _serviceProvider = serviceProvider; + _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); } /// diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/SerializeEnumNameAttribute.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/SerializeEnumNameAttribute.cs new file mode 100644 index 00000000..648581fb --- /dev/null +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/SerializeEnumNameAttribute.cs @@ -0,0 +1,9 @@ +using System; + +namespace PetroGlyph.Games.EawFoc.Clients.Arguments; + +/// +/// Attribute to indicate that an enum shall be serialized by its name. +/// +[AttributeUsage(AttributeTargets.Enum)] +public class SerializeEnumNameAttribute : Attribute { } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/SerializeEnumValueAttribute.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/SerializeEnumValueAttribute.cs new file mode 100644 index 00000000..88bfb175 --- /dev/null +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/SerializeEnumValueAttribute.cs @@ -0,0 +1,9 @@ +using System; + +namespace PetroGlyph.Games.EawFoc.Clients.Arguments; + +/// +/// Attribute to indicate that an enum shall be serialized by its underlying value. +/// +[AttributeUsage(AttributeTargets.Enum)] +public class SerializeEnumValueAttribute : Attribute { } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/AssemblyInfo.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/AssemblyInfo.cs deleted file mode 100644 index e5caa724..00000000 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/AssemblyInfo.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Runtime.CompilerServices; - -//#if DEBUG -[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Steam")] -[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Steam.Windows")] -[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Test")] -[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Steam.Test")] -[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test")] -[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] -//#else -//[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Steam, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a9a456c25c065bc1168c6cbbd797692f366613993df057f7dcda38d72f7e89c8e59f9ed839bc3eec654c766fdf99df3f11d872bd1ef161672d963b4c24bca3ae3928d54bb24eef160875151f91b8666fbf2eb996e1684724ebce8638af0b6c0a5de503d9e911432fb29ce0948bb2372cfc5076a41ba12dd0d37dfd578b9418db")] -//[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Steam.Windows, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a9a456c25c065bc1168c6cbbd797692f366613993df057f7dcda38d72f7e89c8e59f9ed839bc3eec654c766fdf99df3f11d872bd1ef161672d963b4c24bca3ae3928d54bb24eef160875151f91b8666fbf2eb996e1684724ebce8638af0b6c0a5de503d9e911432fb29ce0948bb2372cfc5076a41ba12dd0d37dfd578b9418db")] -//[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a9a456c25c065bc1168c6cbbd797692f366613993df057f7dcda38d72f7e89c8e59f9ed839bc3eec654c766fdf99df3f11d872bd1ef161672d963b4c24bca3ae3928d54bb24eef160875151f91b8666fbf2eb996e1684724ebce8638af0b6c0a5de503d9e911432fb29ce0948bb2372cfc5076a41ba12dd0d37dfd578b9418db")] -//[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Steam.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a9a456c25c065bc1168c6cbbd797692f366613993df057f7dcda38d72f7e89c8e59f9ed839bc3eec654c766fdf99df3f11d872bd1ef161672d963b4c24bca3ae3928d54bb24eef160875151f91b8666fbf2eb996e1684724ebce8638af0b6c0a5de503d9e911432fb29ce0948bb2372cfc5076a41ba12dd0d37dfd578b9418db")] -//[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a9a456c25c065bc1168c6cbbd797692f366613993df057f7dcda38d72f7e89c8e59f9ed839bc3eec654c766fdf99df3f11d872bd1ef161672d963b4c24bca3ae3928d54bb24eef160875151f91b8666fbf2eb996e1684724ebce8638af0b6c0a5de503d9e911432fb29ce0948bb2372cfc5076a41ba12dd0d37dfd578b9418db")] -//[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] -//#endif \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/ClientBase.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/ClientBase.cs index 3597940e..8e795fe7 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/ClientBase.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/ClientBase.cs @@ -6,7 +6,6 @@ using PetroGlyph.Games.EawFoc.Clients.Processes; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Mods; -using Validation; namespace PetroGlyph.Games.EawFoc.Clients; @@ -54,8 +53,7 @@ public IReadOnlyCollection RunningInstances /// The service provider. protected ClientBase(IServiceProvider serviceProvider) { - Requires.NotNull(serviceProvider, nameof(serviceProvider)); - ServiceProvider = serviceProvider; + ServiceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); } /// @@ -94,9 +92,9 @@ protected IGameProcess StartGame(IPlayableObject instance, GameBuildType buildTy var arguments = DefaultArguments; if (instance is IMod mod) { - var modArgFactory = ServiceProvider.GetService() ?? new ModArgumentListFactory(ServiceProvider); + var modArgFactory = ServiceProvider.GetRequiredService(); var modArgs = modArgFactory.BuildArgumentList(mod, false); - var builder = ServiceProvider.GetService() ?? new KeyBasedArgumentCollectionBuilder(); + var builder = ServiceProvider.GetRequiredService(); arguments = builder.AddAll(DefaultArguments).Add(modArgs).Build(); } return StartGame(instance, arguments, buildType); @@ -120,8 +118,10 @@ protected IGameProcess StartGame(IPlayableObject instance, GameBuildType buildTy /// protected IGameProcess StartGame(IPlayableObject instance, IArgumentCollection arguments, GameBuildType type) { - Requires.NotNull(instance, nameof(instance)); - Requires.NotNull(arguments, nameof(arguments)); + if (instance == null) + throw new ArgumentNullException(nameof(instance)); + if (arguments == null) + throw new ArgumentNullException(nameof(arguments)); if (!SupportedPlatforms.Contains(instance.Game.Platform)) throw new GameStartException(instance, diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/DefaultClient.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/DefaultClient.cs index 67dfed14..5fb793df 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/DefaultClient.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/DefaultClient.cs @@ -33,6 +33,6 @@ public DefaultClient(IServiceProvider serviceProvider) : base(serviceProvider) /// The instance. protected internal override IGameProcessLauncher GetGameLauncherService() { - return ServiceProvider.GetService() ?? new DefaultGameProcessLauncher(ServiceProvider); + return ServiceProvider.GetRequiredService(); } } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/GameExecutableFileService.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/GameExecutableFileService.cs index c2e6fe2a..9239261e 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/GameExecutableFileService.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/GameExecutableFileService.cs @@ -7,18 +7,11 @@ namespace PetroGlyph.Games.EawFoc.Clients; -internal class GameExecutableFileService : IGameExecutableFileService +internal class GameExecutableFileService(IServiceProvider serviceProvider) : IGameExecutableFileService { - private readonly IServiceProvider _serviceProvider; - - public GameExecutableFileService(IServiceProvider serviceProvider) - { - _serviceProvider = serviceProvider; - } - public IFileInfo? GetExecutableForGame(IGame game, GameBuildType buildType) { - var nameBuilder = _serviceProvider.GetRequiredService(); + var nameBuilder = serviceProvider.GetRequiredService(); var exeFileName = nameBuilder.GetExecutableFileName(game, buildType); if (string.IsNullOrEmpty(exeFileName)) return null; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/PetroGlyph.Games.EawFoc.Clients.csproj b/src/PetroGlyph.Games.EawFoc.Clients/src/PetroGlyph.Games.EawFoc.Clients.csproj index 6569e428..970935c6 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/PetroGlyph.Games.EawFoc.Clients.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/PetroGlyph.Games.EawFoc.Clients.csproj @@ -19,7 +19,6 @@ - diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/DefaultGameProcessLauncher.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/DefaultGameProcessLauncher.cs index ed36ce22..1cd72eb3 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/DefaultGameProcessLauncher.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/DefaultGameProcessLauncher.cs @@ -3,19 +3,12 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using PetroGlyph.Games.EawFoc.Clients.Arguments; -using Validation; namespace PetroGlyph.Games.EawFoc.Clients.Processes; -internal class DefaultGameProcessLauncher : IGameProcessLauncher +internal class DefaultGameProcessLauncher(IServiceProvider serviceProvider) : IGameProcessLauncher { - private readonly IServiceProvider _serviceProvider; - - public DefaultGameProcessLauncher(IServiceProvider serviceProvider) - { - Requires.NotNull(serviceProvider, nameof(serviceProvider)); - _serviceProvider = serviceProvider; - } + private readonly IServiceProvider _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); public IGameProcess StartGameProcess(IFileInfo executable, GameProcessInfo processInfo) { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcess.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcess.cs index 6ffb5a59..1793c675 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcess.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcess.cs @@ -2,9 +2,8 @@ using System.Diagnostics; using System.Threading; using System.Threading.Tasks; -using Validation; +using AnakinRaW.CommonUtilities; #if !NET -using PetroGlyph.Games.EawFoc.Clients.Threading; #endif namespace PetroGlyph.Games.EawFoc.Clients.Processes; @@ -39,10 +38,8 @@ public event EventHandler? Closed public GameProcess(Process process, GameProcessInfo info) { - Requires.NotNull(process, nameof(process)); - Requires.NotNull(info, nameof(info)); - Process = process; - ProcessInfo = info; + Process = process ?? throw new ArgumentNullException(nameof(process)); + ProcessInfo = info ?? throw new ArgumentNullException(nameof(info)); RegisterExitEvent(process); } diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcessInfo.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcessInfo.cs index 9a37c5d0..45c8ae73 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcessInfo.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcessInfo.cs @@ -1,5 +1,5 @@ -using PetroGlyph.Games.EawFoc.Clients.Arguments; -using Validation; +using System; +using PetroGlyph.Games.EawFoc.Clients.Arguments; namespace PetroGlyph.Games.EawFoc.Clients.Processes; @@ -32,10 +32,8 @@ public class GameProcessInfo /// The arguments of the game process. public GameProcessInfo(IPlayableObject playedInstance, GameBuildType buildType, IArgumentCollection arguments) { - Requires.NotNull(playedInstance, nameof(playedInstance)); - Requires.NotNull(arguments, nameof(arguments)); - PlayedInstance = playedInstance; + PlayedInstance = playedInstance ?? throw new ArgumentNullException(nameof(playedInstance)); BuildType = buildType; - Arguments = arguments; + Arguments = arguments ?? throw new ArgumentNullException(nameof(arguments)); } } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Properties/AssemblyInfo.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..4e81f7f4 --- /dev/null +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Properties/AssemblyInfo.cs @@ -0,0 +1,8 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Steam")] +[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Steam.Windows")] +[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Test")] +[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Steam.Test")] +[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test")] +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Threading/AwaitExtensions.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Threading/AwaitExtensions.cs index c6860ce4..586bcff2 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Threading/AwaitExtensions.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Threading/AwaitExtensions.cs @@ -1,59 +1,54 @@ -using System; -using System.Diagnostics; -using System.Threading; -using System.Threading.Tasks; -using Validation; - -namespace PetroGlyph.Games.EawFoc.Clients.Threading; +namespace PetroGlyph.Games.EawFoc.Clients.Threading; // From https://github.com/microsoft/vs-threading and https://github.com/dotnet/runtime -internal static class AwaitExtensions -{ - /// - /// Returns a task that completes when the process exits and provides the exit code of that process. - /// - /// The process to wait for exit. - /// - /// A token whose cancellation will cause the returned Task to complete - /// before the process exits in a faulted state with an . - /// This token has no effect on the itself. - /// - /// A task whose result is the of the . - public static async Task WaitForExitAsync(this Process process, - CancellationToken cancellationToken = default) - { - Requires.NotNull(process, nameof(process)); - - if (!process.HasExited) - cancellationToken.ThrowIfCancellationRequested(); +//internal static class AwaitExtensions +//{ +// /// +// /// Returns a task that completes when the process exits and provides the exit code of that process. +// /// +// /// The process to wait for exit. +// /// +// /// A token whose cancellation will cause the returned Task to complete +// /// before the process exits in a faulted state with an . +// /// This token has no effect on the itself. +// /// +// /// A task whose result is the of the . +// public static async Task WaitForExitAsync(this Process process, +// CancellationToken cancellationToken = default) +// { +// if (process == null) +// throw new ArgumentNullException(nameof(process)); + +// if (!process.HasExited) +// cancellationToken.ThrowIfCancellationRequested(); - try - { - process.EnableRaisingEvents = true; - } - catch (InvalidOperationException) - { - if (process.HasExited) - return process.ExitCode; - throw; - } +// try +// { +// process.EnableRaisingEvents = true; +// } +// catch (InvalidOperationException) +// { +// if (process.HasExited) +// return process.ExitCode; +// throw; +// } - var tcs = new TaskCompletionSource(); - void Handler(object o, EventArgs eventArgs) => tcs.TrySetResult(process.ExitCode); - try - { - process.Exited += Handler!; - if (process.HasExited) - return process.ExitCode; - using (cancellationToken.Register(() => tcs.TrySetCanceled(cancellationToken))) - { - return await tcs.Task.ConfigureAwait(false); - } - } - finally - { - process.Exited -= Handler!; - } - } -} \ No newline at end of file +// var tcs = new TaskCompletionSource(); +// void Handler(object o, EventArgs eventArgs) => tcs.TrySetResult(process.ExitCode); +// try +// { +// process.Exited += Handler!; +// if (process.HasExited) +// return process.ExitCode; +// using (cancellationToken.Register(() => tcs.TrySetCanceled(cancellationToken))) +// { +// return await tcs.Task.ConfigureAwait(false); +// } +// } +// finally +// { +// process.Exited -= Handler!; +// } +// } +//} \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValueSerializerTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValueSerializerTest.cs index b5687d45..bcc6ded2 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValueSerializerTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValueSerializerTest.cs @@ -1,8 +1,7 @@ using System; -using System.IO.Abstractions.TestingHelpers; -using AnakinRaW.CommonUtilities.FileSystem; -using Moq; using PetroGlyph.Games.EawFoc.Clients.Arguments; +using PG.TestingUtilities; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Clients.Test.Arguments; @@ -39,11 +38,10 @@ public void TestSerializeSignedNotSupported() Assert.Throws(() => serializer.Serialize(-1)); } - [Fact] - public void TestShortenCallsCorrectMethods() + [PlatformSpecificFact(TestPlatformIdentifier.Linux)] + public void TestShorten_Integration_Linux() { - var helper = new Mock(); - var serializer = new ArgumentValueSerializer(helper.Object); + var serializer = new ArgumentValueSerializer(); var fs = new MockFileSystem(); var game = fs.DirectoryInfo.New("game"); @@ -51,12 +49,11 @@ public void TestShortenCallsCorrectMethods() serializer.ShortenPath(mod, game); - helper.Verify(h => h.GetRelativePath(It.IsAny(), It.IsAny()), Times.Exactly(1)); - helper.Verify(h => h.NormalizePath(It.IsAny(), PathNormalizeOptions.FullNoResolve), Times.Exactly(1)); + Assert.Equal("mod", serializer.ShortenPath(mod, game)); } - [Fact] - public void TestShorten_Integration() + [PlatformSpecificFact(TestPlatformIdentifier.Windows)] + public void TestShorten_Integration_Windows() { var serializer = new ArgumentValueSerializer(); @@ -66,6 +63,6 @@ public void TestShorten_Integration() serializer.ShortenPath(mod, game); - Assert.Equal("mod", serializer.ShortenPath(mod, game)); + Assert.Equal("MOD", serializer.ShortenPath(mod, game)); } } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListFactoryTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListFactoryTest.cs index 351e8a2f..ee60b479 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListFactoryTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListFactoryTest.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.IO.Abstractions.TestingHelpers; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; using Moq; @@ -9,6 +8,7 @@ using PetroGlyph.Games.EawFoc.Mods; using PetroGlyph.Games.EawFoc.Services.Dependencies; using PetroGlyph.Games.EawFoc.Services.Steam; +using Testably.Abstractions.Testing; using Xunit; #if NET using System; @@ -97,7 +97,7 @@ public void TestSingleArgModIsRelativeToGame() Assert.Equal("mods/a", arg.Value); else #endif - Assert.Equal("mods\\a", arg.Value); + Assert.Equal("MODS\\A", arg.Value); Assert.Equal(ArgumentNameCatalog.ModPathArg, arg.Name); } @@ -120,7 +120,7 @@ public void TestSingleArgModIsAbsolute() Assert.Equal("../d:/a", arg.Value); else #endif - Assert.Equal("d:\\a", arg.Value); + Assert.Equal("D:\\A", arg.Value); Assert.Equal(ArgumentNameCatalog.ModPathArg, arg.Name); } diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/ClientBaseTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/ClientBaseTest.cs index 88bd57bb..b29b36cc 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/ClientBaseTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/ClientBaseTest.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO.Abstractions; -using System.IO.Abstractions.TestingHelpers; using Microsoft.Extensions.DependencyInjection; using Moq; using PetroGlyph.Games.EawFoc.Games; @@ -10,6 +9,7 @@ using PetroGlyph.Games.EawFoc.Clients.Arguments.GameArguments; using PetroGlyph.Games.EawFoc.Clients.Processes; using PetroGlyph.Games.EawFoc.Mods; +using Testably.Abstractions.Testing; namespace PetroGlyph.Games.EawFoc.Clients.Test { @@ -156,7 +156,7 @@ public void TesGameNotStarted_Throws() _client.Setup(c => c.OnGameStarting(It.IsAny(), ArgumentCollection.Empty, GameBuildType.Release)).Returns(true); var fs = new MockFileSystem(); - fs.AddFile("test.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("test.exe"); _exeService.Setup(s => s.GetExecutableForGame(It.IsAny(), GameBuildType.Release)) .Returns(fs.FileInfo.New("test.exe")); @@ -180,7 +180,7 @@ public void TestGameStarted() _client.Setup(c => c.OnGameStarting(It.IsAny(), It.IsAny(), GameBuildType.Release)).Returns(true); var fs = new MockFileSystem(); - fs.AddFile("test.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("test.exe"); _exeService.Setup(s => s.GetExecutableForGame(It.IsAny(), GameBuildType.Release)) .Returns(fs.FileInfo.New("test.exe")); @@ -232,7 +232,7 @@ public void TestRunningInstanceListUpdates() _client.Setup(c => c.OnGameStarting(It.IsAny(), It.IsAny(), GameBuildType.Release)).Returns(true); var fs = new MockFileSystem(); - fs.AddFile("test.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("test.exe"); _exeService.Setup(s => s.GetExecutableForGame(It.IsAny(), GameBuildType.Release)) .Returns(fs.FileInfo.New("test.exe")); @@ -272,7 +272,7 @@ public void TestGameStartedButClosedWhileInHandler() _client.Setup(c => c.OnGameStarting(It.IsAny(), It.IsAny(), GameBuildType.Release)).Returns(true); var fs = new MockFileSystem(); - fs.AddFile("test.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("test.exe"); _exeService.Setup(s => s.GetExecutableForGame(It.IsAny(), GameBuildType.Release)) .Returns(fs.FileInfo.New("test.exe")); diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/DebugableClientBaseTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/DebugableClientBaseTest.cs index 91d5ba74..4d94819d 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/DebugableClientBaseTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/DebugableClientBaseTest.cs @@ -1,12 +1,12 @@ using System; using System.Collections.Generic; using System.IO.Abstractions; -using System.IO.Abstractions.TestingHelpers; using Microsoft.Extensions.DependencyInjection; using Moq; using PetroGlyph.Games.EawFoc.Clients.Arguments; using PetroGlyph.Games.EawFoc.Clients.Processes; using PetroGlyph.Games.EawFoc.Games; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Clients.Test; @@ -39,7 +39,9 @@ public void TestIsDebugAvailable() _exeService.Setup(s => s.GetExecutableForGame(It.IsAny(), It.IsAny())) .Returns(fs.FileInfo.New("test.exe")); Assert.False(_service.IsDebugAvailable(game.Object)); - fs.AddFile("test.exe", new MockFileData(string.Empty)); + + fs.Initialize().WithFile("test.exe"); + _exeService.Setup(s => s.GetExecutableForGame(It.IsAny(), It.IsAny())) .Returns(fs.FileInfo.New("test.exe")); Assert.True(_service.IsDebugAvailable(game.Object)); @@ -52,7 +54,7 @@ public void TestDebugGame() game.Setup(g => g.Game).Returns(game.Object); game.Setup(g => g.Platform).Returns(GamePlatform.Disk); var fs = new MockFileSystem(); - fs.AddFile("release.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("release.exe"); _exeService.Setup(s => s.GetExecutableForGame(It.IsAny(), GameBuildType.Debug)) .Returns(fs.FileInfo.New("debug.exe")); @@ -71,7 +73,7 @@ public void TestDebugGame() Assert.Equal(GameBuildType.Release, realProcess.ProcessInfo.BuildType); // Use Debug - fs.AddFile("debug.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("debug.exe"); var debugProcess = new Mock(); debugProcess.Setup(p => p.ProcessInfo) .Returns(new GameProcessInfo(game.Object, GameBuildType.Debug, ArgumentCollection.Empty)); @@ -81,13 +83,8 @@ public void TestDebugGame() } - - private class TestDebugClient : DebugableClientBase + private class TestDebugClient(IServiceProvider serviceProvider) : DebugableClientBase(serviceProvider) { - public TestDebugClient(IServiceProvider serviceProvider) : base(serviceProvider) - { - } - public override ISet SupportedPlatforms => new HashSet { GamePlatform.Disk }; protected internal override IGameProcessLauncher GetGameLauncherService() { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/DefaultClientTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/DefaultClientTest.cs index fa316dde..032bd009 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/DefaultClientTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/DefaultClientTest.cs @@ -1,9 +1,9 @@ using System.IO.Abstractions; -using System.IO.Abstractions.TestingHelpers; using Microsoft.Extensions.DependencyInjection; using Moq; using PetroGlyph.Games.EawFoc.Clients.Processes; using PetroGlyph.Games.EawFoc.Games; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Clients.Test; @@ -18,7 +18,7 @@ public class DefaultClientTest public DefaultClientTest() { var fs = new MockFileSystem(); - fs.AddFile("test.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("test.exe"); var sc = new ServiceCollection(); var fileService = new Mock(); fileService.Setup(s => s.GetExecutableForGame(It.IsAny(), It.IsAny())) diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableFileServiceTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableFileServiceTest.cs index 82f3b483..dc443c6b 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableFileServiceTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableFileServiceTest.cs @@ -1,7 +1,7 @@ -using System.IO.Abstractions.TestingHelpers; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using Moq; using PetroGlyph.Games.EawFoc.Games; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Clients.Test; @@ -33,14 +33,12 @@ public void TestInvalidName() [Fact] public void TestFileNotExists() { -#if NET - return; -#endif var game = new Mock(); _nameBuilder.Setup(b => b.GetExecutableFileName(It.IsAny(), It.IsAny())) .Returns("test.exe"); var fs = new MockFileSystem(); + fs.Initialize(); game.Setup(g => g.Directory).Returns(fs.DirectoryInfo.New(".")); var exeFile = _service.GetExecutableForGame(game.Object, GameBuildType.Debug); @@ -50,15 +48,12 @@ public void TestFileNotExists() [Fact] public void TestExists() { -#if NET - return; -#endif var game = new Mock(); _nameBuilder.Setup(b => b.GetExecutableFileName(It.IsAny(), It.IsAny())) .Returns("test.exe"); var fs = new MockFileSystem(); - fs.AddFile("test.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("test.exe"); game.Setup(g => g.Directory).Returns(fs.DirectoryInfo.New(".")); var exeFile = _service.GetExecutableForGame(game.Object, GameBuildType.Debug); diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/PetroGlyph.Games.EawFoc.Clients.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients/test/PetroGlyph.Games.EawFoc.Clients.Test.csproj index 264d05f2..5c06f75c 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/PetroGlyph.Games.EawFoc.Clients.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/PetroGlyph.Games.EawFoc.Clients.Test.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 $(TargetFrameworks);net48 false enable @@ -9,20 +9,20 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -30,6 +30,7 @@ + diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/DefaultGameProcessLauncherTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/DefaultGameProcessLauncherTest.cs index 785eaa1f..571cccb7 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/DefaultGameProcessLauncherTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/DefaultGameProcessLauncherTest.cs @@ -1,9 +1,9 @@ -using System.IO.Abstractions.TestingHelpers; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using Moq; using PetroGlyph.Games.EawFoc.Clients.Arguments; using PetroGlyph.Games.EawFoc.Clients.Processes; using PetroGlyph.Games.EawFoc.Games; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Clients.Test.Processes; @@ -35,10 +35,11 @@ public void TestWrapsException_Throws1() { var fs = new MockFileSystem(); var game = new Mock(); - game.Setup(g => g.Game).Returns(game.Object); - game.Setup(g => g.Directory).Returns(new MockDirectoryInfo(fs, "path")); + game.Setup(g => g.Game).Returns(game.Object); + game.Setup(g => g.Directory).Returns(fs.DirectoryInfo.New("path")); var process = new GameProcessInfo(game.Object, GameBuildType.Release, ArgumentCollection.Empty); - Assert.Throws(() => _service.StartGameProcess(new MockFileInfo(fs, "test.exe"), process)); + Assert.Throws(() => _service.StartGameProcess(fs.FileInfo.New("test.exe"), process)); + _builder.Verify(b => b.BuildCommandLine(ArgumentCollection.Empty), Times.Exactly(1)); } } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/src/AssemblyInfo.cs b/src/PetroGlyph.Games.EawFoc/src/AssemblyInfo.cs deleted file mode 100644 index 6ce1df36..00000000 --- a/src/PetroGlyph.Games.EawFoc/src/AssemblyInfo.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Runtime.CompilerServices; - -//#if DEBUG -[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Test")] -[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] -//#else -//[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a9a456c25c065bc1168c6cbbd797692f366613993df057f7dcda38d72f7e89c8e59f9ed839bc3eec654c766fdf99df3f11d872bd1ef161672d963b4c24bca3ae3928d54bb24eef160875151f91b8666fbf2eb996e1684724ebce8638af0b6c0a5de503d9e911432fb29ce0948bb2372cfc5076a41ba12dd0d37dfd578b9418db")] -//[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] -//#endif - - diff --git a/src/PetroGlyph.Games.EawFoc/src/Games/PetroglyphStarWarsGame.cs b/src/PetroGlyph.Games.EawFoc/src/Games/PetroglyphStarWarsGame.cs index f7b55b2a..27bbe671 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Games/PetroglyphStarWarsGame.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Games/PetroglyphStarWarsGame.cs @@ -4,7 +4,7 @@ using System.IO; using System.IO.Abstractions; using System.Linq; -using AnakinRaW.CommonUtilities.FileSystem; +using AnakinRaW.CommonUtilities.FileSystem.Normalization; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; using PetroGlyph.Games.EawFoc.Mods; @@ -12,7 +12,6 @@ using PetroGlyph.Games.EawFoc.Services.FileService; using PetroGlyph.Games.EawFoc.Services.Icon; using PetroGlyph.Games.EawFoc.Services.Language; -using Validation; namespace PetroGlyph.Games.EawFoc.Games; @@ -27,12 +26,7 @@ public class PetroglyphStarWarsGame : PlayableObject, IGame private readonly string _normalizedPath; private IPhysicalFileService? _fileService; private IDirectoryInfo? _modLocation; - - /// - /// Service for handling file system paths. - /// - protected readonly IPathHelperService PathHelperService; - + /// /// Shared Service provider instance. /// @@ -83,7 +77,7 @@ public virtual IPhysicalFileService FileService { if (_fileService is not null) return _fileService; - var fs = ServiceProvider.GetService() ?? (IPhysicalFileService?)new DefaultFileService(this); + var fs = ServiceProvider.GetService(); _fileService = fs!; return _fileService; } @@ -95,28 +89,34 @@ public virtual IPhysicalFileService FileService /// /// Creates a new game instance. /// - /// - /// - /// - /// + /// The game identity. + /// The game directory + /// The name of the game. + /// The service provider. public PetroglyphStarWarsGame( IGameIdentity gameIdentity, IDirectoryInfo gameDirectory, string name, IServiceProvider serviceProvider) { - Requires.NotNullAllowStructs(gameIdentity, nameof(gameIdentity)); - Requires.NotNullOrEmpty(name, nameof(name)); - Requires.NotNull(gameDirectory, nameof(gameDirectory)); - Requires.NotNull(serviceProvider, nameof(serviceProvider)); + if (gameDirectory == null) + throw new ArgumentNullException(nameof(gameDirectory)); + if (serviceProvider == null) + throw new ArgumentNullException(nameof(serviceProvider)); + if (gameIdentity is null) + throw new ArgumentNullException(nameof(gameIdentity)); + AnakinRaW.CommonUtilities.ThrowHelper.ThrowIfNullOrEmpty(name); + Name = name; Type = gameIdentity.Type; Platform = gameIdentity.Platform; Directory = gameDirectory; ServiceProvider = serviceProvider; - PathHelperService = serviceProvider.GetService() ?? - new PathHelperService(gameDirectory.FileSystem); - _normalizedPath = PathHelperService.NormalizePath(Directory.FullName, PathNormalizeOptions.Full); + _normalizedPath = PathNormalizer.Normalize(FileSystem.Path.GetFullPath(Directory.FullName), new PathNormalizeOptions + { + TrailingDirectorySeparatorBehavior = TrailingDirectorySeparatorBehavior.Trim, + UnifyCase = UnifyCasingKind.UpperCase + }); } /// @@ -205,8 +205,11 @@ public bool Equals(IGame? other) return false; if (Platform != other.Platform) return false; - var normalizedDirectory = - PathHelperService.NormalizePath(other.Directory.FullName, PathNormalizeOptions.Full); + var normalizedDirectory = PathNormalizer.Normalize(FileSystem.Path.GetFullPath(other.Directory.FullName), new PathNormalizeOptions + { + TrailingDirectorySeparatorBehavior = TrailingDirectorySeparatorBehavior.Trim, + UnifyCase = UnifyCasingKind.UpperCase + }); return _normalizedPath.Equals(normalizedDirectory, StringComparison.Ordinal); } diff --git a/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryBase.cs b/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryBase.cs index 59daa298..45d3bba9 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryBase.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryBase.cs @@ -2,7 +2,6 @@ using System.IO.Abstractions; using AnakinRaW.CommonUtilities.Registry; using Microsoft.Extensions.DependencyInjection; -using Validation; #if NET using System.Diagnostics.CodeAnalysis; #endif @@ -154,10 +153,9 @@ public int? Revision /// Service provider for this instance. public GameRegistry(GameType gameType, IRegistryKey registryKey, IServiceProvider serviceProvider) { - Requires.NotNull(registryKey, nameof(registryKey)); Type = gameType; - _registryKey = registryKey; - _fileSystem = serviceProvider.GetService() ?? new FileSystem(); + _registryKey = registryKey ?? throw new ArgumentNullException(nameof(registryKey)); + _fileSystem = serviceProvider.GetRequiredService(); } /// diff --git a/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryFactory.cs b/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryFactory.cs index d09a230c..7901b045 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryFactory.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryFactory.cs @@ -1,8 +1,6 @@ using System; using AnakinRaW.CommonUtilities.Registry; using Microsoft.Extensions.DependencyInjection; -using Validation; - namespace PetroGlyph.Games.EawFoc.Games.Registry; /// @@ -17,7 +15,8 @@ public class GameRegistryFactory : IGameRegistryFactory /// public IGameRegistry CreateRegistry(GameType type, IServiceProvider serviceProvider) { - Requires.NotNull(serviceProvider, nameof(serviceProvider)); + if (serviceProvider == null) + throw new ArgumentNullException(nameof(serviceProvider)); var registry = serviceProvider.GetRequiredService(); var baseKey = registry.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32); diff --git a/src/PetroGlyph.Games.EawFoc/src/Mods/Mod.cs b/src/PetroGlyph.Games.EawFoc/src/Mods/Mod.cs index 6d350bfe..5dc70fe5 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Mods/Mod.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Mods/Mod.cs @@ -1,12 +1,10 @@ using System; using System.IO.Abstractions; -using AnakinRaW.CommonUtilities.FileSystem; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Services.Detection; using PetroGlyph.Games.EawFoc.Services.FileService; -using Validation; namespace PetroGlyph.Games.EawFoc.Mods; @@ -20,11 +18,6 @@ public class Mod : ModBase, IPhysicalMod internal string InternalPath { get; } - /// - /// Service for handling file system paths. - /// - protected readonly IPathHelperService PathHelperService; - /// public IDirectoryInfo Directory { get; } @@ -38,9 +31,7 @@ public virtual IPhysicalFileService FileService { if (_fileService is not null) return _fileService; - var fs = ServiceProvider.GetService() ?? - (IPhysicalFileService?)new DefaultFileService(this); - _fileService = fs!; + _fileService = new DefaultFileService(this); return _fileService; } } @@ -59,8 +50,7 @@ public override string Identifier { if (string.IsNullOrEmpty(_identifier)) { - var identifierBuilder = ServiceProvider.GetService() - ?? new ModIdentifierBuilder(ServiceProvider); + var identifierBuilder = ServiceProvider.GetRequiredService(); _identifier = identifierBuilder.Build(this); } return _identifier!; @@ -78,12 +68,10 @@ public override string Identifier public Mod(IGame game, IDirectoryInfo modDirectory, bool workshop, IModinfoFile modinfoFile, IServiceProvider serviceProvider) : base(game, workshop ? ModType.Workshops : ModType.Default, modinfoFile?.GetModinfo()!, serviceProvider) { - Requires.NotNull(modDirectory, nameof(modDirectory)); - Requires.NotNull(serviceProvider, nameof(serviceProvider)); + if (serviceProvider == null) + throw new ArgumentNullException(nameof(serviceProvider)); ModinfoFile = modinfoFile; - Directory = modDirectory; - PathHelperService = serviceProvider.GetService() ?? - new PathHelperService(modDirectory.FileSystem); + Directory = modDirectory ?? throw new ArgumentNullException(nameof(modDirectory)); InternalPath = CreateInternalPath(modDirectory); } @@ -98,12 +86,12 @@ public Mod(IGame game, IDirectoryInfo modDirectory, bool workshop, IModinfoFile public Mod(IGame game, IDirectoryInfo modDirectory, bool workshop, string name, IServiceProvider serviceProvider) : base(game, workshop ? ModType.Workshops : ModType.Default, name, serviceProvider) { - Requires.NotNull(modDirectory, nameof(modDirectory)); - Requires.NotNullOrEmpty(name, nameof(name)); - Requires.NotNull(serviceProvider, nameof(serviceProvider)); + if (modDirectory == null) + throw new ArgumentNullException(nameof(modDirectory)); + if (serviceProvider == null) + throw new ArgumentNullException(nameof(serviceProvider)); + AnakinRaW.CommonUtilities.ThrowHelper.ThrowIfNullOrEmpty(name); Directory = modDirectory; - PathHelperService = serviceProvider.GetService() ?? - new PathHelperService(modDirectory.FileSystem); InternalPath = CreateInternalPath(modDirectory); } @@ -118,16 +106,14 @@ public Mod(IGame game, IDirectoryInfo modDirectory, bool workshop, string name, public Mod(IGame game, IDirectoryInfo modDirectory, bool workshop, IModinfo modInfoData, IServiceProvider serviceProvider) : base(game, workshop ? ModType.Workshops : ModType.Default, modInfoData, serviceProvider) { - Requires.NotNull(modDirectory, nameof(modDirectory)); - Requires.NotNull(serviceProvider, nameof(serviceProvider)); - Directory = modDirectory; - PathHelperService = serviceProvider.GetService() ?? - new PathHelperService(modDirectory.FileSystem); + if (serviceProvider == null) + throw new ArgumentNullException(nameof(serviceProvider)); + Directory = modDirectory ?? throw new ArgumentNullException(nameof(modDirectory)); InternalPath = CreateInternalPath(modDirectory); } internal string CreateInternalPath(IDirectoryInfo directory) { - return PathHelperService.NormalizePath(directory.FullName, PathNormalizeOptions.Full); + return FileSystem.Path.GetFullPath(directory.FullName); } } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/src/Mods/ModBase.cs b/src/PetroGlyph.Games.EawFoc/src/Mods/ModBase.cs index c9fd6cf8..b0b81461 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Mods/ModBase.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Mods/ModBase.cs @@ -12,7 +12,6 @@ using PetroGlyph.Games.EawFoc.Services.Icon; using PetroGlyph.Games.EawFoc.Services.Language; using Semver; -using Validation; namespace PetroGlyph.Games.EawFoc.Mods; @@ -88,7 +87,7 @@ public IModinfo? ModInfo public SemVersion? Version => _modVersion ??= InitializeVersion(); IModDependencyList IModIdentity.Dependencies => - new DependencyList(Dependencies.OfType().ToList(), DependencyResolveLayout); + new DependencyList(Dependencies.Select(d => d.Mod).OfType().ToList(), DependencyResolveLayout); /// public IReadOnlyList Dependencies => DependenciesInternal.ToList(); @@ -112,9 +111,11 @@ public IModinfo? ModInfo /// The service provider. protected ModBase(IGame game, ModType type, string name, IServiceProvider serviceProvider) { - Requires.NotNull(game, nameof(game)); - Requires.NotNullOrEmpty(name, nameof(name)); - Requires.NotNull(serviceProvider, nameof(serviceProvider)); + if (game == null) + throw new ArgumentNullException(nameof(game)); + if (serviceProvider == null) + throw new ArgumentNullException(nameof(serviceProvider)); + AnakinRaW.CommonUtilities.ThrowHelper.ThrowIfNullOrEmpty(name); ServiceProvider = serviceProvider; Name = name; Game = game; @@ -131,9 +132,12 @@ protected ModBase(IGame game, ModType type, string name, IServiceProvider servic /// when is not valid. protected ModBase(IGame game, ModType type, IModinfo modinfo, IServiceProvider serviceProvider) { - Requires.NotNull(game, nameof(game)); - Requires.NotNull(modinfo, nameof(modinfo)); - Requires.NotNull(serviceProvider, nameof(serviceProvider)); + if (game == null) + throw new ArgumentNullException(nameof(game)); + if (modinfo == null) + throw new ArgumentNullException(nameof(modinfo)); + if (serviceProvider == null) + throw new ArgumentNullException(nameof(serviceProvider)); modinfo.Validate(); _modInfo = modinfo; ServiceProvider = serviceProvider; @@ -145,8 +149,10 @@ protected ModBase(IGame game, ModType type, IModinfo modinfo, IServiceProvider s /// public virtual void ResolveDependencies(IDependencyResolver resolver, DependencyResolverOptions options) { - Requires.NotNull(resolver, nameof(resolver)); - Requires.NotNull(options, nameof(options)); + if (resolver == null) + throw new ArgumentNullException(nameof(resolver)); + if (options == null) + throw new ArgumentNullException(nameof(options)); if (DependencyResolveStatus == DependencyResolveStatus.Resolving) throw new ModDependencyCycleException(this, "Already resolving the current instance's dependencies. Is there a Cycle?"); diff --git a/src/PetroGlyph.Games.EawFoc/src/Mods/ModDependencyEntry.cs b/src/PetroGlyph.Games.EawFoc/src/Mods/ModDependencyEntry.cs index c4fd35aa..f74765fd 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Mods/ModDependencyEntry.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Mods/ModDependencyEntry.cs @@ -1,7 +1,6 @@ using System; using EawModinfo.Spec; using Semver; -using Validation; namespace PetroGlyph.Games.EawFoc.Mods; @@ -39,8 +38,7 @@ public ModDependencyEntry(IMod mod) : this(mod, null) /// The original version range instance. public ModDependencyEntry(IMod mod, SemVersionRange? range) { - Requires.NotNull(mod, nameof(mod)); - Mod = mod; + Mod = mod ?? throw new ArgumentNullException(nameof(mod)); VersionRange = range; } diff --git a/src/PetroGlyph.Games.EawFoc/src/Mods/VirtualMod.cs b/src/PetroGlyph.Games.EawFoc/src/Mods/VirtualMod.cs index d7181ba8..9cc5093a 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Mods/VirtualMod.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Mods/VirtualMod.cs @@ -6,7 +6,6 @@ using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Services.Dependencies; using PetroGlyph.Games.EawFoc.Services.Detection; -using Validation; namespace PetroGlyph.Games.EawFoc.Mods; @@ -65,7 +64,8 @@ public VirtualMod(IGame game, IModinfo modInfoData, IServiceProvider serviceProv public VirtualMod(string name, IGame game, IList dependencies, DependencyResolveLayout layout, IServiceProvider serviceProvider) : base(game, ModType.Virtual, name, serviceProvider) { - Requires.NotNull(dependencies, nameof(dependencies)); + if (dependencies == null) + throw new ArgumentNullException(nameof(dependencies)); if (!dependencies.Any()) throw new PetroglyphException("Virtual mods must be initialized with pre-defined dependencies"); @@ -121,7 +121,7 @@ protected override void OnDependenciesChanged(ModDependenciesChangedEventArgs e) private string CalculateIdentifier() { - var builder = ServiceProvider.GetService() ?? new ModIdentifierBuilder(ServiceProvider); + var builder = ServiceProvider.GetRequiredService(); return builder.Build(this); } } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj b/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj index 7a2770bb..e32be684 100644 --- a/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj +++ b/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj @@ -5,7 +5,7 @@ - netstandard2.0;net6.0 + netstandard2.0;net8.0 enable true @@ -19,16 +19,24 @@ - - - + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + - - - + + + - - + \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/src/Properties/AssemblyInfo.cs b/src/PetroGlyph.Games.EawFoc/src/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..d988f545 --- /dev/null +++ b/src/PetroGlyph.Games.EawFoc/src/Properties/AssemblyInfo.cs @@ -0,0 +1,5 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Test")] +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] + diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/CompositeGameDetector.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/CompositeGameDetector.cs index 628779be..ae38a7e9 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/CompositeGameDetector.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/CompositeGameDetector.cs @@ -3,7 +3,6 @@ using System.Linq; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.Detection; @@ -33,8 +32,9 @@ public sealed class CompositeGameDetector : IGameDetector /// Default is public CompositeGameDetector(IList sortedDetectors, IServiceProvider serviceProvider, bool disposeDetectors = false) { - Requires.NotNullOrEmpty(sortedDetectors, nameof(sortedDetectors)); - Requires.NotNull(serviceProvider, nameof(serviceProvider)); + if (serviceProvider == null) + throw new ArgumentNullException(nameof(serviceProvider)); + ThrowHelper.ThrowIfCollectionNullOrEmpty(sortedDetectors); SortedDetectors = sortedDetectors; _logger = serviceProvider.GetService()?.CreateLogger(GetType()); _disposeDetectors = disposeDetectors; diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/DirectoryGameDetector.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/DirectoryGameDetector.cs index a911f2fb..cc983381 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/DirectoryGameDetector.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/DirectoryGameDetector.cs @@ -4,7 +4,6 @@ using System.Linq; using Microsoft.Extensions.Logging; using PetroGlyph.Games.EawFoc.Games; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.Detection; @@ -25,8 +24,7 @@ public sealed class DirectoryGameDetector : GameDetector /// The service provider. public DirectoryGameDetector(IDirectoryInfo directory, IServiceProvider serviceProvider) : base(serviceProvider, false) { - Requires.NotNull(directory, nameof(directory)); - _directory = directory; + _directory = directory ?? throw new ArgumentNullException(nameof(directory)); } /// diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetectionResult.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetectionResult.cs index 2bff4c15..d0e84894 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetectionResult.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetectionResult.cs @@ -1,7 +1,6 @@ using System; using System.IO.Abstractions; using PetroGlyph.Games.EawFoc.Games; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.Detection; @@ -42,9 +41,8 @@ private GameDetectionResult(GameType type) /// The actual location of the game. Must not be public GameDetectionResult(IGameIdentity gameIdentity, IDirectoryInfo location) { - Requires.NotNull(location, nameof(location)); GameIdentity = gameIdentity; - GameLocation = location; + GameLocation = location ?? throw new ArgumentNullException(nameof(location)); } internal GameDetectionResult(GameType type, Exception error) : this(type) diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetector.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetector.cs index f6a80de1..245fce0b 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetector.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetector.cs @@ -4,7 +4,6 @@ using Microsoft.Extensions.Logging; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Services.Detection.Platform; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.Detection; @@ -42,8 +41,7 @@ public abstract class GameDetector : IGameDetector /// When set to the event will not be raised and initialization cannot be handled. protected GameDetector(IServiceProvider serviceProvider, bool tryHandleInitialization) { - Requires.NotNull(serviceProvider, nameof(serviceProvider)); - ServiceProvider = serviceProvider; + ServiceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); _tryHandleInitialization = tryHandleInitialization; Logger = serviceProvider.GetService()?.CreateLogger(GetType()); FileSystem = serviceProvider.GetService() ?? new FileSystem(); diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetectorOptions.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetectorOptions.cs index c922666a..0e2999d6 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetectorOptions.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetectorOptions.cs @@ -1,7 +1,7 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using PetroGlyph.Games.EawFoc.Games; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.Detection; @@ -23,11 +23,7 @@ public record GameDetectorOptions(GameType Type) public IList TargetPlatforms { get => _targetPlatforms; - set - { - Requires.NotNull(value, nameof(value)); - _targetPlatforms = value; - } + set => _targetPlatforms = value ?? throw new ArgumentNullException(nameof(value)); } internal GameDetectorOptions Normalize() diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/GamePlatformIdentifier.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/GamePlatformIdentifier.cs index 69ccc272..617db426 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/GamePlatformIdentifier.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/GamePlatformIdentifier.cs @@ -5,7 +5,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using PetroGlyph.Games.EawFoc.Games; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.Detection.Platform; @@ -38,23 +37,24 @@ public sealed class GamePlatformIdentifier : IGamePlatformIdentifier /// Service Provider public GamePlatformIdentifier(IServiceProvider serviceProvider) { - Requires.NotNull(serviceProvider, nameof(serviceProvider)); - _serviceProvider = serviceProvider; + _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); _logger = serviceProvider.GetService()?.CreateLogger(typeof(GamePlatformIdentifier)); } /// public GamePlatform GetGamePlatform(GameType type, ref IDirectoryInfo location) { - Requires.NotNull(location, nameof(location)); + if (location == null) throw new ArgumentNullException(nameof(location)); return GetGamePlatformCore(type, ref location, DefaultGamePlatformOrdering); } /// public GamePlatform GetGamePlatform(GameType type, ref IDirectoryInfo location, IList lookupPlatforms) { - Requires.NotNull(location, nameof(location)); - Requires.NotNull(lookupPlatforms, nameof(lookupPlatforms)); + if (location == null) + throw new ArgumentNullException(nameof(location)); + if (lookupPlatforms == null) + throw new ArgumentNullException(nameof(lookupPlatforms)); return GetGamePlatformCore(type, ref location, NormalizeLookupPlatforms(lookupPlatforms)); } diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/RegistryGameDetector.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/RegistryGameDetector.cs index 178ba385..078ed55a 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/RegistryGameDetector.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/RegistryGameDetector.cs @@ -2,7 +2,6 @@ using Microsoft.Extensions.Logging; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Games.Registry; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.Detection; @@ -26,10 +25,8 @@ public sealed class RegistryGameDetector : GameDetector, IDisposable public RegistryGameDetector(IGameRegistry eawRegistry, IGameRegistry focRegistry, bool tryHandleInitialization, IServiceProvider serviceProvider) : base(serviceProvider, tryHandleInitialization) { - Requires.NotNull(eawRegistry, nameof(eawRegistry)); - Requires.NotNull(focRegistry, nameof(focRegistry)); - _eawRegistry = eawRegistry; - _focRegistry = focRegistry; + _eawRegistry = eawRegistry ?? throw new ArgumentNullException(nameof(eawRegistry)); + _focRegistry = focRegistry ?? throw new ArgumentNullException(nameof(focRegistry)); } /// diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/GameFactory.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/GameFactory.cs index bbf9a236..42a3f237 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/GameFactory.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/GameFactory.cs @@ -4,7 +4,6 @@ using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Services.Detection; using PetroGlyph.Games.EawFoc.Services.Name; -using Validation; namespace PetroGlyph.Games.EawFoc.Services; @@ -42,18 +41,16 @@ public GameFactory(IGameNameResolver nameResolver, IServiceProvider serviceProvi /// The service provider which gets passed to the game instances. public GameFactory(IGameNameResolver nameResolver, CultureInfo nameCulture, IServiceProvider serviceProvider) { - Requires.NotNull(serviceProvider, nameof(serviceProvider)); - Requires.NotNull(nameResolver, nameof(nameResolver)); - Requires.NotNull(nameCulture, nameof(nameCulture)); - _nameResolver = nameResolver; - _nameCulture = nameCulture; - _serviceProvider = serviceProvider; + _nameResolver = nameResolver ?? throw new ArgumentNullException(nameof(nameResolver)); + _nameCulture = nameCulture ?? throw new ArgumentNullException(nameof(nameCulture)); + _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); } /// public IGame CreateGame(GameDetectionResult gameDetection) { - Requires.NotNull(gameDetection, nameof(gameDetection)); + if (gameDetection == null) + throw new ArgumentNullException(nameof(gameDetection)); if (gameDetection.Error is not null) throw new GameException("Unable to create a game from faulted detection result."); if (gameDetection.GameLocation is null) @@ -64,7 +61,8 @@ public IGame CreateGame(GameDetectionResult gameDetection) /// public IGame CreateGame(IGameIdentity identity, IDirectoryInfo location, bool checkGameExists) { - Requires.NotNull(location, nameof(location)); + if (location == null) + throw new ArgumentNullException(nameof(location)); if (identity.Platform == GamePlatform.Undefined) throw new ArgumentException("Cannot create a game with undefined platform"); diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Icon/CompositeGameIconFinder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Icon/CompositeGameIconFinder.cs index ff480cfb..cc151454 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Icon/CompositeGameIconFinder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Icon/CompositeGameIconFinder.cs @@ -1,6 +1,6 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using PetroGlyph.Games.EawFoc.Games; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.Icon; @@ -17,7 +17,7 @@ public class CompositeGameIconFinder : IGameIconFinder /// Ordered list of s. public CompositeGameIconFinder(IList orderedFinders) { - Requires.NotNullOrEmpty(orderedFinders, nameof(orderedFinders)); + ThrowHelper.ThrowIfCollectionNullOrEmpty(orderedFinders); _orderedFinders = orderedFinders; } @@ -28,7 +28,8 @@ public CompositeGameIconFinder(IList orderedFinders) /// The first found icon path or public string? FindIcon(IGame game) { - Requires.NotNull(game, nameof(game)); + if (game == null) + throw new ArgumentNullException(nameof(game)); foreach (var finder in _orderedFinders) { var iconFile = finder.FindIcon(game); diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Icon/FallbackGameIconFinder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Icon/FallbackGameIconFinder.cs index cbb2b802..990f5844 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Icon/FallbackGameIconFinder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Icon/FallbackGameIconFinder.cs @@ -1,7 +1,6 @@ using System; using System.Linq; using PetroGlyph.Games.EawFoc.Games; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.Icon; @@ -20,7 +19,8 @@ public class FallbackGameIconFinder : IGameIconFinder /// public string? FindIcon(IGame game) { - Requires.NotNull(game, nameof(game)); + if (game == null) + throw new ArgumentNullException(nameof(game)); var expectedFileName = game.Type switch { GameType.EaW => EawIconName, diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Language/GameLanguageFinder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Language/GameLanguageFinder.cs index 2f791c52..eb149b22 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Language/GameLanguageFinder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Language/GameLanguageFinder.cs @@ -3,7 +3,6 @@ using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; using PetroGlyph.Games.EawFoc.Games; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.Language; @@ -20,7 +19,8 @@ public class GameLanguageFinder : IGameLanguageFinder /// The service provider. public GameLanguageFinder(IServiceProvider serviceProvider) { - Requires.NotNull(serviceProvider, nameof(serviceProvider)); + if (serviceProvider == null) + throw new ArgumentNullException(nameof(serviceProvider)); _helper = serviceProvider.GetService() ?? new FileBasedLanguageFinder(); } diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Name/EnglishGameNameResolver.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Name/EnglishGameNameResolver.cs index a219cc8a..9cd4744e 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Name/EnglishGameNameResolver.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Name/EnglishGameNameResolver.cs @@ -1,6 +1,6 @@ -using System.Globalization; +using System; +using System.Globalization; using PetroGlyph.Games.EawFoc.Games; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.Name; @@ -14,7 +14,8 @@ public class EnglishGameNameResolver : IGameNameResolver /// public string ResolveName(IGameIdentity game) { - Requires.NotNull(game, nameof(game)); + if (game == null) + throw new ArgumentNullException(nameof(game)); var gameName = game.Type == GameType.EaW ? PetroglyphStarWarsGameConstants.EmpireAtWarEnglishNameShort : PetroglyphStarWarsGameConstants.ForcesOfCorruptionEnglishNameShort; diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/SteamGameHelpers.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/SteamGameHelpers.cs index 598b04cc..c22635d8 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/SteamGameHelpers.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/SteamGameHelpers.cs @@ -1,16 +1,17 @@ using System; using System.IO.Abstractions; -using AnakinRaW.CommonUtilities.FileSystem; using Microsoft.Extensions.DependencyInjection; using PetroGlyph.Games.EawFoc.Games; -using Validation; +#if NETSTANDARD2_0 +using AnakinRaW.CommonUtilities.FileSystem; +#endif namespace PetroGlyph.Games.EawFoc.Services.Steam; /// public class SteamGameHelpers : ISteamGameHelpers { - private readonly IPathHelperService _pathHelper; + private readonly IFileSystem _fileSystem; /// /// Creates a new instance @@ -18,19 +19,20 @@ public class SteamGameHelpers : ISteamGameHelpers /// The service provider. public SteamGameHelpers(IServiceProvider serviceProvider) { - Requires.NotNull(serviceProvider, nameof(serviceProvider)); - var fs = serviceProvider.GetService() ?? new FileSystem(); - _pathHelper = serviceProvider.GetService() ?? new PathHelperService(fs); + if (serviceProvider == null) + throw new ArgumentNullException(nameof(serviceProvider)); + _fileSystem = serviceProvider.GetRequiredService(); } /// public IDirectoryInfo GetWorkshopsLocation(IGame game) { - Requires.NotNull(game, nameof(game)); + if (game == null) + throw new ArgumentNullException(nameof(game)); if (game.Platform != GamePlatform.SteamGold) throw new GameException("Unable to get workshops location for non-Steam game."); - if (!_pathHelper.IsAbsolute(game.Directory.FullName)) + if (!_fileSystem.Path.IsPathFullyQualified(game.Directory.FullName)) throw new InvalidOperationException("Game path must be absolute"); var gameDir = game.Directory; diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyGraphBuilder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyGraphBuilder.cs index 34630195..e8b17e87 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyGraphBuilder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyGraphBuilder.cs @@ -3,7 +3,6 @@ using System.Linq; using EawModinfo.Spec; using PetroGlyph.Games.EawFoc.Mods; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.Dependencies; @@ -16,7 +15,8 @@ public class ModDependencyGraphBuilder : IModDependencyGraphBuilder /// public IModDependencyGraph Build(IMod rootMod) { - Requires.NotNull(rootMod, nameof(rootMod)); + if (rootMod == null) + throw new ArgumentNullException(nameof(rootMod)); var graph = new ModDependencyGraph(); AddToGraph(graph, rootMod, ResolvingDependenciesFactory); return graph; @@ -25,7 +25,8 @@ public IModDependencyGraph Build(IMod rootMod) /// public IModDependencyGraph BuildResolveFree(IMod rootMod) { - Requires.NotNull(rootMod, nameof(rootMod)); + if (rootMod == null) + throw new ArgumentNullException(nameof(rootMod)); var graph = new ModDependencyGraph(); AddToGraph(graph, rootMod, mod => { @@ -38,7 +39,8 @@ public IModDependencyGraph BuildResolveFree(IMod rootMod) /// public bool TryBuild(IMod rootMod, out IModDependencyGraph? graph) { - Requires.NotNull(rootMod, nameof(rootMod)); + if (rootMod == null) + throw new ArgumentNullException(nameof(rootMod)); graph = default; try { @@ -54,7 +56,8 @@ public bool TryBuild(IMod rootMod, out IModDependencyGraph? graph) /// public bool TryBuildResolveFree(IMod rootMod, out IModDependencyGraph? graph) { - Requires.NotNull(rootMod, nameof(rootMod)); + if (rootMod == null) + throw new ArgumentNullException(nameof(rootMod)); graph = default; try { @@ -70,7 +73,8 @@ public bool TryBuildResolveFree(IMod rootMod, out IModDependencyGraph? graph) /// public IList GetModDependencyListResolveFree(IMod targetMod) { - Requires.NotNull(targetMod, nameof(targetMod)); + if (targetMod == null) + throw new ArgumentNullException(nameof(targetMod)); return ResolveFreeDependenciesFactory(targetMod).Item1; } @@ -107,14 +111,14 @@ private void AddToGraph(ModDependencyGraph graph, IMod root, Func, DependencyResolveLayout) ResolvingDependenciesFactory(IMod source) + private static (IList dependencies, DependencyResolveLayout resolveLayout) ResolvingDependenciesFactory(IMod source) { if (source.DependencyResolveStatus != DependencyResolveStatus.Resolved) throw new ModException(source, $"Mod {source} is not yet resolved."); return (source.Dependencies.Select(d => d.Mod).ToList(), source.DependencyResolveLayout); } - private (IList, DependencyResolveLayout) ResolveFreeDependenciesFactory(IMod source) + private (IList dependencies, DependencyResolveLayout resolveLayout) ResolveFreeDependenciesFactory(IMod source) { var layout = source.DependencyResolveLayout; if (source.DependencyResolveStatus == DependencyResolveStatus.Resolved) diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyResolver.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyResolver.cs index 814f60d3..5804b86a 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyResolver.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyResolver.cs @@ -3,7 +3,6 @@ using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; using PetroGlyph.Games.EawFoc.Mods; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.Dependencies; @@ -22,19 +21,20 @@ public class ModDependencyResolver : IDependencyResolver /// The service provider. public ModDependencyResolver(IServiceProvider serviceProvider) { - Requires.NotNull(serviceProvider, nameof(serviceProvider)); - _serviceProvider = serviceProvider; + _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); } /// public IList Resolve(IMod mod, DependencyResolverOptions options) { - Requires.NotNull(mod, nameof(mod)); - Requires.NotNull(options, nameof(options)); + if (mod == null) + throw new ArgumentNullException(nameof(mod)); + if (options == null) + throw new ArgumentNullException(nameof(options)); //_visitedMods.Add(mod); - var graphBuilder = _serviceProvider.GetService() ?? new ModDependencyGraphBuilder(); + var graphBuilder = _serviceProvider.GetRequiredService(); var dependencyGraph = graphBuilder.BuildResolveFree(mod); if (options.ResolveCompleteChain) diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyTraverser.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyTraverser.cs index 47551181..c5785830 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyTraverser.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyTraverser.cs @@ -3,7 +3,6 @@ using System.Linq; using Microsoft.Extensions.DependencyInjection; using PetroGlyph.Games.EawFoc.Mods; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.Dependencies; @@ -18,8 +17,7 @@ public class ModDependencyTraverser : IModDependencyTraverser /// The service provider. public ModDependencyTraverser(IServiceProvider serviceProvider) { - Requires.NotNull(serviceProvider, nameof(serviceProvider)); - _serviceProvider = serviceProvider; + _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); } /// diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/MultiModDependencyResolver.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/MultiModDependencyResolver.cs index 23930af3..9e2a8429 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/MultiModDependencyResolver.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/MultiModDependencyResolver.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using PetroGlyph.Games.EawFoc.Mods; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.Dependencies; @@ -24,8 +23,7 @@ public class MultiModDependencyResolver /// The resolver that shall get used. public MultiModDependencyResolver(IDependencyResolver resolver) { - Requires.NotNull(resolver, nameof(resolver)); - _resolver = resolver; + _resolver = resolver ?? throw new ArgumentNullException(nameof(resolver)); } /// @@ -44,8 +42,10 @@ public MultiResolveResult ResolveDependenciesForMods( bool skipResolvedMods, bool abortOnError) { - Requires.NotNull(modsToResolve, nameof(modsToResolve)); - Requires.NotNull(options, nameof(options)); + if (modsToResolve == null) + throw new ArgumentNullException(nameof(modsToResolve)); + if (options == null) + throw new ArgumentNullException(nameof(options)); var result = new MultiResolveResult(); @@ -102,9 +102,8 @@ internal MultiResolveResult() internal void AddError(IMod mod, Exception error) { - Requires.NotNull(mod, nameof(mod)); - Requires.NotNull(error, nameof(error)); - _errorData[mod] = error; + if (mod == null) throw new ArgumentNullException(nameof(mod)); + _errorData[mod] = error ?? throw new ArgumentNullException(nameof(error)); } } } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/FileSystemModFinder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/FileSystemModFinder.cs index 73511bae..b068480c 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/FileSystemModFinder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/FileSystemModFinder.cs @@ -2,13 +2,11 @@ using System.Collections.Generic; using System.IO.Abstractions; using System.Linq; -using AnakinRaW.CommonUtilities.FileSystem; using EawModinfo.Model; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Services.Steam; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.Detection; @@ -17,8 +15,9 @@ namespace PetroGlyph.Games.EawFoc.Services.Detection; /// public class FileSystemModFinder : IModReferenceFinder { - private readonly IPathHelperService _pathHelperService; private readonly ISteamGameHelpers _steamHelper; + private readonly IFileSystem _fileSystem; + private readonly IModIdentifierBuilder _idBuilder; /// /// Creates a new instance. @@ -26,9 +25,10 @@ public class FileSystemModFinder : IModReferenceFinder /// The service provider public FileSystemModFinder(IServiceProvider serviceProvider) { - Requires.NotNull(serviceProvider, nameof(serviceProvider)); - var fs = serviceProvider.GetService() ?? new FileSystem(); - _pathHelperService = serviceProvider.GetService() ?? new PathHelperService(fs); + if (serviceProvider == null) + throw new ArgumentNullException(nameof(serviceProvider)); + _idBuilder = serviceProvider.GetRequiredService(); + _fileSystem = serviceProvider.GetRequiredService(); _steamHelper = serviceProvider.GetRequiredService(); } @@ -41,7 +41,9 @@ public FileSystemModFinder(IServiceProvider serviceProvider) /// If the is not installed. public ISet FindMods(IGame game) { - Requires.NotNull(game, nameof(game)); + if (game == null) + throw new ArgumentNullException(nameof(game)); + if (!game.Exists()) throw new GameException("The game does not exist"); @@ -69,11 +71,10 @@ private IEnumerable GetAllModsFromPath(IDirectoryInfo lookupDirect yield break; var type = isWorkshopsPath ? ModType.Workshops : ModType.Default; + foreach (var modDirectory in lookupDirectory.EnumerateDirectories()) { - var id = isWorkshopsPath - ? modDirectory.Name - : _pathHelperService.NormalizePath(modDirectory.FullName, PathNormalizeOptions.Full); + var id = _idBuilder.Build(modDirectory, isWorkshopsPath); yield return new ModReference(id, type); } } diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/IModIdentiferNormalizer.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/IModIdentiferNormalizer.cs index 67658b92..f673fdc3 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/IModIdentiferNormalizer.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/IModIdentiferNormalizer.cs @@ -1,4 +1,5 @@ -using EawModinfo.Model; +using System.IO.Abstractions; +using EawModinfo.Model; using EawModinfo.Spec; using PetroGlyph.Games.EawFoc.Mods; @@ -6,6 +7,8 @@ namespace PetroGlyph.Games.EawFoc.Services.Detection; internal interface IModIdentifierBuilder { + string Build(IDirectoryInfo modDirectory, bool isWorkshop); + string Build(IMod mod); ModReference Normalize(IModReference modReference); diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/ModIdentifierBuilder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/ModIdentifierBuilder.cs index 76c6abea..38729d95 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/ModIdentifierBuilder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/ModIdentifierBuilder.cs @@ -2,7 +2,7 @@ using System.IO.Abstractions; using System.Linq; using System.Text; -using AnakinRaW.CommonUtilities.FileSystem; +using AnakinRaW.CommonUtilities.FileSystem.Normalization; using EawModinfo.Model; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; @@ -12,7 +12,7 @@ namespace PetroGlyph.Games.EawFoc.Services.Detection; internal class ModIdentifierBuilder : IModIdentifierBuilder { - private readonly IPathHelperService _pathHelper; + private readonly IFileSystem _fileSystem; /// /// Creates a new instance. @@ -20,8 +20,12 @@ internal class ModIdentifierBuilder : IModIdentifierBuilder /// The service provider. public ModIdentifierBuilder(IServiceProvider serviceProvider) { - var fs = serviceProvider.GetService() ?? new FileSystem(); - _pathHelper = serviceProvider.GetService() ?? new PathHelperService(fs); + _fileSystem = serviceProvider.GetRequiredService(); + } + + public string Build(IDirectoryInfo modDirectory, bool isWorkshop) + { + return isWorkshop ? BuildWorkshopsModId(modDirectory) : BuildDefaultModId(modDirectory); } /// @@ -54,7 +58,11 @@ private string BuildDefaultModId(IDirectoryInfo modDir) private string BuildDefaultModId(string modDirPath) { - return _pathHelper.NormalizePath(modDirPath, PathNormalizeOptions.Full); + return PathNormalizer.Normalize(_fileSystem.Path.GetFullPath(modDirPath), new PathNormalizeOptions + { + UnifyCase = UnifyCasingKind.UpperCase, + TrailingDirectorySeparatorBehavior = TrailingDirectorySeparatorBehavior.Trim + }); } private static string BuildWorkshopsModId(IDirectoryInfo modDir) diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/ModReferenceLocationResolver.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/ModReferenceLocationResolver.cs index 834150b6..dd4b03cb 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/ModReferenceLocationResolver.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/ModReferenceLocationResolver.cs @@ -7,7 +7,6 @@ using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Mods; using PetroGlyph.Games.EawFoc.Services.Steam; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.Detection; @@ -28,8 +27,10 @@ public ModReferenceLocationResolver(IServiceProvider serviceProvider) /// public IDirectoryInfo ResolveLocation(IModReference mod, IGame game) { - Requires.NotNull(mod, nameof(mod)); - Requires.NotNull(game, nameof(game)); + if (mod == null) + throw new ArgumentNullException(nameof(mod)); + if (game == null) + throw new ArgumentNullException(nameof(game)); return mod.Type switch { @@ -60,10 +61,9 @@ private IDirectoryInfo ResolveWorkshopsMod(IModReference mod, IGame game) private static IDirectoryInfo ResolveNormalMod(IModReference mod, IGame game) { var fs = game.Directory.FileSystem; - var pathUtilities = new PathHelperService(fs); var modIdentifier = mod.Identifier; - if (!pathUtilities.IsAbsolute(game.Directory.FullName)) + if (!fs.Path.IsPathFullyQualified(game.Directory.FullName)) throw new GameException("Game path must be absolute"); // Note about mod paths: @@ -73,7 +73,7 @@ private static IDirectoryInfo ResolveNormalMod(IModReference mod, IGame game) // For starting mods the path also must not contain any spaces, but that's not assured here, // because may have custom features to still support these mods. - if (pathUtilities.IsAbsolute(modIdentifier)) + if (fs.Path.IsPathFullyQualified(modIdentifier)) return fs.DirectoryInfo.New(modIdentifier); var modLocationPath = fs.Path.Combine(game.Directory.FullName, modIdentifier); diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Icon/CompositeModIconFinder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Icon/CompositeModIconFinder.cs index b9d13929..3c824272 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Icon/CompositeModIconFinder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Icon/CompositeModIconFinder.cs @@ -1,6 +1,6 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using PetroGlyph.Games.EawFoc.Mods; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.Icon; @@ -17,7 +17,7 @@ public class CompositeModIconFinder : IModIconFinder /// Ordered list of s. public CompositeModIconFinder(IList orderedFinders) { - Requires.NotNullOrEmpty(orderedFinders, nameof(orderedFinders)); + ThrowHelper.ThrowIfCollectionNullOrEmpty(orderedFinders); _orderedFinders = orderedFinders; } @@ -28,7 +28,9 @@ public CompositeModIconFinder(IList orderedFinders) /// The first found icon path or public string? FindIcon(IMod game) { - Requires.NotNull(game, nameof(game)); + if (game == null) + throw new ArgumentNullException(nameof(game)); + foreach (var finder in _orderedFinders) { var iconFile = finder.FindIcon(game); diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Icon/SimpleModIconFinder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Icon/SimpleModIconFinder.cs index d9a4e86e..aa1114ed 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Icon/SimpleModIconFinder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Icon/SimpleModIconFinder.cs @@ -2,7 +2,6 @@ using System.Linq; using EawModinfo.Spec; using PetroGlyph.Games.EawFoc.Mods; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.Icon; @@ -19,7 +18,9 @@ public class SimpleModIconFinder : IModIconFinder /// public string? FindIcon(IMod mod) { - Requires.NotNull(mod, nameof(mod)); + if (mod == null) + throw new ArgumentNullException(nameof(mod)); + if (mod is IPhysicalMod physicalMod) return physicalMod.FileService.DataFiles("*.ico", "..", false, false).FirstOrDefault()?.FullName; if (mod.Type == ModType.Virtual) diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/ModLanguageFinderBase.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/ModLanguageFinderBase.cs index 01162edf..4e34626d 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/ModLanguageFinderBase.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/ModLanguageFinderBase.cs @@ -6,7 +6,6 @@ using Microsoft.Extensions.DependencyInjection; using PetroGlyph.Games.EawFoc.Mods; using PetroGlyph.Games.EawFoc.Services.Dependencies; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.Language; @@ -45,8 +44,7 @@ public abstract class ModLanguageFinderBase : IModLanguageFinder /// dependency Resolving should already be performed. Otherwise the has no effect. protected ModLanguageFinderBase(IServiceProvider serviceProvider, bool lookupInheritedLanguages) { - Requires.NotNull(serviceProvider, nameof(serviceProvider)); - ServiceProvider = serviceProvider; + ServiceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); _lookupInheritedLanguages = lookupInheritedLanguages; Helper = serviceProvider.GetService() ?? new FileBasedLanguageFinder(); } diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/ModFactory.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/ModFactory.cs index 457ee1b6..2adc3d49 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/ModFactory.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/ModFactory.cs @@ -12,7 +12,6 @@ using PetroGlyph.Games.EawFoc.Mods; using PetroGlyph.Games.EawFoc.Services.Detection; using PetroGlyph.Games.EawFoc.Services.Name; -using Validation; namespace PetroGlyph.Games.EawFoc.Services; @@ -57,13 +56,13 @@ internal ModFactory( CultureInfo culture, IServiceProvider serviceProvider) { - Requires.NotNull(defaultModinfoFileFinderFactory, nameof(defaultModinfoFileFinderFactory)); - Requires.NotNull(culture, nameof(culture)); - Requires.NotNull(serviceProvider, nameof(serviceProvider)); + if (serviceProvider == null) + throw new ArgumentNullException(nameof(serviceProvider)); + _referenceLocationResolver = serviceProvider.GetRequiredService(); - _defaultModinfoFileFinderFactory = defaultModinfoFileFinderFactory; + _defaultModinfoFileFinderFactory = defaultModinfoFileFinderFactory ?? throw new ArgumentNullException(nameof(defaultModinfoFileFinderFactory)); _nameResolver = serviceProvider.GetRequiredService(); - _culture = culture; + _culture = culture ?? throw new ArgumentNullException(nameof(culture)); _serviceProvider = serviceProvider; } diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/CompositeModNameResolver.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/CompositeModNameResolver.cs index 198455e3..943526e4 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/CompositeModNameResolver.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/CompositeModNameResolver.cs @@ -4,7 +4,6 @@ using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.Name; @@ -23,8 +22,9 @@ public sealed class CompositeModNameResolver : IModNameResolver /// The service provider. public CompositeModNameResolver(IList sortedResolvers, IServiceProvider serviceProvider) { - Requires.NotNullOrEmpty(sortedResolvers, nameof(sortedResolvers)); - Requires.NotNull(serviceProvider, nameof(serviceProvider)); + if (serviceProvider == null) + throw new ArgumentNullException(nameof(serviceProvider)); + ThrowHelper.ThrowIfCollectionNullOrEmpty(sortedResolvers); _sortedResolvers = sortedResolvers; _logger = serviceProvider.GetService()?.CreateLogger(GetType()); } @@ -40,7 +40,8 @@ public CompositeModNameResolver(IList sortedResolvers, IServic /// public static IModNameResolver CreateDefaultModNameResolver(IServiceProvider serviceProvider) { - Requires.NotNull(serviceProvider, nameof(serviceProvider)); + if (serviceProvider == null) + throw new ArgumentNullException(nameof(serviceProvider)); var resolvers = new List { new OnlineWorkshopNameResolver(serviceProvider), @@ -65,8 +66,10 @@ public string ResolveName(IModReference modReference) /// public string? ResolveName(IModReference modReference, CultureInfo culture) { - Requires.NotNull(modReference, nameof(modReference)); - Requires.NotNull(culture, nameof(culture)); + if (modReference == null) + throw new ArgumentNullException(nameof(modReference)); + if (culture == null) + throw new ArgumentNullException(nameof(culture)); foreach (var nameResolver in _sortedResolvers) { diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/DirectoryModNameResolver.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/DirectoryModNameResolver.cs index 46803214..265ec828 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/DirectoryModNameResolver.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/DirectoryModNameResolver.cs @@ -26,7 +26,7 @@ protected internal override string ResolveCore(IModReference modReference, Cultu throw new NotSupportedException("Cannot resolve name for virtual mods."); if (modReference is IPhysicalMod mod) return BeautifyDirectoryName(mod.Directory.Name); - var fs = ServiceProvider.GetService() ?? new FileSystem(); + var fs = ServiceProvider.GetRequiredService(); var directoryName = fs.DirectoryInfo.New(modReference.Identifier).Name; var beautifiedName = BeautifyDirectoryName(directoryName); return string.IsNullOrWhiteSpace(beautifiedName) ? directoryName : beautifiedName; diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/ModNameResolverBase.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/ModNameResolverBase.cs index 8728a229..1580421f 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/ModNameResolverBase.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/ModNameResolverBase.cs @@ -3,7 +3,6 @@ using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.Name; @@ -28,8 +27,7 @@ public abstract class ModNameResolverBase : IModNameResolver /// The Service provider. protected ModNameResolverBase(IServiceProvider serviceProvider) { - Requires.NotNull(serviceProvider, nameof(serviceProvider)); - ServiceProvider = serviceProvider; + ServiceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); Logger = serviceProvider.GetService()?.CreateLogger(GetType()); } @@ -49,8 +47,11 @@ public string ResolveName(IModReference modReference) /// public string? ResolveName(IModReference modReference, CultureInfo culture) { - Requires.NotNull(modReference, nameof(modReference)); - Requires.NotNull(culture, nameof(culture)); + if (modReference == null) + throw new ArgumentNullException(nameof(modReference)); + if (culture == null) + throw new ArgumentNullException(nameof(culture)); + string? modName = null; try { diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/OnlineWorkshopNameResolver.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/OnlineWorkshopNameResolver.cs index 9a7935fc..63358bee 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/OnlineWorkshopNameResolver.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/OnlineWorkshopNameResolver.cs @@ -4,7 +4,6 @@ using HtmlAgilityPack; using Microsoft.Extensions.DependencyInjection; using PetroGlyph.Games.EawFoc.Services.Steam; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.Name; @@ -39,7 +38,9 @@ protected internal override string ResolveCore(IModReference modReference, Cultu private static string GetName(HtmlDocument htmlDocument) { - Requires.NotNull(htmlDocument, nameof(htmlDocument)); + if (htmlDocument == null) + throw new ArgumentNullException(nameof(htmlDocument)); + var node = htmlDocument.DocumentNode.SelectSingleNode("//div[contains(@class, 'workshopItemTitle')]"); if (node is null) throw new InvalidOperationException("Unable to get name form Workshop's web page. Mussing 'workshopItemTitle' node."); diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Shared/FileService/DefaultFileService.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Shared/FileService/DefaultFileService.cs index 26ab5cc8..63e4cc8c 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Shared/FileService/DefaultFileService.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Shared/FileService/DefaultFileService.cs @@ -1,13 +1,11 @@ #if NET using System.Linq; -#else -using System; #endif +using System; using System.Collections.Generic; using System.IO; using System.IO.Abstractions; using System.Runtime.InteropServices; -using Validation; namespace PetroGlyph.Games.EawFoc.Services.FileService; @@ -23,8 +21,7 @@ public sealed class DefaultFileService : IPhysicalFileService /// The this instance is associated to. public DefaultFileService(IPhysicalPlayableObject playableObject) { - Requires.NotNull(playableObject, nameof(playableObject)); - PlayableObject = playableObject; + PlayableObject = playableObject ?? throw new ArgumentNullException(nameof(playableObject)); } /// diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Shared/FileService/IPhysicalFileService.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Shared/FileService/IPhysicalFileService.cs index a93e8832..dc621efd 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Shared/FileService/IPhysicalFileService.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Shared/FileService/IPhysicalFileService.cs @@ -7,6 +7,7 @@ namespace PetroGlyph.Games.EawFoc.Services.FileService; /// /// Service to query files and directories of an /// +// TODO: I don't think we need this interface public interface IPhysicalFileService { /// diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Shared/FileService/IPhysicalFileServiceTest.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Shared/FileService/IPhysicalFileServiceTest.cs deleted file mode 100644 index 272e481a..00000000 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Shared/FileService/IPhysicalFileServiceTest.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace PetroGlyph.Games.EawFoc.Services.FileService; - -internal interface IPhysicalFileServiceTest : IPhysicalFileService -{ -} \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Shared/Language/FileBasedLanguageFinder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Shared/Language/FileBasedLanguageFinder.cs index dc86bb0c..0106651c 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Shared/Language/FileBasedLanguageFinder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Shared/Language/FileBasedLanguageFinder.cs @@ -13,7 +13,6 @@ namespace PetroGlyph.Games.EawFoc.Services.Language; /// public sealed class FileBasedLanguageFinder : ILanguageFinder { - /// public ISet GetTextLocalizations(IPhysicalPlayableObject playableObject) { diff --git a/src/PetroGlyph.Games.EawFoc/src/ThrowHelper.cs b/src/PetroGlyph.Games.EawFoc/src/ThrowHelper.cs new file mode 100644 index 00000000..6ffcddaa --- /dev/null +++ b/src/PetroGlyph.Games.EawFoc/src/ThrowHelper.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; + +namespace PetroGlyph.Games.EawFoc; + +/// +/// Contains helpers for throwing common exceptions. +/// +internal static class ThrowHelper +{ + /// Throws an exception if is null or empty. + /// The string argument to validate as non-null and non-empty. + /// The name of the parameter with which corresponds. + /// is null. + /// is empty. +#pragma warning disable CS8777 // Parameter must have a non-null value when exiting. + public static void ThrowIfCollectionNullOrEmpty([NotNull] ICollection? argument, [CallerArgumentExpression(nameof(argument))] string? paramName = null) + { + if (argument is null) + throw new ArgumentNullException(paramName); + if (argument.Count == 0) + throw new ArgumentException("The value cannot be an empty collection.", nameof(paramName)); + } + + public static void ThrowIfCollectionNullOrEmpty([NotNull] ICollection? argument, [CallerArgumentExpression(nameof(argument))] string? paramName = null) + { + if (argument is null) + throw new ArgumentNullException(paramName); + if (argument.Count == 0) + throw new ArgumentException("The value cannot be an empty collection.", nameof(paramName)); + } +#pragma warning restore CS8777 // Parameter must have a non-null value when exiting. +} \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/src/Utilities/CompilerServices/CallerArgumentExpressionAttribute.cs b/src/PetroGlyph.Games.EawFoc/src/Utilities/CompilerServices/CallerArgumentExpressionAttribute.cs new file mode 100644 index 00000000..5d1c7868 --- /dev/null +++ b/src/PetroGlyph.Games.EawFoc/src/Utilities/CompilerServices/CallerArgumentExpressionAttribute.cs @@ -0,0 +1,9 @@ +#if !NET +namespace System.Runtime.CompilerServices; + +[AttributeUsage(AttributeTargets.Parameter)] +internal sealed class CallerArgumentExpressionAttribute(string parameterName) : Attribute +{ + public string ParameterName { get; } = parameterName; +} +#endif diff --git a/src/PetroGlyph.Games.EawFoc/test/FileBasedLanguageFinderTest.cs b/src/PetroGlyph.Games.EawFoc/test/FileBasedLanguageFinderTest.cs index 7c522fd4..ceb82b56 100644 --- a/src/PetroGlyph.Games.EawFoc/test/FileBasedLanguageFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/FileBasedLanguageFinderTest.cs @@ -1,12 +1,12 @@ using System.Collections.Generic; using System.IO.Abstractions; -using System.IO.Abstractions.TestingHelpers; using EawModinfo.Model; using EawModinfo.Spec; using Moq; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Services.FileService; using PetroGlyph.Games.EawFoc.Services.Language; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Test; @@ -59,8 +59,9 @@ public void TestFindText_None() public void TestFindText_EnglishGerman() { var fs = new MockFileSystem(); - fs.AddFile("Game/Text/MasterTextFile_English.dat", new MockFileData(string.Empty)); - fs.AddFile("Game/Text/MASTERTEXTFILE_GERMAN.DAT", new MockFileData(string.Empty)); + fs.Initialize() + .WithFile("Game/Text/MasterTextFile_English.da") + .WithFile("Game/Text/MASTERTEXTFILE_GERMAN.DAT"); var fileService = new Mock(); fileService.Setup(s => s.DataFiles("MasterTextFile_*.dat", "Text", false, false)) @@ -88,9 +89,10 @@ public void TestFindText_EnglishGerman() public void TestFindSFX_EnglishGerman() { var fs = new MockFileSystem(); - fs.AddFile("Game/Audio/SFX/sfx2d_english.meg", new MockFileData(string.Empty)); - fs.AddFile("Game/Audio/SFX/SFX2D_GERMAN.MEG", new MockFileData(string.Empty)); - fs.AddFile("Game/Audio/SFX/sfx2d_non_localized.meg", new MockFileData(string.Empty)); + fs.Initialize() + .WithFile("Game/Audio/SFX/sfx2d_english.meg") + .WithFile("Game/Audio/SFX/SFX2D_GERMAN.MEG") + .WithFile("Game/Audio/SFX/sfx2d_non_localized.meg"); var fileService = new Mock(); fileService.Setup(s => s.DataFiles("sfx2d_*.meg", "Audio/SFX", false, false)) @@ -120,9 +122,10 @@ public void TestFindSFX_EnglishGerman() public void TestFindSpeechMeg_EnglishGerman() { var fs = new MockFileSystem(); - fs.AddFile("Game/EnglishSpeech.meg", new MockFileData(string.Empty)); - fs.AddFile("Game/GERMANSPEECH.MEG", new MockFileData(string.Empty)); - fs.AddFile("Game/SomeSpeech.meg", new MockFileData(string.Empty)); + fs.Initialize() + .WithFile("Game/EnglishSpeech.meg") + .WithFile("Game/GERMANSPEECH.MEG") + .WithFile("Game/SomeSpeech.meg"); var fileService = new Mock(); fileService.Setup(s => s.DataFiles("*speech.meg", null, false, false)) @@ -152,9 +155,10 @@ public void TestFindSpeechMeg_EnglishGerman() public void TestFindSpeechFolder_EnglishGerman() { var fs = new MockFileSystem(); - fs.AddDirectory("Game/Audio/Speech/English"); - fs.AddDirectory("Game/Audio/Speech/GERMAN"); - fs.AddDirectory("Game/Audio/Speech/Some"); + fs.Initialize() + .WithSubdirectory("Game/Audio/Speech/English") + .WithSubdirectory("Game/Audio/Speech/GERMAN") + .WithSubdirectory("Game/Audio/Speech/Some"); var fileService = new Mock(); fileService.Setup(s => s.DataDirectory("Audio/Speech", false)) diff --git a/src/PetroGlyph.Games.EawFoc/test/GameRegistryFactoryTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameRegistryFactoryTest.cs index da5ede12..b06372b6 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameRegistryFactoryTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameRegistryFactoryTest.cs @@ -1,19 +1,17 @@ -using AnakinRaW.CommonUtilities.Registry; +using System.IO.Abstractions; +using AnakinRaW.CommonUtilities.Registry; using Microsoft.Extensions.DependencyInjection; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Games.Registry; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Test; public class GameRegistryFactoryTest { - private readonly GameRegistryFactory _service; - - public GameRegistryFactoryTest() - { - _service = new GameRegistryFactory(); - } + private readonly GameRegistryFactory _service = new(); + private readonly IFileSystem _fileSystem = new MockFileSystem(); [Fact] public void TestNotFound() @@ -28,6 +26,7 @@ public void TestNotFound() public void TestEaWRegistryFound() { var sc = new ServiceCollection(); + sc.AddSingleton(_fileSystem); var registry = new InMemoryRegistry(); var lm = registry.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32); lm.CreateSubKey(GameRegistryFactory.EawRegistryPath); @@ -42,6 +41,7 @@ public void TestEaWRegistryFound() public void TestFocRegistryFound() { var sc = new ServiceCollection(); + sc.AddSingleton(_fileSystem); var registry = new InMemoryRegistry(); var lm = registry.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32); lm.CreateSubKey(GameRegistryFactory.FocRegistryPath); diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/CompositeDetectorTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/CompositeDetectorTest.cs index f6a10cc9..39d566c1 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/CompositeDetectorTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/CompositeDetectorTest.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; -using System.IO.Abstractions.TestingHelpers; using Moq; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Services.Detection; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Test.GameServices.Detection; @@ -15,7 +15,7 @@ public void TestInvalidArgs_Throws() { Assert.Throws(() => new CompositeGameDetector(null, null)); Assert.Throws(() => new CompositeGameDetector(new List { null }, null)); - Assert.Throws(() => new CompositeGameDetector(new List(), null)); + Assert.Throws(() => new CompositeGameDetector(new List(), new Mock().Object)); } [Fact] @@ -61,7 +61,7 @@ public void TestDetect() new GameDetectionResult(new GameIdentity(GameType.EaW, GamePlatform.Disk), fs.DirectoryInfo.New("Game"))); var result = detector.Detect(options); - Assert.Equal(TestUtils.IsUnixLikePlatform ? "/Game" : "C:\\Game", result.GameLocation?.FullName); + Assert.Equal(fs.Path.GetFullPath("Game"), result.GameLocation?.FullName); } [Fact] @@ -79,6 +79,6 @@ public void TestDetectSecond() new GameDetectionResult(new GameIdentity(GameType.EaW, GamePlatform.Disk), fs.DirectoryInfo.New("Game"))); var result = detector.Detect(options); - Assert.Equal(TestUtils.IsUnixLikePlatform ? "/Game" : "C:\\Game", result.GameLocation?.FullName); + Assert.Equal(fs.Path.GetFullPath("Game"), result.GameLocation?.FullName); } } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/DirectoryGameDetectorTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/DirectoryGameDetectorTest.cs index 66ff1f37..2d7d881e 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/DirectoryGameDetectorTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/DirectoryGameDetectorTest.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; using System.IO.Abstractions; -using System.IO.Abstractions.TestingHelpers; using Moq; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Services.Detection; using PetroGlyph.Games.EawFoc.Services.Detection.Platform; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Test.GameServices.Detection; @@ -25,9 +25,6 @@ public void TestInvalidArgs_Throws() [Fact] public void TestNoGame() { -#if NET - return; -#endif var fs = new MockFileSystem(); var sp = new Mock(); sp.Setup(p => p.GetService(typeof(IFileSystem))).Returns(fs); @@ -40,11 +37,8 @@ public void TestNoGame() [Fact] public void TestNoEawGame() { -#if NET - return; -#endif var fs = new MockFileSystem(); - fs.AddFile("Game/swfoc.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("Game/swfoc.exe"); var sp = new Mock(); sp.Setup(p => p.GetService(typeof(IFileSystem))).Returns(fs); var detector = new DirectoryGameDetector(fs.DirectoryInfo.New("Game"), sp.Object); @@ -56,11 +50,8 @@ public void TestNoEawGame() [Fact] public void TestNoFocGame() { -#if NET - return; -#endif var fs = new MockFileSystem(); - fs.AddFile("Game/sweaw.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("Game/sweaw.exe"); var sp = new Mock(); sp.Setup(p => p.GetService(typeof(IFileSystem))).Returns(fs); var detector = new DirectoryGameDetector(fs.DirectoryInfo.New("Game"), sp.Object); @@ -72,11 +63,8 @@ public void TestNoFocGame() [Fact] public void TestAnyEawGame() { -#if NET - return; -#endif var fs = new MockFileSystem(); - fs.AddFile("Game/sweaw.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("Game/sweaw.exe"); var sp = new Mock(); sp.Setup(p => p.GetService(typeof(IFileSystem))).Returns(fs); var detector = new DirectoryGameDetector(fs.DirectoryInfo.New("Game"), sp.Object); @@ -87,12 +75,9 @@ public void TestAnyEawGame() [Fact] public void TestAnyFocGame() - { -#if NET - return; -#endif + { var fs = new MockFileSystem(); - fs.AddFile("Game/swfoc.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("Game/swfoc.exe"); var sp = new Mock(); sp.Setup(p => p.GetService(typeof(IFileSystem))).Returns(fs); var detector = new DirectoryGameDetector(fs.DirectoryInfo.New("Game"), sp.Object); @@ -104,11 +89,8 @@ public void TestAnyFocGame() [Fact] public void TestInKnownSubFocGame() { -#if NET - return; -#endif var fs = new MockFileSystem(); - fs.AddFile("Dir/EAWX/swfoc.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("Dir/EAWX/swfoc.exe"); var sp = new Mock(); sp.Setup(p => p.GetService(typeof(IFileSystem))).Returns(fs); var detector = new DirectoryGameDetector(fs.DirectoryInfo.New("Dir"), sp.Object); @@ -120,11 +102,8 @@ public void TestInKnownSubFocGame() [Fact] public void TestNotInKnownSubFocGame() { -#if NET - return; -#endif var fs = new MockFileSystem(); - fs.AddFile("Dir/EAWX/sweaw.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("Dir/EAWX/sweaw.exe"); var sp = new Mock(); sp.Setup(p => p.GetService(typeof(IFileSystem))).Returns(fs); var detector = new DirectoryGameDetector(fs.DirectoryInfo.New("Dir"), sp.Object); @@ -136,11 +115,8 @@ public void TestNotInKnownSubFocGame() [Fact] public void TestInUnknownSubFocGame() { -#if NET - return; -#endif var fs = new MockFileSystem(); - fs.AddFile("Dir/SomeDir/sweaw.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("Dir/SomeDir/sweaw.exe"); var sp = new Mock(); sp.Setup(p => p.GetService(typeof(IFileSystem))).Returns(fs); var detector = new DirectoryGameDetector(fs.DirectoryInfo.New("Dir"), sp.Object); @@ -152,11 +128,8 @@ public void TestInUnknownSubFocGame() [Fact] public void TestInKnownSubEawGame() { -#if NET - return; -#endif var fs = new MockFileSystem(); - fs.AddFile("Dir/GameData/sweaw.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("Dir/GameData/sweaw.exe"); var sp = new Mock(); sp.Setup(p => p.GetService(typeof(IFileSystem))).Returns(fs); var detector = new DirectoryGameDetector(fs.DirectoryInfo.New("Dir"), sp.Object); @@ -168,11 +141,8 @@ public void TestInKnownSubEawGame() [Fact] public void TestInKnownSubSubEawGame() { -#if NET - return; -#endif var fs = new MockFileSystem(); - fs.AddFile("Dir/Sub/GameData/sweaw.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("Dir/Sub/GameData/sweaw.exe"); var sp = new Mock(); sp.Setup(p => p.GetService(typeof(IFileSystem))).Returns(fs); var detector = new DirectoryGameDetector(fs.DirectoryInfo.New("Dir"), sp.Object); @@ -185,11 +155,8 @@ public void TestInKnownSubSubEawGame() [Fact] public void TestAnyFocGame_Integration() { -#if NET - return; -#endif var fs = new MockFileSystem(); - fs.AddFile("Game/sweaw.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("Game/sweaw.exe"); var sp = new Mock(); sp.Setup(p => p.GetService(typeof(IFileSystem))).Returns(fs); var pi = new Mock(); diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GameDetectorTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GameDetectorTest.cs index 5f04a55a..4da62080 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GameDetectorTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GameDetectorTest.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; using System.IO.Abstractions; -using System.IO.Abstractions.TestingHelpers; using Moq; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Services.Detection; using PetroGlyph.Games.EawFoc.Services.Detection.Platform; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Test.GameServices.Detection; @@ -19,7 +19,7 @@ public void TestFocGameExists() const GameType type = GameType.Foc; var fs = new MockFileSystem(); - fs.AddFile("Game/swfoc.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("Game/swfoc.exe"); var identifier = new Mock(); identifier.Setup(i => i.GetGamePlatform(It.IsAny(), ref It.Ref.IsAny, It.IsAny>())) @@ -77,7 +77,7 @@ public void TestExceptional() const GameType type = GameType.Foc; var fs = new MockFileSystem(); - fs.AddFile("Game/swfoc.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("Game/swfoc.exe"); var identifier = new Mock(); identifier.Setup(i => i.GetGamePlatform(It.IsAny(), ref It.Ref.IsAny, It.IsAny>())) @@ -106,7 +106,7 @@ public void TestNotRaisingEvent() const GameType type = GameType.Foc; var fs = new MockFileSystem(); - fs.AddFile("Game/swfoc.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("Game/swfoc.exe"); var identifier = new Mock(); identifier.Setup(i => i.GetGamePlatform(It.IsAny(), ref It.Ref.IsAny, It.IsAny>())) @@ -139,7 +139,7 @@ public void TestRaisingEventHandled() const GameType type = GameType.Foc; var fs = new MockFileSystem(); - fs.AddFile("Game/swfoc.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("Game/swfoc.exe"); var identifier = new Mock(); identifier.Setup(i => i.GetGamePlatform(It.IsAny(), ref It.Ref.IsAny, It.IsAny>())) @@ -177,7 +177,7 @@ public void TestRaisingEventNotHandled() const GameType type = GameType.Foc; var fs = new MockFileSystem(); - fs.AddFile("Game/swfoc.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("Game/swfoc.exe"); var identifier = new Mock(); identifier.Setup(i => i.GetGamePlatform(It.IsAny(), ref It.Ref.IsAny, It.IsAny>())) @@ -210,7 +210,7 @@ public void TestWrongPlatform() const GameType type = GameType.Foc; var fs = new MockFileSystem(); - fs.AddFile("Game/swfoc.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("Game/swfoc.exe"); var identifier = new Mock(); identifier.Setup(i => i.GetGamePlatform(It.IsAny(), ref It.Ref.IsAny, diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GamePlatformIdentifierTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GamePlatformIdentifierTest.cs index c888e450..fc00e3d9 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GamePlatformIdentifierTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GamePlatformIdentifierTest.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; using System.IO.Abstractions; -using System.IO.Abstractions.TestingHelpers; using Moq; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Services.Detection.Platform; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Test.GameServices.Detection; @@ -219,30 +219,32 @@ public void TestFocOriginWithSanitization() private static IDirectoryInfo Disk_Eaw() { var fs = new MockFileSystem(); - fs.AddFile("GameData/sweaw.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("GameData/sweaw.exe"); return fs.DirectoryInfo.New("GameData"); } private static IDirectoryInfo Disk_Foc() { var fs = new MockFileSystem(); - fs.AddFile("Game/swfoc.exe", new MockFileData(string.Empty)); + fs.Initialize().WithFile("Game/swfoc.exe"); return fs.DirectoryInfo.New("Game"); } private static IFileSystem SteamFs() { var fs = new MockFileSystem(); - fs.AddFile("Game/corruption/swfoc.exe", new MockFileData(string.Empty)); - fs.AddFile("Game/corruption/StarWarsG.exe", new MockFileData(string.Empty)); - fs.AddFile("Game/GameData/sweaw.exe", new MockFileData(string.Empty)); - fs.AddFile("Game/GameData/StarWarsG.exe", new MockFileData(string.Empty)); - fs.AddFile("Game/32470_install.vdf", new MockFileData(string.Empty)); - fs.AddFile("Game/32472_install.vdf", new MockFileData(string.Empty)); - fs.AddFile("Game/runme.dat", new MockFileData(string.Empty)); - fs.AddFile("Game/runm2.dat", new MockFileData(string.Empty)); - fs.AddFile("Game/runme.exe", new MockFileData(string.Empty)); - fs.AddFile("Game/runme2.exe", new MockFileData(string.Empty)); + + fs.Initialize() + .WithFile("Game/corruption/swfoc.exe") + .WithFile("Game/corruption/StarWarsG.exe") + .WithFile("Game/GameData/sweaw.exe") + .WithFile("Game/GameData/StarWarsG.exe") + .WithFile("Game/32470_install.vdf") + .WithFile("Game/32472_install.vdf") + .WithFile("Game/runme.dat") + .WithFile("Game/runm2.dat") + .WithFile("Game/runme.exe") + .WithFile("Game/runme2.exe"); return fs; } @@ -259,14 +261,15 @@ private static IDirectoryInfo Steam_Foc() private static IFileSystem GogFs() { var fs = new MockFileSystem(); - fs.AddFile("Game/EAWX/swfoc.exe", new MockFileData(string.Empty)); - fs.AddFile("Game/corruption/StarWarsG.exe", new MockFileData(string.Empty)); - fs.AddFile("Game/GameData/sweaw.exe", new MockFileData(string.Empty)); - fs.AddFile("Game/GameData/goggame-1421404887.dll", new MockFileData(string.Empty)); - fs.AddFile("Game/goggame.sdb", new MockFileData(string.Empty)); - fs.AddFile("Game/goggame-1421404887.hashdb", new MockFileData(string.Empty)); - fs.AddFile("Game/goggame-1421404887.info", new MockFileData(string.Empty)); - fs.AddFile("Game/Language.exe", new MockFileData(string.Empty)); + fs.Initialize() + .WithFile("Game/EAWX/swfoc.exe") + .WithFile("Game/corruption/StarWarsG.exe") + .WithFile("Game/GameData/sweaw.exe") + .WithFile("Game/GameData/goggame-1421404887.dll") + .WithFile("Game/goggame.sdb") + .WithFile("Game/goggame-1421404887.hashdb") + .WithFile("Game/goggame-1421404887.info") + .WithFile("Game/Language.exe"); return fs; } @@ -283,19 +286,20 @@ private static IDirectoryInfo Gog_Foc() private static IFileSystem DiskGoldFs() { var fs = new MockFileSystem(); - fs.AddFile("Game/Foc/swfoc.exe", new MockFileData(string.Empty)); - fs.AddFile("Game/Foc/fpupdate.exe", new MockFileData(string.Empty)); - fs.AddFile("Game/Foc/LaunchEAWX.exe", new MockFileData(string.Empty)); - fs.AddFile("Game/Foc/main.wav", new MockFileData(string.Empty)); - fs.AddDirectory("Game/Foc/Install"); - fs.AddDirectory("Game/Foc/Manuals"); - - fs.AddFile("Game/Eaw/GameData/sweaw.exe", new MockFileData(string.Empty)); - fs.AddFile("Game/Eaw/GameData/fpupdate.exe", new MockFileData(string.Empty)); - fs.AddFile("Game/Eaw/GameData/MCELaunch.exe", new MockFileData(string.Empty)); - fs.AddFile("Game/Eaw/GameData/StubUpdate.exe", new MockFileData(string.Empty)); - fs.AddFile("Game/Eaw/LaunchEAW.exe", new MockFileData(string.Empty)); - fs.AddFile("Game/Eaw/main.wav", new MockFileData(string.Empty)); + fs.Initialize() + .WithFile("Game/Foc/swfoc.exe") + .WithFile("Game/Foc/fpupdate.exe") + .WithFile("Game/Foc/LaunchEAWX.exe") + .WithFile("Game/Foc/main.wav") + .WithSubdirectory("Game/Foc/Install") + .WithSubdirectory("Game/Foc/Manuals") + + .WithFile("Game/Eaw/GameData/sweaw.exe") + .WithFile("Game/Eaw/GameData/fpupdate.exe") + .WithFile("Game/Eaw/GameData/MCELaunch.exe") + .WithFile("Game/Eaw/GameData/StubUpdate.exe") + .WithFile("Game/Eaw/LaunchEAW.exe") + .WithFile("Game/Eaw/main.wav"); return fs; } @@ -312,12 +316,13 @@ private static IDirectoryInfo DiskGold_Foc() private static IFileSystem OriginFs() { var fs = new MockFileSystem(); - fs.AddFile("Game/EAWX/swfoc.exe", new MockFileData(string.Empty)); - fs.AddFile("Game/EAWX/EALaunchHelper.exe", new MockFileData(string.Empty)); + fs.Initialize() + .WithFile("Game/EAWX/swfoc.exe") + .WithFile("Game/EAWX/EALaunchHelper.exe") - fs.AddFile("Game/GameData/sweaw.exe", new MockFileData(string.Empty)); - fs.AddDirectory("Game/Manuals"); - fs.AddDirectory("Game/__Installer"); + .WithFile("Game/GameData/sweaw.exe") + .WithSubdirectory("Game/Manuals") + .WithSubdirectory("Game/__Installer"); return fs; } diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/RegistryGameDetectorTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/RegistryGameDetectorTest.cs index f99b4b0f..d97c2f44 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/RegistryGameDetectorTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/RegistryGameDetectorTest.cs @@ -1,10 +1,10 @@ using System; using System.IO.Abstractions; -using System.IO.Abstractions.TestingHelpers; using Moq; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Games.Registry; using PetroGlyph.Games.EawFoc.Services.Detection; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Test.GameServices.Detection; diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/FallbackIconFinderTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/FallbackIconFinderTest.cs index 8f1307fd..7ede2059 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/FallbackIconFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/FallbackIconFinderTest.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; using System.IO.Abstractions; -using System.IO.Abstractions.TestingHelpers; using Moq; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Services.FileService; using PetroGlyph.Games.EawFoc.Services.Icon; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Test.GameServices; @@ -52,7 +52,7 @@ public void TestFocIcon() game.Setup(g => g.FileService).Returns(fileService.Object); var finder = new FallbackGameIconFinder(); var icon = finder.FindIcon(game.Object); - Assert.Equal(TestUtils.IsUnixLikePlatform ? "/Game/foc.ico" : "C:\\Game\\foc.ico", icon); + Assert.Equal(fs.Path.GetFullPath("Game/foc.ico"), icon); } [Fact] @@ -70,6 +70,6 @@ public void TestEawIcon() game.Setup(g => g.FileService).Returns(fileService.Object); var finder = new FallbackGameIconFinder(); var icon = finder.FindIcon(game.Object); - Assert.Equal(TestUtils.IsUnixLikePlatform ? "/Game/eaw.ico" : "C:\\Game\\eaw.ico", icon); + Assert.Equal(fs.Path.GetFullPath("Game/eaw.ico"), icon); } } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/GameFactoryTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/GameFactoryTest.cs index 474161e1..4083a70e 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/GameFactoryTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/GameFactoryTest.cs @@ -1,12 +1,12 @@ using System; using System.Globalization; using System.IO.Abstractions; -using System.IO.Abstractions.TestingHelpers; using Moq; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Services; using PetroGlyph.Games.EawFoc.Services.Detection; using PetroGlyph.Games.EawFoc.Services.Name; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Test.GameServices; @@ -96,8 +96,9 @@ public void GameFromIdentity() var factory = new GameFactory(nameResolver.Object, culture, sp.Object); var identity = new GameIdentity(GameType.EaW, GamePlatform.Disk); var fs = new MockFileSystem(); - fs.AddDirectory("GameData"); - fs.AddFile("GameData/sweaw.exe", new MockFileData(string.Empty)); + fs.Initialize() + .WithSubdirectory("GameData") + .WithFile("GameData/sweaw.exe"); var game = factory.CreateGame(identity, fs.DirectoryInfo.New("GameData"), false); Assert.Equal(identity.Platform, game.Platform); Assert.Equal(identity.Type, game.Type); @@ -114,8 +115,9 @@ public void GameFromDetectionResult() var identity = new GameIdentity(GameType.EaW, GamePlatform.Disk); var fs = new MockFileSystem(); var detectionResult = new GameDetectionResult(identity, fs.DirectoryInfo.New("GameData")); - fs.AddDirectory("GameData"); - fs.AddFile("GameData/sweaw.exe", new MockFileData(string.Empty)); + fs.Initialize() + .WithSubdirectory("GameData") + .WithFile("GameData/sweaw.exe"); var game = factory.CreateGame(detectionResult); Assert.Equal(identity.Platform, game.Platform); Assert.Equal(identity.Type, game.Type); diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/GameHelperTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/GameHelperTest.cs index b8278224..da8368fe 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/GameHelperTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/GameHelperTest.cs @@ -1,9 +1,9 @@ using System.IO.Abstractions; -using System.IO.Abstractions.TestingHelpers; using Microsoft.Extensions.DependencyInjection; using Moq; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Services.Steam; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Test.GameServices; @@ -24,37 +24,35 @@ public GameHelperTest() [Fact] public void GetWorkshopDir_Success() { - var fs = new MockFileSystem(); + _fileSystem.Initialize() + .WithSubdirectory("SteamLib/Apps/common/32470/Game") + .WithSubdirectory("workshop/content/32470"); + var mock = new Mock(); - mock.Setup(g => g.Directory).Returns(fs.DirectoryInfo.New("SteamLib/Apps/common/32470/Game")); + mock.Setup(g => g.Directory).Returns(_fileSystem.DirectoryInfo.New("SteamLib/Apps/common/32470/Game")); mock.Setup(g => g.Platform).Returns(GamePlatform.SteamGold); - fs.AddDirectory("SteamLib/Apps/common/32470/Game"); - fs.AddDirectory("workshop/content/32470"); var wsDir = _service.GetWorkshopsLocation(mock.Object); - Assert.Equal( - TestUtils.IsUnixLikePlatform - ? "/SteamLib/Apps/workshop/content/32470" - : "C:\\SteamLib\\Apps\\workshop\\content\\32470", wsDir.FullName); + Assert.Equal(_fileSystem.Path.GetFullPath("SteamLib/Apps/workshop/content/32470"), wsDir.FullName); } [Fact] public void GetWorkshopDir_FailNotExisting() { - var fs = new MockFileSystem(); + _fileSystem.Initialize() + .WithSubdirectory("Game"); var mock = new Mock(); - mock.Setup(g => g.Directory).Returns(fs.DirectoryInfo.New("Game")); + mock.Setup(g => g.Directory).Returns(_fileSystem.DirectoryInfo.New("Game")); mock.Setup(g => g.Platform).Returns(GamePlatform.SteamGold); - fs.AddDirectory("Game"); Assert.Throws(() => _service.GetWorkshopsLocation(mock.Object)); } [Fact] public void GetWorkshopDir_FailNoSteam() { - var fs = new MockFileSystem(); + _fileSystem.Initialize() + .WithSubdirectory("Game"); var mock = new Mock(); - mock.Setup(g => g.Directory).Returns(fs.DirectoryInfo.New("Game")); - fs.AddDirectory("Game"); + mock.Setup(g => g.Directory).Returns(_fileSystem.DirectoryInfo.New("Game")); Assert.Throws(() => _service.GetWorkshopsLocation(mock.Object)); } } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/GameLanguageFinderTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/GameLanguageFinderTest.cs index 1fbafc2c..b497189e 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/GameLanguageFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/GameLanguageFinderTest.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; -using System.IO.Abstractions.TestingHelpers; using EawModinfo.Spec; using Moq; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Services.Language; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Test.GameServices; @@ -21,7 +21,7 @@ public void NullSp_Throws() public void TestEmptyResult() { var fs = new MockFileSystem(); - fs.AddDirectory("Game"); + fs.Initialize().WithSubdirectory("Game"); var game = new Mock(); game.Setup(g => g.Directory).Returns(fs.DirectoryInfo.New("Game")); @@ -43,7 +43,7 @@ public void TestEmptyResult() public void TestSomeResult() { var fs = new MockFileSystem(); - fs.AddDirectory("Game"); + fs.Initialize().WithSubdirectory("Game"); var game = new Mock(); game.Setup(g => g.Directory).Returns(fs.DirectoryInfo.New("Game")); diff --git a/src/PetroGlyph.Games.EawFoc/test/GameTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameTest.cs index 76c1852b..6c8f6b1e 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameTest.cs @@ -1,11 +1,11 @@ using System; -using System.IO.Abstractions.TestingHelpers; using EawModinfo.Model; using EawModinfo.Spec; using Moq; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Mods; using PetroGlyph.Games.EawFoc.Services.Detection; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Test; @@ -23,7 +23,7 @@ public void InvalidCtor_Throws() Assert.Throws(() => new PetroglyphStarWarsGame(id, loc, null!, null!)); var nameEmpty = string.Empty; var name = "Name"; - Assert.Throws(() => new PetroglyphStarWarsGame(id, loc, nameEmpty, null!)); + Assert.Throws(() => new PetroglyphStarWarsGame(id, loc, nameEmpty, new Mock().Object)); Assert.Throws(() => new PetroglyphStarWarsGame(id, loc, name, null!)); } @@ -205,13 +205,13 @@ public void TestEquals() public void GetModDirTest() { var fs = new MockFileSystem(); + fs.Initialize().WithSubdirectory("Game"); var sp = new Mock(); var id = new GameIdentity(GameType.EaW, GamePlatform.SteamGold); var loc = fs.DirectoryInfo.New("Game"); var name = "Name"; var game = new PetroglyphStarWarsGame(id, loc, name, sp.Object); - fs.AddDirectory("Game"); var dataLocation = game.ModsLocation; - Assert.Equal(TestUtils.IsUnixLikePlatform ? "/Game/Mods" : "C:\\Game\\Mods", dataLocation.FullName); + Assert.Equal(fs.Path.GetFullPath("Game/Mods"), dataLocation.FullName); } } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/CompositeModNameResolverTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/CompositeModNameResolverTest.cs index d7e1afbc..599a82e4 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/CompositeModNameResolverTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/CompositeModNameResolverTest.cs @@ -15,7 +15,7 @@ public class CompositeModNameResolverTest public void NullArgTest_Throws() { Assert.Throws(() => new CompositeModNameResolver(null, null)); - Assert.Throws(() => new CompositeModNameResolver(new List(), null)); + Assert.Throws(() => new CompositeModNameResolver(new List(), new Mock().Object)); Assert.Throws(() => new CompositeModNameResolver(new List { null }, null)); Assert.Throws(() => CompositeModNameResolver.CreateDefaultModNameResolver(null)); var sp = new Mock(); diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/DirectoryModNameResolverTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/DirectoryModNameResolverTest.cs index 73986de6..30ec8cd5 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/DirectoryModNameResolverTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/DirectoryModNameResolverTest.cs @@ -1,9 +1,11 @@ using System; using System.Globalization; +using System.IO.Abstractions; using EawModinfo.Model; using EawModinfo.Spec; using Moq; using PetroGlyph.Games.EawFoc.Services.Name; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Test.ModServices; @@ -14,6 +16,7 @@ public class DirectoryModNameResolverTest public void TestWithModsPath() { var sp = new Mock(); + sp.Setup(s => s.GetService(typeof(IFileSystem))).Returns(new MockFileSystem()); var resolver = new DirectoryModNameResolver(sp.Object); var modRef = new ModReference("Mods/Name", ModType.Default); @@ -28,6 +31,7 @@ public void TestWithModsPath() public void TestWithoutPath() { var sp = new Mock(); + sp.Setup(s => s.GetService(typeof(IFileSystem))).Returns(new MockFileSystem()); var resolver = new DirectoryModNameResolver(sp.Object); var modRef = new ModReference("Name", ModType.Default); @@ -42,6 +46,7 @@ public void TestWithoutPath() public void TestBeautify() { var sp = new Mock(); + sp.Setup(s => s.GetService(typeof(IFileSystem))).Returns(new MockFileSystem()); var resolver = new DirectoryModNameResolver(sp.Object); var modRef = new ModReference("Name_Name", ModType.Default); @@ -56,6 +61,7 @@ public void TestBeautify() public void TestBeautify_EdgeCase() { var sp = new Mock(); + sp.Setup(s => s.GetService(typeof(IFileSystem))).Returns(new MockFileSystem()); var resolver = new DirectoryModNameResolver(sp.Object); var modRef = new ModReference("___", ModType.Default); diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/FileSystemModFinderTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/FileSystemModFinderTest.cs index 450e0582..d92404ce 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/FileSystemModFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/FileSystemModFinderTest.cs @@ -1,11 +1,12 @@ using System.IO.Abstractions; -using System.IO.Abstractions.TestingHelpers; +using System.Linq; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; using Moq; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Services.Detection; using PetroGlyph.Games.EawFoc.Services.Steam; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Test.ModServices; @@ -15,14 +16,17 @@ public class FileSystemModFinderTest private readonly FileSystemModFinder _service; private readonly Mock _steamHelper; private readonly MockFileSystem _fileSystem; + private readonly Mock _idBuilder; public FileSystemModFinderTest() { var sc = new ServiceCollection(); _steamHelper = new Mock(); _fileSystem = new MockFileSystem(); + _idBuilder = new Mock(); sc.AddTransient(_ => _steamHelper.Object); - sc.AddTransient(_ => _fileSystem); + sc.AddSingleton(_ => _fileSystem); + sc.AddSingleton(_ => _idBuilder.Object); _service = new FileSystemModFinder(sc.BuildServiceProvider()); } @@ -36,7 +40,7 @@ public void GameNotExists_Throws() [Fact] public void TestNoMods_Normal() { - _fileSystem.AddDirectory("Game/Mods"); + _fileSystem.Initialize().WithSubdirectory("Game/Mods"); var game = new Mock(); game.Setup(g => g.Exists()).Returns(true); game.Setup(g => g.Platform).Returns(GamePlatform.Disk); @@ -49,7 +53,7 @@ public void TestNoMods_Normal() [Fact] public void TestNoMods_Normal_NoFolder() { - _fileSystem.AddDirectory("Game"); + _fileSystem.Initialize().WithSubdirectory("Game"); var game = new Mock(); game.Setup(g => g.Exists()).Returns(true); game.Setup(g => g.Platform).Returns(GamePlatform.Disk); @@ -62,7 +66,7 @@ public void TestNoMods_Normal_NoFolder() [Fact] public void TestNoMods_Steam() { - _fileSystem.AddDirectory("Lib/Game/Eaw/Mods"); + _fileSystem.Initialize().WithSubdirectory("Lib/Game/Eaw/Mods"); var game = new Mock(); game.Setup(g => g.Exists()).Returns(true); game.Setup(g => g.Platform).Returns(GamePlatform.SteamGold); @@ -77,28 +81,39 @@ public void TestNoMods_Steam() [Fact] public void TestOneMods_Normal() { - _fileSystem.AddDirectory("Game/Mods/ModA"); + _fileSystem.Initialize().WithSubdirectory("Game/Mods/ModA"); var game = new Mock(); game.Setup(g => g.Exists()).Returns(true); game.Setup(g => g.Platform).Returns(GamePlatform.Disk); game.Setup(g => g.Directory).Returns(_fileSystem.DirectoryInfo.New("Game")); game.Setup(g => g.ModsLocation).Returns(_fileSystem.DirectoryInfo.New("Game/Mods")); + + _idBuilder.Setup(ib => ib.Build(It.IsAny(), false)) + .Returns("somePath"); + var mods = _service.FindMods(game.Object); var mod = Assert.Single(mods); - Assert.Equal(TestUtils.IsUnixLikePlatform ? "/Game/Mods/ModA" : "c:\\game\\mods\\moda", mod.Identifier); + Assert.Equal("somePath", mod.Identifier); Assert.Equal(ModType.Default, mod.Type); } [Fact] public void TestTwoMods_Normal() { - _fileSystem.AddDirectory("Game/Mods/ModA"); - _fileSystem.AddDirectory("Game/Mods/ModB"); + _fileSystem.Initialize() + .WithSubdirectory("Game/Mods/ModA") + .WithSubdirectory("Game/Mods/ModB"); + var game = new Mock(); game.Setup(g => g.Exists()).Returns(true); game.Setup(g => g.Platform).Returns(GamePlatform.Disk); game.Setup(g => g.Directory).Returns(_fileSystem.DirectoryInfo.New("Game")); game.Setup(g => g.ModsLocation).Returns(_fileSystem.DirectoryInfo.New("Game/Mods")); + + _idBuilder.SetupSequence(ib => ib.Build(It.IsAny(), false)) + .Returns("somePath1") + .Returns("somePath2"); + var mods = _service.FindMods(game.Object); Assert.Equal(2, mods.Count); } @@ -106,7 +121,9 @@ public void TestTwoMods_Normal() [Fact] public void TestOneDefaultMod_Steam() { - _fileSystem.AddDirectory("Lib/Game/Eaw/Mods/ModA"); + _fileSystem.Initialize() + .WithSubdirectory("Lib/Game/Eaw/Mods/ModA"); + var game = new Mock(); game.Setup(g => g.Exists()).Returns(true); game.Setup(g => g.Platform).Returns(GamePlatform.SteamGold); @@ -114,18 +131,24 @@ public void TestOneDefaultMod_Steam() game.Setup(g => g.ModsLocation).Returns(_fileSystem.DirectoryInfo.New("Lib/Game/Eaw/Mods")); _steamHelper.Setup(h => h.GetWorkshopsLocation(game.Object)) .Returns(_fileSystem.DirectoryInfo.New("path")); + + _idBuilder.Setup(ib => ib.Build(It.IsAny(), false)) + .Returns("builderPath"); + var mods = _service.FindMods(game.Object); var mod = Assert.Single(mods); - Assert.Equal(TestUtils.IsUnixLikePlatform ? "/Lib/Game/Eaw/Mods/ModA" : "c:\\lib\\game\\eaw\\mods\\moda", - mod.Identifier); + + Assert.Equal("builderPath", mod.Identifier); Assert.Equal(ModType.Default, mod.Type); } [Fact] public void TestOneDefaultModOneWsMod_Steam() { - _fileSystem.AddDirectory("Lib/Game/Eaw/Mods/ModA"); - _fileSystem.AddDirectory("Lib/workshop/content/32470/12345678"); + _fileSystem.Initialize() + .WithSubdirectory("Lib/Game/Eaw/Mods/ModA") + .WithSubdirectory("Lib/workshop/content/32470/12345678"); + var game = new Mock(); game.Setup(g => g.Exists()).Returns(true); game.Setup(g => g.Platform).Returns(GamePlatform.SteamGold); @@ -134,14 +157,27 @@ public void TestOneDefaultModOneWsMod_Steam() _steamHelper.Setup(h => h.GetWorkshopsLocation(game.Object)) .Returns(_fileSystem.DirectoryInfo.New("Lib/workshop/content/32470/")); + _idBuilder.Setup(ib => ib.Build(It.IsAny(), false)) + .Returns("defaultPath"); + _idBuilder.Setup(ib => ib.Build(It.IsAny(), true)) + .Returns("workshopPath"); + var mods = _service.FindMods(game.Object); Assert.Equal(2, mods.Count); + + var wsMod = mods.First(m => m.Type == ModType.Workshops); + Assert.Equal("workshopPath", wsMod.Identifier); + + var defaultMod = mods.First(m => m.Type == ModType.Default); + Assert.Equal("defaultPath", defaultMod.Identifier); } [Fact] public void TestOneWsMod_Steam() { - _fileSystem.AddDirectory("Lib/workshop/content/32470/12345678"); + _fileSystem.Initialize() + .WithSubdirectory("Lib/workshop/content/32470/12345678"); + var game = new Mock(); game.Setup(g => g.Exists()).Returns(true); game.Setup(g => g.Platform).Returns(GamePlatform.SteamGold); @@ -150,9 +186,12 @@ public void TestOneWsMod_Steam() _steamHelper.Setup(h => h.GetWorkshopsLocation(game.Object)) .Returns(_fileSystem.DirectoryInfo.New("Lib/workshop/content/32470/")); + _idBuilder.Setup(ib => ib.Build(It.IsAny(), true)) + .Returns("workshopPath"); + var mods = _service.FindMods(game.Object); var mod = Assert.Single(mods); - Assert.Equal("12345678", mod.Identifier); + Assert.Equal("workshopPath", mod.Identifier); Assert.Equal(ModType.Workshops, mod.Type); } } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyGraphBuilderIntegrationTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyGraphBuilderIntegrationTest.cs index b8b2aacd..48e68745 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyGraphBuilderIntegrationTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyGraphBuilderIntegrationTest.cs @@ -1,13 +1,13 @@ using System; using System.Collections.Generic; using System.IO.Abstractions; -using System.IO.Abstractions.TestingHelpers; using System.Linq; using EawModinfo.Spec; using Moq; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Mods; using PetroGlyph.Games.EawFoc.Services.Dependencies; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Test.ModServices; @@ -21,7 +21,9 @@ public void Test_OnlySelf() var sp = new Mock(); var game = SetupGame(fs, sp.Object); - fs.AddDirectory("Game/Mods/Target"); + fs.Initialize() + .WithSubdirectory("Game/Mods/Target"); + var targetMod = new TestMod(game, fs.DirectoryInfo.New("Game/Mods/Target"), false, "Name", sp.Object); targetMod.SetStatus(DependencyResolveStatus.Resolved); @@ -38,7 +40,9 @@ public void Test_Cycle1() var sp = new Mock(); var game = SetupGame(fs, sp.Object); - fs.AddDirectory("Game/Mods/Target"); + fs.Initialize() + .WithSubdirectory("Game/Mods/Target"); + var targetMod = new TestMod(game, fs.DirectoryInfo.New("Game/Mods/Target"), false, "Name", sp.Object); targetMod.SetStatus(DependencyResolveStatus.Resolved); @@ -58,11 +62,13 @@ public void Test_Cycle2() var sp = new Mock(); var game = SetupGame(fs, sp.Object); - fs.AddDirectory("Game/Mods/Target"); + fs.Initialize() + .WithSubdirectory("Game/Mods/Target") + .WithSubdirectory("Game/Mods/dep"); + var targetMod = new TestMod(game, fs.DirectoryInfo.New("Game/Mods/Target"), false, "Name", sp.Object); targetMod.SetStatus(DependencyResolveStatus.Resolved); - fs.AddDirectory("Game/Mods/dep"); var depMod = new TestMod(game, fs.DirectoryInfo.New("Game/Mods/dep"), false, "Name", sp.Object); depMod.SetStatus(DependencyResolveStatus.Resolved); depMod.DependencyAction(list => list.Add(new(targetMod))); @@ -84,24 +90,25 @@ public void Test_LeftRightOrder1() var sp = new Mock(); var game = SetupGame(fs, sp.Object); - fs.AddDirectory("Game/Mods/dep1"); + fs.Initialize() + .WithSubdirectory("Game/Mods/Target") + .WithSubdirectory("Game/Mods/dep1") + .WithSubdirectory("Game/Mods/dep2") + .WithSubdirectory("Game/Mods/dep3") + .WithSubdirectory("Game/Mods/dep4"); + var dep1 = new TestMod(game, fs.DirectoryInfo.New("Game/Mods/dep1"), false, "Name", sp.Object); dep1.SetStatus(DependencyResolveStatus.Resolved); - fs.AddDirectory("Game/Mods/dep2"); var dep2 = new TestMod(game, fs.DirectoryInfo.New("Game/Mods/dep2"), false, "Name", sp.Object); dep2.SetStatus(DependencyResolveStatus.Resolved); - fs.AddDirectory("Game/Mods/dep3"); var dep3 = new TestMod(game, fs.DirectoryInfo.New("Game/Mods/dep3"), false, "Name", sp.Object); dep3.SetStatus(DependencyResolveStatus.Resolved); - fs.AddDirectory("Game/Mods/dep4"); var dep4 = new TestMod(game, fs.DirectoryInfo.New("Game/Mods/dep4"), false, "Name", sp.Object); dep4.SetStatus(DependencyResolveStatus.Resolved); - - fs.AddDirectory("Game/Mods/Target"); var targetMod = new TestMod(game, fs.DirectoryInfo.New("Game/Mods/Target"), false, "Name", sp.Object); targetMod.SetStatus(DependencyResolveStatus.Resolved); @@ -129,24 +136,26 @@ public void Test_LeftRightOrder2() var sp = new Mock(); var game = SetupGame(fs, sp.Object); - fs.AddDirectory("Game/Mods/dep1"); + fs.Initialize() + .WithSubdirectory("Game/Mods/Target") + .WithSubdirectory("Game/Mods/dep1") + .WithSubdirectory("Game/Mods/dep2") + .WithSubdirectory("Game/Mods/dep3") + .WithSubdirectory("Game/Mods/dep4"); + var dep1 = new TestMod(game, fs.DirectoryInfo.New("Game/Mods/dep1"), false, "Name", sp.Object); dep1.SetStatus(DependencyResolveStatus.Resolved); - fs.AddDirectory("Game/Mods/dep2"); var dep2 = new TestMod(game, fs.DirectoryInfo.New("Game/Mods/dep2"), false, "Name", sp.Object); dep2.SetStatus(DependencyResolveStatus.Resolved); - fs.AddDirectory("Game/Mods/dep3"); var dep3 = new TestMod(game, fs.DirectoryInfo.New("Game/Mods/dep3"), false, "Name", sp.Object); dep3.SetStatus(DependencyResolveStatus.Resolved); - fs.AddDirectory("Game/Mods/dep4"); var dep4 = new TestMod(game, fs.DirectoryInfo.New("Game/Mods/dep4"), false, "Name", sp.Object); dep4.SetStatus(DependencyResolveStatus.Resolved); - fs.AddDirectory("Game/Mods/Target"); var targetMod = new TestMod(game, fs.DirectoryInfo.New("Game/Mods/Target"), false, "Name", sp.Object); targetMod.SetStatus(DependencyResolveStatus.Resolved); @@ -174,26 +183,29 @@ public void Test_LeftRightOrder3() var sp = new Mock(); var game = SetupGame(fs, sp.Object); + fs.Initialize() + .WithSubdirectory("Game/Mods/Target") + .WithSubdirectory("Game/Mods/dep1") + .WithSubdirectory("Game/Mods/dep2") + .WithSubdirectory("Game/Mods/dep3") + .WithSubdirectory("Game/Mods/dep4") + .WithSubdirectory("Game/Mods/dep5"); + // Target: 1, 2 // 2: 3, 4, 5 - fs.AddDirectory("Game/Mods/dep1"); var dep1 = new TestMod(game, fs.DirectoryInfo.New("Game/Mods/dep1"), false, "Name", sp.Object); dep1.SetStatus(DependencyResolveStatus.Resolved); - fs.AddDirectory("Game/Mods/dep2"); var dep2 = new TestMod(game, fs.DirectoryInfo.New("Game/Mods/dep2"), false, "Name", sp.Object); dep2.SetStatus(DependencyResolveStatus.Resolved); - fs.AddDirectory("Game/Mods/dep3"); var dep3 = new TestMod(game, fs.DirectoryInfo.New("Game/Mods/dep3"), false, "Name", sp.Object); dep3.SetStatus(DependencyResolveStatus.Resolved); - fs.AddDirectory("Game/Mods/dep4"); var dep4 = new TestMod(game, fs.DirectoryInfo.New("Game/Mods/dep4"), false, "Name", sp.Object); dep4.SetStatus(DependencyResolveStatus.Resolved); - fs.AddDirectory("Game/Mods/dep5"); var dep5 = new TestMod(game, fs.DirectoryInfo.New("Game/Mods/dep5"), false, "Name", sp.Object); dep5.SetStatus(DependencyResolveStatus.Resolved); @@ -204,8 +216,6 @@ public void Test_LeftRightOrder3() list.Add(new(dep5)); }); - - fs.AddDirectory("Game/Mods/Target"); var targetMod = new TestMod(game, fs.DirectoryInfo.New("Game/Mods/Target"), false, "Name", sp.Object); targetMod.SetStatus(DependencyResolveStatus.Resolved); @@ -225,9 +235,9 @@ public void Test_LeftRightOrder3() } - private static IGame SetupGame(IMockFileDataAccessor fileSystem, IServiceProvider sp) + private static IGame SetupGame(MockFileSystem fileSystem, IServiceProvider sp) { - fileSystem.AddFile("Game/swfoc.exe", new MockFileData(string.Empty)); + fileSystem.Initialize().WithFile("Game/swfoc.exe"); var game = new PetroglyphStarWarsGame(new GameIdentity(GameType.Foc, GamePlatform.Disk), fileSystem.DirectoryInfo.New("Game"), "Foc", sp); return game; diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverIntegrationTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverIntegrationTest.cs index 04bff57f..4c5047df 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverIntegrationTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverIntegrationTest.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO.Abstractions; -using System.IO.Abstractions.TestingHelpers; using System.Linq; using EawModinfo.Model; using EawModinfo.Spec; @@ -10,6 +9,7 @@ using PetroGlyph.Games.EawFoc.Mods; using PetroGlyph.Games.EawFoc.Services.Dependencies; using Semver; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Test.ModServices; @@ -25,6 +25,7 @@ public ModDependencyResolverIntegrationTest() _fileSystem = new MockFileSystem(); var sc = new ServiceCollection(); sc.AddSingleton(_fileSystem); + sc.AddSingleton(new ModDependencyGraphBuilder()); PetroglyphGameInfrastructureLibrary.InitializeLibraryWithDefaultServices(sc); _serviceProvider = sc.BuildServiceProvider(); _game = SetupGame(_fileSystem, _serviceProvider); @@ -33,7 +34,7 @@ public ModDependencyResolverIntegrationTest() [Fact] public void TestNoDependencies() { - _fileSystem.AddDirectory("Game/Mods/Target"); + _fileSystem.Initialize().WithFile("Game/Mods/Target"); var targetMod = new TestMod(_game, _fileSystem.DirectoryInfo.New("Game/Mods/Target"), false, "Name", _serviceProvider); var resolver = new ModDependencyResolver(_serviceProvider); @@ -51,33 +52,20 @@ public void TestNoDependencies() [Fact] public void TestResolveDependency() { - _fileSystem.AddDirectory("Game/Mods/Target"); + _fileSystem.Initialize() + .WithSubdirectory("Game/Mods/Target") + .WithSubdirectory("Game/Mods/dep"); - IModinfo targetInfo; - if (TestUtils.IsUnixLikePlatform) + var targetInfo = new ModinfoData("Name") { - targetInfo = new ModinfoData("Name") + Dependencies = new DependencyList(new List { - Dependencies = new DependencyList(new List() - { - new ModReference("/Game/Mods/dep", ModType.Default, SemVersionRange.Parse("1.*")) - }, DependencyResolveLayout.ResolveRecursive) - }; - } - else - { - targetInfo = new ModinfoData("Name") - { - Dependencies = new DependencyList(new List() - { - new ModReference("C:\\Game\\Mods\\dep", ModType.Default, SemVersionRange.Parse("1.*")) - }, DependencyResolveLayout.ResolveRecursive) - }; - } + new ModReference(_fileSystem.Path.GetFullPath("Game/Mods/dep"), ModType.Default, SemVersionRange.Parse("1.*")) + }, DependencyResolveLayout.ResolveRecursive) + }; var targetMod = new TestMod(_game, _fileSystem.DirectoryInfo.New("Game/Mods/Target"), false, targetInfo, _serviceProvider); - _fileSystem.AddDirectory("Game/Mods/dep"); var depMod = new TestMod(_game, _fileSystem.DirectoryInfo.New("Game/Mods/dep"), false, "Name", _serviceProvider); @@ -102,33 +90,20 @@ public void TestResolveDependency() [Fact] public void TestResolveDependencyIgnoreCycle() { - _fileSystem.AddDirectory("Game/Mods/Target"); + _fileSystem.Initialize() + .WithSubdirectory("Game/Mods/Target") + .WithSubdirectory("Game/Mods/dep"); - IModinfo targetInfo; - if (TestUtils.IsUnixLikePlatform) - { - targetInfo = new ModinfoData("Name") - { - Dependencies = new DependencyList(new List - { - new ModReference("/Game/Mods/dep", ModType.Default, SemVersionRange.Parse("1.*")) - }, DependencyResolveLayout.ResolveRecursive) - }; - } - else + var targetInfo = new ModinfoData("Name") { - targetInfo = new ModinfoData("Name") + Dependencies = new DependencyList(new List { - Dependencies = new DependencyList(new List - { - new ModReference("C:\\Game\\Mods\\dep", ModType.Default, SemVersionRange.Parse("1.*")) - }, DependencyResolveLayout.ResolveRecursive) - }; - } + new ModReference(_fileSystem.Path.GetFullPath("Game/Mods/dep"), ModType.Default, SemVersionRange.Parse("1.*")) + }, DependencyResolveLayout.ResolveRecursive) + }; var targetMod = new TestMod(_game, _fileSystem.DirectoryInfo.New("Game/Mods/Target"), false, targetInfo, _serviceProvider); - _fileSystem.AddDirectory("Game/Mods/dep"); var depMod = new TestMod(_game, _fileSystem.DirectoryInfo.New("Game/Mods/dep"), false, "Name", _serviceProvider); depMod.SetStatus(DependencyResolveStatus.Resolved); depMod.DependencyAction(l => l.Add(new ModDependencyEntry(targetMod))); @@ -151,31 +126,20 @@ public void TestResolveDependencyIgnoreCycle() [Fact] public void TestResolveDependencyCycle_Throws() { - _fileSystem.AddDirectory("Game/Mods/Target"); - IModinfo targetInfo; - if (TestUtils.IsUnixLikePlatform) - { - targetInfo = new ModinfoData("Name") - { - Dependencies = new DependencyList(new List - { - new ModReference("/Game/Mods/dep", ModType.Default, SemVersionRange.Parse("1.*")) - }, DependencyResolveLayout.ResolveRecursive) - }; - } - else + _fileSystem.Initialize() + .WithSubdirectory("Game/Mods/Target") + .WithSubdirectory("Game/Mods/dep"); + + var targetInfo = new ModinfoData("Name") { - targetInfo = new ModinfoData("Name") + Dependencies = new DependencyList(new List { - Dependencies = new DependencyList(new List - { - new ModReference("C:\\Game\\Mods\\dep", ModType.Default, SemVersionRange.Parse("1.*")) - }, DependencyResolveLayout.ResolveRecursive) - }; - } + new ModReference(_fileSystem.Path.GetFullPath("Game/Mods/dep"), ModType.Default, SemVersionRange.Parse("1.*")) + }, DependencyResolveLayout.ResolveRecursive) + }; + var targetMod = new TestMod(_game, _fileSystem.DirectoryInfo.New("Game/Mods/Target"), false, targetInfo, _serviceProvider); - _fileSystem.AddDirectory("Game/Mods/dep"); var depMod = new TestMod(_game, _fileSystem.DirectoryInfo.New("Game/Mods/dep"), false, "Name", _serviceProvider); depMod.SetStatus(DependencyResolveStatus.Resolved); depMod.DependencyAction(l => l.Add(new ModDependencyEntry(targetMod))); @@ -198,55 +162,31 @@ public void TestResolveDependencyCycle_Throws() [Fact] public void TestResolveDependencyChain() { - _fileSystem.AddDirectory("Game/Mods/Target"); - IModinfo targetInfo; - if (TestUtils.IsUnixLikePlatform) - { - targetInfo = new ModinfoData("Name") - { - Dependencies = new DependencyList(new List - { - new ModReference("/Game/Mods/dep", ModType.Default, SemVersionRange.Parse("1.*")) - }, DependencyResolveLayout.ResolveRecursive) - }; - } - else + _fileSystem.Initialize() + .WithSubdirectory("Game/Mods/Target") + .WithSubdirectory("Game/Mods/dep") + .WithSubdirectory("Game/Mods/subdep"); + + var targetInfo = new ModinfoData("Name") { - targetInfo = new ModinfoData("Name") + Dependencies = new DependencyList(new List { - Dependencies = new DependencyList(new List - { - new ModReference("C:\\Game\\Mods\\dep", ModType.Default, SemVersionRange.Parse("1.*")) - }, DependencyResolveLayout.ResolveRecursive) - }; - } + new ModReference(_fileSystem.Path.GetFullPath("Game/Mods/dep"), ModType.Default, SemVersionRange.Parse("1.*")) + }, DependencyResolveLayout.ResolveRecursive) + }; + var targetMod = new TestMod(_game, _fileSystem.DirectoryInfo.New("Game/Mods/Target"), false, targetInfo, _serviceProvider); - _fileSystem.AddDirectory("Game/Mods/dep"); - IModinfo depInfo; - if (TestUtils.IsUnixLikePlatform) - { - depInfo = new ModinfoData("Dep") - { - Dependencies = new DependencyList(new List - { - new ModReference("/Game/Mods/subdep", ModType.Default) - }, DependencyResolveLayout.ResolveRecursive) - }; - } - else + var depInfo = new ModinfoData("Dep") { - depInfo = new ModinfoData("Dep") + Dependencies = new DependencyList(new List { - Dependencies = new DependencyList(new List - { - new ModReference("C:\\Game\\Mods\\subdep", ModType.Default) - }, DependencyResolveLayout.ResolveRecursive) - }; - } + new ModReference(_fileSystem.Path.GetFullPath("Game/Mods/subdep"), ModType.Default) + }, DependencyResolveLayout.ResolveRecursive) + }; + var depMod = new TestMod(_game, _fileSystem.DirectoryInfo.New("Game/Mods/dep"), false, depInfo, _serviceProvider); - _fileSystem.AddDirectory("Game/Mods/subdep"); var subDepMod = new TestMod(_game, _fileSystem.DirectoryInfo.New("Game/Mods/subdep"), false, "SubDep", _serviceProvider); @@ -276,61 +216,36 @@ public void TestResolveDependencyChain() [Fact] public void TestResolveDependencyChainLayoutLastItem() { - _fileSystem.AddDirectory("Game/Mods/Target"); - IModinfo targetInfo; - if (TestUtils.IsUnixLikePlatform) - { - targetInfo = new ModinfoData("Name") - { - Dependencies = new DependencyList(new List - { - new ModReference("/Game/Mods/dep", ModType.Default, SemVersionRange.Parse("1.*")), - new ModReference("/Game/Mods/dep2", ModType.Default) - }, DependencyResolveLayout.ResolveLastItem) - }; - } - else + _fileSystem.Initialize() + .WithSubdirectory("Game/Mods/Target") + .WithSubdirectory("Game/Mods/dep") + .WithSubdirectory("Game/Mods/dep2") + .WithSubdirectory("Game/Mods/subdep"); + + var targetInfo = new ModinfoData("Name") { - targetInfo = new ModinfoData("Name") + Dependencies = new DependencyList(new List { - Dependencies = new DependencyList(new List - { - new ModReference("C:\\Game\\Mods\\dep", ModType.Default, SemVersionRange.Parse("1.*")), - new ModReference("C:\\Game\\Mods\\dep2", ModType.Default) - }, DependencyResolveLayout.ResolveLastItem) - }; - } + new ModReference(_fileSystem.Path.GetFullPath("Game/Mods/dep"), ModType.Default, SemVersionRange.Parse("1.*")), + new ModReference(_fileSystem.Path.GetFullPath("Game/Mods/dep2"), ModType.Default) + }, DependencyResolveLayout.ResolveLastItem) + }; + var targetMod = new TestMod(_game, _fileSystem.DirectoryInfo.New("Game/Mods/Target"), false, targetInfo, _serviceProvider); targetMod.SetLayout(DependencyResolveLayout.ResolveLastItem); - _fileSystem.AddDirectory("Game/Mods/dep"); - IModinfo depInfo; - if (TestUtils.IsUnixLikePlatform) - { - depInfo = new ModinfoData("Dep") - { - Dependencies = new DependencyList(new List - { - new ModReference("/Game/Mods/subdep", ModType.Default) - }, DependencyResolveLayout.ResolveRecursive) - }; - } - else + IModinfo depInfo = new ModinfoData("Dep") { - depInfo = new ModinfoData("Dep") + Dependencies = new DependencyList(new List { - Dependencies = new DependencyList(new List - { - new ModReference("C:\\Game\\Mods\\subdep", ModType.Default) - }, DependencyResolveLayout.ResolveRecursive) - }; - } + new ModReference(_fileSystem.Path.GetFullPath("Game/Mods/subdep"), ModType.Default) + }, DependencyResolveLayout.ResolveRecursive) + }; + var depMod = new TestMod(_game, _fileSystem.DirectoryInfo.New("Game/Mods/dep"), false, depInfo, _serviceProvider); - _fileSystem.AddDirectory("Game/Mods/dep2"); var dep2Mod = new TestMod(_game, _fileSystem.DirectoryInfo.New("Game/Mods/dep2"), false, "Dep2", _serviceProvider); - _fileSystem.AddDirectory("Game/Mods/subdep"); var subDepMod = new TestMod(_game, _fileSystem.DirectoryInfo.New("Game/Mods/subdep"), false, "SubDep", _serviceProvider); @@ -359,61 +274,36 @@ public void TestResolveDependencyChainLayoutLastItem() [Fact] public void TestResolveDependencyChainLayoutFullResolved() { - _fileSystem.AddDirectory("Game/Mods/Target"); - IModinfo targetInfo; - if (TestUtils.IsUnixLikePlatform) - { - targetInfo = new ModinfoData("Name") - { - Dependencies = new DependencyList(new List - { - new ModReference("/Game/Mods/dep", ModType.Default, SemVersionRange.Parse("1.*")), - new ModReference("/Game/Mods/dep2", ModType.Default) - }, DependencyResolveLayout.FullResolved) - }; - } - else + _fileSystem.Initialize() + .WithSubdirectory("Game/Mods/Target") + .WithSubdirectory("Game/Mods/dep") + .WithSubdirectory("Game/Mods/dep2") + .WithSubdirectory("Game/Mods/subdep"); + + var targetInfo = new ModinfoData("Name") { - targetInfo = new ModinfoData("Name") + Dependencies = new DependencyList(new List { - Dependencies = new DependencyList(new List - { - new ModReference("C:\\Game\\Mods\\dep", ModType.Default, SemVersionRange.Parse("1.*")), - new ModReference("C:\\Game\\Mods\\dep2", ModType.Default) - }, DependencyResolveLayout.FullResolved) - }; - } + new ModReference(_fileSystem.Path.GetFullPath("Game/Mods/dep"), ModType.Default, SemVersionRange.Parse("1.*")), + new ModReference(_fileSystem.Path.GetFullPath("Game/Mods/dep2"), ModType.Default) + }, DependencyResolveLayout.FullResolved) + }; + var targetMod = new TestMod(_game, _fileSystem.DirectoryInfo.New("Game/Mods/Target"), false, targetInfo, _serviceProvider); targetMod.SetLayout(DependencyResolveLayout.FullResolved); - _fileSystem.AddDirectory("Game/Mods/dep"); - IModinfo depInfo; - if (TestUtils.IsUnixLikePlatform) + var depInfo = new ModinfoData("Dep") { - depInfo = new ModinfoData("Dep") + Dependencies = new DependencyList(new List { - Dependencies = new DependencyList(new List - { - new ModReference("/Game/Mods/subdep", ModType.Default) - }, DependencyResolveLayout.ResolveRecursive) - }; - } - else - { - depInfo = new ModinfoData("Dep") - { - Dependencies = new DependencyList(new List - { - new ModReference("C:\\Game\\Mods\\subdep", ModType.Default) - }, DependencyResolveLayout.ResolveRecursive) - }; - } + new ModReference(_fileSystem.Path.GetFullPath("Game/Mods/subdep"), ModType.Default) + }, DependencyResolveLayout.ResolveRecursive) + }; + var depMod = new TestMod(_game, _fileSystem.DirectoryInfo.New("Game/Mods/dep"), false, depInfo, _serviceProvider); - _fileSystem.AddDirectory("Game/Mods/dep2"); var dep2Mod = new TestMod(_game, _fileSystem.DirectoryInfo.New("Game/Mods/dep2"), false, "Dep2", _serviceProvider); - _fileSystem.AddDirectory("Game/Mods/subdep"); var subDepMod = new TestMod(_game, _fileSystem.DirectoryInfo.New("Game/Mods/subdep"), false, "SubDep", _serviceProvider); @@ -440,9 +330,10 @@ public void TestResolveDependencyChainLayoutFullResolved() } - private static IGame SetupGame(IMockFileDataAccessor fileSystem, IServiceProvider sp) + private static IGame SetupGame(MockFileSystem fileSystem, IServiceProvider sp) { - fileSystem.AddFile("Game/swfoc.exe", new MockFileData(string.Empty)); + fileSystem.Initialize() + .WithFile("Game/swfoc.exe"); var game = new PetroglyphStarWarsGame(new GameIdentity(GameType.Foc, GamePlatform.Disk), fileSystem.DirectoryInfo.New("Game"), "Foc", sp); return game; diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyTraverserIntegrationTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyTraverserIntegrationTest.cs index bbd3a94f..437f543e 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyTraverserIntegrationTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyTraverserIntegrationTest.cs @@ -2,13 +2,14 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO.Abstractions; -using System.IO.Abstractions.TestingHelpers; using System.Linq; using EawModinfo.Spec; -using Moq; +using Microsoft.Extensions.DependencyInjection; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Mods; using PetroGlyph.Games.EawFoc.Services.Dependencies; +using PetroGlyph.Games.EawFoc.Services.Detection; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Test.ModServices; @@ -22,7 +23,10 @@ public class ModDependencyTraverserIntegrationTest public ModDependencyTraverserIntegrationTest() { _fileSystem = new MockFileSystem(); - _serviceProvider = new Mock().Object; + var sc = new ServiceCollection(); + sc.AddSingleton(sp => new ModIdentifierBuilder(sp)); + sc.AddSingleton(_fileSystem); + _serviceProvider = sc.BuildServiceProvider(); _game = SetupGame(_fileSystem, _serviceProvider); } @@ -329,13 +333,13 @@ public void TestTraverse_LayoutRecursive_ModinfoSpec_M_Throws() private TestMod CreateMod(string name) { - _fileSystem.AddDirectory($"Game/Mods/{name}"); + _fileSystem.Initialize().WithSubdirectory($"Game/Mods/{name}"); return new TestMod(_game, _fileSystem.DirectoryInfo.New($"Game/Mods/{name}"), false, name, _serviceProvider); } - private static IGame SetupGame(IMockFileDataAccessor fileSystem, IServiceProvider sp) + private static IGame SetupGame(MockFileSystem fileSystem, IServiceProvider sp) { - fileSystem.AddFile("Game/swfoc.exe", new MockFileData(string.Empty)); + fileSystem.Initialize().WithFile("Game/swfoc.exe"); var game = new PetroglyphStarWarsGame(new GameIdentity(GameType.Foc, GamePlatform.Disk), fileSystem.DirectoryInfo.New("Game"), "Foc", sp); return game; diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModFactoryTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModFactoryTest.cs index de477f55..57e7d2b9 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModFactoryTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModFactoryTest.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Globalization; using System.IO.Abstractions; -using System.IO.Abstractions.TestingHelpers; using System.Linq; using EawModinfo.Model; using EawModinfo.Spec; @@ -12,6 +11,7 @@ using PetroGlyph.Games.EawFoc.Services; using PetroGlyph.Games.EawFoc.Services.Detection; using PetroGlyph.Games.EawFoc.Services.Name; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Test.ModServices; @@ -49,7 +49,7 @@ public void NullCtor_Throws() [Fact] public void TestModInfoSpecCreation_NoModinfoFiles() { - _fileSystem.AddDirectory("Mods/Name"); + _fileSystem.Initialize().WithSubdirectory("Mods/Name"); var game = new Mock(); var modLoc = _fileSystem.DirectoryInfo.New("Mods/Name"); _locationResolver.Setup(r => r.ResolveLocation(It.IsAny(), It.IsAny())) @@ -69,7 +69,7 @@ public void TestModInfoSpecCreation_NoModinfoFiles() [Fact] public void TestModInfoSpecCreation_MainModinfoFiles() { - _fileSystem.AddDirectory("Mods/Name"); + _fileSystem.Initialize().WithSubdirectory("Mods/Name"); var game = new Mock(); var modLoc = _fileSystem.DirectoryInfo.New("Mods/Name"); _locationResolver.Setup(r => r.ResolveLocation(It.IsAny(), It.IsAny())) @@ -94,7 +94,7 @@ public void TestModInfoSpecCreation_MainModinfoFiles() [Fact] public void TestModInfoSpecCreation_VariantsOnly() { - _fileSystem.AddDirectory("Mods/Name"); + _fileSystem.Initialize().WithSubdirectory("Mods/Name"); var game = new Mock(); var modLoc = _fileSystem.DirectoryInfo.New("Mods/Name"); _locationResolver.Setup(r => r.ResolveLocation(It.IsAny(), It.IsAny())) @@ -131,7 +131,7 @@ public void TestModInfoSpecCreation_VariantsOnly() [Fact] public void TestModCreation_NoModinfoFiles() { - _fileSystem.AddDirectory("Mods/Name"); + _fileSystem.Initialize().WithSubdirectory("Mods/Name"); var game = new Mock(); var modLoc = _fileSystem.DirectoryInfo.New("Mods/Name"); _locationResolver.Setup(r => r.ResolveLocation(It.IsAny(), It.IsAny())) @@ -152,7 +152,7 @@ public void TestModCreation_NoModinfoFiles() [Fact] public void TestModCreation_WithModinfo() { - _fileSystem.AddDirectory("Mods/Name"); + _fileSystem.Initialize().WithSubdirectory("Mods/Name"); var game = new Mock(); var modLoc = _fileSystem.DirectoryInfo.New("Mods/Name"); @@ -179,7 +179,7 @@ public void TestModCreation_WithModinfo() [Fact] public void TestModCreation_SearchMainModinfo() { - _fileSystem.AddDirectory("Mods/Name"); + _fileSystem.Initialize().WithSubdirectory("Mods/Name"); var game = new Mock(); var modLoc = _fileSystem.DirectoryInfo.New("Mods/Name"); _locationResolver.Setup(r => r.ResolveLocation(It.IsAny(), It.IsAny())) @@ -210,7 +210,7 @@ public void TestModCreation_SearchMainModinfo() [Fact] public void TestModCreation_NoSearchMainModinfo() { - _fileSystem.AddDirectory("Mods/Name"); + _fileSystem.Initialize().WithSubdirectory("Mods/Name"); var game = new Mock(); var modLoc = _fileSystem.DirectoryInfo.New("Mods/Name"); _locationResolver.Setup(r => r.ResolveLocation(It.IsAny(), It.IsAny())) @@ -241,7 +241,7 @@ public void TestModCreation_NoSearchMainModinfo() [Fact] public void TestVariantModCreation_NoVariants() { - _fileSystem.AddDirectory("Mods/Name"); + _fileSystem.Initialize().WithSubdirectory("Mods/Name"); var game = new Mock(); var modLoc = _fileSystem.DirectoryInfo.New("Mods/Name"); _locationResolver.Setup(r => r.ResolveLocation(It.IsAny(), It.IsAny())) @@ -267,7 +267,7 @@ public void TestVariantModCreation_NoVariants() [Fact] public void TestVariantModCreation_TwoVariants() { - _fileSystem.AddDirectory("Mods/Name"); + _fileSystem.Initialize().WithSubdirectory("Mods/Name"); var game = new Mock(); var modLoc = _fileSystem.DirectoryInfo.New("Mods/Name"); _locationResolver.Setup(r => r.ResolveLocation(It.IsAny(), It.IsAny())) diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModIdentifierBuilderTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModIdentifierBuilderTest.cs index 90341837..7f6f2bd0 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModIdentifierBuilderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModIdentifierBuilderTest.cs @@ -1,13 +1,14 @@ using System.Collections.Generic; -using System.IO.Abstractions.TestingHelpers; -using AnakinRaW.CommonUtilities.FileSystem; +using System.IO.Abstractions; using EawModinfo.Model; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; using Moq; using PetroGlyph.Games.EawFoc.Mods; using PetroGlyph.Games.EawFoc.Services.Detection; +using PG.TestingUtilities; using Semver; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Test.ModServices; @@ -15,32 +16,38 @@ namespace PetroGlyph.Games.EawFoc.Test.ModServices; public class ModIdentifierBuilderTest { private readonly ModIdentifierBuilder _service; - private readonly Mock _pathHelper; private readonly Mock _physicalMod; private readonly Mock _virtualMod; private readonly MockFileSystem _fileSystem; public ModIdentifierBuilderTest() { - var sc = new ServiceCollection(); - _pathHelper = new Mock(); - sc.AddTransient(sp => _pathHelper.Object); - _service = new ModIdentifierBuilder(sc.BuildServiceProvider()); _physicalMod = new Mock(); _virtualMod = new Mock(); _fileSystem = new MockFileSystem(); + var sc = new ServiceCollection(); + sc.AddSingleton(_fileSystem); + _service = new ModIdentifierBuilder(sc.BuildServiceProvider()); } - [Fact] - public void TestDefaultMod() + [PlatformSpecificFact(TestPlatformIdentifier.Windows)] + public void TestDefaultMod_Windows() { _physicalMod.Setup(m => m.Type).Returns(ModType.Default); _physicalMod.Setup(m => m.Directory).Returns(_fileSystem.DirectoryInfo.New("ModPath")); - _pathHelper.Setup(p => p.NormalizePath(It.IsAny(), PathNormalizeOptions.Full)).Returns("c:\\modpath"); + var identifier = _service.Build(_physicalMod.Object); + Assert.Equal("C:\\MODPATH", identifier); + } + + [PlatformSpecificFact(TestPlatformIdentifier.Linux)] + public void TestDefaultMod_Linux() + { + _physicalMod.Setup(m => m.Type).Returns(ModType.Default); + _physicalMod.Setup(m => m.Directory).Returns(_fileSystem.DirectoryInfo.New("ModPath")); var identifier = _service.Build(_physicalMod.Object); - Assert.Equal("c:\\modpath", identifier); + Assert.Equal("/ModPath", identifier); } [Fact] @@ -66,12 +73,20 @@ public void TestVirtualMod() Assert.Equal("VirtualMod-1138-1138", identifier); } - [Fact] - public void TestNormalizeDefault() + [PlatformSpecificFact(TestPlatformIdentifier.Windows)] + public void TestNormalizeDefault_Windows() + { + var mRef = new ModReference("path", ModType.Default, SemVersionRange.Parse("1.*")); + var expected = new ModReference("C:\\PATH", ModType.Default, SemVersionRange.Parse("1.*")); + var normalizedRef = _service.Normalize(mRef); + Assert.Equal(expected, normalizedRef); + } + + [PlatformSpecificFact(TestPlatformIdentifier.Linux)] + public void TestNormalizeDefault_Linux() { var mRef = new ModReference("path", ModType.Default, SemVersionRange.Parse("1.*")); - var expected = new ModReference("c:\\path", ModType.Default, SemVersionRange.Parse("1.*")); - _pathHelper.Setup(p => p.NormalizePath(It.IsAny(), PathNormalizeOptions.Full)).Returns("c:\\path"); + var expected = new ModReference("/path", ModType.Default, SemVersionRange.Parse("1.*")); var normalizedRef = _service.Normalize(mRef); Assert.Equal(expected, normalizedRef); } diff --git a/src/PetroGlyph.Games.EawFoc/test/ModTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModTest.cs index 2cb31b9d..79a928bb 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModTest.cs @@ -1,11 +1,12 @@ using System; -using System.IO.Abstractions.TestingHelpers; using EawModinfo; using EawModinfo.Model; using EawModinfo.Spec; using Moq; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Mods; +using PetroGlyph.Games.EawFoc.Services.Detection; +using Testably.Abstractions.Testing; using Xunit; namespace PetroGlyph.Games.EawFoc.Test; @@ -26,8 +27,8 @@ public void InvalidCtor_Throws() var modDir = fs.DirectoryInfo.New("Game/Mods/A"); Assert.Throws(() => new Mod(game.Object, modDir, false, (IModinfo)null, null)); Assert.Throws(() => new Mod(game.Object, modDir, false, (IModinfoFile)null, null)); - Assert.Throws(() => new Mod(game.Object, modDir, false, (string)null, null)); - Assert.Throws(() => new Mod(game.Object, modDir, false, string.Empty, null)); + Assert.Throws(() => new Mod(game.Object, modDir, false, (string)null, new Mock().Object)); + Assert.Throws(() => new Mod(game.Object, modDir, false, string.Empty, new Mock().Object)); var sp = new Mock(); Assert.Throws(() => new Mod(game.Object, modDir, false, (IModinfo)null, sp.Object)); Assert.Throws(() => new Mod(game.Object, modDir, false, (IModinfoFile)null, sp.Object)); @@ -43,14 +44,19 @@ public void InvalidCtor_Throws() [Fact] public void ValidCtors_Properties() { + var modIdBuilder = new Mock(); var game = new Mock(); var fs = new MockFileSystem(); var modDir = fs.DirectoryInfo.New("Game/Mods/A"); var sp = new Mock(); + sp.Setup(s => s.GetService(typeof(IModIdentifierBuilder))).Returns(modIdBuilder.Object); + var mod = new Mod(game.Object, modDir, false, "Name", sp.Object); + modIdBuilder.Setup(b => b.Build(mod)).Returns("somePath"); + Assert.Equal("Name", mod.Name); Assert.Equal(ModType.Default, mod.Type); - Assert.Equal(TestUtils.IsUnixLikePlatform ? "/Game/Mods/A" : "c:\\game\\mods\\a", mod.Identifier); + Assert.Equal("somePath", mod.Identifier); Assert.NotNull(mod.FileService); Assert.NotNull(mod.FileSystem); Assert.Null(mod.ModinfoFile); @@ -62,6 +68,6 @@ public void ValidCtors_Properties() Assert.NotNull(modA.ModinfoFile); var modB = new Mod(game.Object, modDir, true, "Name", sp.Object); - Assert.Equal("A", modB.Identifier); + Assert.Equal("somePath", modB.Identifier); } } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/test/PetroGlyph.Games.EawFoc.Test.csproj b/src/PetroGlyph.Games.EawFoc/test/PetroGlyph.Games.EawFoc.Test.csproj index 96013ad2..a4b32fa1 100644 --- a/src/PetroGlyph.Games.EawFoc/test/PetroGlyph.Games.EawFoc.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc/test/PetroGlyph.Games.EawFoc.Test.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 $(TargetFrameworks);net48 false true @@ -10,27 +10,28 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all + diff --git a/src/PetroGlyph.Games.EawFoc/test/TestUtils.cs b/src/PetroGlyph.Games.EawFoc/test/TestUtils.cs deleted file mode 100644 index f43ba8f4..00000000 --- a/src/PetroGlyph.Games.EawFoc/test/TestUtils.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System.Runtime.InteropServices; - -namespace PetroGlyph.Games.EawFoc.Test; - -internal static class TestUtils -{ - internal static bool IsUnixLikePlatform = RuntimeInformation.IsOSPlatform(OSPlatform.Linux); -} \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/test/VirtualModTest.cs b/src/PetroGlyph.Games.EawFoc/test/VirtualModTest.cs index ec56d0b5..f20d1cec 100644 --- a/src/PetroGlyph.Games.EawFoc/test/VirtualModTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/VirtualModTest.cs @@ -7,6 +7,7 @@ using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Mods; using PetroGlyph.Games.EawFoc.Services.Dependencies; +using PetroGlyph.Games.EawFoc.Services.Detection; using Xunit; namespace PetroGlyph.Games.EawFoc.Test; @@ -40,6 +41,7 @@ public void ValidCtors_Properties() var game = new Mock(); game.Setup(g => g.Equals(It.IsAny())).Returns(true); var sp = new Mock(); + sp.Setup(s => s.GetService(typeof(IModIdentifierBuilder))).Returns(new Mock().Object); var dep = new Mock(); dep.Setup(d => d.Game).Returns(game.Object); var mod = new VirtualMod("Name", game.Object, new List { new(dep.Object) }, DependencyResolveLayout.ResolveLastItem, sp.Object); @@ -56,6 +58,7 @@ public void NotSupportedOperation_Throws() var game = new Mock(); game.Setup(g => g.Equals(It.IsAny())).Returns(true); var sp = new Mock(); + sp.Setup(s => s.GetService(typeof(IModIdentifierBuilder))).Returns(new Mock().Object); var dep = new Mock(); dep.Setup(d => d.Game).Returns(game.Object); var mod = new VirtualMod("Name", game.Object, new List { new(dep.Object) }, DependencyResolveLayout.ResolveLastItem, sp.Object); diff --git a/src/Testing/PG.TestingUtilities/ConditionalFactAttribute.cs b/src/Testing/PG.TestingUtilities/ConditionalFactAttribute.cs new file mode 100644 index 00000000..2bd168a3 --- /dev/null +++ b/src/Testing/PG.TestingUtilities/ConditionalFactAttribute.cs @@ -0,0 +1,35 @@ +using System.Runtime.InteropServices; + +namespace PG.TestingUtilities; + +public class PlatformSpecificFactAttribute : FactAttribute +{ + public PlatformSpecificFactAttribute(params TestPlatformIdentifier[] platformIds) + { + var platforms = platformIds.Select(targetPlatform => OSPlatform.Create(Enum.GetName(typeof(TestPlatformIdentifier), targetPlatform)!.ToUpper())); + var platformMatches = platforms.Any(RuntimeInformation.IsOSPlatform); + + if (!platformMatches) + Skip = "Test execution is not supported on the current platform"; + } +} + +public class PlatformSpecificTheoryAttribute : TheoryAttribute +{ + public PlatformSpecificTheoryAttribute(params TestPlatformIdentifier[] platformIds) + { + var platforms = platformIds.Select(targetPlatform => OSPlatform.Create(Enum.GetName(typeof(TestPlatformIdentifier), targetPlatform)!.ToUpper())); + var platformMatches = platforms.Any(RuntimeInformation.IsOSPlatform); + + if (!platformMatches) + Skip = "Test execution is not supported on the current platform"; + } +} + + +[Flags] +public enum TestPlatformIdentifier +{ + Windows = 1, + Linux = 2, +} \ No newline at end of file diff --git a/src/Testing/PG.TestingUtilities/PG.TestingUtilities.csproj b/src/Testing/PG.TestingUtilities/PG.TestingUtilities.csproj new file mode 100644 index 00000000..f9c84d76 --- /dev/null +++ b/src/Testing/PG.TestingUtilities/PG.TestingUtilities.csproj @@ -0,0 +1,33 @@ + + + + net8.0 + $(TargetFrameworks);net48 + enable + enable + false + false + PG.TestingUtilities.Testing + PG.TestingUtilities.Testing + PG.TestingUtilities.Testing + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + diff --git a/testEnvironments.json b/testEnvironments.json index 6f838837..9e3990a1 100644 --- a/testEnvironments.json +++ b/testEnvironments.json @@ -4,7 +4,7 @@ { "name": "Ubuntu", "type": "wsl", - "wslDistribution": "Ubuntu-20.04" + "wslDistribution": "Ubuntu-22.04" } ] } \ No newline at end of file From 0fbfacdb4395d95f243f4cd6a26745df6b28827d Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Thu, 14 Mar 2024 12:11:51 +0100 Subject: [PATCH 05/41] start renaming packages and ns --- Directory.Build.props | 66 +++++++++++-------- .../src/PetroGlyph.Games.EawFoc.csproj | 26 ++++---- 2 files changed, 52 insertions(+), 40 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index e74fe5c5..57042a4f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,29 +1,41 @@ - - PetroglyphTools - Copyright © Anakin Sklavenwalker 2019-2023 - Anakin Sklavenwalker - Republic at War Modding Team - petroglyph, alamo, glyphx, foc, eaw - https://github.com/AlamoEngine-Tools - MIT - README.md - true - - - latest - disable - - - - all - 3.6.133 - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - + + $(MSBuildThisFileDirectory) + true + true + $(MSBuildThisFileDirectory) + $(RepoRootPath)bin\Packages\$(Configuration)\ + + + Alamo Engine Tools and Contributors + Copyright © 2024 Alamo Engine Tools and contributors. All rights reserved. + Alamo Engine Tools + petroglyph, alamo, glyphx, foc, eaw + https://github.com/AlamoEngine-Tools + $(MSBuildThisFileDirectory)LICENSE + MIT + README.md + true + https://github.com/AlamoEngine-Tools/PetroglyphTools + git + aet.png + + + latest + disable + enable + true + + + + all + 3.6.133 + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj b/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj index e32be684..b8afb044 100644 --- a/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj +++ b/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj @@ -1,23 +1,24 @@ - - + - Core implementation for the Petroglyph Game infrastructire, providing classes and services to detect and initialize PG Star Wars games (EaW, FoC) and their mods. + netstandard2.0;net8.0 - - netstandard2.0;net8.0 - enable - true + PG.StarWarsGame.Infrastructure + Core implementation for the Petroglyph Game infrastructire, providing classes and services to detect and initialize PG Star Wars games (EaW, FoC) and their mods. + AlamoEngineTools.PG.StarWarsGame.Infrastructure + alamo,petroglyph,glyphx + en - - true - snupkg true true true - + + true + snupkg + true + @@ -37,6 +38,5 @@ - - + \ No newline at end of file From a85e9d5dcb6ceedeedd9af67402b6132a6b26b62 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Thu, 14 Mar 2024 17:15:36 +0100 Subject: [PATCH 06/41] build for linux again --- sample/SampleApplication/SampleApplication.csproj | 11 +---------- ...troGlyph.Games.EawFoc.Clients.Steam.Windows.csproj | 2 -- ...yph.Games.EawFoc.Clients.Steam.Windows.Test.csproj | 4 ++-- .../src/PetroGlyph.Games.EawFoc.Clients.Steam.csproj | 2 -- .../PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj | 1 - .../src/PetroGlyph.Games.EawFoc.Clients.csproj | 2 -- .../test/PetroGlyph.Games.EawFoc.Clients.Test.csproj | 1 - .../test/PetroGlyph.Games.EawFoc.Test.csproj | 1 - .../PG.TestingUtilities/ConditionalFactAttribute.cs | 4 +++- .../PG.TestingUtilities/PG.TestingUtilities.csproj | 5 ----- 10 files changed, 6 insertions(+), 27 deletions(-) diff --git a/sample/SampleApplication/SampleApplication.csproj b/sample/SampleApplication/SampleApplication.csproj index a5fee1fa..b77d5a18 100644 --- a/sample/SampleApplication/SampleApplication.csproj +++ b/sample/SampleApplication/SampleApplication.csproj @@ -2,19 +2,10 @@ Exe - 10.0 net8.0-windows - disable - enable false - - - true - false - false - - + diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj index ab51c4a5..2258bba0 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj @@ -7,8 +7,6 @@ net8.0-windows;net48 PetroGlyph.Games.EawFoc.Clients.Steam - enable - true diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj index ea61534e..458d14dc 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj @@ -1,8 +1,8 @@  - net8.0-windows;net48 - enable + net8.0-windows + $(TargetFrameworks);net48 false true diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/PetroGlyph.Games.EawFoc.Clients.Steam.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/PetroGlyph.Games.EawFoc.Clients.Steam.csproj index 47595b9b..d60b0d3c 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/PetroGlyph.Games.EawFoc.Clients.Steam.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/PetroGlyph.Games.EawFoc.Clients.Steam.csproj @@ -6,8 +6,6 @@ netstandard2.0 - enable - true diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj index 798b5829..5c6b3a4c 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj @@ -3,7 +3,6 @@ net8.0 $(TargetFrameworks);net48 - enable false true diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/PetroGlyph.Games.EawFoc.Clients.csproj b/src/PetroGlyph.Games.EawFoc.Clients/src/PetroGlyph.Games.EawFoc.Clients.csproj index 970935c6..2c3d0d8a 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/PetroGlyph.Games.EawFoc.Clients.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/PetroGlyph.Games.EawFoc.Clients.csproj @@ -6,8 +6,6 @@ netstandard2.0;netstandard2.1 - enable - true diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/PetroGlyph.Games.EawFoc.Clients.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients/test/PetroGlyph.Games.EawFoc.Clients.Test.csproj index 5c06f75c..aeaaf008 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/PetroGlyph.Games.EawFoc.Clients.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/PetroGlyph.Games.EawFoc.Clients.Test.csproj @@ -4,7 +4,6 @@ net8.0 $(TargetFrameworks);net48 false - enable true diff --git a/src/PetroGlyph.Games.EawFoc/test/PetroGlyph.Games.EawFoc.Test.csproj b/src/PetroGlyph.Games.EawFoc/test/PetroGlyph.Games.EawFoc.Test.csproj index a4b32fa1..e258928a 100644 --- a/src/PetroGlyph.Games.EawFoc/test/PetroGlyph.Games.EawFoc.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc/test/PetroGlyph.Games.EawFoc.Test.csproj @@ -5,7 +5,6 @@ $(TargetFrameworks);net48 false true - enable 8600;8625;0162 diff --git a/src/Testing/PG.TestingUtilities/ConditionalFactAttribute.cs b/src/Testing/PG.TestingUtilities/ConditionalFactAttribute.cs index 2bd168a3..754dcd79 100644 --- a/src/Testing/PG.TestingUtilities/ConditionalFactAttribute.cs +++ b/src/Testing/PG.TestingUtilities/ConditionalFactAttribute.cs @@ -1,4 +1,6 @@ -using System.Runtime.InteropServices; +using System; +using System.Linq; +using System.Runtime.InteropServices; namespace PG.TestingUtilities; diff --git a/src/Testing/PG.TestingUtilities/PG.TestingUtilities.csproj b/src/Testing/PG.TestingUtilities/PG.TestingUtilities.csproj index f9c84d76..bd1b345c 100644 --- a/src/Testing/PG.TestingUtilities/PG.TestingUtilities.csproj +++ b/src/Testing/PG.TestingUtilities/PG.TestingUtilities.csproj @@ -3,13 +3,8 @@ net8.0 $(TargetFrameworks);net48 - enable - enable false false - PG.TestingUtilities.Testing - PG.TestingUtilities.Testing - PG.TestingUtilities.Testing From 9a06943b427f779bd8edc918ff3742d9c1b28383 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Thu, 14 Mar 2024 17:47:17 +0100 Subject: [PATCH 07/41] rename assemblies --- PetroGlyphGameInfrastructure.sln | 2 +- ....Games.EawFoc.Clients.Steam.Windows.csproj | 13 ++++++++---- .../src/Properties/AssemblyInfo.cs | 2 +- ...s.EawFoc.Clients.Steam.Windows.Test.csproj | 4 ++++ ...troGlyph.Games.EawFoc.Clients.Steam.csproj | 20 +++++++++---------- .../src/Properties/AssemblyInfo.cs | 2 +- ...yph.Games.EawFoc.Clients.Steam.Test.csproj | 4 ++++ .../PetroGlyph.Games.EawFoc.Clients.csproj | 16 +++++++-------- .../src/Properties/AssemblyInfo.cs | 10 +++++----- ...etroGlyph.Games.EawFoc.Clients.Test.csproj | 4 ++++ .../src/PetroGlyph.Games.EawFoc.csproj | 2 ++ .../src/Properties/AssemblyInfo.cs | 2 +- .../test/PetroGlyph.Games.EawFoc.Test.csproj | 4 ++++ 13 files changed, 54 insertions(+), 31 deletions(-) diff --git a/PetroGlyphGameInfrastructure.sln b/PetroGlyphGameInfrastructure.sln index 37a2ac1e..0f766aaf 100644 --- a/PetroGlyphGameInfrastructure.sln +++ b/PetroGlyphGameInfrastructure.sln @@ -25,7 +25,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PetroGlyph.Games.EawFoc.Cli EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleApplication", "sample\SampleApplication\SampleApplication.csproj", "{8F295344-3D7B-4983-88FD-D0E5C692CBAB}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PG.TestingUtilities", "src\Testing\PG.TestingUtilities\PG.TestingUtilities.csproj", "{C8F51821-F25D-4C4E-8050-5C559ADD39DB}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PG.TestingUtilities", "src\Testing\PG.TestingUtilities\PG.TestingUtilities.csproj", "{C8F51821-F25D-4C4E-8050-5C559ADD39DB}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj index 2258bba0..f1202782 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj @@ -1,12 +1,17 @@  - - Provides tools for launching Petroglyph Star Wars games on various clients, such as Steam or Disk release. + net8.0-windows;net48 + PG.StarWarsGame.Infrastructure.Clients.Steam + PG.StarWarsGame.Infrastructure.Clients.Steam.Windows - net8.0-windows;net48 - PetroGlyph.Games.EawFoc.Clients.Steam + PG.StarWarsGame.Infrastructure.Clients.Steam.Windows + Provides tools for launching Petroglyph Star Wars games on various clients, such as Steam or Disk release. + AlamoEngineTools.PG.StarWarsGame.Infrastructure.Clients.Steam.Windows + alamo,petroglyph,glyphx + en + diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Properties/AssemblyInfo.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Properties/AssemblyInfo.cs index f72f245c..791c6ea4 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Properties/AssemblyInfo.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ using System.Runtime.CompilerServices; -[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test")] +[assembly: InternalsVisibleTo("PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj index 458d14dc..291f5d7c 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj @@ -1,5 +1,9 @@  + + PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test + + net8.0-windows $(TargetFrameworks);net48 diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/PetroGlyph.Games.EawFoc.Clients.Steam.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/PetroGlyph.Games.EawFoc.Clients.Steam.csproj index d60b0d3c..4cc5e06f 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/PetroGlyph.Games.EawFoc.Clients.Steam.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/PetroGlyph.Games.EawFoc.Clients.Steam.csproj @@ -1,13 +1,16 @@  - - - Steam abstraction layer for Petroglyph Star Wars games. - - netstandard2.0 + PG.StarWarsGame.Infrastructure.Clients.Steam + PG.StarWarsGame.Infrastructure.Clients.Steam + + + PG.StarWarsGame.Infrastructure.Clients.Steam + Steam abstraction layer for Petroglyph Star Wars games. + AlamoEngineTools.PG.StarWarsGame.Infrastructure.Clients.Steam + alamo,petroglyph,glyphx + en - true snupkg @@ -15,14 +18,11 @@ true true - - + - - \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/Properties/AssemblyInfo.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/Properties/AssemblyInfo.cs index b7dda2ee..bc1d0a0b 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/Properties/AssemblyInfo.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ using System.Runtime.CompilerServices; -[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Test")] +[assembly: InternalsVisibleTo("PG.StarWarsGame.Infrastructure.Clients.Test")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj index 5c6b3a4c..6dab9857 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj @@ -1,5 +1,9 @@  + + PG.StarWarsGame.Infrastructure.Clients.Steam.Test + + net8.0 $(TargetFrameworks);net48 diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/PetroGlyph.Games.EawFoc.Clients.csproj b/src/PetroGlyph.Games.EawFoc.Clients/src/PetroGlyph.Games.EawFoc.Clients.csproj index 2c3d0d8a..cf435b96 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/PetroGlyph.Games.EawFoc.Clients.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/PetroGlyph.Games.EawFoc.Clients.csproj @@ -1,13 +1,16 @@  - - Provides tools for launching Petroglyph Star Wars games on various clients, such as Steam or Disk release. + netstandard2.0;netstandard2.1 + PG.StarWarsGame.Infrastructure.Clients + PG.StarWarsGame.Infrastructure.Clients - - netstandard2.0;netstandard2.1 + PG.StarWarsGame.Infrastructure.Clients + Provides tools for launching Petroglyph Star Wars games on various clients, such as Steam or Disk release. + AlamoEngineTools.PG.StarWarsGame.Infrastructure.Clients + alamo,petroglyph,glyphx + en - true snupkg @@ -15,13 +18,10 @@ true true - - - diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Properties/AssemblyInfo.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Properties/AssemblyInfo.cs index 4e81f7f4..6732144f 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Properties/AssemblyInfo.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Properties/AssemblyInfo.cs @@ -1,8 +1,8 @@ using System.Runtime.CompilerServices; -[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Steam")] -[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Steam.Windows")] -[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Test")] -[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Steam.Test")] -[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test")] +[assembly: InternalsVisibleTo("PG.StarWarsGame.Infrastructure.Clients.Steam")] +[assembly: InternalsVisibleTo("PG.StarWarsGame.Infrastructure.Clients.Steam.Windows")] +[assembly: InternalsVisibleTo("PG.StarWarsGame.Infrastructure.Clients.Test")] +[assembly: InternalsVisibleTo("PG.StarWarsGame.Infrastructure.Clients.Steam.Test")] +[assembly: InternalsVisibleTo("PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/PetroGlyph.Games.EawFoc.Clients.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients/test/PetroGlyph.Games.EawFoc.Clients.Test.csproj index aeaaf008..e60bda3f 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/PetroGlyph.Games.EawFoc.Clients.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/PetroGlyph.Games.EawFoc.Clients.Test.csproj @@ -1,5 +1,9 @@  + + PG.StarWarsGame.Infrastructure.Clients.Test + + net8.0 $(TargetFrameworks);net48 diff --git a/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj b/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj index b8afb044..f72c0c93 100644 --- a/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj +++ b/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj @@ -1,6 +1,8 @@  netstandard2.0;net8.0 + PG.StarWarsGame.Infrastructure + PG.StarWarsGame.Infrastructure PG.StarWarsGame.Infrastructure diff --git a/src/PetroGlyph.Games.EawFoc/src/Properties/AssemblyInfo.cs b/src/PetroGlyph.Games.EawFoc/src/Properties/AssemblyInfo.cs index d988f545..872ea40c 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Properties/AssemblyInfo.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Properties/AssemblyInfo.cs @@ -1,5 +1,5 @@ using System.Runtime.CompilerServices; -[assembly: InternalsVisibleTo("PetroGlyph.Games.EawFoc.Test")] +[assembly: InternalsVisibleTo("PG.StarWarsGame.Infrastructure.Test")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] diff --git a/src/PetroGlyph.Games.EawFoc/test/PetroGlyph.Games.EawFoc.Test.csproj b/src/PetroGlyph.Games.EawFoc/test/PetroGlyph.Games.EawFoc.Test.csproj index e258928a..c7f9aa56 100644 --- a/src/PetroGlyph.Games.EawFoc/test/PetroGlyph.Games.EawFoc.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc/test/PetroGlyph.Games.EawFoc.Test.csproj @@ -1,5 +1,9 @@  + + PG.StarWarsGame.Infrastructure.Test + + net8.0 $(TargetFrameworks);net48 From bccab87146ba9f46dc820c314f922cb0b31256a5 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Thu, 14 Mar 2024 17:50:00 +0100 Subject: [PATCH 08/41] rename project files --- PetroGlyphGameInfrastructure.sln | 16 ++++++++-------- .../SampleApplication/SampleApplication.csproj | 8 ++++---- ....Infrastructure.Clients.Steam.Windows.csproj} | 6 +++--- ...astructure.Clients.Steam.Windows.Test.csproj} | 4 ++-- ...WarsGame.Infrastructure.Clients.Steam.csproj} | 6 +++--- ...ame.Infrastructure.Clients.Steam.Test.csproj} | 4 ++-- ...G.StarWarsGame.Infrastructure.Clients.csproj} | 2 +- ...ame.Infrastructure.Clients.csproj.DotSettings | 2 ++ ...rWarsGame.Infrastructure.Clients.Test.csproj} | 4 ++-- ...roj => PG.StarWarsGame.Infrastructure.csproj} | 0 ...tarWarsGame.Infrastructure.csproj.DotSettings | 4 ++++ ...> PG.StarWarsGame.Infrastructure.Test.csproj} | 2 +- 12 files changed, 32 insertions(+), 26 deletions(-) rename src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj => PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.csproj} (91%) rename src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj => PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.csproj} (92%) rename src/PetroGlyph.Games.EawFoc.Clients.Steam/src/{PetroGlyph.Games.EawFoc.Clients.Steam.csproj => PG.StarWarsGame.Infrastructure.Clients.Steam.csproj} (91%) rename src/PetroGlyph.Games.EawFoc.Clients.Steam/test/{PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj => PG.StarWarsGame.Infrastructure.Clients.Steam.Test.csproj} (92%) rename src/PetroGlyph.Games.EawFoc.Clients/src/{PetroGlyph.Games.EawFoc.Clients.csproj => PG.StarWarsGame.Infrastructure.Clients.csproj} (96%) create mode 100644 src/PetroGlyph.Games.EawFoc.Clients/src/PG.StarWarsGame.Infrastructure.Clients.csproj.DotSettings rename src/PetroGlyph.Games.EawFoc.Clients/test/{PetroGlyph.Games.EawFoc.Clients.Test.csproj => PG.StarWarsGame.Infrastructure.Clients.Test.csproj} (92%) rename src/PetroGlyph.Games.EawFoc/src/{PetroGlyph.Games.EawFoc.csproj => PG.StarWarsGame.Infrastructure.csproj} (100%) create mode 100644 src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj.DotSettings rename src/PetroGlyph.Games.EawFoc/test/{PetroGlyph.Games.EawFoc.Test.csproj => PG.StarWarsGame.Infrastructure.Test.csproj} (95%) diff --git a/PetroGlyphGameInfrastructure.sln b/PetroGlyphGameInfrastructure.sln index 0f766aaf..ab118a90 100644 --- a/PetroGlyphGameInfrastructure.sln +++ b/PetroGlyphGameInfrastructure.sln @@ -5,23 +5,23 @@ VisualStudioVersion = 17.0.31717.71 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{DDF4836A-1257-4323-A288-B5F277242010}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PetroGlyph.Games.EawFoc.Test", "src\PetroGlyph.Games.EawFoc\test\PetroGlyph.Games.EawFoc.Test.csproj", "{90490B07-F4E3-4D1E-B3E3-FD059A0DAB8D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PG.StarWarsGame.Infrastructure.Test", "src\PetroGlyph.Games.EawFoc\test\PG.StarWarsGame.Infrastructure.Test.csproj", "{90490B07-F4E3-4D1E-B3E3-FD059A0DAB8D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PetroGlyph.Games.EawFoc.Clients", "src\PetroGlyph.Games.EawFoc.Clients\src\PetroGlyph.Games.EawFoc.Clients.csproj", "{F622B36D-E5C9-4C14-B4B1-8871DCF1FF46}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PG.StarWarsGame.Infrastructure.Clients", "src\PetroGlyph.Games.EawFoc.Clients\src\PG.StarWarsGame.Infrastructure.Clients.csproj", "{F622B36D-E5C9-4C14-B4B1-8871DCF1FF46}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PetroGlyph.Games.EawFoc.Clients.Steam.Windows", "src\PetroGlyph.Games.EawFoc.Clients.Steam.Windows\src\PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj", "{3EB69B97-AD3F-4D72-BE49-D17547EE0895}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PG.StarWarsGame.Infrastructure.Clients.Steam.Windows", "src\PetroGlyph.Games.EawFoc.Clients.Steam.Windows\src\PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.csproj", "{3EB69B97-AD3F-4D72-BE49-D17547EE0895}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PetroGlyph.Games.EawFoc", "src\PetroGlyph.Games.EawFoc\src\PetroGlyph.Games.EawFoc.csproj", "{6A14A57C-60E6-4DDE-B8F0-55ADB3A20758}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PG.StarWarsGame.Infrastructure", "src\PetroGlyph.Games.EawFoc\src\PG.StarWarsGame.Infrastructure.csproj", "{6A14A57C-60E6-4DDE-B8F0-55ADB3A20758}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{91EC3980-0C87-484F-91E5-0FE684C1D2E0}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test", "src\PetroGlyph.Games.EawFoc.Clients.Steam.Windows\test\PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj", "{9F5EB615-86CB-4AF1-88B9-A1DAF4EAF9F2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test", "src\PetroGlyph.Games.EawFoc.Clients.Steam.Windows\test\PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.csproj", "{9F5EB615-86CB-4AF1-88B9-A1DAF4EAF9F2}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PetroGlyph.Games.EawFoc.Clients.Test", "src\PetroGlyph.Games.EawFoc.Clients\test\PetroGlyph.Games.EawFoc.Clients.Test.csproj", "{0D5DAC91-BB5F-46F4-9145-4296E9151DC3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PG.StarWarsGame.Infrastructure.Clients.Test", "src\PetroGlyph.Games.EawFoc.Clients\test\PG.StarWarsGame.Infrastructure.Clients.Test.csproj", "{0D5DAC91-BB5F-46F4-9145-4296E9151DC3}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PetroGlyph.Games.EawFoc.Clients.Steam", "src\PetroGlyph.Games.EawFoc.Clients.Steam\src\PetroGlyph.Games.EawFoc.Clients.Steam.csproj", "{179786D1-8C85-46B3-9943-30A1902D92B4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PG.StarWarsGame.Infrastructure.Clients.Steam", "src\PetroGlyph.Games.EawFoc.Clients.Steam\src\PG.StarWarsGame.Infrastructure.Clients.Steam.csproj", "{179786D1-8C85-46B3-9943-30A1902D92B4}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PetroGlyph.Games.EawFoc.Clients.Steam.Test", "src\PetroGlyph.Games.EawFoc.Clients.Steam\test\PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj", "{69666FB7-7F44-451B-8ABF-7F18DEC3AD45}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PG.StarWarsGame.Infrastructure.Clients.Steam.Test", "src\PetroGlyph.Games.EawFoc.Clients.Steam\test\PG.StarWarsGame.Infrastructure.Clients.Steam.Test.csproj", "{69666FB7-7F44-451B-8ABF-7F18DEC3AD45}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleApplication", "sample\SampleApplication\SampleApplication.csproj", "{8F295344-3D7B-4983-88FD-D0E5C692CBAB}" EndProject diff --git a/sample/SampleApplication/SampleApplication.csproj b/sample/SampleApplication/SampleApplication.csproj index b77d5a18..e82cb188 100644 --- a/sample/SampleApplication/SampleApplication.csproj +++ b/sample/SampleApplication/SampleApplication.csproj @@ -11,10 +11,10 @@ - - - - + + + + diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.csproj similarity index 91% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj rename to src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.csproj index f1202782..344db389 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.csproj @@ -32,9 +32,9 @@ - - - + + + diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.csproj similarity index 92% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj rename to src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.csproj index 291f5d7c..13255144 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.csproj @@ -32,9 +32,9 @@ - + - + \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/PetroGlyph.Games.EawFoc.Clients.Steam.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/PG.StarWarsGame.Infrastructure.Clients.Steam.csproj similarity index 91% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam/src/PetroGlyph.Games.EawFoc.Clients.Steam.csproj rename to src/PetroGlyph.Games.EawFoc.Clients.Steam/src/PG.StarWarsGame.Infrastructure.Clients.Steam.csproj index 4cc5e06f..a294655d 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/PetroGlyph.Games.EawFoc.Clients.Steam.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/PG.StarWarsGame.Infrastructure.Clients.Steam.csproj @@ -19,10 +19,10 @@ true - + - - + + \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PG.StarWarsGame.Infrastructure.Clients.Steam.Test.csproj similarity index 92% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj rename to src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PG.StarWarsGame.Infrastructure.Clients.Steam.Test.csproj index 6dab9857..60769d49 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PetroGlyph.Games.EawFoc.Clients.Steam.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PG.StarWarsGame.Infrastructure.Clients.Steam.Test.csproj @@ -32,8 +32,8 @@ - - + + diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/PetroGlyph.Games.EawFoc.Clients.csproj b/src/PetroGlyph.Games.EawFoc.Clients/src/PG.StarWarsGame.Infrastructure.Clients.csproj similarity index 96% rename from src/PetroGlyph.Games.EawFoc.Clients/src/PetroGlyph.Games.EawFoc.Clients.csproj rename to src/PetroGlyph.Games.EawFoc.Clients/src/PG.StarWarsGame.Infrastructure.Clients.csproj index cf435b96..6a343f64 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/PetroGlyph.Games.EawFoc.Clients.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/PG.StarWarsGame.Infrastructure.Clients.csproj @@ -22,6 +22,6 @@ - + diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/PG.StarWarsGame.Infrastructure.Clients.csproj.DotSettings b/src/PetroGlyph.Games.EawFoc.Clients/src/PG.StarWarsGame.Infrastructure.Clients.csproj.DotSettings new file mode 100644 index 00000000..9e07e2fd --- /dev/null +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/PG.StarWarsGame.Infrastructure.Clients.csproj.DotSettings @@ -0,0 +1,2 @@ + + True \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/PetroGlyph.Games.EawFoc.Clients.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients/test/PG.StarWarsGame.Infrastructure.Clients.Test.csproj similarity index 92% rename from src/PetroGlyph.Games.EawFoc.Clients/test/PetroGlyph.Games.EawFoc.Clients.Test.csproj rename to src/PetroGlyph.Games.EawFoc.Clients/test/PG.StarWarsGame.Infrastructure.Clients.Test.csproj index e60bda3f..2a12dc93 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/PetroGlyph.Games.EawFoc.Clients.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/PG.StarWarsGame.Infrastructure.Clients.Test.csproj @@ -32,9 +32,9 @@ - + - + diff --git a/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj b/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj similarity index 100% rename from src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj rename to src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj diff --git a/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj.DotSettings b/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj.DotSettings new file mode 100644 index 00000000..2c647cc2 --- /dev/null +++ b/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj.DotSettings @@ -0,0 +1,4 @@ + + True + True + True \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/test/PetroGlyph.Games.EawFoc.Test.csproj b/src/PetroGlyph.Games.EawFoc/test/PG.StarWarsGame.Infrastructure.Test.csproj similarity index 95% rename from src/PetroGlyph.Games.EawFoc/test/PetroGlyph.Games.EawFoc.Test.csproj rename to src/PetroGlyph.Games.EawFoc/test/PG.StarWarsGame.Infrastructure.Test.csproj index c7f9aa56..efd4550b 100644 --- a/src/PetroGlyph.Games.EawFoc/test/PetroGlyph.Games.EawFoc.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc/test/PG.StarWarsGame.Infrastructure.Test.csproj @@ -35,7 +35,7 @@ - + From da4b48f4c16e69992b54ee70cbc9af930a2a8978 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Thu, 14 Mar 2024 17:50:30 +0100 Subject: [PATCH 09/41] remove odd warning suppression for now --- .../test/PG.StarWarsGame.Infrastructure.Test.csproj | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/PetroGlyph.Games.EawFoc/test/PG.StarWarsGame.Infrastructure.Test.csproj b/src/PetroGlyph.Games.EawFoc/test/PG.StarWarsGame.Infrastructure.Test.csproj index efd4550b..4ace9d3a 100644 --- a/src/PetroGlyph.Games.EawFoc/test/PG.StarWarsGame.Infrastructure.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc/test/PG.StarWarsGame.Infrastructure.Test.csproj @@ -8,8 +8,7 @@ net8.0 $(TargetFrameworks);net48 false - true - 8600;8625;0162 + true8600;8625;0162 From dbf1cca6ba28f39cfdb86e8fd1f7209d1411b062 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Thu, 14 Mar 2024 17:51:10 +0100 Subject: [PATCH 10/41] use new ns syntax --- .../src/SteamRegistry.cs | 113 ++--- .../src/SteamWrapper.cs | 365 +++++++------ .../test/Steam/SteamGameFinderTest.cs | 31 +- .../test/Steam/SteamLibraryFinderTest.cs | 253 +++++---- .../test/Steam/SteamLibraryTest.cs | 259 +++++----- .../test/Steam/SteamWrapperIntegrationTest.cs | 59 ++- .../test/Steam/SteamWrapperTest.cs | 263 +++++----- .../src/PetroglyphClientsLibrary.cs | 33 +- .../test/ClientBaseTest.cs | 479 +++++++++--------- .../src/Games/Registry/GameRegistryBase.cs | 305 ++++++----- 10 files changed, 1075 insertions(+), 1085 deletions(-) diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamRegistry.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamRegistry.cs index 522ab99e..3b377a62 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamRegistry.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamRegistry.cs @@ -8,81 +8,81 @@ using System.Diagnostics.CodeAnalysis; #endif -namespace PetroGlyph.Games.EawFoc.Clients.Steam +namespace PetroGlyph.Games.EawFoc.Clients.Steam; + +internal sealed class SteamRegistry : ISteamRegistry { - internal sealed class SteamRegistry : ISteamRegistry - { - private const string SteamExeKey = "SteamExe"; - private const string SteamPathKey = "SteamPath"; - private const string SteamProcessIdKey = "pid"; - private const string SteamActiveUserKey = "ActiveUser"; + private const string SteamExeKey = "SteamExe"; + private const string SteamPathKey = "SteamPath"; + private const string SteamProcessIdKey = "pid"; + private const string SteamActiveUserKey = "ActiveUser"; - private const string SteamProcessNode = "ActiveProcess"; - private const string SteamAppsNode = "Apps"; + private const string SteamProcessNode = "ActiveProcess"; + private const string SteamAppsNode = "Apps"; - private IRegistryKey? _registryKey; - private bool _disposed; - private readonly IFileSystem _fileSystem; + private IRegistryKey? _registryKey; + private bool _disposed; + private readonly IFileSystem _fileSystem; - public IRegistryKey? ActiveProcessKey + public IRegistryKey? ActiveProcessKey + { + get { - get - { ThrowIfDisposed(); return _registryKey!.GetKey(SteamProcessNode); } - } + } - int? ISteamRegistry.ActiveUserId + int? ISteamRegistry.ActiveUserId + { + get { - get - { ThrowIfDisposed(); return !_registryKey!.GetValue(SteamActiveUserKey, SteamProcessNode, out int? userId) ? null : userId; } - set - { + set + { ThrowIfDisposed(); value ??= 0; _registryKey!.WriteValue(SteamActiveUserKey, SteamProcessNode, value); } - } + } - public int? ProcessId + public int? ProcessId + { + get { - get - { ThrowIfDisposed(); return !_registryKey!.GetValue(SteamProcessIdKey, SteamProcessNode, out int? pid) ? null : pid; } - } + } - public IFileInfo? ExeFile + public IFileInfo? ExeFile + { + get { - get - { ThrowIfDisposed(); return !_registryKey!.GetValue(SteamExeKey, out string? filePath) ? null : _fileSystem.FileInfo.New(filePath!); } - } + } - public IDirectoryInfo? InstallationDirectory + public IDirectoryInfo? InstallationDirectory + { + get { - get - { ThrowIfDisposed(); return !_registryKey!.GetValue(SteamPathKey, out string? path) ? null : _fileSystem.DirectoryInfo.New(path!); } - } + } - public ISet? InstalledApps + public ISet? InstalledApps + { + get { - get - { ThrowIfDisposed(); var keyNames = _registryKey!.GetSubKeyNames(SteamAppsNode); if (keyNames is null) @@ -92,11 +92,11 @@ public ISet? InstalledApps .OfType(); return new HashSet(ids); } - } + } - public SteamRegistry(IServiceProvider serviceProvider) - { + public SteamRegistry(IServiceProvider serviceProvider) + { _registryKey = serviceProvider.GetRequiredService() .OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default) .CreateSubKey("Software\\Valve\\Steam"); @@ -104,27 +104,27 @@ public SteamRegistry(IServiceProvider serviceProvider) } - /// - ~SteamRegistry() - { + /// + ~SteamRegistry() + { Dispose(false); } - /// - /// Disposed all managed resources acquired by this instance. - /// - public void Dispose() - { + /// + /// Disposed all managed resources acquired by this instance. + /// + public void Dispose() + { Dispose(true); GC.SuppressFinalize(this); } - /// - /// Disposed all managed resources acquired by this instance. - /// - /// if called from the destructor; otherwise. - private void Dispose(bool disposing) - { + /// + /// Disposed all managed resources acquired by this instance. + /// + /// if called from the destructor; otherwise. + private void Dispose(bool disposing) + { if (disposing) { _registryKey?.Dispose(); @@ -136,12 +136,11 @@ private void Dispose(bool disposing) #if NET [MemberNotNull(nameof(_registryKey))] #endif - private void ThrowIfDisposed() - { + private void ThrowIfDisposed() + { if (_disposed) throw new ObjectDisposedException(ToString()); if (_registryKey is null) throw new Exception("registry must not be null in non-disposed state"); } - } } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamWrapper.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamWrapper.cs index 2481fed5..948b6f94 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamWrapper.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamWrapper.cs @@ -15,244 +15,243 @@ using System.Diagnostics.CodeAnalysis; #endif -namespace PetroGlyph.Games.EawFoc.Clients.Steam +namespace PetroGlyph.Games.EawFoc.Clients.Steam; + +internal class SteamWrapper : ISteamWrapper { - internal class SteamWrapper : ISteamWrapper - { - private readonly ISteamRegistry _registry; - private readonly IServiceProvider _serviceProvider; - private readonly IProcessHelper _processHelper; - private readonly IFileSystem _fileSystem; + private readonly ISteamRegistry _registry; + private readonly IServiceProvider _serviceProvider; + private readonly IProcessHelper _processHelper; + private readonly IFileSystem _fileSystem; - public bool Installed => _registry.ExeFile?.Exists ?? false; - public bool IsRunning + public bool Installed => _registry.ExeFile?.Exists ?? false; + public bool IsRunning + { + get { - get - { - var pid = _registry.ProcessId; - if (pid is null or 0) - return false; - return _processHelper.GetProcessByPid(pid.Value) != null; - } + var pid = _registry.ProcessId; + if (pid is null or 0) + return false; + return _processHelper.GetProcessByPid(pid.Value) != null; } + } - public bool? WantOfflineMode + public bool? WantOfflineMode + { + get { - get - { - var steamDirectory = _registry.InstallationDirectory; - if (steamDirectory is null || !steamDirectory.Exists) - return null; + var steamDirectory = _registry.InstallationDirectory; + if (steamDirectory is null || !steamDirectory.Exists) + return null; - var configFile = _fileSystem.Path.Combine(steamDirectory.FullName, "config/loginusers.vdf"); - if (!_fileSystem.File.Exists(configFile)) - return null; + var configFile = _fileSystem.Path.Combine(steamDirectory.FullName, "config/loginusers.vdf"); + if (!_fileSystem.File.Exists(configFile)) + return null; - try - { - var config = VdfConvert.Deserialize(_fileSystem.File.ReadAllText(configFile)).ToJson(); - var usersWantingOffline = config.SelectTokens("$..[?(@.WantsOfflineMode=='1')]").ToList(); - if (!usersWantingOffline.Any()) - return false; + try + { + var config = VdfConvert.Deserialize(_fileSystem.File.ReadAllText(configFile)).ToJson(); + var usersWantingOffline = config.SelectTokens("$..[?(@.WantsOfflineMode=='1')]").ToList(); + if (!usersWantingOffline.Any()) + return false; - var anyMostRecent = config.SelectTokens("$..[?(@.mostrecent)]"); - if (!anyMostRecent.Any()) - return true; + var anyMostRecent = config.SelectTokens("$..[?(@.mostrecent)]"); + if (!anyMostRecent.Any()) + return true; - var mostRecent = usersWantingOffline.FirstOrDefault(x => x.SelectToken("$..[?(@.mostrecent=='1')]") != null); - return mostRecent is not null; - } - catch - { - return null; - } + var mostRecent = usersWantingOffline.FirstOrDefault(x => x.SelectToken("$..[?(@.mostrecent=='1')]") != null); + return mostRecent is not null; } - } - - internal bool IsUserLoggedIn - { - get + catch { - var userId = _registry.ActiveUserId; - return userId is not (null or 0); + return null; } } + } - public SteamWrapper(IServiceProvider serviceProvider) + internal bool IsUserLoggedIn + { + get { - _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); - _registry = serviceProvider.GetRequiredService(); - _processHelper = serviceProvider.GetRequiredService(); - _fileSystem = serviceProvider.GetRequiredService(); + var userId = _registry.ActiveUserId; + return userId is not (null or 0); } + } + + public SteamWrapper(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); + _registry = serviceProvider.GetRequiredService(); + _processHelper = serviceProvider.GetRequiredService(); + _fileSystem = serviceProvider.GetRequiredService(); + } #if NET - public bool IsGameInstalled(uint gameId, [NotNullWhen(true)] out SteamAppManifest? game) + public bool IsGameInstalled(uint gameId, [NotNullWhen(true)] out SteamAppManifest? game) #else public bool IsGameInstalled(uint gameId, out SteamAppManifest? game) #endif - { - ThrowIfSteamNotInstalled(); - game = null; - var apps = _registry.InstalledApps; - if (apps is null) - return false; + { + ThrowIfSteamNotInstalled(); + game = null; + var apps = _registry.InstalledApps; + if (apps is null) + return false; - if (!apps.Contains(gameId)) - return false; + if (!apps.Contains(gameId)) + return false; - var gameFinder = _serviceProvider.GetRequiredService(); - game = gameFinder.FindGame(gameId); - return game is not null; - } + var gameFinder = _serviceProvider.GetRequiredService(); + game = gameFinder.FindGame(gameId); + return game is not null; + } - public void StartSteam() + public void StartSteam() + { + ThrowIfSteamNotInstalled(); + if (IsRunning) + return; + var process = new Process { - ThrowIfSteamNotInstalled(); - if (IsRunning) - return; - var process = new Process + StartInfo = { - StartInfo = - { - FileName = _registry.ExeFile!.FullName, - UseShellExecute = false - } - }; - process.Start(); - } + FileName = _registry.ExeFile!.FullName, + UseShellExecute = false + } + }; + process.Start(); + } - public async Task WaitSteamRunningAndLoggedInAsync(bool startIfNotRunning, - CancellationToken cancellation = default) + public async Task WaitSteamRunningAndLoggedInAsync(bool startIfNotRunning, + CancellationToken cancellation = default) + { + ThrowIfSteamNotInstalled(); + var running = IsRunning; + if (!running) { - ThrowIfSteamNotInstalled(); - var running = IsRunning; - if (!running) - { - // Required because a taskmgr kill does not reset this value, so we have to do this manually - _registry.ActiveUserId = 0; - if (startIfNotRunning) - StartSteam(); - await WaitSteamRunningAsync(cancellation); - } + // Required because a taskmgr kill does not reset this value, so we have to do this manually + _registry.ActiveUserId = 0; + if (startIfNotRunning) + StartSteam(); + await WaitSteamRunningAsync(cancellation); + } - if (IsUserLoggedIn) - return; + if (IsUserLoggedIn) + return; - var wantsOffline = WantOfflineMode; - if (wantsOffline != null && wantsOffline.Value) - { - await Task.Delay(2000, cancellation); - await WaitSteamOfflineRunning(cancellation); - cancellation.ThrowIfCancellationRequested(); - if (!IsRunning) - throw new SteamException("Steam is not running anymore."); - } - else - { - await WaitSteamUserLoggedInAsync(cancellation); - } + var wantsOffline = WantOfflineMode; + if (wantsOffline != null && wantsOffline.Value) + { + await Task.Delay(2000, cancellation); + await WaitSteamOfflineRunning(cancellation); + cancellation.ThrowIfCancellationRequested(); + if (!IsRunning) + throw new SteamException("Steam is not running anymore."); } + else + { + await WaitSteamUserLoggedInAsync(cancellation); + } + } - private async Task WaitSteamOfflineRunning(CancellationToken token) + private async Task WaitSteamOfflineRunning(CancellationToken token) + { + var linkedCts = CancellationTokenSource.CreateLinkedTokenSource(token); + var linkedToken = linkedCts.Token; + try { - var linkedCts = CancellationTokenSource.CreateLinkedTokenSource(token); - var linkedToken = linkedCts.Token; - try - { - var mainWindowTask = Task.Run(() => WaitMainWindowIsSteamClient(linkedToken), token); - var userLoginTask = Task.Run(() => WaitSteamUserLoggedInAsync(linkedToken), token); - await Task.WhenAny(mainWindowTask, userLoginTask).ConfigureAwait(false); - } - finally - { - linkedCts.Cancel(); - linkedCts.Dispose(); - } + var mainWindowTask = Task.Run(() => WaitMainWindowIsSteamClient(linkedToken), token); + var userLoginTask = Task.Run(() => WaitSteamUserLoggedInAsync(linkedToken), token); + await Task.WhenAny(mainWindowTask, userLoginTask).ConfigureAwait(false); } + finally + { + linkedCts.Cancel(); + linkedCts.Dispose(); + } + } - private async Task WaitSteamUserLoggedInAsync(CancellationToken token) + private async Task WaitSteamUserLoggedInAsync(CancellationToken token) + { + token.ThrowIfCancellationRequested(); + if (IsUserLoggedIn) + return; + + while (!IsUserLoggedIn) { token.ThrowIfCancellationRequested(); - if (IsUserLoggedIn) + var processKey = _registry.ActiveProcessKey; + if (processKey is null) return; - - while (!IsUserLoggedIn) - { - token.ThrowIfCancellationRequested(); - var processKey = _registry.ActiveProcessKey; - if (processKey is null) - return; - if (processKey is not WindowsRegistryKey windowsRegistryKey) - throw new InvalidOperationException("Expected Windows registry Key"); + if (processKey is not WindowsRegistryKey windowsRegistryKey) + throw new InvalidOperationException("Expected Windows registry Key"); - await windowsRegistryKey.WindowsKey.WaitForChangeAsync(false, RegistryChangeNotificationFilters.Value, token); - } + await windowsRegistryKey.WindowsKey.WaitForChangeAsync(false, RegistryChangeNotificationFilters.Value, token); } + } + + private async Task WaitSteamRunningAsync(CancellationToken token) + { + token.ThrowIfCancellationRequested(); + if (IsRunning) + return; - private async Task WaitSteamRunningAsync(CancellationToken token) + while (!IsRunning) { token.ThrowIfCancellationRequested(); - if (IsRunning) + var processKey = _registry.ActiveProcessKey; + if (processKey is null) return; - - while (!IsRunning) - { - token.ThrowIfCancellationRequested(); - var processKey = _registry.ActiveProcessKey; - if (processKey is null) - return; - if (processKey is not WindowsRegistryKey windowsRegistryKey) - throw new InvalidOperationException("Expected Windows registry Key"); - await windowsRegistryKey.WindowsKey.WaitForChangeAsync(false, RegistryChangeNotificationFilters.Value, token); - } + if (processKey is not WindowsRegistryKey windowsRegistryKey) + throw new InvalidOperationException("Expected Windows registry Key"); + await windowsRegistryKey.WindowsKey.WaitForChangeAsync(false, RegistryChangeNotificationFilters.Value, token); } + } - private async Task WaitMainWindowIsSteamClient(CancellationToken token) + private async Task WaitMainWindowIsSteamClient(CancellationToken token) + { + while (IsRunning) { - while (IsRunning) - { - token.ThrowIfCancellationRequested(); - var mainWindowHasChildren = GetSteamMainWindowHandle(); - if (mainWindowHasChildren) - return; - // Just some arbitrary waiting - await Task.Delay(750, token); - } + token.ThrowIfCancellationRequested(); + var mainWindowHasChildren = GetSteamMainWindowHandle(); + if (mainWindowHasChildren) + return; + // Just some arbitrary waiting + await Task.Delay(750, token); + } - // If anybody knows a smarter way, let me know! - static bool GetSteamMainWindowHandle() + // If anybody knows a smarter way, let me know! + static bool GetSteamMainWindowHandle() + { + var p = Process.GetProcessesByName("steam").FirstOrDefault(); + try { - var p = Process.GetProcessesByName("steam").FirstOrDefault(); - try - { - var handle = p?.MainWindowHandle; - if (handle is null) - return false; - var c = new WindowHandleInfo(handle.Value).GetAllChildHandles(); - var text = User32.GetWindowTitle(handle.Value); + var handle = p?.MainWindowHandle; + if (handle is null) + return false; + var c = new WindowHandleInfo(handle.Value).GetAllChildHandles(); + var text = User32.GetWindowTitle(handle.Value); - // Empty string typically is the Installer/Updater dialog. - // We don't want to early-exit on this one! - if (string.IsNullOrEmpty(text)) - return false; + // Empty string typically is the Installer/Updater dialog. + // We don't want to early-exit on this one! + if (string.IsNullOrEmpty(text)) + return false; - // The Steam-Client has children while the selection dialog (Go Online/Stay Offline) has none. - return c.Any(); - } - finally - { - p?.Dispose(); - } + // The Steam-Client has children while the selection dialog (Go Online/Stay Offline) has none. + return c.Any(); + } + finally + { + p?.Dispose(); } } + } - private void ThrowIfSteamNotInstalled() - { - if (!Installed) - throw new SteamException("Steam is not installed!"); - } + private void ThrowIfSteamNotInstalled() + { + if (!Installed) + throw new SteamException("Steam is not installed!"); } -} +} \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamGameFinderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamGameFinderTest.cs index c42d91b9..01399c51 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamGameFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamGameFinderTest.cs @@ -5,16 +5,16 @@ using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.Steam +namespace PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.Steam; + +public class SteamGameFinderTest { - public class SteamGameFinderTest - { - private readonly SteamGameFinder _service; - private readonly MockFileSystem _fileSystem; - private readonly Mock _libraryFinder; + private readonly SteamGameFinder _service; + private readonly MockFileSystem _fileSystem; + private readonly Mock _libraryFinder; - public SteamGameFinderTest() - { + public SteamGameFinderTest() + { var sc = new ServiceCollection(); _fileSystem = new MockFileSystem(); _libraryFinder = new Mock(); @@ -23,17 +23,17 @@ public SteamGameFinderTest() _service = new SteamGameFinder(sc.BuildServiceProvider()); } - [Fact] - public void TestGameNotFound() - { + [Fact] + public void TestGameNotFound() + { _libraryFinder.Setup(l => l.FindLibraries()).Returns(new List()); var app = _service.FindGame(456); Assert.Null(app); } - [Fact] - public void TestGameFound() - { + [Fact] + public void TestGameFound() + { var lib1 = new Mock(); var lib2 = new Mock(); @@ -49,5 +49,4 @@ public void TestGameFound() Assert.NotNull(app); Assert.Equal(game, app); } - } -} +} \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryFinderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryFinderTest.cs index a5c4d1e9..89d7da4f 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryFinderTest.cs @@ -6,133 +6,132 @@ using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.Steam +namespace PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.Steam; + +public class SteamLibraryFinderTest { - public class SteamLibraryFinderTest + private readonly SteamLibraryFinder _service; + private readonly Mock _reader; + private readonly Mock _registry; + private readonly MockFileSystem _fileSystem; + + public SteamLibraryFinderTest() + { + var sc = new ServiceCollection(); + _fileSystem = new MockFileSystem(); + sc.AddSingleton(_fileSystem); + sc.AddSingleton(sp => new SteamRegistry(sp)); + _reader = new Mock(); + sc.AddTransient(_ => _reader.Object); + _registry = new Mock(); + sc.AddTransient(_ => _registry.Object); + _service = new SteamLibraryFinder(sc.BuildServiceProvider()); + } + + [Fact] + public void TestNoSteam_Throws() + { + Assert.Throws(() => _service.FindLibraries()); + } + + [Fact] + public void TestNoLibrariesFound() + { + _fileSystem.Initialize().WithSubdirectory("Steam"); + _registry.Setup(r => r.InstallationDirectory) + .Returns(_fileSystem.DirectoryInfo.New("Steam")); + + var libraries = _service.FindLibraries(); + + Assert.Empty(libraries); + } + + [Fact] + public void TestNoLibrary_MissingSteamDll() + { + _fileSystem.Initialize().WithFile("Steam/steamapps/libraryfolders.vdf"); + var libraryLocation = _fileSystem.DirectoryInfo.New("Steam"); + _registry.Setup(r => r.InstallationDirectory) + .Returns(_fileSystem.DirectoryInfo.New("Steam")); + _reader.Setup(r => r.ReadLibraryLocationsFromConfig(It.IsAny())) + .Returns(new List { libraryLocation }); + + var libraries = _service.FindLibraries(); + + Assert.Empty(libraries); + } + + [Fact] + public void TestNoLibrary_NoConfigFile() { - private readonly SteamLibraryFinder _service; - private readonly Mock _reader; - private readonly Mock _registry; - private readonly MockFileSystem _fileSystem; - - public SteamLibraryFinderTest() - { - var sc = new ServiceCollection(); - _fileSystem = new MockFileSystem(); - sc.AddSingleton(_fileSystem); - sc.AddSingleton(sp => new SteamRegistry(sp)); - _reader = new Mock(); - sc.AddTransient(_ => _reader.Object); - _registry = new Mock(); - sc.AddTransient(_ => _registry.Object); - _service = new SteamLibraryFinder(sc.BuildServiceProvider()); - } - - [Fact] - public void TestNoSteam_Throws() - { - Assert.Throws(() => _service.FindLibraries()); - } - - [Fact] - public void TestNoLibrariesFound() - { - _fileSystem.Initialize().WithSubdirectory("Steam"); - _registry.Setup(r => r.InstallationDirectory) - .Returns(_fileSystem.DirectoryInfo.New("Steam")); - - var libraries = _service.FindLibraries(); - - Assert.Empty(libraries); - } - - [Fact] - public void TestNoLibrary_MissingSteamDll() - { - _fileSystem.Initialize().WithFile("Steam/steamapps/libraryfolders.vdf"); - var libraryLocation = _fileSystem.DirectoryInfo.New("Steam"); - _registry.Setup(r => r.InstallationDirectory) - .Returns(_fileSystem.DirectoryInfo.New("Steam")); - _reader.Setup(r => r.ReadLibraryLocationsFromConfig(It.IsAny())) - .Returns(new List { libraryLocation }); - - var libraries = _service.FindLibraries(); - - Assert.Empty(libraries); - } - - [Fact] - public void TestNoLibrary_NoConfigFile() - { - _fileSystem.Initialize() - .WithFile("Steam/noValidConfigPath/libraryfolders.vdf") - .WithFile("Steam/steam.dll"); - - var libraryLocation = _fileSystem.DirectoryInfo.New("Steam"); - _registry.Setup(r => r.InstallationDirectory) - .Returns(_fileSystem.DirectoryInfo.New("Steam")); - _reader.Setup(r => r.ReadLibraryLocationsFromConfig(It.IsAny())) - .Returns(new List { libraryLocation }); - - var libraries = _service.FindLibraries(); - - Assert.Empty(libraries); - } - - [Fact] - public void TestSingleLibrary() - { - _fileSystem.Initialize() - .WithFile("Steam/steamapps/libraryfolders.vdf") - .WithFile("Steam/steam.dll"); - - var libraryLocation = _fileSystem.DirectoryInfo.New("Steam"); - _registry.Setup(r => r.InstallationDirectory) - .Returns(_fileSystem.DirectoryInfo.New("Steam")); - _reader.Setup(r => r.ReadLibraryLocationsFromConfig(It.IsAny())) - .Returns(new List { libraryLocation }); - - var libraries = _service.FindLibraries(); - - Assert.Single(libraries); - Assert.Equal(libraryLocation, libraries.First().LibraryLocation); - } - - [Fact] - public void TestSingleAlternateConfig() - { - _fileSystem.Initialize() - .WithFile("Steam/config/libraryfolders.vdf") - .WithFile("Steam/steam.dll"); - - var libraryLocation = _fileSystem.DirectoryInfo.New("Steam"); - _registry.Setup(r => r.InstallationDirectory) - .Returns(_fileSystem.DirectoryInfo.New("Steam")); - _reader.Setup(r => r.ReadLibraryLocationsFromConfig(It.IsAny())) - .Returns(new List { libraryLocation }); - - var libraries = _service.FindLibraries(); - - Assert.Single(libraries); - Assert.Equal(libraryLocation, libraries.First().LibraryLocation); - } - - [Fact] - public void TestUniqueResult() - { - _fileSystem.Initialize() - .WithFile("Steam/config/libraryfolders.vdf") - .WithFile("Steam/steam.dll"); - - var libraryLocation = _fileSystem.DirectoryInfo.New("Steam"); - _registry.Setup(r => r.InstallationDirectory) - .Returns(_fileSystem.DirectoryInfo.New("Steam")); - _reader.Setup(r => r.ReadLibraryLocationsFromConfig(It.IsAny())) - .Returns(new List { libraryLocation, libraryLocation }); - - var libraries = _service.FindLibraries(); - - Assert.Single(libraries); - } + _fileSystem.Initialize() + .WithFile("Steam/noValidConfigPath/libraryfolders.vdf") + .WithFile("Steam/steam.dll"); + + var libraryLocation = _fileSystem.DirectoryInfo.New("Steam"); + _registry.Setup(r => r.InstallationDirectory) + .Returns(_fileSystem.DirectoryInfo.New("Steam")); + _reader.Setup(r => r.ReadLibraryLocationsFromConfig(It.IsAny())) + .Returns(new List { libraryLocation }); + + var libraries = _service.FindLibraries(); + + Assert.Empty(libraries); + } + + [Fact] + public void TestSingleLibrary() + { + _fileSystem.Initialize() + .WithFile("Steam/steamapps/libraryfolders.vdf") + .WithFile("Steam/steam.dll"); + + var libraryLocation = _fileSystem.DirectoryInfo.New("Steam"); + _registry.Setup(r => r.InstallationDirectory) + .Returns(_fileSystem.DirectoryInfo.New("Steam")); + _reader.Setup(r => r.ReadLibraryLocationsFromConfig(It.IsAny())) + .Returns(new List { libraryLocation }); + + var libraries = _service.FindLibraries(); + + Assert.Single(libraries); + Assert.Equal(libraryLocation, libraries.First().LibraryLocation); + } + + [Fact] + public void TestSingleAlternateConfig() + { + _fileSystem.Initialize() + .WithFile("Steam/config/libraryfolders.vdf") + .WithFile("Steam/steam.dll"); + + var libraryLocation = _fileSystem.DirectoryInfo.New("Steam"); + _registry.Setup(r => r.InstallationDirectory) + .Returns(_fileSystem.DirectoryInfo.New("Steam")); + _reader.Setup(r => r.ReadLibraryLocationsFromConfig(It.IsAny())) + .Returns(new List { libraryLocation }); + + var libraries = _service.FindLibraries(); + + Assert.Single(libraries); + Assert.Equal(libraryLocation, libraries.First().LibraryLocation); + } + + [Fact] + public void TestUniqueResult() + { + _fileSystem.Initialize() + .WithFile("Steam/config/libraryfolders.vdf") + .WithFile("Steam/steam.dll"); + + var libraryLocation = _fileSystem.DirectoryInfo.New("Steam"); + _registry.Setup(r => r.InstallationDirectory) + .Returns(_fileSystem.DirectoryInfo.New("Steam")); + _reader.Setup(r => r.ReadLibraryLocationsFromConfig(It.IsAny())) + .Returns(new List { libraryLocation, libraryLocation }); + + var libraries = _service.FindLibraries(); + + Assert.Single(libraries); } -} +} \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryTest.cs index dfb06dd3..8d5d4df2 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryTest.cs @@ -7,136 +7,135 @@ using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.Steam +namespace PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.Steam; + +public class SteamLibraryTest { - public class SteamLibraryTest + private readonly IServiceProvider _serviceProvider; + private readonly MockFileSystem _fileSystem; + private readonly Mock _reader; + + public SteamLibraryTest() + { + var sc = new ServiceCollection(); + _fileSystem = new MockFileSystem(); + sc.AddTransient(_ => _fileSystem); + _reader = new Mock(); + sc.AddTransient(_ => _reader.Object); + _serviceProvider = sc.BuildServiceProvider(); + } + + [Fact] + public void TestProperties() + { + var lib = new SteamLibrary(_fileSystem.DirectoryInfo.New("Library"), _serviceProvider); + Assert.NotNull(lib.CommonLocation); + Assert.NotNull(lib.SteamAppsLocation); + Assert.NotNull(lib.WorkshopsLocation); + } + + [Fact] + public void TestEquality() + { + var lib = new SteamLibrary(_fileSystem.DirectoryInfo.New("Library"), _serviceProvider); + var other = new Mock(); + other.Setup(o => o.LibraryLocation) + .Returns(_fileSystem.DirectoryInfo.New("OtherLib")); + Assert.NotEqual(lib, other.Object); + other.Setup(o => o.LibraryLocation) + .Returns(_fileSystem.DirectoryInfo.New("Library")); + Assert.Equal(lib, other.Object); + + var otherInst = new SteamLibrary(_fileSystem.DirectoryInfo.New("./Library"), _serviceProvider); + Assert.Equal(lib, otherInst); + Assert.Equal(lib.GetHashCode(), otherInst.GetHashCode()); + } + + [Fact] + public void TestNoApps1() + { + var lib = new SteamLibrary(_fileSystem.DirectoryInfo.New("Library"), _serviceProvider); + + var app = new SteamAppManifest(lib, _fileSystem.FileInfo.New("file"), 123, "name", + _fileSystem.DirectoryInfo.New("game"), SteamAppState.StateFullyInstalled, + new HashSet()); + + _reader.Setup(r => r.ReadManifest(It.IsAny(), lib)) + .Returns(app); + + var apps = lib.GetApps(); + + Assert.Empty(apps); + } + + [Fact] + public void TestNoApps2() + { + _fileSystem.Initialize().WithSubdirectory("Library/steamapps"); + var lib = new SteamLibrary(_fileSystem.DirectoryInfo.New("Library"), _serviceProvider); + + var app = new SteamAppManifest(lib, _fileSystem.FileInfo.New("file"), 123, "name", + _fileSystem.DirectoryInfo.New("game"), SteamAppState.StateFullyInstalled, + new HashSet()); + + _reader.Setup(r => r.ReadManifest(It.IsAny(), lib)) + .Returns(app); + + var apps = lib.GetApps(); + + Assert.Empty(apps); + } + + [Fact] + public void TestApps() + { + _fileSystem.Initialize().WithFile("Library/steamapps/test.acf"); + var lib = new SteamLibrary(_fileSystem.DirectoryInfo.New("Library"), _serviceProvider); + + var app = new SteamAppManifest(lib, _fileSystem.FileInfo.New("file"), 123, "name", + _fileSystem.DirectoryInfo.New("game"), SteamAppState.StateFullyInstalled, + new HashSet()); + + _reader.Setup(r => r.ReadManifest(It.IsAny(), lib)) + .Returns(app); + + var apps = lib.GetApps(); + var result = Assert.Single(apps); + Assert.Same(app, result); + } + + [Fact] + public void TestNoDuplicatesApps() + { + _fileSystem.Initialize() + .WithFile("Library/steamapps/test1.acf") + .WithFile("Library/steamapps/test2.acf"); + + var lib = new SteamLibrary(_fileSystem.DirectoryInfo.New("Library"), _serviceProvider); + + var app = new SteamAppManifest(lib, _fileSystem.FileInfo.New("file"), 123, "name", + _fileSystem.DirectoryInfo.New("game"), SteamAppState.StateFullyInstalled, + new HashSet()); + + _reader.Setup(r => r.ReadManifest(It.IsAny(), lib)) + .Returns(app); + + var apps = lib.GetApps(); + var result = Assert.Single(apps); + Assert.Same(app, result); + } + + [PlatformSpecificFact(TestPlatformIdentifier.Windows)] + public void TestLocations_Windows() + { + var lib = new SteamLibrary(_fileSystem.DirectoryInfo.New("Library"), _serviceProvider); + Assert.Equal("C:\\Library\\steamapps\\common", lib.CommonLocation.FullName); + } + + [PlatformSpecificFact(TestPlatformIdentifier.Linux)] + public void TestLocations_Linux() { - private readonly IServiceProvider _serviceProvider; - private readonly MockFileSystem _fileSystem; - private readonly Mock _reader; - - public SteamLibraryTest() - { - var sc = new ServiceCollection(); - _fileSystem = new MockFileSystem(); - sc.AddTransient(_ => _fileSystem); - _reader = new Mock(); - sc.AddTransient(_ => _reader.Object); - _serviceProvider = sc.BuildServiceProvider(); - } - - [Fact] - public void TestProperties() - { - var lib = new SteamLibrary(_fileSystem.DirectoryInfo.New("Library"), _serviceProvider); - Assert.NotNull(lib.CommonLocation); - Assert.NotNull(lib.SteamAppsLocation); - Assert.NotNull(lib.WorkshopsLocation); - } - - [Fact] - public void TestEquality() - { - var lib = new SteamLibrary(_fileSystem.DirectoryInfo.New("Library"), _serviceProvider); - var other = new Mock(); - other.Setup(o => o.LibraryLocation) - .Returns(_fileSystem.DirectoryInfo.New("OtherLib")); - Assert.NotEqual(lib, other.Object); - other.Setup(o => o.LibraryLocation) - .Returns(_fileSystem.DirectoryInfo.New("Library")); - Assert.Equal(lib, other.Object); - - var otherInst = new SteamLibrary(_fileSystem.DirectoryInfo.New("./Library"), _serviceProvider); - Assert.Equal(lib, otherInst); - Assert.Equal(lib.GetHashCode(), otherInst.GetHashCode()); - } - - [Fact] - public void TestNoApps1() - { - var lib = new SteamLibrary(_fileSystem.DirectoryInfo.New("Library"), _serviceProvider); - - var app = new SteamAppManifest(lib, _fileSystem.FileInfo.New("file"), 123, "name", - _fileSystem.DirectoryInfo.New("game"), SteamAppState.StateFullyInstalled, - new HashSet()); - - _reader.Setup(r => r.ReadManifest(It.IsAny(), lib)) - .Returns(app); - - var apps = lib.GetApps(); - - Assert.Empty(apps); - } - - [Fact] - public void TestNoApps2() - { - _fileSystem.Initialize().WithSubdirectory("Library/steamapps"); - var lib = new SteamLibrary(_fileSystem.DirectoryInfo.New("Library"), _serviceProvider); - - var app = new SteamAppManifest(lib, _fileSystem.FileInfo.New("file"), 123, "name", - _fileSystem.DirectoryInfo.New("game"), SteamAppState.StateFullyInstalled, - new HashSet()); - - _reader.Setup(r => r.ReadManifest(It.IsAny(), lib)) - .Returns(app); - - var apps = lib.GetApps(); - - Assert.Empty(apps); - } - - [Fact] - public void TestApps() - { - _fileSystem.Initialize().WithFile("Library/steamapps/test.acf"); - var lib = new SteamLibrary(_fileSystem.DirectoryInfo.New("Library"), _serviceProvider); - - var app = new SteamAppManifest(lib, _fileSystem.FileInfo.New("file"), 123, "name", - _fileSystem.DirectoryInfo.New("game"), SteamAppState.StateFullyInstalled, - new HashSet()); - - _reader.Setup(r => r.ReadManifest(It.IsAny(), lib)) - .Returns(app); - - var apps = lib.GetApps(); - var result = Assert.Single(apps); - Assert.Same(app, result); - } - - [Fact] - public void TestNoDuplicatesApps() - { - _fileSystem.Initialize() - .WithFile("Library/steamapps/test1.acf") - .WithFile("Library/steamapps/test2.acf"); - - var lib = new SteamLibrary(_fileSystem.DirectoryInfo.New("Library"), _serviceProvider); - - var app = new SteamAppManifest(lib, _fileSystem.FileInfo.New("file"), 123, "name", - _fileSystem.DirectoryInfo.New("game"), SteamAppState.StateFullyInstalled, - new HashSet()); - - _reader.Setup(r => r.ReadManifest(It.IsAny(), lib)) - .Returns(app); - - var apps = lib.GetApps(); - var result = Assert.Single(apps); - Assert.Same(app, result); - } - - [PlatformSpecificFact(TestPlatformIdentifier.Windows)] - public void TestLocations_Windows() - { - var lib = new SteamLibrary(_fileSystem.DirectoryInfo.New("Library"), _serviceProvider); - Assert.Equal("C:\\Library\\steamapps\\common", lib.CommonLocation.FullName); - } - - [PlatformSpecificFact(TestPlatformIdentifier.Linux)] - public void TestLocations_Linux() - { - var lib = new SteamLibrary(_fileSystem.DirectoryInfo.New("Library"), _serviceProvider); - Assert.Equal("/Library/steamapps/common", lib.CommonLocation.FullName); - } + var lib = new SteamLibrary(_fileSystem.DirectoryInfo.New("Library"), _serviceProvider); + Assert.Equal("/Library/steamapps/common", lib.CommonLocation.FullName); } -} +} \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperIntegrationTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperIntegrationTest.cs index 688f3784..295b827b 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperIntegrationTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperIntegrationTest.cs @@ -3,40 +3,39 @@ using Microsoft.Extensions.DependencyInjection; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.Steam +namespace PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.Steam; + +public class SteamWrapperIntegrationTest { - public class SteamWrapperIntegrationTest - { - private readonly SteamWrapper _service; - private readonly IServiceProvider _sp; + private readonly SteamWrapper _service; + private readonly IServiceProvider _sp; - public SteamWrapperIntegrationTest() - { - var sc = new ServiceCollection(); - PetroglyphClientsLibrary.InitializeLibraryWithDefaultServices(sc); - PetroglyphWindowsSteamClientsLibrary.InitializeLibraryWithDefaultServices(sc); + public SteamWrapperIntegrationTest() + { + var sc = new ServiceCollection(); + PetroglyphClientsLibrary.InitializeLibraryWithDefaultServices(sc); + PetroglyphWindowsSteamClientsLibrary.InitializeLibraryWithDefaultServices(sc); - _sp = sc.BuildServiceProvider(); - _service = _sp.GetRequiredService() as SteamWrapper ?? throw new InvalidOperationException(); - } + _sp = sc.BuildServiceProvider(); + _service = _sp.GetRequiredService() as SteamWrapper ?? throw new InvalidOperationException(); + } - //[Fact] - public void TestGameInstalled() - { - Assert.False(_service.IsGameInstalled(0, out _)); - Assert.True(_service.IsGameInstalled(32470, out _)); - } + //[Fact] + public void TestGameInstalled() + { + Assert.False(_service.IsGameInstalled(0, out _)); + Assert.True(_service.IsGameInstalled(32470, out _)); + } - //[Fact] - public void Running() - { - var running = _service.IsRunning; - } + //[Fact] + public void Running() + { + var running = _service.IsRunning; + } - //[Fact] - public async Task WaitRunning() - { - await _service.WaitSteamRunningAndLoggedInAsync(false); - } + //[Fact] + public async Task WaitRunning() + { + await _service.WaitSteamRunningAndLoggedInAsync(false); } -} +} \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperTest.cs index 5e3e0b8e..e4695bf9 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperTest.cs @@ -8,139 +8,138 @@ using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.Steam +namespace PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.Steam; + +public class SteamWrapperTest { - public class SteamWrapperTest + private readonly SteamWrapper _service; + private readonly Mock _steamRegistry; + private readonly MockFileSystem _fileSystem; + private readonly Mock _processHelper; + private readonly Mock _gameFinder; + + public SteamWrapperTest() + { + var sc = new ServiceCollection(); + _steamRegistry = new Mock(); + _fileSystem = new MockFileSystem(); + _processHelper = new Mock(); + _gameFinder = new Mock(); + sc.AddTransient(_ => _steamRegistry.Object); + sc.AddTransient(_ => _processHelper.Object); + sc.AddTransient(_ => _gameFinder.Object); + sc.AddTransient(_ => _fileSystem); + _service = new SteamWrapper(sc.BuildServiceProvider()); + } + + [Fact] + public void TestInvalidArgs_Throws() + { + Assert.Throws(() => new SteamWrapper(null)); + } + + [Fact] + public void TestRunning() + { + _processHelper.SetupSequence(h => h.GetProcessByPid(It.IsAny())) + .Returns((Process)null) + .Returns(Process.GetCurrentProcess); + _steamRegistry.SetupSequence(r => r.ProcessId) + .Returns((int?)null) + .Returns(0) + .Returns(123) + .Returns(123); + + Assert.False(_service.IsRunning); + Assert.False(_service.IsRunning); + Assert.False(_service.IsRunning); + Assert.True(_service.IsRunning); + } + + [Fact] + public void TestInstalled() + { + _steamRegistry.SetupSequence(r => r.ExeFile) + .Returns((IFileInfo?)null) + .Returns(() => _fileSystem.FileInfo.New("steam.exe")) + .Returns(() => _fileSystem.FileInfo.New("steam.exe")); + + Assert.False(_service.Installed); + Assert.False(_service.Installed); + + _fileSystem.Initialize().WithFile("steam.exe"); + + Assert.True(_service.Installed); + } + + [Fact] + public void TestUserLoggedIn() + { + _steamRegistry.SetupSequence(r => r.ActiveUserId) + .Returns((int?)null) + .Returns(0) + .Returns(123); + + Assert.False(_service.IsUserLoggedIn); + Assert.False(_service.IsUserLoggedIn); + Assert.True(_service.IsUserLoggedIn); + } + + [Fact] + public void TestGameInstalled() + { + _fileSystem.Initialize(); + + SetupInstalledRegistry(); + var mFile = _fileSystem.FileInfo.New("manifest.acf"); + + var expectedApp = new SteamAppManifest(new Mock().Object, mFile, 1234, "name", + _fileSystem.DirectoryInfo.New("Game"), SteamAppState.StateFullyInstalled, + new HashSet()); + + _gameFinder.SetupSequence(f => f.FindGame(It.IsAny())) + .Returns((SteamAppManifest?)null) + .Returns(expectedApp); + _steamRegistry.Setup(r => r.InstalledApps).Returns(new HashSet { 1, 2, 3 }); + _steamRegistry.Setup(r => r.InstallationDirectory).Returns(_fileSystem.DirectoryInfo.New("Steam")); + + Assert.False(_service.IsGameInstalled(0, out _)); + Assert.False(_service.IsGameInstalled(1, out _)); + Assert.True(_service.IsGameInstalled(1, out var app)); + } + + [Fact] + public void TestWantsOffline() + { + SetupInstalledRegistry(); + + _steamRegistry.Setup(r => r.InstallationDirectory).Returns(_fileSystem.DirectoryInfo.New(".")); + + Assert.Null(_service.WantOfflineMode); + + _fileSystem.Initialize().WithFile("config/loginusers.vdf"); + Assert.Null(_service.WantOfflineMode); + + _fileSystem.File.WriteAllText("config/loginusers.vdf", WantsNotOffline()); + Assert.False(_service.WantOfflineMode); + + _fileSystem.File.WriteAllText("config/loginusers.vdf", WantsOffline()); + Assert.True(_service.WantOfflineMode); + } + + private void SetupInstalledRegistry() + { + _fileSystem.Initialize().WithFile("steam.exe"); + _steamRegistry.Setup(r => r.ExeFile).Returns(_fileSystem.FileInfo.New("steam.exe")); + } + + private static string WantsNotOffline() + { + return "\"users\"\n{\n\t\"123\"\n\t{\n\t\t\"AccountName\"\t\t\"user_name\"\n\t\t\"PersonaName\"\t\t\"User Name\"\n\t\t\"RememberPassword\"\t\t\"1\"\n\t\t\"MostRecent\"\t\t\"1\"\n\t\t\"Timestamp\"\t\t\"0000000000\"\n\t\t\"WantsOfflineMode\"\t\t\"0\"\n\t\t\"SkipOfflineModeWarning\"\t\t\"0\"\n\t}\n}"; + } + + private static string WantsOffline() { - private readonly SteamWrapper _service; - private readonly Mock _steamRegistry; - private readonly MockFileSystem _fileSystem; - private readonly Mock _processHelper; - private readonly Mock _gameFinder; - - public SteamWrapperTest() - { - var sc = new ServiceCollection(); - _steamRegistry = new Mock(); - _fileSystem = new MockFileSystem(); - _processHelper = new Mock(); - _gameFinder = new Mock(); - sc.AddTransient(_ => _steamRegistry.Object); - sc.AddTransient(_ => _processHelper.Object); - sc.AddTransient(_ => _gameFinder.Object); - sc.AddTransient(_ => _fileSystem); - _service = new SteamWrapper(sc.BuildServiceProvider()); - } - - [Fact] - public void TestInvalidArgs_Throws() - { - Assert.Throws(() => new SteamWrapper(null)); - } - - [Fact] - public void TestRunning() - { - _processHelper.SetupSequence(h => h.GetProcessByPid(It.IsAny())) - .Returns((Process)null) - .Returns(Process.GetCurrentProcess); - _steamRegistry.SetupSequence(r => r.ProcessId) - .Returns((int?)null) - .Returns(0) - .Returns(123) - .Returns(123); - - Assert.False(_service.IsRunning); - Assert.False(_service.IsRunning); - Assert.False(_service.IsRunning); - Assert.True(_service.IsRunning); - } - - [Fact] - public void TestInstalled() - { - _steamRegistry.SetupSequence(r => r.ExeFile) - .Returns((IFileInfo?)null) - .Returns(() => _fileSystem.FileInfo.New("steam.exe")) - .Returns(() => _fileSystem.FileInfo.New("steam.exe")); - - Assert.False(_service.Installed); - Assert.False(_service.Installed); - - _fileSystem.Initialize().WithFile("steam.exe"); - - Assert.True(_service.Installed); - } - - [Fact] - public void TestUserLoggedIn() - { - _steamRegistry.SetupSequence(r => r.ActiveUserId) - .Returns((int?)null) - .Returns(0) - .Returns(123); - - Assert.False(_service.IsUserLoggedIn); - Assert.False(_service.IsUserLoggedIn); - Assert.True(_service.IsUserLoggedIn); - } - - [Fact] - public void TestGameInstalled() - { - _fileSystem.Initialize(); - - SetupInstalledRegistry(); - var mFile = _fileSystem.FileInfo.New("manifest.acf"); - - var expectedApp = new SteamAppManifest(new Mock().Object, mFile, 1234, "name", - _fileSystem.DirectoryInfo.New("Game"), SteamAppState.StateFullyInstalled, - new HashSet()); - - _gameFinder.SetupSequence(f => f.FindGame(It.IsAny())) - .Returns((SteamAppManifest?)null) - .Returns(expectedApp); - _steamRegistry.Setup(r => r.InstalledApps).Returns(new HashSet { 1, 2, 3 }); - _steamRegistry.Setup(r => r.InstallationDirectory).Returns(_fileSystem.DirectoryInfo.New("Steam")); - - Assert.False(_service.IsGameInstalled(0, out _)); - Assert.False(_service.IsGameInstalled(1, out _)); - Assert.True(_service.IsGameInstalled(1, out var app)); - } - - [Fact] - public void TestWantsOffline() - { - SetupInstalledRegistry(); - - _steamRegistry.Setup(r => r.InstallationDirectory).Returns(_fileSystem.DirectoryInfo.New(".")); - - Assert.Null(_service.WantOfflineMode); - - _fileSystem.Initialize().WithFile("config/loginusers.vdf"); - Assert.Null(_service.WantOfflineMode); - - _fileSystem.File.WriteAllText("config/loginusers.vdf", WantsNotOffline()); - Assert.False(_service.WantOfflineMode); - - _fileSystem.File.WriteAllText("config/loginusers.vdf", WantsOffline()); - Assert.True(_service.WantOfflineMode); - } - - private void SetupInstalledRegistry() - { - _fileSystem.Initialize().WithFile("steam.exe"); - _steamRegistry.Setup(r => r.ExeFile).Returns(_fileSystem.FileInfo.New("steam.exe")); - } - - private static string WantsNotOffline() - { - return "\"users\"\n{\n\t\"123\"\n\t{\n\t\t\"AccountName\"\t\t\"user_name\"\n\t\t\"PersonaName\"\t\t\"User Name\"\n\t\t\"RememberPassword\"\t\t\"1\"\n\t\t\"MostRecent\"\t\t\"1\"\n\t\t\"Timestamp\"\t\t\"0000000000\"\n\t\t\"WantsOfflineMode\"\t\t\"0\"\n\t\t\"SkipOfflineModeWarning\"\t\t\"0\"\n\t}\n}"; - } - - private static string WantsOffline() - { - return "\"users\"\n{\n\t\"123\"\n\t{\n\t\t\"AccountName\"\t\t\"user_name\"\n\t\t\"PersonaName\"\t\t\"User Name\"\n\t\t\"RememberPassword\"\t\t\"1\"\n\t\t\"MostRecent\"\t\t\"1\"\n\t\t\"Timestamp\"\t\t\"0000000000\"\n\t\t\"WantsOfflineMode\"\t\t\"1\"\n\t\t\"SkipOfflineModeWarning\"\t\t\"0\"\n\t}\n}"; - } + return "\"users\"\n{\n\t\"123\"\n\t{\n\t\t\"AccountName\"\t\t\"user_name\"\n\t\t\"PersonaName\"\t\t\"User Name\"\n\t\t\"RememberPassword\"\t\t\"1\"\n\t\t\"MostRecent\"\t\t\"1\"\n\t\t\"Timestamp\"\t\t\"0000000000\"\n\t\t\"WantsOfflineMode\"\t\t\"1\"\n\t\t\"SkipOfflineModeWarning\"\t\t\"0\"\n\t}\n}"; } } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/PetroglyphClientsLibrary.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/PetroglyphClientsLibrary.cs index 706854f3..affd5457 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/PetroglyphClientsLibrary.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/PetroglyphClientsLibrary.cs @@ -2,27 +2,26 @@ using PetroGlyph.Games.EawFoc.Clients.Arguments; using PetroGlyph.Games.EawFoc.Clients.Processes; -namespace PetroGlyph.Games.EawFoc.Clients +namespace PetroGlyph.Games.EawFoc.Clients; + +/// +/// Provides initialization routines for this library. +/// +public class PetroglyphClientsLibrary { /// - /// Provides initialization routines for this library. + /// Adds services provided by this library to the given + /// so that the library can be used in client applications. /// - public class PetroglyphClientsLibrary + /// The service collection to be filled. + public static void InitializeLibraryWithDefaultServices(IServiceCollection serviceCollection) { - /// - /// Adds services provided by this library to the given - /// so that the library can be used in client applications. - /// - /// The service collection to be filled. - public static void InitializeLibraryWithDefaultServices(IServiceCollection serviceCollection) - { - serviceCollection.AddTransient(_ => new ProcessHelper()); + serviceCollection.AddTransient(_ => new ProcessHelper()); - serviceCollection.AddTransient(sp => new GameExecutableFileService(sp)); - serviceCollection.AddTransient(_ => new GameExecutableNameBuilder()); + serviceCollection.AddTransient(sp => new GameExecutableFileService(sp)); + serviceCollection.AddTransient(_ => new GameExecutableNameBuilder()); - serviceCollection.AddTransient(_ => new ArgumentValidator()); - serviceCollection.AddTransient(sp => new ArgumentCommandLineBuilder(sp)); - } + serviceCollection.AddTransient(_ => new ArgumentValidator()); + serviceCollection.AddTransient(sp => new ArgumentCommandLineBuilder(sp)); } -} +} \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/ClientBaseTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/ClientBaseTest.cs index b29b36cc..4f2d2113 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/ClientBaseTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/ClientBaseTest.cs @@ -11,297 +11,296 @@ using PetroGlyph.Games.EawFoc.Mods; using Testably.Abstractions.Testing; -namespace PetroGlyph.Games.EawFoc.Clients.Test +namespace PetroGlyph.Games.EawFoc.Clients.Test; + +public class ClientBaseTest { - public class ClientBaseTest - { - private readonly Mock _client; - private readonly Mock _game; - private readonly Mock _modListFactory; - private readonly Mock _argBuilder; - private readonly Mock _exeService; - private readonly Mock _launcher; + private readonly Mock _client; + private readonly Mock _game; + private readonly Mock _modListFactory; + private readonly Mock _argBuilder; + private readonly Mock _exeService; + private readonly Mock _launcher; - public ClientBaseTest() - { - var sc = new ServiceCollection(); - _modListFactory = new Mock(); - _argBuilder = new Mock(); - _exeService = new Mock(); - _launcher = new Mock(); - sc.AddTransient(_ => _modListFactory.Object); - sc.AddTransient(_ => _argBuilder.Object); - sc.AddTransient(_ => _exeService.Object); - sc.AddTransient(_ => _launcher.Object); - _client = new Mock(sc.BuildServiceProvider()); - _client.Setup(c => c.GetGameLauncherService()).Returns(_launcher.Object); - _game = new Mock(); - } - - [Fact] - public void TestPlatformNotSupported_Throws() - { - _game.Setup(g => g.Game).Returns(_game.Object); - _game.Setup(g => g.Platform).Returns(GamePlatform.SteamGold); + public ClientBaseTest() + { + var sc = new ServiceCollection(); + _modListFactory = new Mock(); + _argBuilder = new Mock(); + _exeService = new Mock(); + _launcher = new Mock(); + sc.AddTransient(_ => _modListFactory.Object); + sc.AddTransient(_ => _argBuilder.Object); + sc.AddTransient(_ => _exeService.Object); + sc.AddTransient(_ => _launcher.Object); + _client = new Mock(sc.BuildServiceProvider()); + _client.Setup(c => c.GetGameLauncherService()).Returns(_launcher.Object); + _game = new Mock(); + } - _client.Setup(c => c.SupportedPlatforms).Returns(new HashSet { GamePlatform.Disk }); - _client.Setup(c => c.DefaultArguments).Returns(ArgumentCollection.Empty); + [Fact] + public void TestPlatformNotSupported_Throws() + { + _game.Setup(g => g.Game).Returns(_game.Object); + _game.Setup(g => g.Platform).Returns(GamePlatform.SteamGold); + + _client.Setup(c => c.SupportedPlatforms).Returns(new HashSet { GamePlatform.Disk }); + _client.Setup(c => c.DefaultArguments).Returns(ArgumentCollection.Empty); - var e = Assert.Throws(() => _client.Object.Play(_game.Object)); - Assert.StartsWith("Unable to start", e.Message); - } + var e = Assert.Throws(() => _client.Object.Play(_game.Object)); + Assert.StartsWith("Unable to start", e.Message); + } - [Fact] - public void TestPlatformOnGameStartingCancels_Throws() - { - _game.Setup(g => g.Game).Returns(_game.Object); - _game.Setup(g => g.Platform).Returns(GamePlatform.Disk); + [Fact] + public void TestPlatformOnGameStartingCancels_Throws() + { + _game.Setup(g => g.Game).Returns(_game.Object); + _game.Setup(g => g.Platform).Returns(GamePlatform.Disk); - _client.Setup(c => c.SupportedPlatforms).Returns(new HashSet { GamePlatform.Disk }); - _client.Setup(c => c.DefaultArguments).Returns(ArgumentCollection.Empty); - _client.Setup(c => c.OnGameStarting(It.IsAny(), ArgumentCollection.Empty, GameBuildType.Release)).Returns(false); + _client.Setup(c => c.SupportedPlatforms).Returns(new HashSet { GamePlatform.Disk }); + _client.Setup(c => c.DefaultArguments).Returns(ArgumentCollection.Empty); + _client.Setup(c => c.OnGameStarting(It.IsAny(), ArgumentCollection.Empty, GameBuildType.Release)).Returns(false); - var e = Assert.Throws(() => _client.Object.Play(_game.Object)); - Assert.Equal("Game starting was aborted.", e.Message); - } + var e = Assert.Throws(() => _client.Object.Play(_game.Object)); + Assert.Equal("Game starting was aborted.", e.Message); + } - [Fact] - public void TestPlatformOnGameStartingEventCancel_Throws() - { - _game.Setup(g => g.Game).Returns(_game.Object); - _game.Setup(g => g.Platform).Returns(GamePlatform.Disk); + [Fact] + public void TestPlatformOnGameStartingEventCancel_Throws() + { + _game.Setup(g => g.Game).Returns(_game.Object); + _game.Setup(g => g.Platform).Returns(GamePlatform.Disk); - _client.Setup(c => c.SupportedPlatforms).Returns(new HashSet { GamePlatform.Disk }); - _client.Setup(c => c.DefaultArguments).Returns(ArgumentCollection.Empty); - _client.Setup(c => c.OnGameStarting(It.IsAny(), ArgumentCollection.Empty, GameBuildType.Release)).Returns(true); + _client.Setup(c => c.SupportedPlatforms).Returns(new HashSet { GamePlatform.Disk }); + _client.Setup(c => c.DefaultArguments).Returns(ArgumentCollection.Empty); + _client.Setup(c => c.OnGameStarting(It.IsAny(), ArgumentCollection.Empty, GameBuildType.Release)).Returns(true); - var handlerCalled = false; - _client.Object.GameStarting += (sender, args) => - { - Assert.Empty(args.GameArguments); - Assert.Equal(GameBuildType.Release, args.BuildType); - args.Cancel = true; - handlerCalled = true; - }; - - var e = Assert.Throws(() => _client.Object.Play(_game.Object)); - Assert.Equal("Game starting was aborted.", e.Message); - Assert.True(handlerCalled); - } - - [Fact] - public void TestModDependenciesAutoAddToArgs() + var handlerCalled = false; + _client.Object.GameStarting += (sender, args) => { - var mod = new Mock(); - mod.Setup(g => g.Game).Returns(_game.Object); - - var expectedModList = new ModArgumentList(new[] - { new ModArgument("path", false), new ModArgument("other", true) }); - _modListFactory.Setup(f => f.BuildArgumentList(It.IsAny(), false)) - .Returns(expectedModList); - _argBuilder.Setup(b => b.AddAll(It.IsAny())).Returns(_argBuilder.Object); - _argBuilder.Setup(b => b.Add(It.IsAny())).Returns(_argBuilder.Object); - _argBuilder.Setup(b => b.Build()) - .Returns(new ArgumentCollection(new List { expectedModList })); - - _game.Setup(g => g.Platform).Returns(GamePlatform.Disk); - - _client.Setup(c => c.SupportedPlatforms).Returns(new HashSet { GamePlatform.Disk }); - _client.Setup(c => c.DefaultArguments).Returns(ArgumentCollection.Empty); - var callbackTriggered = false; - _client.Setup(c => c.OnGameStarting(It.IsAny(), It.IsAny(), GameBuildType.Release)) - .Callback((IPlayableObject _, IArgumentCollection args, GameBuildType _) => - { - callbackTriggered = true; - Assert.Equal(new ArgumentCollection(new List { expectedModList }), args); - }) - .Returns(true); - - Assert.Throws(() => _client.Object.Play(mod.Object)); - Assert.True(callbackTriggered); - _argBuilder.Verify(b => b.Build(), Times.Exactly(1)); - } - - [Fact] - public void TestExeNotFound_Throws() - { - _game.Setup(g => g.Game).Returns(_game.Object); - _game.Setup(g => g.Platform).Returns(GamePlatform.Disk); - - _client.Setup(c => c.SupportedPlatforms).Returns(new HashSet { GamePlatform.Disk }); - _client.Setup(c => c.DefaultArguments).Returns(ArgumentCollection.Empty); - _client.Setup(c => c.OnGameStarting(It.IsAny(), ArgumentCollection.Empty, GameBuildType.Release)).Returns(true); - - var e1 = Assert.Throws(() => _client.Object.Play(_game.Object)); - Assert.StartsWith("Executable for", e1.Message); - - var fs = new MockFileSystem(); - - _exeService.Setup(s => s.GetExecutableForGame(It.IsAny(), GameBuildType.Release)) - .Returns(fs.FileInfo.New("test.exe")); - - var e2 = Assert.Throws(() => _client.Object.Play(_game.Object)); - Assert.StartsWith("Executable for", e2.Message); - } - - [Fact] - public void TesGameNotStarted_Throws() - { - _game.Setup(g => g.Game).Returns(_game.Object); - _game.Setup(g => g.Platform).Returns(GamePlatform.Disk); + Assert.Empty(args.GameArguments); + Assert.Equal(GameBuildType.Release, args.BuildType); + args.Cancel = true; + handlerCalled = true; + }; + + var e = Assert.Throws(() => _client.Object.Play(_game.Object)); + Assert.Equal("Game starting was aborted.", e.Message); + Assert.True(handlerCalled); + } - _client.Setup(c => c.SupportedPlatforms).Returns(new HashSet { GamePlatform.Disk }); - _client.Setup(c => c.DefaultArguments).Returns(ArgumentCollection.Empty); - _client.Setup(c => c.OnGameStarting(It.IsAny(), ArgumentCollection.Empty, GameBuildType.Release)).Returns(true); + [Fact] + public void TestModDependenciesAutoAddToArgs() + { + var mod = new Mock(); + mod.Setup(g => g.Game).Returns(_game.Object); + + var expectedModList = new ModArgumentList(new[] + { new ModArgument("path", false), new ModArgument("other", true) }); + _modListFactory.Setup(f => f.BuildArgumentList(It.IsAny(), false)) + .Returns(expectedModList); + _argBuilder.Setup(b => b.AddAll(It.IsAny())).Returns(_argBuilder.Object); + _argBuilder.Setup(b => b.Add(It.IsAny())).Returns(_argBuilder.Object); + _argBuilder.Setup(b => b.Build()) + .Returns(new ArgumentCollection(new List { expectedModList })); + + _game.Setup(g => g.Platform).Returns(GamePlatform.Disk); + + _client.Setup(c => c.SupportedPlatforms).Returns(new HashSet { GamePlatform.Disk }); + _client.Setup(c => c.DefaultArguments).Returns(ArgumentCollection.Empty); + var callbackTriggered = false; + _client.Setup(c => c.OnGameStarting(It.IsAny(), It.IsAny(), GameBuildType.Release)) + .Callback((IPlayableObject _, IArgumentCollection args, GameBuildType _) => + { + callbackTriggered = true; + Assert.Equal(new ArgumentCollection(new List { expectedModList }), args); + }) + .Returns(true); + + Assert.Throws(() => _client.Object.Play(mod.Object)); + Assert.True(callbackTriggered); + _argBuilder.Verify(b => b.Build(), Times.Exactly(1)); + } - var fs = new MockFileSystem(); - fs.Initialize().WithFile("test.exe"); + [Fact] + public void TestExeNotFound_Throws() + { + _game.Setup(g => g.Game).Returns(_game.Object); + _game.Setup(g => g.Platform).Returns(GamePlatform.Disk); - _exeService.Setup(s => s.GetExecutableForGame(It.IsAny(), GameBuildType.Release)) - .Returns(fs.FileInfo.New("test.exe")); + _client.Setup(c => c.SupportedPlatforms).Returns(new HashSet { GamePlatform.Disk }); + _client.Setup(c => c.DefaultArguments).Returns(ArgumentCollection.Empty); + _client.Setup(c => c.OnGameStarting(It.IsAny(), ArgumentCollection.Empty, GameBuildType.Release)).Returns(true); - _launcher.Setup(l => l.StartGameProcess(It.IsAny(), It.IsAny())) - .Throws(new GameStartException(_game.Object, "Test message")); + var e1 = Assert.Throws(() => _client.Object.Play(_game.Object)); + Assert.StartsWith("Executable for", e1.Message); - var e2 = Assert.Throws(() => _client.Object.Play(_game.Object)); - Assert.Equal("Test message", e2.Message); - } + var fs = new MockFileSystem(); - [Fact] - public void TestGameStarted() - { - _game.Setup(g => g.Game).Returns(_game.Object); - _game.Setup(g => g.Platform).Returns(GamePlatform.Disk); + _exeService.Setup(s => s.GetExecutableForGame(It.IsAny(), GameBuildType.Release)) + .Returns(fs.FileInfo.New("test.exe")); + + var e2 = Assert.Throws(() => _client.Object.Play(_game.Object)); + Assert.StartsWith("Executable for", e2.Message); + } - _client.Setup(c => c.SupportedPlatforms).Returns(new HashSet { GamePlatform.Disk }); - _client.Setup(c => c.DefaultArguments) - .Returns(new ArgumentCollection(new List { new WindowedArgument() })); - _client.Setup(c => c.OnGameStarting(It.IsAny(), It.IsAny(), GameBuildType.Release)).Returns(true); + [Fact] + public void TesGameNotStarted_Throws() + { + _game.Setup(g => g.Game).Returns(_game.Object); + _game.Setup(g => g.Platform).Returns(GamePlatform.Disk); + + _client.Setup(c => c.SupportedPlatforms).Returns(new HashSet { GamePlatform.Disk }); + _client.Setup(c => c.DefaultArguments).Returns(ArgumentCollection.Empty); + _client.Setup(c => c.OnGameStarting(It.IsAny(), ArgumentCollection.Empty, GameBuildType.Release)).Returns(true); + + var fs = new MockFileSystem(); + fs.Initialize().WithFile("test.exe"); - var fs = new MockFileSystem(); - fs.Initialize().WithFile("test.exe"); + _exeService.Setup(s => s.GetExecutableForGame(It.IsAny(), GameBuildType.Release)) + .Returns(fs.FileInfo.New("test.exe")); - _exeService.Setup(s => s.GetExecutableForGame(It.IsAny(), GameBuildType.Release)) - .Returns(fs.FileInfo.New("test.exe")); + _launcher.Setup(l => l.StartGameProcess(It.IsAny(), It.IsAny())) + .Throws(new GameStartException(_game.Object, "Test message")); - var process = new Mock(); - _launcher.Setup(l => l.StartGameProcess(It.IsAny(), It.IsAny())) - .Callback((IFileInfo _, GameProcessInfo g) => - { - var arg = Assert.Single(g.Arguments); - Assert.Equal(new WindowedArgument(), arg); - process.Setup(p => p.ProcessInfo).Returns(g); - process.Setup(p => p.State).Returns(GameProcessState.Running); - }) - .Returns(process.Object); + var e2 = Assert.Throws(() => _client.Object.Play(_game.Object)); + Assert.Equal("Test message", e2.Message); + } + + [Fact] + public void TestGameStarted() + { + _game.Setup(g => g.Game).Returns(_game.Object); + _game.Setup(g => g.Platform).Returns(GamePlatform.Disk); + _client.Setup(c => c.SupportedPlatforms).Returns(new HashSet { GamePlatform.Disk }); + _client.Setup(c => c.DefaultArguments) + .Returns(new ArgumentCollection(new List { new WindowedArgument() })); + _client.Setup(c => c.OnGameStarting(It.IsAny(), It.IsAny(), GameBuildType.Release)).Returns(true); - _client.Setup(c => c.OnGameStarted(It.IsAny())) - .Callback((IGameProcess p) => - { - Assert.Equal(GameProcessState.Running, p.State); - }); + var fs = new MockFileSystem(); + fs.Initialize().WithFile("test.exe"); + _exeService.Setup(s => s.GetExecutableForGame(It.IsAny(), GameBuildType.Release)) + .Returns(fs.FileInfo.New("test.exe")); - var gameStarted = false; - _client.Object.GameStarted += (_, gameProcess) => + var process = new Mock(); + _launcher.Setup(l => l.StartGameProcess(It.IsAny(), It.IsAny())) + .Callback((IFileInfo _, GameProcessInfo g) => { - Assert.Equal(gameProcess.ProcessInfo, process.Object.ProcessInfo); - gameStarted = true; - }; - - - var actualProcess = _client.Object.Play(_game.Object); + var arg = Assert.Single(g.Arguments); + Assert.Equal(new WindowedArgument(), arg); + process.Setup(p => p.ProcessInfo).Returns(g); + process.Setup(p => p.State).Returns(GameProcessState.Running); + }) + .Returns(process.Object); - Assert.Equal(actualProcess.ProcessInfo, process.Object.ProcessInfo); - Assert.True(gameStarted); - _launcher.Verify(l => l.StartGameProcess(It.IsAny(), It.IsAny()), Times.Exactly(1)); - _client.Verify(l => l.OnGameStarted(It.IsAny()), Times.Exactly(1)); - } - [Fact] - public void TestRunningInstanceListUpdates() - { - _game.Setup(g => g.Game).Returns(_game.Object); - _game.Setup(g => g.Platform).Returns(GamePlatform.Disk); + _client.Setup(c => c.OnGameStarted(It.IsAny())) + .Callback((IGameProcess p) => + { + Assert.Equal(GameProcessState.Running, p.State); + }); - _client.Setup(c => c.SupportedPlatforms).Returns(new HashSet { GamePlatform.Disk }); - _client.Setup(c => c.DefaultArguments) - .Returns(new ArgumentCollection(new List { new WindowedArgument() })); - _client.Setup(c => c.OnGameStarting(It.IsAny(), It.IsAny(), GameBuildType.Release)).Returns(true); - var fs = new MockFileSystem(); - fs.Initialize().WithFile("test.exe"); + var gameStarted = false; + _client.Object.GameStarted += (_, gameProcess) => + { + Assert.Equal(gameProcess.ProcessInfo, process.Object.ProcessInfo); + gameStarted = true; + }; + + + var actualProcess = _client.Object.Play(_game.Object); - _exeService.Setup(s => s.GetExecutableForGame(It.IsAny(), GameBuildType.Release)) - .Returns(fs.FileInfo.New("test.exe")); + Assert.Equal(actualProcess.ProcessInfo, process.Object.ProcessInfo); + Assert.True(gameStarted); + _launcher.Verify(l => l.StartGameProcess(It.IsAny(), It.IsAny()), Times.Exactly(1)); + _client.Verify(l => l.OnGameStarted(It.IsAny()), Times.Exactly(1)); + } - var process = new Mock(); - _launcher.Setup(l => l.StartGameProcess(It.IsAny(), It.IsAny())) - .Returns(process.Object); + [Fact] + public void TestRunningInstanceListUpdates() + { + _game.Setup(g => g.Game).Returns(_game.Object); + _game.Setup(g => g.Platform).Returns(GamePlatform.Disk); + _client.Setup(c => c.SupportedPlatforms).Returns(new HashSet { GamePlatform.Disk }); + _client.Setup(c => c.DefaultArguments) + .Returns(new ArgumentCollection(new List { new WindowedArgument() })); + _client.Setup(c => c.OnGameStarting(It.IsAny(), It.IsAny(), GameBuildType.Release)).Returns(true); - Assert.Empty(_client.Object.RunningInstances); - _client.Object.Play(_game.Object); - Assert.Single(_client.Object.RunningInstances); + var fs = new MockFileSystem(); + fs.Initialize().WithFile("test.exe"); - var closed = false; - _client.Object.GameClosed += (_, gameProcess) => - { - Assert.Equal(gameProcess.ProcessInfo, process.Object.ProcessInfo); - closed = true; - }; + _exeService.Setup(s => s.GetExecutableForGame(It.IsAny(), GameBuildType.Release)) + .Returns(fs.FileInfo.New("test.exe")); - process.Raise(p => p.Closed += null, EventArgs.Empty); + var process = new Mock(); + _launcher.Setup(l => l.StartGameProcess(It.IsAny(), It.IsAny())) + .Returns(process.Object); - Assert.True(closed); - Assert.Empty(_client.Object.RunningInstances); - } + Assert.Empty(_client.Object.RunningInstances); + _client.Object.Play(_game.Object); + Assert.Single(_client.Object.RunningInstances); - [Fact] - public void TestGameStartedButClosedWhileInHandler() + var closed = false; + _client.Object.GameClosed += (_, gameProcess) => { - _game.Setup(g => g.Game).Returns(_game.Object); - _game.Setup(g => g.Platform).Returns(GamePlatform.Disk); + Assert.Equal(gameProcess.ProcessInfo, process.Object.ProcessInfo); + closed = true; + }; - _client.Setup(c => c.SupportedPlatforms).Returns(new HashSet { GamePlatform.Disk }); - _client.Setup(c => c.DefaultArguments) - .Returns(new ArgumentCollection(new List { new WindowedArgument() })); - _client.Setup(c => c.OnGameStarting(It.IsAny(), It.IsAny(), GameBuildType.Release)).Returns(true); + process.Raise(p => p.Closed += null, EventArgs.Empty); - var fs = new MockFileSystem(); - fs.Initialize().WithFile("test.exe"); - _exeService.Setup(s => s.GetExecutableForGame(It.IsAny(), GameBuildType.Release)) - .Returns(fs.FileInfo.New("test.exe")); + Assert.True(closed); + Assert.Empty(_client.Object.RunningInstances); + } - var process = new Mock(); - _launcher.Setup(l => l.StartGameProcess(It.IsAny(), It.IsAny())) - .Returns(process.Object); + [Fact] + public void TestGameStartedButClosedWhileInHandler() + { + _game.Setup(g => g.Game).Returns(_game.Object); + _game.Setup(g => g.Platform).Returns(GamePlatform.Disk); + _client.Setup(c => c.SupportedPlatforms).Returns(new HashSet { GamePlatform.Disk }); + _client.Setup(c => c.DefaultArguments) + .Returns(new ArgumentCollection(new List { new WindowedArgument() })); + _client.Setup(c => c.OnGameStarting(It.IsAny(), It.IsAny(), GameBuildType.Release)).Returns(true); - _client.Setup(c => c.OnGameStarted(It.IsAny())) - .Callback(() => - { - process.Setup(p => p.State).Returns(GameProcessState.Closed); - }); + var fs = new MockFileSystem(); + fs.Initialize().WithFile("test.exe"); + _exeService.Setup(s => s.GetExecutableForGame(It.IsAny(), GameBuildType.Release)) + .Returns(fs.FileInfo.New("test.exe")); - var gameStarted = false; - _client.Object.GameStarted += (_, _) => + var process = new Mock(); + _launcher.Setup(l => l.StartGameProcess(It.IsAny(), It.IsAny())) + .Returns(process.Object); + + + _client.Setup(c => c.OnGameStarted(It.IsAny())) + .Callback(() => { - gameStarted = true; - }; + process.Setup(p => p.State).Returns(GameProcessState.Closed); + }); + + + var gameStarted = false; + _client.Object.GameStarted += (_, _) => + { + gameStarted = true; + }; - var actualProcess = _client.Object.Play(_game.Object); + var actualProcess = _client.Object.Play(_game.Object); - Assert.Equal(actualProcess.ProcessInfo, process.Object.ProcessInfo); - Assert.False(gameStarted); - _client.Verify(l => l.OnGameStarted(It.IsAny()), Times.Exactly(1)); - Assert.Empty(_client.Object.RunningInstances); - } + Assert.Equal(actualProcess.ProcessInfo, process.Object.ProcessInfo); + Assert.False(gameStarted); + _client.Verify(l => l.OnGameStarted(It.IsAny()), Times.Exactly(1)); + Assert.Empty(_client.Object.RunningInstances); } -} +} \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryBase.cs b/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryBase.cs index 45d3bba9..f50f002b 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryBase.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryBase.cs @@ -6,203 +6,202 @@ using System.Diagnostics.CodeAnalysis; #endif -namespace PetroGlyph.Games.EawFoc.Games.Registry +namespace PetroGlyph.Games.EawFoc.Games.Registry; + +/// +/// Windows only registry wrapper for an Petroglyph Star Wars game. +/// +public sealed class GameRegistry : IGameRegistry { - /// - /// Windows only registry wrapper for an Petroglyph Star Wars game. - /// - public sealed class GameRegistry : IGameRegistry - { - private IRegistryKey? _registryKey; + private IRegistryKey? _registryKey; - private const string VersionKey = "1.0"; - private const string CDKeyProperty = "CD Key"; - private const string EawGoldProperty = "EAWGold"; - private const string ExePathProperty = "ExePath"; - private const string InstalledProperty = "Installed"; - private const string InstallPathProperty = "InstallPath"; - private const string LauncherProperty = "Launcher"; - private const string RevisionProperty = "Revision"; + private const string VersionKey = "1.0"; + private const string CDKeyProperty = "CD Key"; + private const string EawGoldProperty = "EAWGold"; + private const string ExePathProperty = "ExePath"; + private const string InstalledProperty = "Installed"; + private const string InstallPathProperty = "InstallPath"; + private const string LauncherProperty = "Launcher"; + private const string RevisionProperty = "Revision"; - private static readonly Version VersionInstance = new(1, 0); + private static readonly Version VersionInstance = new(1, 0); - private readonly IFileSystem _fileSystem; + private readonly IFileSystem _fileSystem; - private bool _disposed; + private bool _disposed; - /// - public GameType Type { get; } + /// + public GameType Type { get; } - /// - public bool Exits + /// + public bool Exits + { + get { - get - { - ThrowIfDisposed(); - return _registryKey!.GetKey(string.Empty) is not null; - } + ThrowIfDisposed(); + return _registryKey!.GetKey(string.Empty) is not null; } + } - /// - public IGame? Game { get; private set; } + /// + public IGame? Game { get; private set; } - /// - public Version? Version + /// + public Version? Version + { + get { - get - { - ThrowIfDisposed(); - // Currently the there only exists a 1.x release of the game - // and likely never to happen that we see a change here. - // Thus we leave this part hardcoded and pray PG does not alter the deal. - return _registryKey!.HasPath(VersionKey) ? VersionInstance : null; - } + ThrowIfDisposed(); + // Currently the there only exists a 1.x release of the game + // and likely never to happen that we see a change here. + // Thus we leave this part hardcoded and pray PG does not alter the deal. + return _registryKey!.HasPath(VersionKey) ? VersionInstance : null; } + } - /// - public string? CdKey + /// + public string? CdKey + { + get { - get - { - ThrowIfDisposed(); - if (!_registryKey!.GetValueOrDefault(CDKeyProperty, VersionKey, out string? value, null)) - return null; - return value; - } + ThrowIfDisposed(); + if (!_registryKey!.GetValueOrDefault(CDKeyProperty, VersionKey, out string? value, null)) + return null; + return value; } + } - /// - public int? EaWGold + /// + public int? EaWGold + { + get { - get - { - ThrowIfDisposed(); - if (!_registryKey!.GetValueOrDefault(EawGoldProperty, VersionKey, out int? value, null)) - return null; - return value; - } + ThrowIfDisposed(); + if (!_registryKey!.GetValueOrDefault(EawGoldProperty, VersionKey, out int? value, null)) + return null; + return value; } + } - /// - public IFileInfo? ExePath + /// + public IFileInfo? ExePath + { + get { - get - { - ThrowIfDisposed(); - if (!_registryKey!.GetValueOrDefault(ExePathProperty, VersionKey, out string? value, null)) - return null; - return string.IsNullOrEmpty(value) ? null : _fileSystem.FileInfo.New(value!); - } + ThrowIfDisposed(); + if (!_registryKey!.GetValueOrDefault(ExePathProperty, VersionKey, out string? value, null)) + return null; + return string.IsNullOrEmpty(value) ? null : _fileSystem.FileInfo.New(value!); } + } - /// - public bool? Installed + /// + public bool? Installed + { + get { - get - { - ThrowIfDisposed(); - if (!_registryKey!.GetValueOrDefault(InstalledProperty, VersionKey, out bool? value, null)) - return null; - return value; - } + ThrowIfDisposed(); + if (!_registryKey!.GetValueOrDefault(InstalledProperty, VersionKey, out bool? value, null)) + return null; + return value; } + } - /// - public IDirectoryInfo? InstallPath + /// + public IDirectoryInfo? InstallPath + { + get { - get - { - ThrowIfDisposed(); - if (!_registryKey!.GetValueOrDefault(InstallPathProperty, VersionKey, out string? value, null)) - return null; - return string.IsNullOrEmpty(value) ? null : _fileSystem.DirectoryInfo.New(value!); - } + ThrowIfDisposed(); + if (!_registryKey!.GetValueOrDefault(InstallPathProperty, VersionKey, out string? value, null)) + return null; + return string.IsNullOrEmpty(value) ? null : _fileSystem.DirectoryInfo.New(value!); } + } - /// - public IFileInfo? Launcher + /// + public IFileInfo? Launcher + { + get { - get - { - ThrowIfDisposed(); - if (!_registryKey!.GetValueOrDefault(LauncherProperty, VersionKey, out string? value, null)) - return null; - if (string.IsNullOrEmpty(value)) - return null; - return _fileSystem.FileInfo.New(value!); - } + ThrowIfDisposed(); + if (!_registryKey!.GetValueOrDefault(LauncherProperty, VersionKey, out string? value, null)) + return null; + if (string.IsNullOrEmpty(value)) + return null; + return _fileSystem.FileInfo.New(value!); } + } - /// - public int? Revision + /// + public int? Revision + { + get { - get - { - ThrowIfDisposed(); - if (!_registryKey!.GetValueOrDefault(RevisionProperty, VersionKey, out int? value, null)) - return null; - return value; - } + ThrowIfDisposed(); + if (!_registryKey!.GetValueOrDefault(RevisionProperty, VersionKey, out int? value, null)) + return null; + return value; } + } - /// - /// Creates a new instance - /// - /// The this registry is associated to. - /// The root key of the game's registry. - /// Service provider for this instance. - public GameRegistry(GameType gameType, IRegistryKey registryKey, IServiceProvider serviceProvider) - { - Type = gameType; - _registryKey = registryKey ?? throw new ArgumentNullException(nameof(registryKey)); - _fileSystem = serviceProvider.GetRequiredService(); - } + /// + /// Creates a new instance + /// + /// The this registry is associated to. + /// The root key of the game's registry. + /// Service provider for this instance. + public GameRegistry(GameType gameType, IRegistryKey registryKey, IServiceProvider serviceProvider) + { + Type = gameType; + _registryKey = registryKey ?? throw new ArgumentNullException(nameof(registryKey)); + _fileSystem = serviceProvider.GetRequiredService(); + } - /// - ~GameRegistry() - { - Dispose(false); - } + /// + ~GameRegistry() + { + Dispose(false); + } - /// - public void AssignGame(IGame? game) - { - Game = game; - } + /// + public void AssignGame(IGame? game) + { + Game = game; + } - /// - /// Disposed all managed resources acquired by this instance. - /// - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } + /// + /// Disposed all managed resources acquired by this instance. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } - /// - /// Disposed all managed resources acquired by this instance. - /// - /// if called from the destructor; otherwise. - private void Dispose(bool disposing) + /// + /// Disposed all managed resources acquired by this instance. + /// + /// if called from the destructor; otherwise. + private void Dispose(bool disposing) + { + if (disposing) { - if (disposing) - { - _registryKey?.Dispose(); - _registryKey = null; - _disposed = true; - } + _registryKey?.Dispose(); + _registryKey = null; + _disposed = true; } + } #if NET - [MemberNotNull(nameof(_registryKey))] + [MemberNotNull(nameof(_registryKey))] #endif - private void ThrowIfDisposed() - { - if (_disposed) - throw new ObjectDisposedException(ToString()); - if (_registryKey is null) - throw new Exception("registry must not be null in non-disposed state"); - } + private void ThrowIfDisposed() + { + if (_disposed) + throw new ObjectDisposedException(ToString()); + if (_registryKey is null) + throw new Exception("registry must not be null in non-disposed state"); } } \ No newline at end of file From 416dcadddf96c37d33a7098b7aadd9f8849de1fc Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Thu, 14 Mar 2024 17:57:41 +0100 Subject: [PATCH 11/41] rename test namespaces --- aet.png | Bin 0 -> 3613 bytes .../test/Steam/SteamGameFinderTest.cs | 3 ++- .../test/Steam/SteamLibraryFinderTest.cs | 4 ++- .../test/Steam/SteamLibraryTest.cs | 3 ++- .../test/Steam/SteamVdfReaderTest.cs | 4 ++- .../test/Steam/SteamWrapperIntegrationTest.cs | 4 ++- .../test/Steam/SteamWrapperTest.cs | 3 ++- .../test/SteamGameClientTest.cs | 4 ++- .../test/SteamGameLanguageFinderTest.cs | 3 ++- ...SteamPetroglyphStarWarsGameDetectorTest.cs | 3 ++- .../test/Arguments/ArgumentCollectionTest.cs | 2 +- .../ArgumentCommandLineBuilderTest.cs | 2 +- .../test/Arguments/ArgumentValidatorTest.cs | 2 +- .../Arguments/ArgumentValueSerializerTest.cs | 2 +- .../test/Arguments/FlagArgumentTest.cs | 2 +- .../test/Arguments/GameArgumentTest.cs | 2 +- .../KeyBasedArgumentCollectionBuilderTest.cs | 2 +- .../Arguments/ModArgumentListFactoryTest.cs | 22 +++++----------- .../test/Arguments/ModArgumentListTest.cs | 2 +- .../test/Arguments/ModArgumentTest.cs | 2 +- .../test/Arguments/NamedArgumentTest.cs | 2 +- .../test/ClientBaseTest.cs | 8 +++--- .../test/DebugableClientBaseTest.cs | 3 ++- .../test/DefaultClientTest.cs | 3 ++- .../test/GameExecutableFileServiceTest.cs | 3 ++- .../test/GameExecutableNameBuilderTest.cs | 3 ++- .../DefaultGameProcessLauncherTest.cs | 3 ++- .../test/Processes/GameProcessTest.cs | 24 +++++------------- .../test/FileBasedLanguageFinderTest.cs | 2 +- .../test/GameRegistryFactoryTest.cs | 2 +- .../CompositeGameIconFinderTest.cs | 2 +- .../Detection/CompositeDetectorTest.cs | 2 +- .../Detection/DirectoryGameDetectorTest.cs | 2 +- .../Detection/GameDetectorTest.cs | 2 +- .../Detection/GamePlatformIdentifierTest.cs | 2 +- .../Detection/RegistryGameDetectorTest.cs | 2 +- .../EnglishGameNameResolverTest.cs | 2 +- .../GameServices/FallbackIconFinderTest.cs | 2 +- .../test/GameServices/GameFactoryTest.cs | 2 +- .../test/GameServices/GameHelperTest.cs | 3 ++- .../GameServices/GameLanguageFinderTest.cs | 2 +- .../SteamWorkshopWebpageDownloaderTest.cs | 2 +- src/PetroGlyph.Games.EawFoc/test/GameTest.cs | 3 ++- .../test/LanguageInfoUtilitiesTest.cs | 2 +- .../test/ModBaseTest.cs | 3 ++- .../test/ModDependencyEntryTest.cs | 2 +- .../test/ModEqualityComparerTest.cs | 2 +- .../ModServices/CompositeModIconFinderTest.cs | 2 +- .../CompositeModNameResolverTest.cs | 3 ++- .../DirectoryModNameResolverTest.cs | 2 +- .../ModServices/FileSystemModFinderTest.cs | 2 +- ...odDependencyGraphBuilderIntegrationTest.cs | 2 +- .../ModDependencyGraphBuilderTest.cs | 2 +- .../ModDependencyResolverIntegrationTest.cs | 3 ++- .../ModServices/ModDependencyResolverTest.cs | 2 +- .../ModDependencyTraverserIntegrationTest.cs | 2 +- .../ModServices/ModDependencyTraverserTest.cs | 2 +- .../test/ModServices/ModFactoryTest.cs | 2 +- .../ModServices/ModIdentifierBuilderTest.cs | 2 +- .../ModServices/ModLanguageFinderBaseTest.cs | 2 +- src/PetroGlyph.Games.EawFoc/test/ModTest.cs | 2 +- .../test/PlayableObjectTest.cs | 3 ++- .../test/VirtualModTest.cs | 3 ++- 63 files changed, 102 insertions(+), 95 deletions(-) create mode 100644 aet.png diff --git a/aet.png b/aet.png new file mode 100644 index 0000000000000000000000000000000000000000..ac479433817de947441ad136ccdc8962baeca251 GIT binary patch literal 3613 zcmV+&4&w2NP)_l zV8H^{I-UryXU`tg)YJskuCSp-$~ip048ZLG$^h)nbVGLS+Lg3Udt^a_0K5p`bpQ(i zd_mk(1FEZ0zX-tRGTcVb@H7J=gs%ZuY?SQuWp z1^{RTFgJtkc0`nCfNEPm06!tGKaDI#v70LZ9A-TmfA7uXLb9mt?0k)~47A@9qDlbO zSuazgQ7q#w04Iw3e*;j>^Di5-KndmHJpVb5y~X_oQJ!@~l>nDe;7Y`e>o<5T1~7v} zyBxp@0LKH^4`2fc_mFsQEP!nxx8F0ON`P$?rV>v9C=l0jMhqdpUkBi9mem8e3cw!) zn|d6;Gak8F~^4j`S;NfGOFr z(^79y2<;67Q6j)R06zpU62LOHEr)97Y)k#U)R3CR2v_x|Tk1Y4zEu%yDuC@|O%H|q zU9N}<3sRjjP+Wfrz$>(T&vSTYD=l0l8y*qw`I)6|B~{UVe4qU8%N(A`2%hYb8d*f6y9sZ<&)sY5Uy}19bxPLy`RExM@=itf+1hH5wY2QX=1{|aZ(}u$?&nav9 zRjQy$0CzI(mr%GXIk5%6Jpdj9@BlTc?mNNlh%b===?QUJ2SN3x78SeAW>) z8IUhJUgI^F`hPX9KcH;@I^oXZ>^X%tfa%7tL9wYG0Nx@YLq*gG&_ZoyAk#`VxM)WT zHyPJmDAy9a-UZ+nmgn;5A?*&}3?7x5dI38>mu`_K1N=5CqDBBv;Ldcp-<7_fdjZ^L z+*4Z5N{-$HwWLlYOeb2_-N=dxleFXOM-u_MF_wE0J5alhbB$18p6~(Xv*QZbVW+Z# zPf7B>uH#?2I6r`QBt_T+=tvfDYdcVRO>_}PTxbZpQywOpXm6bl4$jc+hA=xuv5HY4 zzCRPN6-g9UYAWXlf< zL^fNhP&4Q^M%fOd^DBI6NbQmZ&7^VTgg;Y0$hdD;I@(r?vH}`LJ!#SQ;4@`3qH>sk zRV|*m*!W*2Q78NS78^?o6hRYUfDu}hQ2cxfjhktfw31s40(7Jw$ZVssmVd{NUm?oR zpw=bPB+hR#cz>K}F1gGfvZ0$pd0+^V1)XM$Mu`vj@sE)&+uRGLTj3ypx5afUpI0-W zztQ<+Tr*&XF11W42JozL?-jP`YG%tNENya|$$=n90{qlLXsHjq2*7$#wuV}cL{G~H zOM&?<0OKjJCDg3jPsz72u^7tsYQ8{WzY zmK$urcGGit63f@|`bL)yZvgN<*8z+YS#nb?b)8lmUQO8`>)J9h+>k>xye<}tJs);Z z{x|>&j8T3Fz}*y-Zdhe0>up@`2Jj*Cgz^}uIg7%vke%Mh5x&n7rtI!85S$igDAqX3 zuqAp@SbISkpVyh)$x~j^oB{KV(Xzvb7qQ48r1(Xn-s>#yb*cz^`b8YOJF6=ZaJb(34t^#xiD}ZTI<}6_&Do#C7+Ox4 zV38-_Y}(}Ec_mA}P21o+2bV-8qi?2q`!-Wy)_ZAaDg^ie8`aDX8Rn9slML%P<;^x# ziEC*fJpkZ(m-ppT=uUFDpG+~3SW9gw*DwihRDsC*=&ELih@*n2kQY zoo;y5A}E`w`GA?v@}80%PgCgi<@BFO?W5L3O*L~#z2IDauTG1}qnazR+>9+hf1fzWgk)I28D7qF`OXa%t?hpZIx(x7`u3GVKm~yp z9m+2O@DH)&K)P6*VtjWB+2U(d1T=n0A-px6MtLQ`02)|*LfCcWJ&sNrnuV2}F1#dV z*>D4o#iDFFQ{fxZZIo96tf4{Dn(jZepiQj#)u^TazlerWi3mGZ&{DN&P;u(sW*p#S zhx*A-!sSgG2|5L<0vZ&a2~ZcrKXZZEId5=k>yK>UEP0prs;Lc`cE^pvRk1^quS`)> z8zEHCRvLqWt}~8Gx`^o)YT}eXkAk>NEJ@O6p_@XZR%k0t276eRLYuk?V=7LUw)^&1 zDIh8Y*lfraoe8&vg1AOF=H>~(EVuEJv$RAkZB?E3hZNd0h4GC9?T`5>ydx>1LI6_^ zbSDe?$f$QRv+NdgCB59vpkAE!7NJa~D(>;wo^lbJm>5>)BSHj#v3Nr3){-@ir2C^Q z_k-AESjqBSZuGGvg|1WIk8=jrQ&`uh^Ra#j(9BM-1<2!U;1Lp|jSV~`8hwDo)Ad^T@jCxsb;?)7I|tJ3 zt1*L#xwB~%CzxP0fcm=Bj&7h3ZlUdP3Ol%1bb7kjMpsG7EGrcu{2)L4exqD3xXZU} znvp8H7y>bm@!kpK{c+1)aT*;0TCC@Uda9~v$%|A7&`RG(LTD^u!YLq=Y?*18NRSKI z(rSDm9U(l-B^&x^Mk@ziDlU%yLplVAGcfXa5DjT3h%+!1*uK+2sG;LNBSg>xZcdOd z4ayD}7q-_h%ZO9^3$*hQuq$Fb11ZA;dS5gBKlRMIJ4|n=KI)~cM_9Lono)w^6&L5= zbw_$qdsz0Sc7l$E%?s$eK82utK_hweLxei68{1B==Pq{q;gFI5!2DA$1ZZUnVrUz` z22FrC1KInyA)Xg>FH91~sqIzizKmyJ4F7;|_jJ>Q)-o{*?r>p0BYfrc2ZT%pWX5|S zLRE?>i}QOB&1{;w-CNq{z5%vCORx`(I{UFWbB{%G+_9T`V9LXy*yEaHAx z{774n7-lJ(>Jnkg2(lFuRwM4a4)@AJ__;wPU%p|KJ>$bz3=P=~%0DH3`NG8bfcNSd zWP~eUh{}F;+0KfXLY89&^H1=w*MwK(7~0ipE;3JbWoMwsHUYrx&1_3uM=?VoU0lu8 zj$o?FZALCpRuKgPfT7L%4I*@AmU6n#T2%|xP`|0_p&}{-0Ds@*9wW=(PLXJv3OdpC ztP===T-_N6qC^02zo7fXOvtAzBUQw>TIShfzoh3K&rwL~HC}^Uen~GG`f(kylggWQ zM3DdrzZSoIU6jIhlNxb)KQoqW>laZa0O*guo*~OYV&R4#REE9#dAf))0l=k6mvI5# z=oFq0E2bP6a{jwxM-pt_ycs)p+J2-oW5}V4q9&V-@Qc#YQk0jwZ*}2`0LKs>qRxVj jdK@D_mhqne009607wx>LkmG_g00000NkvXXu0mjfZf2dG literal 0 HcmV?d00001 diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamGameFinderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamGameFinderTest.cs index 01399c51..3ecad753 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamGameFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamGameFinderTest.cs @@ -2,10 +2,11 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; +using PetroGlyph.Games.EawFoc.Clients.Steam; using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.Steam; public class SteamGameFinderTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryFinderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryFinderTest.cs index 89d7da4f..23311387 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryFinderTest.cs @@ -3,10 +3,12 @@ using System.Linq; using Microsoft.Extensions.DependencyInjection; using Moq; +using PetroGlyph.Games.EawFoc; +using PetroGlyph.Games.EawFoc.Clients.Steam; using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.Steam; public class SteamLibraryFinderTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryTest.cs index 8d5d4df2..4eaa154a 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryTest.cs @@ -3,11 +3,12 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; +using PetroGlyph.Games.EawFoc.Clients.Steam; using PG.TestingUtilities; using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.Steam; public class SteamLibraryTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamVdfReaderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamVdfReaderTest.cs index e07b70b7..c4cf65f5 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamVdfReaderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamVdfReaderTest.cs @@ -2,10 +2,12 @@ using System.Linq; using Microsoft.Extensions.DependencyInjection; using Moq; +using PetroGlyph.Games.EawFoc; +using PetroGlyph.Games.EawFoc.Clients.Steam; using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.Steam; public class SteamVdfReaderTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperIntegrationTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperIntegrationTest.cs index 295b827b..d869ba87 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperIntegrationTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperIntegrationTest.cs @@ -1,9 +1,11 @@ using System; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; +using PetroGlyph.Games.EawFoc.Clients; +using PetroGlyph.Games.EawFoc.Clients.Steam; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.Steam; public class SteamWrapperIntegrationTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperTest.cs index e4695bf9..9538c3f3 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperTest.cs @@ -5,10 +5,11 @@ using Microsoft.Extensions.DependencyInjection; using Moq; using PetroGlyph.Games.EawFoc.Clients.Processes; +using PetroGlyph.Games.EawFoc.Clients.Steam; using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.Windows.Test.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.Steam; public class SteamWrapperTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameClientTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameClientTest.cs index c27f4213..14b82698 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameClientTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameClientTest.cs @@ -1,12 +1,14 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; +using PetroGlyph.Games.EawFoc.Clients; using PetroGlyph.Games.EawFoc.Clients.Processes; +using PetroGlyph.Games.EawFoc.Clients.Steam; using PetroGlyph.Games.EawFoc.Games; using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.Test; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Test; public class SteamGameClientTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameLanguageFinderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameLanguageFinderTest.cs index cb697eeb..a8f5f1e7 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameLanguageFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameLanguageFinderTest.cs @@ -4,11 +4,12 @@ using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; using Moq; +using PetroGlyph.Games.EawFoc.Clients.Steam; using PetroGlyph.Games.EawFoc.Games; using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.Test; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Test; public class SteamGameLanguageFinderTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamPetroglyphStarWarsGameDetectorTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamPetroglyphStarWarsGameDetectorTest.cs index 11289150..65ab4caa 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamPetroglyphStarWarsGameDetectorTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamPetroglyphStarWarsGameDetectorTest.cs @@ -3,13 +3,14 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; +using PetroGlyph.Games.EawFoc.Clients.Steam; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Games.Registry; using PetroGlyph.Games.EawFoc.Services.Detection; using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.Test; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Test; public class SteamPetroglyphStarWarsGameDetectorTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCollectionTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCollectionTest.cs index 320eaaae..83ffb6bb 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCollectionTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCollectionTest.cs @@ -3,7 +3,7 @@ using PetroGlyph.Games.EawFoc.Clients.Arguments.GameArguments; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Test.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Test.Arguments; public class ArgumentCollectionTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCommandLineBuilderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCommandLineBuilderTest.cs index 7b46931b..14507353 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCommandLineBuilderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCommandLineBuilderTest.cs @@ -6,7 +6,7 @@ using PetroGlyph.Games.EawFoc.Clients.Arguments.GameArguments; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Test.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Test.Arguments; public class ArgumentCommandLineBuilderTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValidatorTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValidatorTest.cs index 87027fa2..891b3337 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValidatorTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValidatorTest.cs @@ -4,7 +4,7 @@ using PetroGlyph.Games.EawFoc.Clients.Arguments.GameArguments; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Test.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Test.Arguments; public class ArgumentValidatorTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValueSerializerTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValueSerializerTest.cs index bcc6ded2..8433a53d 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValueSerializerTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValueSerializerTest.cs @@ -4,7 +4,7 @@ using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Test.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Test.Arguments; public class ArgumentValueSerializerTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/FlagArgumentTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/FlagArgumentTest.cs index 35f8e8aa..eff9fb0e 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/FlagArgumentTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/FlagArgumentTest.cs @@ -1,7 +1,7 @@ using PetroGlyph.Games.EawFoc.Clients.Arguments; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Test.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Test.Arguments; public class FlagArgumentTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/GameArgumentTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/GameArgumentTest.cs index d30340b7..aaf55ded 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/GameArgumentTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/GameArgumentTest.cs @@ -2,7 +2,7 @@ using PetroGlyph.Games.EawFoc.Clients.Arguments; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Test.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Test.Arguments; public class GameArgumentTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/KeyBasedArgumentCollectionBuilderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/KeyBasedArgumentCollectionBuilderTest.cs index bee29cdf..b711f972 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/KeyBasedArgumentCollectionBuilderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/KeyBasedArgumentCollectionBuilderTest.cs @@ -4,7 +4,7 @@ using PetroGlyph.Games.EawFoc.Clients.Arguments.GameArguments; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Test.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Test.Arguments; public class KeyBasedArgumentCollectionBuilderTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListFactoryTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListFactoryTest.cs index ee60b479..c5091c60 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListFactoryTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListFactoryTest.cs @@ -2,6 +2,7 @@ using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; using Moq; +using PetroGlyph.Games.EawFoc; using PetroGlyph.Games.EawFoc.Clients.Arguments; using PetroGlyph.Games.EawFoc.Clients.Arguments.GameArguments; using PetroGlyph.Games.EawFoc.Games; @@ -10,11 +11,9 @@ using PetroGlyph.Games.EawFoc.Services.Steam; using Testably.Abstractions.Testing; using Xunit; -#if NET -using System; -#endif +using System.Runtime.InteropServices; -namespace PetroGlyph.Games.EawFoc.Clients.Test.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Test.Arguments; public class ModArgumentListFactoryTest { @@ -92,12 +91,8 @@ public void TestSingleArgModIsRelativeToGame() var modList = _service.BuildArgumentList(new List { modA.Object }, false); var arg = Assert.Single(modList.Value); -#if NET - if (!OperatingSystem.IsWindows()) - Assert.Equal("mods/a", arg.Value); - else -#endif - Assert.Equal("MODS\\A", arg.Value); + + Assert.Equal(!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "mods/a" : "MODS\\A", arg.Value); Assert.Equal(ArgumentNameCatalog.ModPathArg, arg.Name); } @@ -115,12 +110,7 @@ public void TestSingleArgModIsAbsolute() var modList = _service.BuildArgumentList(new List { modA.Object }, false); var arg = Assert.Single(modList.Value); -#if NET - if (!OperatingSystem.IsWindows()) - Assert.Equal("../d:/a", arg.Value); - else -#endif - Assert.Equal("D:\\A", arg.Value); + Assert.Equal(!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "../d:/a" : "D:\\A", arg.Value); Assert.Equal(ArgumentNameCatalog.ModPathArg, arg.Name); } diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListTest.cs index f684adab..ef45d515 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListTest.cs @@ -4,7 +4,7 @@ using PetroGlyph.Games.EawFoc.Clients.Arguments.GameArguments; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Test.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Test.Arguments; public class ModArgumentListTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentTest.cs index 63d9e126..91984360 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentTest.cs @@ -1,7 +1,7 @@ using PetroGlyph.Games.EawFoc.Clients.Arguments.GameArguments; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Test.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Test.Arguments; public class ModArgumentTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/NamedArgumentTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/NamedArgumentTest.cs index e3462b57..582b665d 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/NamedArgumentTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/NamedArgumentTest.cs @@ -1,7 +1,7 @@ using PetroGlyph.Games.EawFoc.Clients.Arguments; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Test.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Test.Arguments; public class NamedArgumentTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/ClientBaseTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/ClientBaseTest.cs index 4f2d2113..6bada0da 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/ClientBaseTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/ClientBaseTest.cs @@ -3,15 +3,17 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc.Games; -using Xunit; +using PetroGlyph.Games.EawFoc; +using PetroGlyph.Games.EawFoc.Clients; using PetroGlyph.Games.EawFoc.Clients.Arguments; using PetroGlyph.Games.EawFoc.Clients.Arguments.GameArguments; using PetroGlyph.Games.EawFoc.Clients.Processes; +using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Mods; using Testably.Abstractions.Testing; +using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Test; +namespace PG.StarWarsGame.Infrastructure.Clients.Test; public class ClientBaseTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/DebugableClientBaseTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/DebugableClientBaseTest.cs index 4d94819d..ef33c127 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/DebugableClientBaseTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/DebugableClientBaseTest.cs @@ -3,13 +3,14 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; +using PetroGlyph.Games.EawFoc.Clients; using PetroGlyph.Games.EawFoc.Clients.Arguments; using PetroGlyph.Games.EawFoc.Clients.Processes; using PetroGlyph.Games.EawFoc.Games; using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Test; +namespace PG.StarWarsGame.Infrastructure.Clients.Test; public class DebugableClientBaseTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/DefaultClientTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/DefaultClientTest.cs index 032bd009..b2a2660e 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/DefaultClientTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/DefaultClientTest.cs @@ -1,12 +1,13 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; +using PetroGlyph.Games.EawFoc.Clients; using PetroGlyph.Games.EawFoc.Clients.Processes; using PetroGlyph.Games.EawFoc.Games; using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Test; +namespace PG.StarWarsGame.Infrastructure.Clients.Test; public class DefaultClientTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableFileServiceTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableFileServiceTest.cs index dc443c6b..b9a3e2bf 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableFileServiceTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableFileServiceTest.cs @@ -1,10 +1,11 @@ using Microsoft.Extensions.DependencyInjection; using Moq; +using PetroGlyph.Games.EawFoc.Clients; using PetroGlyph.Games.EawFoc.Games; using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Test; +namespace PG.StarWarsGame.Infrastructure.Clients.Test; public class GameExecutableFileServiceTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableNameBuilderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableNameBuilderTest.cs index b982ce92..d1f91ba4 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableNameBuilderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableNameBuilderTest.cs @@ -1,8 +1,9 @@ using Moq; +using PetroGlyph.Games.EawFoc.Clients; using PetroGlyph.Games.EawFoc.Games; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Test; +namespace PG.StarWarsGame.Infrastructure.Clients.Test; public class GameExecutableNameBuilderTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/DefaultGameProcessLauncherTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/DefaultGameProcessLauncherTest.cs index 571cccb7..ca1c1ca9 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/DefaultGameProcessLauncherTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/DefaultGameProcessLauncherTest.cs @@ -1,12 +1,13 @@ using Microsoft.Extensions.DependencyInjection; using Moq; +using PetroGlyph.Games.EawFoc.Clients; using PetroGlyph.Games.EawFoc.Clients.Arguments; using PetroGlyph.Games.EawFoc.Clients.Processes; using PetroGlyph.Games.EawFoc.Games; using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Test.Processes; +namespace PG.StarWarsGame.Infrastructure.Clients.Test.Processes; public class DefaultGameProcessLauncherTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/GameProcessTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/GameProcessTest.cs index f1e79e83..0a30d75d 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/GameProcessTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/GameProcessTest.cs @@ -1,14 +1,15 @@ -using System; -using System.Diagnostics; +using System.Diagnostics; +using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; using Moq; +using PetroGlyph.Games.EawFoc.Clients; using PetroGlyph.Games.EawFoc.Clients.Arguments; using PetroGlyph.Games.EawFoc.Clients.Processes; using PetroGlyph.Games.EawFoc.Games; using Xunit; -namespace PetroGlyph.Games.EawFoc.Clients.Test.Processes; +namespace PG.StarWarsGame.Infrastructure.Clients.Test.Processes; public class GameProcessTest { @@ -17,13 +18,7 @@ public async Task TestOnExit() { var game = new Mock(); - string processName; -#if NET - if (!OperatingSystem.IsWindows()) - processName = "bash"; - else -#endif - processName = "cmd"; + var processName = !RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "bash" : "cmd"; var p = Process.Start(processName); var gp = new GameProcess(p, new GameProcessInfo(game.Object, GameBuildType.Debug, ArgumentCollection.Empty)); @@ -43,13 +38,8 @@ public async Task TestOnExit() public async Task TestAlreadyExited() { var game = new Mock(); - string processName; -#if NET - if (!OperatingSystem.IsWindows()) - processName = "bash"; - else -#endif - processName = "cmd"; + var processName = !RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "bash" : "cmd"; + var p = Process.Start(processName); p.Kill(); var gp = new GameProcess(p, new GameProcessInfo(game.Object, GameBuildType.Debug, ArgumentCollection.Empty)); diff --git a/src/PetroGlyph.Games.EawFoc/test/FileBasedLanguageFinderTest.cs b/src/PetroGlyph.Games.EawFoc/test/FileBasedLanguageFinderTest.cs index ceb82b56..85ab7d99 100644 --- a/src/PetroGlyph.Games.EawFoc/test/FileBasedLanguageFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/FileBasedLanguageFinderTest.cs @@ -9,7 +9,7 @@ using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test; +namespace PG.StarWarsGame.Infrastructure.Test; public class FileBasedLanguageFinderTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/GameRegistryFactoryTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameRegistryFactoryTest.cs index b06372b6..046ffebd 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameRegistryFactoryTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameRegistryFactoryTest.cs @@ -6,7 +6,7 @@ using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test; +namespace PG.StarWarsGame.Infrastructure.Test; public class GameRegistryFactoryTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/CompositeGameIconFinderTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/CompositeGameIconFinderTest.cs index 77121169..d7680db8 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/CompositeGameIconFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/CompositeGameIconFinderTest.cs @@ -5,7 +5,7 @@ using PetroGlyph.Games.EawFoc.Services.Icon; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.GameServices; +namespace PG.StarWarsGame.Infrastructure.Test.GameServices; public class CompositeGameIconFinderTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/CompositeDetectorTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/CompositeDetectorTest.cs index 39d566c1..a88e69fa 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/CompositeDetectorTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/CompositeDetectorTest.cs @@ -6,7 +6,7 @@ using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.GameServices.Detection; +namespace PG.StarWarsGame.Infrastructure.Test.GameServices.Detection; public class CompositeDetectorTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/DirectoryGameDetectorTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/DirectoryGameDetectorTest.cs index 2d7d881e..1bab3425 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/DirectoryGameDetectorTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/DirectoryGameDetectorTest.cs @@ -8,7 +8,7 @@ using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.GameServices.Detection; +namespace PG.StarWarsGame.Infrastructure.Test.GameServices.Detection; public class DirectoryGameDetectorTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GameDetectorTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GameDetectorTest.cs index 4da62080..e4fb3c05 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GameDetectorTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GameDetectorTest.cs @@ -8,7 +8,7 @@ using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.GameServices.Detection; +namespace PG.StarWarsGame.Infrastructure.Test.GameServices.Detection; public class GameDetectorTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GamePlatformIdentifierTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GamePlatformIdentifierTest.cs index fc00e3d9..24301c26 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GamePlatformIdentifierTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GamePlatformIdentifierTest.cs @@ -7,7 +7,7 @@ using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.GameServices.Detection; +namespace PG.StarWarsGame.Infrastructure.Test.GameServices.Detection; public class GamePlatformIdentifierTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/RegistryGameDetectorTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/RegistryGameDetectorTest.cs index d97c2f44..4c9eab03 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/RegistryGameDetectorTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/RegistryGameDetectorTest.cs @@ -7,7 +7,7 @@ using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.GameServices.Detection; +namespace PG.StarWarsGame.Infrastructure.Test.GameServices.Detection; public class RegistryGameDetectorTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/EnglishGameNameResolverTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/EnglishGameNameResolverTest.cs index 2ad12901..be46b955 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/EnglishGameNameResolverTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/EnglishGameNameResolverTest.cs @@ -3,7 +3,7 @@ using PetroGlyph.Games.EawFoc.Services.Name; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.GameServices; +namespace PG.StarWarsGame.Infrastructure.Test.GameServices; public class EnglishGameNameResolverTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/FallbackIconFinderTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/FallbackIconFinderTest.cs index 7ede2059..65b7c98a 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/FallbackIconFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/FallbackIconFinderTest.cs @@ -7,7 +7,7 @@ using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.GameServices; +namespace PG.StarWarsGame.Infrastructure.Test.GameServices; public class FallbackIconFinderTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/GameFactoryTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/GameFactoryTest.cs index 4083a70e..d3a6cae2 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/GameFactoryTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/GameFactoryTest.cs @@ -9,7 +9,7 @@ using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.GameServices; +namespace PG.StarWarsGame.Infrastructure.Test.GameServices; public class GameFactoryTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/GameHelperTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/GameHelperTest.cs index da8368fe..696ab02a 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/GameHelperTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/GameHelperTest.cs @@ -1,12 +1,13 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; +using PetroGlyph.Games.EawFoc; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Services.Steam; using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.GameServices; +namespace PG.StarWarsGame.Infrastructure.Test.GameServices; public class GameHelperTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/GameLanguageFinderTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/GameLanguageFinderTest.cs index b497189e..49a78fc0 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/GameLanguageFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/GameLanguageFinderTest.cs @@ -7,7 +7,7 @@ using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.GameServices; +namespace PG.StarWarsGame.Infrastructure.Test.GameServices; public class GameLanguageFinderTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/SteamWorkshopWebpageDownloaderTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/SteamWorkshopWebpageDownloaderTest.cs index edaeb6d2..e5429861 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/SteamWorkshopWebpageDownloaderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/SteamWorkshopWebpageDownloaderTest.cs @@ -2,7 +2,7 @@ using PetroGlyph.Games.EawFoc.Services.Steam; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.GameServices; +namespace PG.StarWarsGame.Infrastructure.Test.GameServices; public class SteamWorkshopWebpageDownloaderTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/GameTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameTest.cs index 6c8f6b1e..234f9f36 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameTest.cs @@ -2,13 +2,14 @@ using EawModinfo.Model; using EawModinfo.Spec; using Moq; +using PetroGlyph.Games.EawFoc; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Mods; using PetroGlyph.Games.EawFoc.Services.Detection; using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test; +namespace PG.StarWarsGame.Infrastructure.Test; public class GameTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/LanguageInfoUtilitiesTest.cs b/src/PetroGlyph.Games.EawFoc/test/LanguageInfoUtilitiesTest.cs index 6fcd315b..8faa64cc 100644 --- a/src/PetroGlyph.Games.EawFoc/test/LanguageInfoUtilitiesTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/LanguageInfoUtilitiesTest.cs @@ -3,7 +3,7 @@ using PetroGlyph.Games.EawFoc.Services.Language; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test; +namespace PG.StarWarsGame.Infrastructure.Test; public class LanguageInfoUtilitiesTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/ModBaseTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModBaseTest.cs index 58393732..dc080e78 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModBaseTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModBaseTest.cs @@ -4,6 +4,7 @@ using EawModinfo.Model; using EawModinfo.Spec; using Moq; +using PetroGlyph.Games.EawFoc; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Mods; using PetroGlyph.Games.EawFoc.Services.Dependencies; @@ -12,7 +13,7 @@ using Semver; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test; +namespace PG.StarWarsGame.Infrastructure.Test; public class ModBaseTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/ModDependencyEntryTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModDependencyEntryTest.cs index 8b367f1a..48fe5ee4 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModDependencyEntryTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModDependencyEntryTest.cs @@ -4,7 +4,7 @@ using Semver; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test; +namespace PG.StarWarsGame.Infrastructure.Test; public class ModDependencyEntryTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/ModEqualityComparerTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModEqualityComparerTest.cs index 0eaf7e51..948905f0 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModEqualityComparerTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModEqualityComparerTest.cs @@ -6,7 +6,7 @@ using Semver; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test; +namespace PG.StarWarsGame.Infrastructure.Test; public class ModEqualityComparerTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/CompositeModIconFinderTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/CompositeModIconFinderTest.cs index 292bd2df..19f5186c 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/CompositeModIconFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/CompositeModIconFinderTest.cs @@ -5,7 +5,7 @@ using PetroGlyph.Games.EawFoc.Services.Icon; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.ModServices; +namespace PG.StarWarsGame.Infrastructure.Test.ModServices; public class CompositeModIconFinderTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/CompositeModNameResolverTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/CompositeModNameResolverTest.cs index 599a82e4..c688c1ec 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/CompositeModNameResolverTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/CompositeModNameResolverTest.cs @@ -4,10 +4,11 @@ using EawModinfo.Model; using EawModinfo.Spec; using Moq; +using PetroGlyph.Games.EawFoc; using PetroGlyph.Games.EawFoc.Services.Name; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.ModServices; +namespace PG.StarWarsGame.Infrastructure.Test.ModServices; public class CompositeModNameResolverTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/DirectoryModNameResolverTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/DirectoryModNameResolverTest.cs index 30ec8cd5..0aa52458 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/DirectoryModNameResolverTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/DirectoryModNameResolverTest.cs @@ -8,7 +8,7 @@ using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.ModServices; +namespace PG.StarWarsGame.Infrastructure.Test.ModServices; public class DirectoryModNameResolverTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/FileSystemModFinderTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/FileSystemModFinderTest.cs index d92404ce..89fe98fb 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/FileSystemModFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/FileSystemModFinderTest.cs @@ -9,7 +9,7 @@ using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.ModServices; +namespace PG.StarWarsGame.Infrastructure.Test.ModServices; public class FileSystemModFinderTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyGraphBuilderIntegrationTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyGraphBuilderIntegrationTest.cs index 48e68745..45996df7 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyGraphBuilderIntegrationTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyGraphBuilderIntegrationTest.cs @@ -10,7 +10,7 @@ using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.ModServices; +namespace PG.StarWarsGame.Infrastructure.Test.ModServices; public class ModDependencyGraphBuilderIntegrationTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyGraphBuilderTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyGraphBuilderTest.cs index 324dec4d..d2666efe 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyGraphBuilderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyGraphBuilderTest.cs @@ -8,7 +8,7 @@ using PetroGlyph.Games.EawFoc.Services.Dependencies; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.ModServices; +namespace PG.StarWarsGame.Infrastructure.Test.ModServices; public class ModDependencyGraphBuilderTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverIntegrationTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverIntegrationTest.cs index 4c5047df..eb02c5f3 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverIntegrationTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverIntegrationTest.cs @@ -5,6 +5,7 @@ using EawModinfo.Model; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; +using PetroGlyph.Games.EawFoc; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Mods; using PetroGlyph.Games.EawFoc.Services.Dependencies; @@ -12,7 +13,7 @@ using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.ModServices; +namespace PG.StarWarsGame.Infrastructure.Test.ModServices; public class ModDependencyResolverIntegrationTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverTest.cs index bd5e00e4..384ac8fe 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverTest.cs @@ -6,7 +6,7 @@ using PetroGlyph.Games.EawFoc.Services.Dependencies; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.ModServices; +namespace PG.StarWarsGame.Infrastructure.Test.ModServices; public class ModDependencyResolverTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyTraverserIntegrationTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyTraverserIntegrationTest.cs index 437f543e..53147b10 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyTraverserIntegrationTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyTraverserIntegrationTest.cs @@ -12,7 +12,7 @@ using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.ModServices; +namespace PG.StarWarsGame.Infrastructure.Test.ModServices; public class ModDependencyTraverserIntegrationTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyTraverserTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyTraverserTest.cs index 2f7c6833..a7f32a32 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyTraverserTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyTraverserTest.cs @@ -4,7 +4,7 @@ using PetroGlyph.Games.EawFoc.Services.Dependencies; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.ModServices; +namespace PG.StarWarsGame.Infrastructure.Test.ModServices; public class ModDependencyTraverserTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModFactoryTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModFactoryTest.cs index 57e7d2b9..762885f1 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModFactoryTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModFactoryTest.cs @@ -14,7 +14,7 @@ using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.ModServices; +namespace PG.StarWarsGame.Infrastructure.Test.ModServices; public class ModFactoryTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModIdentifierBuilderTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModIdentifierBuilderTest.cs index 7f6f2bd0..da0540f6 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModIdentifierBuilderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModIdentifierBuilderTest.cs @@ -11,7 +11,7 @@ using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.ModServices; +namespace PG.StarWarsGame.Infrastructure.Test.ModServices; public class ModIdentifierBuilderTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModLanguageFinderBaseTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModLanguageFinderBaseTest.cs index a7d628dc..b05361d4 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModLanguageFinderBaseTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModLanguageFinderBaseTest.cs @@ -9,7 +9,7 @@ using PetroGlyph.Games.EawFoc.Services.Language; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test.ModServices; +namespace PG.StarWarsGame.Infrastructure.Test.ModServices; public class ModLanguageFinderBaseTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/ModTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModTest.cs index 79a928bb..5974441d 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModTest.cs @@ -9,7 +9,7 @@ using Testably.Abstractions.Testing; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test; +namespace PG.StarWarsGame.Infrastructure.Test; public class ModTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/PlayableObjectTest.cs b/src/PetroGlyph.Games.EawFoc/test/PlayableObjectTest.cs index d613e44d..c596e65a 100644 --- a/src/PetroGlyph.Games.EawFoc/test/PlayableObjectTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/PlayableObjectTest.cs @@ -1,10 +1,11 @@ using System; using System.Collections.Generic; using EawModinfo.Spec; +using PetroGlyph.Games.EawFoc; using PetroGlyph.Games.EawFoc.Games; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test; +namespace PG.StarWarsGame.Infrastructure.Test; public class PlayableObjectTest { diff --git a/src/PetroGlyph.Games.EawFoc/test/VirtualModTest.cs b/src/PetroGlyph.Games.EawFoc/test/VirtualModTest.cs index f20d1cec..b88c4969 100644 --- a/src/PetroGlyph.Games.EawFoc/test/VirtualModTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/VirtualModTest.cs @@ -4,13 +4,14 @@ using EawModinfo.Model; using EawModinfo.Spec; using Moq; +using PetroGlyph.Games.EawFoc; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Mods; using PetroGlyph.Games.EawFoc.Services.Dependencies; using PetroGlyph.Games.EawFoc.Services.Detection; using Xunit; -namespace PetroGlyph.Games.EawFoc.Test; +namespace PG.StarWarsGame.Infrastructure.Test; public class VirtualModTest { From 067249ada93678fc314bfbd5707767e624f1bef8 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Thu, 14 Mar 2024 18:02:16 +0100 Subject: [PATCH 12/41] rename clients windows ns --- sample/SampleApplication/Program.cs | 1 + .../src/ILibraryConfigReader.cs | 2 +- .../src/ISteamAppManifestReader.cs | 3 ++- .../src/ISteamGameLocationFinder.cs | 4 +++- .../src/ISteamLibraryFinder.cs | 3 ++- .../src/NativeMethods/Advapi32.cs | 4 ++-- .../src/NativeMethods/Kernel32.cs | 2 +- .../src/NativeMethods/User32.cs | 2 +- .../src/NativeMethods/WindowHandleInfo.cs | 2 +- .../src/PetroglyphWindowsSteamClientsLibrary.cs | 3 ++- .../src/SteamGameFinder.cs | 5 +++-- .../src/SteamLibrary.cs | 3 ++- .../src/SteamLibraryFinder.cs | 4 +++- .../src/SteamRegistry.cs | 7 +++---- .../src/SteamVdfReader.cs | 4 +++- .../src/SteamWrapper.cs | 12 ++++++------ .../src/Threading/AwaitExtensions.cs | 4 ++-- .../src/Threading/EmptyStruct.cs | 2 +- .../src/Threading/NoMessagePumpSyncContext.cs | 4 ++-- .../Threading/RegistryChangeNotificationFilters.cs | 2 +- .../src/Threading/SpecializedSyncContext.cs | 2 +- .../src/Threading/ThreadingTools.cs | 2 +- .../src/Threading/TplExtensions.cs | 2 +- 23 files changed, 45 insertions(+), 34 deletions(-) diff --git a/sample/SampleApplication/Program.cs b/sample/SampleApplication/Program.cs index d406b983..0e34e67a 100644 --- a/sample/SampleApplication/Program.cs +++ b/sample/SampleApplication/Program.cs @@ -12,6 +12,7 @@ using PetroGlyph.Games.EawFoc.Services.Dependencies; using PetroGlyph.Games.EawFoc.Services.Detection; using PetroGlyph.Games.EawFoc.Services.Name; +using PG.StarWarsGame.Infrastructure.Clients.Steam; var sp = SetupApplication(); diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ILibraryConfigReader.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ILibraryConfigReader.cs index 9ecc701d..976aa0b3 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ILibraryConfigReader.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ILibraryConfigReader.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.IO.Abstractions; -namespace PetroGlyph.Games.EawFoc.Clients.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam; internal interface ILibraryConfigReader { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamAppManifestReader.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamAppManifestReader.cs index 06e34d68..54ddd807 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamAppManifestReader.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamAppManifestReader.cs @@ -1,6 +1,7 @@ using System.IO.Abstractions; +using PetroGlyph.Games.EawFoc.Clients.Steam; -namespace PetroGlyph.Games.EawFoc.Clients.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam; internal interface ISteamAppManifestReader { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamGameLocationFinder.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamGameLocationFinder.cs index 3ab06791..78fb9445 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamGameLocationFinder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamGameLocationFinder.cs @@ -1,4 +1,6 @@ -namespace PetroGlyph.Games.EawFoc.Clients.Steam; +using PetroGlyph.Games.EawFoc.Clients.Steam; + +namespace PG.StarWarsGame.Infrastructure.Clients.Steam; internal interface ISteamGameFinder { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamLibraryFinder.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamLibraryFinder.cs index 1ea2ce90..8a422684 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamLibraryFinder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamLibraryFinder.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; +using PetroGlyph.Games.EawFoc.Clients.Steam; -namespace PetroGlyph.Games.EawFoc.Clients.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam; internal interface ISteamLibraryFinder { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/Advapi32.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/Advapi32.cs index 2606faaf..0a6912fc 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/Advapi32.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/Advapi32.cs @@ -1,8 +1,8 @@ using System.Runtime.InteropServices; using Microsoft.Win32.SafeHandles; -using PetroGlyph.Games.EawFoc.Clients.Steam.Threading; +using PG.StarWarsGame.Infrastructure.Clients.Steam.Threading; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.NativeMethods; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam.NativeMethods; internal static class Advapi32 { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/Kernel32.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/Kernel32.cs index 7a314e85..5c4f9ede 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/Kernel32.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/Kernel32.cs @@ -1,7 +1,7 @@ using System; using System.Runtime.InteropServices; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.NativeMethods; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam.NativeMethods; internal static class Kernel32 { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/User32.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/User32.cs index 52189976..4b96d1d5 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/User32.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/User32.cs @@ -2,7 +2,7 @@ using System.Runtime.InteropServices; using System.Text; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.NativeMethods; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam.NativeMethods; internal static class User32 { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/WindowHandleInfo.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/WindowHandleInfo.cs index 1432866d..faee7c71 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/WindowHandleInfo.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/WindowHandleInfo.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Runtime.InteropServices; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.NativeMethods; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam.NativeMethods; internal class WindowHandleInfo { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroglyphWindowsSteamClientsLibrary.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroglyphWindowsSteamClientsLibrary.cs index 6a80a418..59fb5c09 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroglyphWindowsSteamClientsLibrary.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroglyphWindowsSteamClientsLibrary.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.DependencyInjection; +using PetroGlyph.Games.EawFoc.Clients.Steam; -namespace PetroGlyph.Games.EawFoc.Clients.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam; /// /// Provides initialization routines for this library. diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamGameFinder.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamGameFinder.cs index 58842823..75c49e97 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamGameFinder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamGameFinder.cs @@ -1,8 +1,9 @@ using System; -using System.Linq; using Microsoft.Extensions.DependencyInjection; +using System.Linq; +using PetroGlyph.Games.EawFoc.Clients.Steam; -namespace PetroGlyph.Games.EawFoc.Clients.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam; internal class SteamGameFinder : ISteamGameFinder { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibrary.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibrary.cs index f1677159..d841d315 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibrary.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibrary.cs @@ -5,8 +5,9 @@ using System.IO.Abstractions; using AnakinRaW.CommonUtilities.FileSystem.Normalization; using Microsoft.Extensions.DependencyInjection; +using PetroGlyph.Games.EawFoc.Clients.Steam; -namespace PetroGlyph.Games.EawFoc.Clients.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam; internal class SteamLibrary : ISteamLibrary { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibraryFinder.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibraryFinder.cs index d8dbb010..77f99715 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibraryFinder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibraryFinder.cs @@ -2,8 +2,10 @@ using System.Collections.Generic; using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; +using PetroGlyph.Games.EawFoc; +using PetroGlyph.Games.EawFoc.Clients.Steam; -namespace PetroGlyph.Games.EawFoc.Clients.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam; internal class SteamLibraryFinder : ISteamLibraryFinder { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamRegistry.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamRegistry.cs index 3b377a62..b8c9c72f 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamRegistry.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamRegistry.cs @@ -1,14 +1,13 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.IO.Abstractions; using System.Linq; using AnakinRaW.CommonUtilities.Registry; using Microsoft.Extensions.DependencyInjection; -#if NET -using System.Diagnostics.CodeAnalysis; -#endif +using PetroGlyph.Games.EawFoc.Clients.Steam; -namespace PetroGlyph.Games.EawFoc.Clients.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam; internal sealed class SteamRegistry : ISteamRegistry { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamVdfReader.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamVdfReader.cs index 60e12a57..a25ede45 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamVdfReader.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamVdfReader.cs @@ -7,8 +7,10 @@ using Gameloop.Vdf.JsonConverter; using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json.Linq; +using PetroGlyph.Games.EawFoc; +using PetroGlyph.Games.EawFoc.Clients.Steam; -namespace PetroGlyph.Games.EawFoc.Clients.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam; internal class SteamVdfReader : ISteamAppManifestReader, ILibraryConfigReader { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamWrapper.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamWrapper.cs index 948b6f94..a6342c75 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamWrapper.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamWrapper.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.IO.Abstractions; using System.Linq; using System.Threading; @@ -8,14 +9,13 @@ using Gameloop.Vdf; using Gameloop.Vdf.JsonConverter; using Microsoft.Extensions.DependencyInjection; +using PetroGlyph.Games.EawFoc; using PetroGlyph.Games.EawFoc.Clients.Processes; -using PetroGlyph.Games.EawFoc.Clients.Steam.NativeMethods; -using PetroGlyph.Games.EawFoc.Clients.Steam.Threading; -#if NET -using System.Diagnostics.CodeAnalysis; -#endif +using PetroGlyph.Games.EawFoc.Clients.Steam; +using PG.StarWarsGame.Infrastructure.Clients.Steam.NativeMethods; +using PG.StarWarsGame.Infrastructure.Clients.Steam.Threading; -namespace PetroGlyph.Games.EawFoc.Clients.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam; internal class SteamWrapper : ISteamWrapper { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/AwaitExtensions.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/AwaitExtensions.cs index a9fdeb24..48c05e36 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/AwaitExtensions.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/AwaitExtensions.cs @@ -5,9 +5,9 @@ using System.Threading.Tasks; using Microsoft.Win32; using Microsoft.Win32.SafeHandles; -using PetroGlyph.Games.EawFoc.Clients.Steam.NativeMethods; +using PG.StarWarsGame.Infrastructure.Clients.Steam.NativeMethods; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.Threading; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Threading; // From https://github.com/microsoft/vs-threading internal static class AwaitExtensions diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/EmptyStruct.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/EmptyStruct.cs index d4e6e601..609e18bc 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/EmptyStruct.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/EmptyStruct.cs @@ -1,4 +1,4 @@ -namespace PetroGlyph.Games.EawFoc.Clients.Steam.Threading; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Threading; // From https://github.com/microsoft/vs-threading internal readonly struct EmptyStruct diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/NoMessagePumpSyncContext.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/NoMessagePumpSyncContext.cs index 1988f723..1a71821a 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/NoMessagePumpSyncContext.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/NoMessagePumpSyncContext.cs @@ -1,9 +1,9 @@ using System; using System.Runtime.InteropServices; using System.Threading; -using PetroGlyph.Games.EawFoc.Clients.Steam.NativeMethods; +using PG.StarWarsGame.Infrastructure.Clients.Steam.NativeMethods; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.Threading; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Threading; // From https://github.com/microsoft/vs-threading internal class NoMessagePumpSyncContext : SynchronizationContext diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/RegistryChangeNotificationFilters.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/RegistryChangeNotificationFilters.cs index 4778d16a..3b29e6c1 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/RegistryChangeNotificationFilters.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/RegistryChangeNotificationFilters.cs @@ -1,6 +1,6 @@ using System; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.Threading; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Threading; // From https://github.com/microsoft/vs-threading /// diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/SpecializedSyncContext.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/SpecializedSyncContext.cs index 73c2fa05..a8cb9152 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/SpecializedSyncContext.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/SpecializedSyncContext.cs @@ -1,7 +1,7 @@ using System; using System.Threading; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.Threading; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Threading; // From https://github.com/microsoft/vs-threading internal readonly struct SpecializedSyncContext : IDisposable diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/ThreadingTools.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/ThreadingTools.cs index 488074bc..f435ce42 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/ThreadingTools.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/ThreadingTools.cs @@ -1,6 +1,6 @@ using System.Threading; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.Threading; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Threading; // From https://github.com/microsoft/vs-threading internal static class ThreadingTools diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/TplExtensions.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/TplExtensions.cs index 05e0989c..f1b2da8d 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/TplExtensions.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/TplExtensions.cs @@ -2,7 +2,7 @@ using System.Threading; using System.Threading.Tasks; -namespace PetroGlyph.Games.EawFoc.Clients.Steam.Threading; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Threading; // From https://github.com/microsoft/vs-threading internal static class TplExtensions From 9aee771378f49dcad17777bac7f2439816227266 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Thu, 14 Mar 2024 18:03:37 +0100 Subject: [PATCH 13/41] rename clients and steam ns --- sample/SampleApplication/Program.cs | 3 +-- .../src/ISteamAppManifestReader.cs | 1 - .../src/ISteamGameLocationFinder.cs | 4 +--- .../src/ISteamLibraryFinder.cs | 1 - .../src/PetroglyphWindowsSteamClientsLibrary.cs | 1 - .../src/SteamGameFinder.cs | 1 - .../src/SteamLibrary.cs | 1 - .../src/SteamLibraryFinder.cs | 1 - .../src/SteamRegistry.cs | 1 - .../src/SteamVdfReader.cs | 1 - .../src/SteamWrapper.cs | 3 +-- .../test/Steam/SteamGameFinderTest.cs | 1 - .../test/Steam/SteamLibraryFinderTest.cs | 1 - .../test/Steam/SteamLibraryTest.cs | 1 - .../test/Steam/SteamVdfReaderTest.cs | 1 - .../test/Steam/SteamWrapperIntegrationTest.cs | 2 -- .../test/Steam/SteamWrapperTest.cs | 3 +-- .../src/DefaultGameClientFactory.cs | 2 +- .../src/ISteamLibrary.cs | 2 +- .../src/ISteamRegistry.cs | 2 +- .../src/ISteamWrapper.cs | 3 ++- .../src/SteamAppManifest.cs | 6 +++--- .../src/SteamAppState.cs | 2 +- .../src/SteamGameClient.cs | 4 ++-- .../src/SteamGameLanguageFinder.cs | 2 +- .../src/SteamPetroglyphStarWarsGameDetector.cs | 2 +- .../test/SteamGameClientTest.cs | 4 +--- .../test/SteamGameLanguageFinderTest.cs | 1 - .../test/SteamPetroglyphStarWarsGameDetectorTest.cs | 1 - .../src/Arguments/ArgumentCollection.cs | 2 +- .../src/Arguments/ArgumentCommandLineBuilder.cs | 2 +- .../src/Arguments/ArgumentKind.cs | 2 +- .../src/Arguments/ArgumentNameCatalog.cs | 2 +- .../src/Arguments/ArgumentValidator.cs | 2 +- .../src/Arguments/ArgumentValidityStatus.cs | 2 +- .../src/Arguments/ArgumentValueSerializer.cs | 2 +- .../src/Arguments/FlagArgument.cs | 2 +- .../src/Arguments/GameArgument.cs | 2 +- .../src/Arguments/GameArgumentException.cs | 4 +++- .../src/Arguments/GameArguments/GameArguments.cs | 2 +- .../src/Arguments/GameArguments/ModArgument.cs | 2 +- .../src/Arguments/GameArguments/ModArgumentList.cs | 2 +- .../src/Arguments/IArgumentCollection.cs | 2 +- .../src/Arguments/IArgumentCollectionBuilder.cs | 2 +- .../src/Arguments/IArgumentCommandLineBuilder.cs | 2 +- .../src/Arguments/IArgumentValidator.cs | 2 +- .../src/Arguments/IGameArgument.cs | 2 +- .../src/Arguments/IModArgumentListFactory.cs | 4 ++-- .../src/Arguments/KeyBasedArgumentCollectionBuilder.cs | 2 +- .../src/Arguments/ModArgumentListFactory.cs | 5 +++-- .../src/Arguments/NamedArgument.cs | 2 +- .../src/Arguments/SerializeEnumNameAttribute.cs | 2 +- .../src/Arguments/SerializeEnumValueAttribute.cs | 2 +- src/PetroGlyph.Games.EawFoc.Clients/src/ClientBase.cs | 7 ++++--- src/PetroGlyph.Games.EawFoc.Clients/src/ClientException.cs | 2 +- .../src/DebugableClientBase.cs | 7 ++++--- src/PetroGlyph.Games.EawFoc.Clients/src/DefaultClient.cs | 4 ++-- src/PetroGlyph.Games.EawFoc.Clients/src/GameBuildType.cs | 2 +- .../src/GameExecutableFileService.cs | 2 +- .../src/GameExecutableNameBuilder.cs | 2 +- .../src/GameStartException.cs | 3 ++- .../src/GameStartingEventArgs.cs | 5 +++-- .../src/IDebugableGameClient.cs | 7 ++++--- src/PetroGlyph.Games.EawFoc.Clients/src/IGameClient.cs | 7 ++++--- .../src/IGameClientFactory.cs | 2 +- .../src/IGameExecutableFileService.cs | 2 +- .../src/IGameExecutableNameBuilder.cs | 2 +- .../src/PetroglyphClientsLibrary.cs | 6 +++--- .../src/Processes/DefaultGameProcessLauncher.cs | 4 ++-- .../src/Processes/GameProcess.cs | 2 +- .../src/Processes/GameProcessInfo.cs | 5 +++-- .../src/Processes/GameProcessState.cs | 2 +- .../src/Processes/IGameProcess.cs | 2 +- .../src/Processes/IGameProcessLauncher.cs | 2 +- .../src/Processes/IProcessHelper.cs | 2 +- .../src/Processes/ProcessHelper.cs | 2 +- .../src/Threading/AwaitExtensions.cs | 2 +- .../test/Arguments/ArgumentCollectionTest.cs | 4 ++-- .../test/Arguments/ArgumentCommandLineBuilderTest.cs | 4 ++-- .../test/Arguments/ArgumentValidatorTest.cs | 4 ++-- .../test/Arguments/ArgumentValueSerializerTest.cs | 2 +- .../test/Arguments/FlagArgumentTest.cs | 2 +- .../test/Arguments/GameArgumentTest.cs | 2 +- .../Arguments/KeyBasedArgumentCollectionBuilderTest.cs | 4 ++-- .../test/Arguments/ModArgumentListFactoryTest.cs | 4 ++-- .../test/Arguments/ModArgumentListTest.cs | 4 ++-- .../test/Arguments/ModArgumentTest.cs | 2 +- .../test/Arguments/NamedArgumentTest.cs | 2 +- src/PetroGlyph.Games.EawFoc.Clients/test/ClientBaseTest.cs | 7 +++---- .../test/DebugableClientBaseTest.cs | 5 ++--- .../test/DefaultClientTest.cs | 3 +-- .../test/GameExecutableFileServiceTest.cs | 1 - .../test/GameExecutableNameBuilderTest.cs | 1 - .../test/Processes/DefaultGameProcessLauncherTest.cs | 5 ++--- .../test/Processes/GameProcessTest.cs | 5 ++--- 95 files changed, 119 insertions(+), 138 deletions(-) diff --git a/sample/SampleApplication/Program.cs b/sample/SampleApplication/Program.cs index 0e34e67a..14e25295 100644 --- a/sample/SampleApplication/Program.cs +++ b/sample/SampleApplication/Program.cs @@ -4,14 +4,13 @@ using AnakinRaW.CommonUtilities.Registry.Windows; using Microsoft.Extensions.DependencyInjection; using PetroGlyph.Games.EawFoc; -using PetroGlyph.Games.EawFoc.Clients; -using PetroGlyph.Games.EawFoc.Clients.Steam; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Mods; using PetroGlyph.Games.EawFoc.Services; using PetroGlyph.Games.EawFoc.Services.Dependencies; using PetroGlyph.Games.EawFoc.Services.Detection; using PetroGlyph.Games.EawFoc.Services.Name; +using PG.StarWarsGame.Infrastructure.Clients; using PG.StarWarsGame.Infrastructure.Clients.Steam; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamAppManifestReader.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamAppManifestReader.cs index 54ddd807..0fb60f5a 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamAppManifestReader.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamAppManifestReader.cs @@ -1,5 +1,4 @@ using System.IO.Abstractions; -using PetroGlyph.Games.EawFoc.Clients.Steam; namespace PG.StarWarsGame.Infrastructure.Clients.Steam; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamGameLocationFinder.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamGameLocationFinder.cs index 78fb9445..f622c217 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamGameLocationFinder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamGameLocationFinder.cs @@ -1,6 +1,4 @@ -using PetroGlyph.Games.EawFoc.Clients.Steam; - -namespace PG.StarWarsGame.Infrastructure.Clients.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam; internal interface ISteamGameFinder { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamLibraryFinder.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamLibraryFinder.cs index 8a422684..338d7989 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamLibraryFinder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamLibraryFinder.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using PetroGlyph.Games.EawFoc.Clients.Steam; namespace PG.StarWarsGame.Infrastructure.Clients.Steam; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroglyphWindowsSteamClientsLibrary.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroglyphWindowsSteamClientsLibrary.cs index 59fb5c09..5cd2d596 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroglyphWindowsSteamClientsLibrary.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroglyphWindowsSteamClientsLibrary.cs @@ -1,5 +1,4 @@ using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Clients.Steam; namespace PG.StarWarsGame.Infrastructure.Clients.Steam; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamGameFinder.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamGameFinder.cs index 75c49e97..fa6cd08b 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamGameFinder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamGameFinder.cs @@ -1,7 +1,6 @@ using System; using Microsoft.Extensions.DependencyInjection; using System.Linq; -using PetroGlyph.Games.EawFoc.Clients.Steam; namespace PG.StarWarsGame.Infrastructure.Clients.Steam; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibrary.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibrary.cs index d841d315..74ef4fe0 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibrary.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibrary.cs @@ -5,7 +5,6 @@ using System.IO.Abstractions; using AnakinRaW.CommonUtilities.FileSystem.Normalization; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Clients.Steam; namespace PG.StarWarsGame.Infrastructure.Clients.Steam; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibraryFinder.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibraryFinder.cs index 77f99715..22af4f29 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibraryFinder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibraryFinder.cs @@ -3,7 +3,6 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using PetroGlyph.Games.EawFoc; -using PetroGlyph.Games.EawFoc.Clients.Steam; namespace PG.StarWarsGame.Infrastructure.Clients.Steam; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamRegistry.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamRegistry.cs index b8c9c72f..d53a3e8c 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamRegistry.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamRegistry.cs @@ -5,7 +5,6 @@ using System.Linq; using AnakinRaW.CommonUtilities.Registry; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Clients.Steam; namespace PG.StarWarsGame.Infrastructure.Clients.Steam; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamVdfReader.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamVdfReader.cs index a25ede45..687499c1 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamVdfReader.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamVdfReader.cs @@ -8,7 +8,6 @@ using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json.Linq; using PetroGlyph.Games.EawFoc; -using PetroGlyph.Games.EawFoc.Clients.Steam; namespace PG.StarWarsGame.Infrastructure.Clients.Steam; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamWrapper.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamWrapper.cs index a6342c75..f2ad4f3e 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamWrapper.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamWrapper.cs @@ -10,8 +10,7 @@ using Gameloop.Vdf.JsonConverter; using Microsoft.Extensions.DependencyInjection; using PetroGlyph.Games.EawFoc; -using PetroGlyph.Games.EawFoc.Clients.Processes; -using PetroGlyph.Games.EawFoc.Clients.Steam; +using PG.StarWarsGame.Infrastructure.Clients.Processes; using PG.StarWarsGame.Infrastructure.Clients.Steam.NativeMethods; using PG.StarWarsGame.Infrastructure.Clients.Steam.Threading; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamGameFinderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamGameFinderTest.cs index 3ecad753..cd20ae5e 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamGameFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamGameFinderTest.cs @@ -2,7 +2,6 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc.Clients.Steam; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryFinderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryFinderTest.cs index 23311387..4a63aca1 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryFinderTest.cs @@ -4,7 +4,6 @@ using Microsoft.Extensions.DependencyInjection; using Moq; using PetroGlyph.Games.EawFoc; -using PetroGlyph.Games.EawFoc.Clients.Steam; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryTest.cs index 4eaa154a..3ebe7250 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryTest.cs @@ -3,7 +3,6 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc.Clients.Steam; using PG.TestingUtilities; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamVdfReaderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamVdfReaderTest.cs index c4cf65f5..b0047ccf 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamVdfReaderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamVdfReaderTest.cs @@ -3,7 +3,6 @@ using Microsoft.Extensions.DependencyInjection; using Moq; using PetroGlyph.Games.EawFoc; -using PetroGlyph.Games.EawFoc.Clients.Steam; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperIntegrationTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperIntegrationTest.cs index d869ba87..cd492a91 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperIntegrationTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperIntegrationTest.cs @@ -1,8 +1,6 @@ using System; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Clients; -using PetroGlyph.Games.EawFoc.Clients.Steam; using Xunit; namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.Steam; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperTest.cs index 9538c3f3..204d9791 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperTest.cs @@ -4,8 +4,7 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc.Clients.Processes; -using PetroGlyph.Games.EawFoc.Clients.Steam; +using PG.StarWarsGame.Infrastructure.Clients.Processes; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/DefaultGameClientFactory.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/DefaultGameClientFactory.cs index 7876b488..1d3f3a0b 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/DefaultGameClientFactory.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/DefaultGameClientFactory.cs @@ -1,7 +1,7 @@ using System; using PetroGlyph.Games.EawFoc.Games; -namespace PetroGlyph.Games.EawFoc.Clients.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam; /// /// which creates a for the Steam platform diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamLibrary.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamLibrary.cs index 9bc2efe4..65f4f7d5 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamLibrary.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamLibrary.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.IO.Abstractions; -namespace PetroGlyph.Games.EawFoc.Clients.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam; /// /// Represents a Steam Library location. diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamRegistry.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamRegistry.cs index 72c044d1..1b7c5597 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamRegistry.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamRegistry.cs @@ -3,7 +3,7 @@ using System.IO.Abstractions; using AnakinRaW.CommonUtilities.Registry; -namespace PetroGlyph.Games.EawFoc.Clients.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam; /// /// Registry representation for the Steam Client. diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamWrapper.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamWrapper.cs index d1919676..98672551 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamWrapper.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamWrapper.cs @@ -1,10 +1,11 @@ using System.Threading; using System.Threading.Tasks; +using PetroGlyph.Games.EawFoc; #if NET using System.Diagnostics.CodeAnalysis; #endif -namespace PetroGlyph.Games.EawFoc.Clients.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam; /// /// .NET Wrapper to interact with the Steam Client diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamAppManifest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamAppManifest.cs index 17c232fa..4ee2eb50 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamAppManifest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamAppManifest.cs @@ -1,9 +1,9 @@ -using AnakinRaW.CommonUtilities; -using System; +using System; using System.Collections.Generic; using System.IO.Abstractions; +using AnakinRaW.CommonUtilities; -namespace PetroGlyph.Games.EawFoc.Clients.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam; /// /// Manifest representing an installed Steam game. diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamAppState.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamAppState.cs index dfcfcdf4..fdf862d4 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamAppState.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamAppState.cs @@ -1,6 +1,6 @@ using System; -namespace PetroGlyph.Games.EawFoc.Clients.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam; /// /// Indicates the State of a Steam game. diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameClient.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameClient.cs index f35b9847..da768218 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameClient.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameClient.cs @@ -2,10 +2,10 @@ using System.Collections.Generic; using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Clients.Processes; using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Clients.Processes; -namespace PetroGlyph.Games.EawFoc.Clients.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam; /// /// dedicated to the steam version of the games. diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameLanguageFinder.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameLanguageFinder.cs index 44954557..b64c9c74 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameLanguageFinder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameLanguageFinder.cs @@ -6,7 +6,7 @@ using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Services.Language; -namespace PetroGlyph.Games.EawFoc.Clients.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam; /// /// Searches installed game languages, based on the Steam Game Manifest. diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamPetroglyphStarWarsGameDetector.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamPetroglyphStarWarsGameDetector.cs index 78f99140..5a9e7cc1 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamPetroglyphStarWarsGameDetector.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamPetroglyphStarWarsGameDetector.cs @@ -5,7 +5,7 @@ using PetroGlyph.Games.EawFoc.Games.Registry; using PetroGlyph.Games.EawFoc.Services.Detection; -namespace PetroGlyph.Games.EawFoc.Clients.Steam; +namespace PG.StarWarsGame.Infrastructure.Clients.Steam; /// /// Searches an installation of a Petroglyph Star Wars game on the Steam client. diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameClientTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameClientTest.cs index 14b82698..ee92b0ea 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameClientTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameClientTest.cs @@ -1,10 +1,8 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc.Clients; -using PetroGlyph.Games.EawFoc.Clients.Processes; -using PetroGlyph.Games.EawFoc.Clients.Steam; using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Clients.Processes; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameLanguageFinderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameLanguageFinderTest.cs index a8f5f1e7..4ed0d373 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameLanguageFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameLanguageFinderTest.cs @@ -4,7 +4,6 @@ using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc.Clients.Steam; using PetroGlyph.Games.EawFoc.Games; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamPetroglyphStarWarsGameDetectorTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamPetroglyphStarWarsGameDetectorTest.cs index 65ab4caa..bd5d1189 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamPetroglyphStarWarsGameDetectorTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamPetroglyphStarWarsGameDetectorTest.cs @@ -3,7 +3,6 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc.Clients.Steam; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Games.Registry; using PetroGlyph.Games.EawFoc.Services.Detection; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentCollection.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentCollection.cs index 55e66876..624f4b53 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentCollection.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentCollection.cs @@ -3,7 +3,7 @@ using System.Collections.ObjectModel; using System.Linq; -namespace PetroGlyph.Games.EawFoc.Clients.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; /// public sealed class ArgumentCollection : IArgumentCollection diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentCommandLineBuilder.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentCommandLineBuilder.cs index 5a3d8136..0773c2c0 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentCommandLineBuilder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentCommandLineBuilder.cs @@ -4,7 +4,7 @@ using System.Text; using Microsoft.Extensions.DependencyInjection; -namespace PetroGlyph.Games.EawFoc.Clients.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; internal class ArgumentCommandLineBuilder : IArgumentCommandLineBuilder { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentKind.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentKind.cs index 5fe14cff..f97cae44 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentKind.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentKind.cs @@ -1,4 +1,4 @@ -namespace PetroGlyph.Games.EawFoc.Clients.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; /// /// Flag indication the kindness of an diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentNameCatalog.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentNameCatalog.cs index cc82337f..7e16547f 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentNameCatalog.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentNameCatalog.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; -namespace PetroGlyph.Games.EawFoc.Clients.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; /// /// Collections of supported Argument Names diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentValidator.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentValidator.cs index d8b1373d..b0d1382c 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentValidator.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentValidator.cs @@ -1,6 +1,6 @@ using System.Linq; -namespace PetroGlyph.Games.EawFoc.Clients.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; internal sealed class ArgumentValidator : IArgumentValidator { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentValidityStatus.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentValidityStatus.cs index 55a5f856..ae2e94b0 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentValidityStatus.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentValidityStatus.cs @@ -1,4 +1,4 @@ -namespace PetroGlyph.Games.EawFoc.Clients.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; /// /// Indicates the validity of a diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentValueSerializer.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentValueSerializer.cs index df68b3df..a2d88f23 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentValueSerializer.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ArgumentValueSerializer.cs @@ -5,7 +5,7 @@ using AnakinRaW.CommonUtilities.FileSystem; using AnakinRaW.CommonUtilities.FileSystem.Normalization; -namespace PetroGlyph.Games.EawFoc.Clients.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; internal class ArgumentValueSerializer { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/FlagArgument.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/FlagArgument.cs index 2fbb50cd..1699db3b 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/FlagArgument.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/FlagArgument.cs @@ -1,6 +1,6 @@ using System; -namespace PetroGlyph.Games.EawFoc.Clients.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; /// /// Argument which enables a game behavior because it exists. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArgument.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArgument.cs index fcea4649..06b7cb66 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArgument.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArgument.cs @@ -1,6 +1,6 @@ using System; -namespace PetroGlyph.Games.EawFoc.Clients.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; /// /// Base implementation for a typed . diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArgumentException.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArgumentException.cs index 0f4ba3e4..8f623e30 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArgumentException.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArgumentException.cs @@ -1,4 +1,6 @@ -namespace PetroGlyph.Games.EawFoc.Clients.Arguments; +using PetroGlyph.Games.EawFoc; + +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; /// /// The exception that is thrown when a or handling it caused an error. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArguments/GameArguments.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArguments/GameArguments.cs index 0499823e..cfc2ac98 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArguments/GameArguments.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArguments/GameArguments.cs @@ -2,7 +2,7 @@ using EawModinfo.Spec; using PetroGlyph.Games.EawFoc.Services.Language; -namespace PetroGlyph.Games.EawFoc.Clients.Arguments.GameArguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments; #region Flags Normal diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArguments/ModArgument.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArguments/ModArgument.cs index f061020a..920fb9f8 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArguments/ModArgument.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArguments/ModArgument.cs @@ -1,4 +1,4 @@ -namespace PetroGlyph.Games.EawFoc.Clients.Arguments.GameArguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments; /// /// Dedicated argument to represent a mod diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArguments/ModArgumentList.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArguments/ModArgumentList.cs index 9eaa4230..4115a636 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArguments/ModArgumentList.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArguments/ModArgumentList.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; -namespace PetroGlyph.Games.EawFoc.Clients.Arguments.GameArguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments; /// /// Special argument which holds an ordered list of arguments to represent a mod chain. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IArgumentCollection.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IArgumentCollection.cs index 0537f0dc..b37943f6 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IArgumentCollection.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IArgumentCollection.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace PetroGlyph.Games.EawFoc.Clients.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; /// /// Represents a collection of s. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IArgumentCollectionBuilder.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IArgumentCollectionBuilder.cs index 5bf45076..efda3e42 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IArgumentCollectionBuilder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IArgumentCollectionBuilder.cs @@ -1,4 +1,4 @@ -namespace PetroGlyph.Games.EawFoc.Clients.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; /// /// Service to build an diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IArgumentCommandLineBuilder.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IArgumentCommandLineBuilder.cs index 337ed8d4..10a2d54b 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IArgumentCommandLineBuilder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IArgumentCommandLineBuilder.cs @@ -1,4 +1,4 @@ -namespace PetroGlyph.Games.EawFoc.Clients.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; internal interface IArgumentCommandLineBuilder { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IArgumentValidator.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IArgumentValidator.cs index ad8a9cd9..d560d308 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IArgumentValidator.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IArgumentValidator.cs @@ -1,4 +1,4 @@ -namespace PetroGlyph.Games.EawFoc.Clients.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; internal interface IArgumentValidator { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IGameArgument.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IGameArgument.cs index d801b217..d3ff890e 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IGameArgument.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IGameArgument.cs @@ -1,6 +1,6 @@ using System; -namespace PetroGlyph.Games.EawFoc.Clients.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; /// /// Represents a typed argument for a Petroglyph Star Wars game. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IModArgumentListFactory.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IModArgumentListFactory.cs index e8ac1a83..c6ae5fdb 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IModArgumentListFactory.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IModArgumentListFactory.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; -using PetroGlyph.Games.EawFoc.Clients.Arguments.GameArguments; using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments; -namespace PetroGlyph.Games.EawFoc.Clients.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; /// /// Factory service to create a from a given mod instance. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/KeyBasedArgumentCollectionBuilder.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/KeyBasedArgumentCollectionBuilder.cs index 8b11ccaf..be56b646 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/KeyBasedArgumentCollectionBuilder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/KeyBasedArgumentCollectionBuilder.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; -namespace PetroGlyph.Games.EawFoc.Clients.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; /// /// which takes the argument's name as key. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ModArgumentListFactory.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ModArgumentListFactory.cs index 640c5b7d..b32f0210 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ModArgumentListFactory.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ModArgumentListFactory.cs @@ -3,12 +3,13 @@ using System.Linq; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Clients.Arguments.GameArguments; +using PetroGlyph.Games.EawFoc; using PetroGlyph.Games.EawFoc.Mods; using PetroGlyph.Games.EawFoc.Services.Dependencies; using PetroGlyph.Games.EawFoc.Services.Steam; +using PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments; -namespace PetroGlyph.Games.EawFoc.Clients.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; /// /// Create a from a given mod instance diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/NamedArgument.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/NamedArgument.cs index c5e0b937..94977179 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/NamedArgument.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/NamedArgument.cs @@ -1,6 +1,6 @@ using System; -namespace PetroGlyph.Games.EawFoc.Clients.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; /// /// with the format Name=Value diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/SerializeEnumNameAttribute.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/SerializeEnumNameAttribute.cs index 648581fb..dc12a11c 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/SerializeEnumNameAttribute.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/SerializeEnumNameAttribute.cs @@ -1,6 +1,6 @@ using System; -namespace PetroGlyph.Games.EawFoc.Clients.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; /// /// Attribute to indicate that an enum shall be serialized by its name. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/SerializeEnumValueAttribute.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/SerializeEnumValueAttribute.cs index 88bfb175..fb812aec 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/SerializeEnumValueAttribute.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/SerializeEnumValueAttribute.cs @@ -1,6 +1,6 @@ using System; -namespace PetroGlyph.Games.EawFoc.Clients.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; /// /// Attribute to indicate that an enum shall be serialized by its underlying value. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/ClientBase.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/ClientBase.cs index 8e795fe7..38792d93 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/ClientBase.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/ClientBase.cs @@ -2,12 +2,13 @@ using System.Collections.Generic; using System.Linq; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Clients.Arguments; -using PetroGlyph.Games.EawFoc.Clients.Processes; +using PetroGlyph.Games.EawFoc; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Clients.Arguments; +using PG.StarWarsGame.Infrastructure.Clients.Processes; -namespace PetroGlyph.Games.EawFoc.Clients; +namespace PG.StarWarsGame.Infrastructure.Clients; /// /// Base implementation for an which handles registration and raising of the game events. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/ClientException.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/ClientException.cs index 6199d7d7..ab40fa92 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/ClientException.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/ClientException.cs @@ -1,6 +1,6 @@ using System; -namespace PetroGlyph.Games.EawFoc.Clients; +namespace PG.StarWarsGame.Infrastructure.Clients; /// /// The exception that is thrown when a Client operation caused an error. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/DebugableClientBase.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/DebugableClientBase.cs index 316be9c4..e6210c30 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/DebugableClientBase.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/DebugableClientBase.cs @@ -1,9 +1,10 @@ using System; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Clients.Arguments; -using PetroGlyph.Games.EawFoc.Clients.Processes; +using PetroGlyph.Games.EawFoc; +using PG.StarWarsGame.Infrastructure.Clients.Arguments; +using PG.StarWarsGame.Infrastructure.Clients.Processes; -namespace PetroGlyph.Games.EawFoc.Clients; +namespace PG.StarWarsGame.Infrastructure.Clients; /// /// Base implementation for an . diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/DefaultClient.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/DefaultClient.cs index 5fb793df..ca496b87 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/DefaultClient.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/DefaultClient.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Clients.Processes; using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Clients.Processes; -namespace PetroGlyph.Games.EawFoc.Clients; +namespace PG.StarWarsGame.Infrastructure.Clients; /// /// Default client implementation for non-Steam games. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/GameBuildType.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/GameBuildType.cs index 6f5a7c53..a3aa9477 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/GameBuildType.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/GameBuildType.cs @@ -1,4 +1,4 @@ -namespace PetroGlyph.Games.EawFoc.Clients; +namespace PG.StarWarsGame.Infrastructure.Clients; /// /// The game's build type identifier. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/GameExecutableFileService.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/GameExecutableFileService.cs index 9239261e..d422b68d 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/GameExecutableFileService.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/GameExecutableFileService.cs @@ -5,7 +5,7 @@ using Microsoft.Extensions.DependencyInjection; using PetroGlyph.Games.EawFoc.Games; -namespace PetroGlyph.Games.EawFoc.Clients; +namespace PG.StarWarsGame.Infrastructure.Clients; internal class GameExecutableFileService(IServiceProvider serviceProvider) : IGameExecutableFileService { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/GameExecutableNameBuilder.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/GameExecutableNameBuilder.cs index 1cf939c9..d5e0016e 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/GameExecutableNameBuilder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/GameExecutableNameBuilder.cs @@ -1,7 +1,7 @@ using System; using PetroGlyph.Games.EawFoc.Games; -namespace PetroGlyph.Games.EawFoc.Clients; +namespace PG.StarWarsGame.Infrastructure.Clients; internal sealed class GameExecutableNameBuilder : IGameExecutableNameBuilder { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/GameStartException.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/GameStartException.cs index 22cc01df..d23cabed 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/GameStartException.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/GameStartException.cs @@ -1,6 +1,7 @@ using System; +using PetroGlyph.Games.EawFoc; -namespace PetroGlyph.Games.EawFoc.Clients; +namespace PG.StarWarsGame.Infrastructure.Clients; /// /// The exception that is thrown when a game was not started successfully. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/GameStartingEventArgs.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/GameStartingEventArgs.cs index 18993e52..e28491a1 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/GameStartingEventArgs.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/GameStartingEventArgs.cs @@ -1,7 +1,8 @@ using System.ComponentModel; -using PetroGlyph.Games.EawFoc.Clients.Arguments; +using PetroGlyph.Games.EawFoc; +using PG.StarWarsGame.Infrastructure.Clients.Arguments; -namespace PetroGlyph.Games.EawFoc.Clients; +namespace PG.StarWarsGame.Infrastructure.Clients; /// /// Cancelable event handler when a game was requested to start. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/IDebugableGameClient.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/IDebugableGameClient.cs index 5cc44699..d03652f1 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/IDebugableGameClient.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/IDebugableGameClient.cs @@ -1,8 +1,9 @@ -using PetroGlyph.Games.EawFoc.Clients.Arguments; -using PetroGlyph.Games.EawFoc.Clients.Processes; +using PetroGlyph.Games.EawFoc; using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Clients.Arguments; +using PG.StarWarsGame.Infrastructure.Clients.Processes; -namespace PetroGlyph.Games.EawFoc.Clients; +namespace PG.StarWarsGame.Infrastructure.Clients; /// /// with additional support to start the debug builds of the games. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/IGameClient.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/IGameClient.cs index fe8b5f02..451f2d0a 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/IGameClient.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/IGameClient.cs @@ -1,11 +1,12 @@ using System; using System.Collections.Generic; -using PetroGlyph.Games.EawFoc.Clients.Arguments; -using PetroGlyph.Games.EawFoc.Clients.Processes; +using PetroGlyph.Games.EawFoc; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Clients.Arguments; +using PG.StarWarsGame.Infrastructure.Clients.Processes; -namespace PetroGlyph.Games.EawFoc.Clients; +namespace PG.StarWarsGame.Infrastructure.Clients; /// /// A is responsible for starting a Petroglyph Star Wars game, diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/IGameClientFactory.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/IGameClientFactory.cs index d6cf9799..ccaca126 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/IGameClientFactory.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/IGameClientFactory.cs @@ -1,7 +1,7 @@ using System; using PetroGlyph.Games.EawFoc.Games; -namespace PetroGlyph.Games.EawFoc.Clients; +namespace PG.StarWarsGame.Infrastructure.Clients; /// /// Factory that allows the creation of different s diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/IGameExecutableFileService.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/IGameExecutableFileService.cs index be567156..756cb434 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/IGameExecutableFileService.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/IGameExecutableFileService.cs @@ -1,7 +1,7 @@ using System.IO.Abstractions; using PetroGlyph.Games.EawFoc.Games; -namespace PetroGlyph.Games.EawFoc.Clients; +namespace PG.StarWarsGame.Infrastructure.Clients; /// /// Get the executable file of a Petroglyph Star Wars game. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/IGameExecutableNameBuilder.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/IGameExecutableNameBuilder.cs index c57f94be..db8b407c 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/IGameExecutableNameBuilder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/IGameExecutableNameBuilder.cs @@ -1,6 +1,6 @@ using PetroGlyph.Games.EawFoc.Games; -namespace PetroGlyph.Games.EawFoc.Clients; +namespace PG.StarWarsGame.Infrastructure.Clients; /// /// Service that gets the correct executable file name for a Petroglyph Star Wars game. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/PetroglyphClientsLibrary.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/PetroglyphClientsLibrary.cs index affd5457..a4484ad7 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/PetroglyphClientsLibrary.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/PetroglyphClientsLibrary.cs @@ -1,8 +1,8 @@ using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Clients.Arguments; -using PetroGlyph.Games.EawFoc.Clients.Processes; +using PG.StarWarsGame.Infrastructure.Clients.Arguments; +using PG.StarWarsGame.Infrastructure.Clients.Processes; -namespace PetroGlyph.Games.EawFoc.Clients; +namespace PG.StarWarsGame.Infrastructure.Clients; /// /// Provides initialization routines for this library. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/DefaultGameProcessLauncher.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/DefaultGameProcessLauncher.cs index 1cd72eb3..6d8c9d96 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/DefaultGameProcessLauncher.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/DefaultGameProcessLauncher.cs @@ -2,9 +2,9 @@ using System.Diagnostics; using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Clients.Arguments; +using PG.StarWarsGame.Infrastructure.Clients.Arguments; -namespace PetroGlyph.Games.EawFoc.Clients.Processes; +namespace PG.StarWarsGame.Infrastructure.Clients.Processes; internal class DefaultGameProcessLauncher(IServiceProvider serviceProvider) : IGameProcessLauncher { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcess.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcess.cs index 1793c675..268d1d10 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcess.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcess.cs @@ -6,7 +6,7 @@ #if !NET #endif -namespace PetroGlyph.Games.EawFoc.Clients.Processes; +namespace PG.StarWarsGame.Infrastructure.Clients.Processes; internal sealed class GameProcess : IGameProcess { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcessInfo.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcessInfo.cs index 45c8ae73..9ac48b5c 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcessInfo.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcessInfo.cs @@ -1,7 +1,8 @@ using System; -using PetroGlyph.Games.EawFoc.Clients.Arguments; +using PetroGlyph.Games.EawFoc; +using PG.StarWarsGame.Infrastructure.Clients.Arguments; -namespace PetroGlyph.Games.EawFoc.Clients.Processes; +namespace PG.StarWarsGame.Infrastructure.Clients.Processes; /// /// Metadata for an . diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcessState.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcessState.cs index 57988934..18db5480 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcessState.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcessState.cs @@ -1,4 +1,4 @@ -namespace PetroGlyph.Games.EawFoc.Clients.Processes; +namespace PG.StarWarsGame.Infrastructure.Clients.Processes; /// /// The sate of a game process. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/IGameProcess.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/IGameProcess.cs index accf3136..8f918262 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/IGameProcess.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/IGameProcess.cs @@ -4,7 +4,7 @@ #if NETSTANDARD2_0_OR_GREATER #endif -namespace PetroGlyph.Games.EawFoc.Clients.Processes; +namespace PG.StarWarsGame.Infrastructure.Clients.Processes; /// /// High-Level representation of a game process. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/IGameProcessLauncher.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/IGameProcessLauncher.cs index 12ca43d4..c71f943e 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/IGameProcessLauncher.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/IGameProcessLauncher.cs @@ -1,6 +1,6 @@ using System.IO.Abstractions; -namespace PetroGlyph.Games.EawFoc.Clients.Processes; +namespace PG.StarWarsGame.Infrastructure.Clients.Processes; /// /// Low-Level service that actually starts the game process. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/IProcessHelper.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/IProcessHelper.cs index 3c5ee2c2..dc0d87c4 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/IProcessHelper.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/IProcessHelper.cs @@ -1,6 +1,6 @@ using System.Diagnostics; -namespace PetroGlyph.Games.EawFoc.Clients.Processes; +namespace PG.StarWarsGame.Infrastructure.Clients.Processes; internal interface IProcessHelper { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/ProcessHelper.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/ProcessHelper.cs index a5a88658..e2d63317 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/ProcessHelper.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/ProcessHelper.cs @@ -1,7 +1,7 @@ using System.Diagnostics; using System.Linq; -namespace PetroGlyph.Games.EawFoc.Clients.Processes; +namespace PG.StarWarsGame.Infrastructure.Clients.Processes; internal class ProcessHelper : IProcessHelper { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Threading/AwaitExtensions.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Threading/AwaitExtensions.cs index 586bcff2..509e5626 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Threading/AwaitExtensions.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Threading/AwaitExtensions.cs @@ -1,4 +1,4 @@ -namespace PetroGlyph.Games.EawFoc.Clients.Threading; +namespace PG.StarWarsGame.Infrastructure.Clients.Threading; // From https://github.com/microsoft/vs-threading and https://github.com/dotnet/runtime diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCollectionTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCollectionTest.cs index 83ffb6bb..ef93f739 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCollectionTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCollectionTest.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -using PetroGlyph.Games.EawFoc.Clients.Arguments; -using PetroGlyph.Games.EawFoc.Clients.Arguments.GameArguments; +using PG.StarWarsGame.Infrastructure.Clients.Arguments; +using PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments; using Xunit; namespace PG.StarWarsGame.Infrastructure.Clients.Test.Arguments; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCommandLineBuilderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCommandLineBuilderTest.cs index 14507353..1a83b9b7 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCommandLineBuilderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCommandLineBuilderTest.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc.Clients.Arguments; -using PetroGlyph.Games.EawFoc.Clients.Arguments.GameArguments; +using PG.StarWarsGame.Infrastructure.Clients.Arguments; +using PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments; using Xunit; namespace PG.StarWarsGame.Infrastructure.Clients.Test.Arguments; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValidatorTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValidatorTest.cs index 891b3337..e16ea5fa 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValidatorTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValidatorTest.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -using PetroGlyph.Games.EawFoc.Clients.Arguments; -using PetroGlyph.Games.EawFoc.Clients.Arguments.GameArguments; +using PG.StarWarsGame.Infrastructure.Clients.Arguments; +using PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments; using Xunit; namespace PG.StarWarsGame.Infrastructure.Clients.Test.Arguments; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValueSerializerTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValueSerializerTest.cs index 8433a53d..464b242f 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValueSerializerTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValueSerializerTest.cs @@ -1,5 +1,5 @@ using System; -using PetroGlyph.Games.EawFoc.Clients.Arguments; +using PG.StarWarsGame.Infrastructure.Clients.Arguments; using PG.TestingUtilities; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/FlagArgumentTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/FlagArgumentTest.cs index eff9fb0e..049b6ccb 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/FlagArgumentTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/FlagArgumentTest.cs @@ -1,4 +1,4 @@ -using PetroGlyph.Games.EawFoc.Clients.Arguments; +using PG.StarWarsGame.Infrastructure.Clients.Arguments; using Xunit; namespace PG.StarWarsGame.Infrastructure.Clients.Test.Arguments; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/GameArgumentTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/GameArgumentTest.cs index aaf55ded..de88974a 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/GameArgumentTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/GameArgumentTest.cs @@ -1,5 +1,5 @@ using Moq; -using PetroGlyph.Games.EawFoc.Clients.Arguments; +using PG.StarWarsGame.Infrastructure.Clients.Arguments; using Xunit; namespace PG.StarWarsGame.Infrastructure.Clients.Test.Arguments; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/KeyBasedArgumentCollectionBuilderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/KeyBasedArgumentCollectionBuilderTest.cs index b711f972..06b88eff 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/KeyBasedArgumentCollectionBuilderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/KeyBasedArgumentCollectionBuilderTest.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; -using PetroGlyph.Games.EawFoc.Clients.Arguments; -using PetroGlyph.Games.EawFoc.Clients.Arguments.GameArguments; +using PG.StarWarsGame.Infrastructure.Clients.Arguments; +using PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments; using Xunit; namespace PG.StarWarsGame.Infrastructure.Clients.Test.Arguments; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListFactoryTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListFactoryTest.cs index c5091c60..284a8309 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListFactoryTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListFactoryTest.cs @@ -3,8 +3,6 @@ using Microsoft.Extensions.DependencyInjection; using Moq; using PetroGlyph.Games.EawFoc; -using PetroGlyph.Games.EawFoc.Clients.Arguments; -using PetroGlyph.Games.EawFoc.Clients.Arguments.GameArguments; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Mods; using PetroGlyph.Games.EawFoc.Services.Dependencies; @@ -12,6 +10,8 @@ using Testably.Abstractions.Testing; using Xunit; using System.Runtime.InteropServices; +using PG.StarWarsGame.Infrastructure.Clients.Arguments; +using PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments; namespace PG.StarWarsGame.Infrastructure.Clients.Test.Arguments; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListTest.cs index ef45d515..1b08b77d 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListTest.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -using PetroGlyph.Games.EawFoc.Clients.Arguments; -using PetroGlyph.Games.EawFoc.Clients.Arguments.GameArguments; +using PG.StarWarsGame.Infrastructure.Clients.Arguments; +using PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments; using Xunit; namespace PG.StarWarsGame.Infrastructure.Clients.Test.Arguments; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentTest.cs index 91984360..88e34565 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentTest.cs @@ -1,4 +1,4 @@ -using PetroGlyph.Games.EawFoc.Clients.Arguments.GameArguments; +using PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments; using Xunit; namespace PG.StarWarsGame.Infrastructure.Clients.Test.Arguments; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/NamedArgumentTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/NamedArgumentTest.cs index 582b665d..258f8d42 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/NamedArgumentTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/NamedArgumentTest.cs @@ -1,4 +1,4 @@ -using PetroGlyph.Games.EawFoc.Clients.Arguments; +using PG.StarWarsGame.Infrastructure.Clients.Arguments; using Xunit; namespace PG.StarWarsGame.Infrastructure.Clients.Test.Arguments; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/ClientBaseTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/ClientBaseTest.cs index 6bada0da..d708ecf7 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/ClientBaseTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/ClientBaseTest.cs @@ -4,12 +4,11 @@ using Microsoft.Extensions.DependencyInjection; using Moq; using PetroGlyph.Games.EawFoc; -using PetroGlyph.Games.EawFoc.Clients; -using PetroGlyph.Games.EawFoc.Clients.Arguments; -using PetroGlyph.Games.EawFoc.Clients.Arguments.GameArguments; -using PetroGlyph.Games.EawFoc.Clients.Processes; using PetroGlyph.Games.EawFoc.Games; using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Clients.Arguments; +using PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments; +using PG.StarWarsGame.Infrastructure.Clients.Processes; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/DebugableClientBaseTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/DebugableClientBaseTest.cs index ef33c127..9c085fac 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/DebugableClientBaseTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/DebugableClientBaseTest.cs @@ -3,10 +3,9 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc.Clients; -using PetroGlyph.Games.EawFoc.Clients.Arguments; -using PetroGlyph.Games.EawFoc.Clients.Processes; using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Clients.Arguments; +using PG.StarWarsGame.Infrastructure.Clients.Processes; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/DefaultClientTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/DefaultClientTest.cs index b2a2660e..b8a800da 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/DefaultClientTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/DefaultClientTest.cs @@ -1,9 +1,8 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc.Clients; -using PetroGlyph.Games.EawFoc.Clients.Processes; using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Clients.Processes; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableFileServiceTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableFileServiceTest.cs index b9a3e2bf..54a32044 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableFileServiceTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableFileServiceTest.cs @@ -1,6 +1,5 @@ using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc.Clients; using PetroGlyph.Games.EawFoc.Games; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableNameBuilderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableNameBuilderTest.cs index d1f91ba4..1571286a 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableNameBuilderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableNameBuilderTest.cs @@ -1,5 +1,4 @@ using Moq; -using PetroGlyph.Games.EawFoc.Clients; using PetroGlyph.Games.EawFoc.Games; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/DefaultGameProcessLauncherTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/DefaultGameProcessLauncherTest.cs index ca1c1ca9..464eb8d8 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/DefaultGameProcessLauncherTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/DefaultGameProcessLauncherTest.cs @@ -1,9 +1,8 @@ using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc.Clients; -using PetroGlyph.Games.EawFoc.Clients.Arguments; -using PetroGlyph.Games.EawFoc.Clients.Processes; using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Clients.Arguments; +using PG.StarWarsGame.Infrastructure.Clients.Processes; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/GameProcessTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/GameProcessTest.cs index 0a30d75d..f92af242 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/GameProcessTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/GameProcessTest.cs @@ -3,10 +3,9 @@ using System.Threading; using System.Threading.Tasks; using Moq; -using PetroGlyph.Games.EawFoc.Clients; -using PetroGlyph.Games.EawFoc.Clients.Arguments; -using PetroGlyph.Games.EawFoc.Clients.Processes; using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Clients.Arguments; +using PG.StarWarsGame.Infrastructure.Clients.Processes; using Xunit; namespace PG.StarWarsGame.Infrastructure.Clients.Test.Processes; From 438b2df0f693ee0c25e600508b9932f78a009297 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Thu, 14 Mar 2024 18:13:51 +0100 Subject: [PATCH 14/41] rename other ns --- sample/SampleApplication/Program.cs | 14 +++++++------- .../src/SteamLibraryFinder.cs | 1 - .../src/SteamVdfReader.cs | 1 - .../src/SteamWrapper.cs | 1 - .../test/Steam/SteamLibraryFinderTest.cs | 1 - .../test/Steam/SteamVdfReaderTest.cs | 1 - .../src/DefaultGameClientFactory.cs | 2 +- .../src/ISteamWrapper.cs | 1 - .../src/SteamGameClient.cs | 2 +- .../src/SteamGameLanguageFinder.cs | 4 ++-- .../src/SteamPetroglyphStarWarsGameDetector.cs | 6 +++--- .../test/SteamGameClientTest.cs | 2 +- .../test/SteamGameLanguageFinderTest.cs | 2 +- .../SteamPetroglyphStarWarsGameDetectorTest.cs | 6 +++--- .../src/Arguments/GameArgumentException.cs | 4 +--- .../src/Arguments/GameArguments/GameArguments.cs | 2 +- .../src/Arguments/IModArgumentListFactory.cs | 2 +- .../src/Arguments/ModArgumentListFactory.cs | 7 +++---- .../src/ClientBase.cs | 5 ++--- .../src/DebugableClientBase.cs | 1 - .../src/DefaultClient.cs | 2 +- .../src/GameExecutableFileService.cs | 2 +- .../src/GameExecutableNameBuilder.cs | 2 +- .../src/GameStartException.cs | 1 - .../src/GameStartingEventArgs.cs | 1 - .../src/IDebugableGameClient.cs | 5 ++--- .../src/IGameClient.cs | 5 ++--- .../src/IGameClientFactory.cs | 2 +- .../src/IGameExecutableFileService.cs | 2 +- .../src/IGameExecutableNameBuilder.cs | 2 +- .../src/Processes/GameProcessInfo.cs | 1 - .../test/Arguments/ModArgumentListFactoryTest.cs | 9 ++++----- .../test/ClientBaseTest.cs | 5 ++--- .../test/DebugableClientBaseTest.cs | 2 +- .../test/DefaultClientTest.cs | 2 +- .../test/GameExecutableFileServiceTest.cs | 2 +- .../test/GameExecutableNameBuilderTest.cs | 2 +- .../Processes/DefaultGameProcessLauncherTest.cs | 2 +- .../test/Processes/GameProcessTest.cs | 2 +- .../src/Games/GameException.cs | 2 +- .../src/Games/GameIdentity.cs | 2 +- .../src/Games/GamePlatform.cs | 2 +- src/PetroGlyph.Games.EawFoc/src/Games/GameType.cs | 2 +- src/PetroGlyph.Games.EawFoc/src/Games/IGame.cs | 2 +- .../src/Games/IGameIdentity.cs | 2 +- .../src/Games/PetroglyphStarWarsGame.cs | 12 ++++++------ .../src/Games/PetroglyphStarWarsGameConstants.cs | 2 +- .../src/Games/Registry/GameRegistryBase.cs | 6 ++---- .../src/Games/Registry/GameRegistryFactory.cs | 3 ++- .../Registry/GameRegistryNotFoundException.cs | 2 +- .../src/Games/Registry/IGameRegistry.cs | 2 +- .../src/Games/Registry/IGameRegistryFactory.cs | 2 +- src/PetroGlyph.Games.EawFoc/src/IModContainer.cs | 6 +++--- .../src/IPhysicalPlayableObject.cs | 4 ++-- src/PetroGlyph.Games.EawFoc/src/IPlayableObject.cs | 6 +++--- .../src/ModCollectionChangedAction.cs | 2 +- .../src/ModCollectionChangedEventArgs.cs | 4 ++-- src/PetroGlyph.Games.EawFoc/src/Mods/IMod.cs | 4 ++-- .../src/Mods/IPhysicalMod.cs | 2 +- .../src/Mods/IVirtualMod.cs | 2 +- src/PetroGlyph.Games.EawFoc/src/Mods/Mod.cs | 8 ++++---- src/PetroGlyph.Games.EawFoc/src/Mods/ModBase.cs | 10 +++++----- .../src/Mods/ModDependenciesChangedEventArgs.cs | 2 +- .../src/Mods/ModDependencyCycleException.cs | 2 +- .../src/Mods/ModDependencyEntry.cs | 2 +- .../src/Mods/ModEqualityComparer.cs | 2 +- .../src/Mods/ModException.cs | 2 +- .../src/Mods/ModNotFoundException.cs | 2 +- .../src/Mods/ModinfoResolvedEventArgs.cs | 2 +- .../src/Mods/ResolvingModinfoEventArgs.cs | 2 +- src/PetroGlyph.Games.EawFoc/src/Mods/VirtualMod.cs | 8 ++++---- .../src/PetroglyphException.cs | 2 +- .../src/PetroglyphGameInfrastructureLibrary.cs | 8 ++++---- src/PetroGlyph.Games.EawFoc/src/PlayableObject.cs | 4 ++-- .../Games/Detection/CompositeGameDetector.cs | 2 +- .../Games/Detection/DirectoryGameDetector.cs | 4 ++-- .../Games/Detection/GameDetectionResult.cs | 4 ++-- .../src/Services/Games/Detection/GameDetector.cs | 6 +++--- .../Games/Detection/GameDetectorOptions.cs | 4 ++-- .../Detection/GameInitializeRequestEventArgs.cs | 2 +- .../src/Services/Games/Detection/IGameDetector.cs | 2 +- .../Games/Detection/Platform/DiskGoldIdentifier.cs | 4 ++-- .../Games/Detection/Platform/DiskIdentifier.cs | 4 ++-- .../Detection/Platform/GamePlatformIdentifier.cs | 4 ++-- .../Platform/GamePlatformIdentifierFactory.cs | 4 ++-- .../Games/Detection/Platform/GogIdentifier.cs | 4 ++-- .../Detection/Platform/IGamePlatformIdentifier.cs | 4 ++-- .../Platform/ISpecificPlatformIdentifier.cs | 4 ++-- .../Games/Detection/Platform/OriginIdentifier.cs | 4 ++-- .../Platform/SpecificPlatformIdentifier.cs | 6 +++--- .../Games/Detection/Platform/SteamIdentifier.cs | 4 ++-- .../Games/Detection/RegistryGameDetector.cs | 6 +++--- .../src/Services/Games/GameFactory.cs | 8 ++++---- .../src/Services/Games/IGameFactory.cs | 6 +++--- .../Services/Games/Icon/CompositeGameIconFinder.cs | 4 ++-- .../Services/Games/Icon/FallbackGameIconFinder.cs | 4 ++-- .../src/Services/Games/Icon/IGameIconFinder.cs | 4 ++-- .../Services/Games/Language/GameLanguageFinder.cs | 4 ++-- .../Services/Games/Language/IGameLanguageFinder.cs | 4 ++-- .../Services/Games/Name/EnglishGameNameResolver.cs | 4 ++-- .../src/Services/Games/Name/IGameNameResolver.cs | 4 ++-- .../src/Services/Games/Steam/ISteamGameHelpers.cs | 4 ++-- .../Games/Steam/ISteamWorkshopWebpageDownloader.cs | 2 +- .../src/Services/Games/Steam/SteamGameHelpers.cs | 4 ++-- .../Games/Steam/SteamWorkshopWebpageDownloader.cs | 2 +- .../Mods/Dependencies/DependencyResolveStatus.cs | 4 ++-- .../Mods/Dependencies/DependencyResolverOptions.cs | 2 +- .../Mods/Dependencies/IDependencyResolver.cs | 4 ++-- .../Mods/Dependencies/IModDependencyGraph.cs | 4 ++-- .../Dependencies/IModDependencyGraphBuilder.cs | 4 ++-- .../Mods/Dependencies/IModDependencyTraverser.cs | 4 ++-- .../Mods/Dependencies/ModDependencyGraph.cs | 4 ++-- .../Mods/Dependencies/ModDependencyGraphBuilder.cs | 4 ++-- .../Mods/Dependencies/ModDependencyResolver.cs | 4 ++-- .../Mods/Dependencies/ModDependencyTraverser.cs | 4 ++-- .../Dependencies/MultiModDependencyResolver.cs | 4 ++-- .../Services/Mods/Detection/FileSystemModFinder.cs | 6 +++--- .../Mods/Detection/IModIdentiferNormalizer.cs | 4 ++-- .../Services/Mods/Detection/IModReferenceFinder.cs | 4 ++-- .../Detection/IModReferenceLocationResolver.cs | 4 ++-- .../Mods/Detection/ModIdentifierBuilder.cs | 4 ++-- .../Mods/Detection/ModReferenceLocationResolver.cs | 12 +++++++----- .../src/Services/Mods/IModFactory.cs | 6 +++--- .../Services/Mods/Icon/CompositeModIconFinder.cs | 4 ++-- .../src/Services/Mods/Icon/IModIconFinder.cs | 4 ++-- .../src/Services/Mods/Icon/SimpleModIconFinder.cs | 4 ++-- .../Services/Mods/Language/IModLanguageFinder.cs | 4 ++-- .../Mods/Language/IModLanguageFinderFactory.cs | 4 ++-- .../Mods/Language/ModLanguageFinderBase.cs | 6 +++--- .../Mods/Language/ModLanguageFinderFactory.cs | 4 ++-- .../Mods/Language/PhysicalModLanguageFinder.cs | 4 ++-- .../Mods/Language/VirtualModLanguageFinder.cs | 4 ++-- .../src/Services/Mods/ModFactory.cs | 10 +++++----- .../Services/Mods/Name/CompositeModNameResolver.cs | 2 +- .../Services/Mods/Name/DirectoryModNameResolver.cs | 4 ++-- .../src/Services/Mods/Name/IModNameResolver.cs | 2 +- .../src/Services/Mods/Name/ModNameResolverBase.cs | 2 +- .../Mods/Name/OnlineWorkshopNameResolver.cs | 4 ++-- .../Shared/FileService/DefaultFileService.cs | 7 +++---- .../Shared/FileService/IPhysicalFileService.cs | 2 +- .../Shared/Language/FileBasedLanguageFinder.cs | 2 +- .../Services/Shared/Language/ILanguageFinder.cs | 2 +- .../Shared/Language/LanguageInfoUtilities.cs | 2 +- src/PetroGlyph.Games.EawFoc/src/SteamException.cs | 2 +- src/PetroGlyph.Games.EawFoc/src/ThrowHelper.cs | 2 +- .../test/FileBasedLanguageFinderTest.cs | 6 +++--- .../test/GameRegistryFactoryTest.cs | 4 ++-- .../GameServices/CompositeGameIconFinderTest.cs | 4 ++-- .../Detection/CompositeDetectorTest.cs | 4 ++-- .../Detection/DirectoryGameDetectorTest.cs | 6 +++--- .../GameServices/Detection/GameDetectorTest.cs | 6 +++--- .../Detection/GamePlatformIdentifierTest.cs | 4 ++-- .../Detection/RegistryGameDetectorTest.cs | 6 +++--- .../GameServices/EnglishGameNameResolverTest.cs | 4 ++-- .../test/GameServices/FallbackIconFinderTest.cs | 6 +++--- .../test/GameServices/GameFactoryTest.cs | 8 ++++---- .../test/GameServices/GameHelperTest.cs | 5 ++--- .../test/GameServices/GameLanguageFinderTest.cs | 4 ++-- .../SteamWorkshopWebpageDownloaderTest.cs | 2 +- src/PetroGlyph.Games.EawFoc/test/GameTest.cs | 7 +++---- .../test/LanguageInfoUtilitiesTest.cs | 2 +- src/PetroGlyph.Games.EawFoc/test/ModBaseTest.cs | 11 +++++------ .../test/ModDependencyEntryTest.cs | 2 +- .../test/ModEqualityComparerTest.cs | 4 ++-- .../test/ModServices/CompositeModIconFinderTest.cs | 4 ++-- .../ModServices/CompositeModNameResolverTest.cs | 3 +-- .../ModServices/DirectoryModNameResolverTest.cs | 2 +- .../test/ModServices/FileSystemModFinderTest.cs | 6 +++--- .../ModDependencyGraphBuilderIntegrationTest.cs | 6 +++--- .../ModServices/ModDependencyGraphBuilderTest.cs | 6 +++--- .../ModDependencyResolverIntegrationTest.cs | 7 +++---- .../test/ModServices/ModDependencyResolverTest.cs | 6 +++--- .../ModDependencyTraverserIntegrationTest.cs | 8 ++++---- .../test/ModServices/ModDependencyTraverserTest.cs | 4 ++-- .../test/ModServices/ModFactoryTest.cs | 8 ++++---- .../test/ModServices/ModIdentifierBuilderTest.cs | 4 ++-- .../test/ModServices/ModLanguageFinderBaseTest.cs | 6 +++--- src/PetroGlyph.Games.EawFoc/test/ModTest.cs | 6 +++--- .../test/PlayableObjectTest.cs | 3 +-- src/PetroGlyph.Games.EawFoc/test/VirtualModTest.cs | 9 ++++----- 180 files changed, 345 insertions(+), 370 deletions(-) diff --git a/sample/SampleApplication/Program.cs b/sample/SampleApplication/Program.cs index 14e25295..8d091de8 100644 --- a/sample/SampleApplication/Program.cs +++ b/sample/SampleApplication/Program.cs @@ -3,15 +3,15 @@ using System.Linq; using AnakinRaW.CommonUtilities.Registry.Windows; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Mods; -using PetroGlyph.Games.EawFoc.Services; -using PetroGlyph.Games.EawFoc.Services.Dependencies; -using PetroGlyph.Games.EawFoc.Services.Detection; -using PetroGlyph.Games.EawFoc.Services.Name; +using PG.StarWarsGame.Infrastructure; using PG.StarWarsGame.Infrastructure.Clients; using PG.StarWarsGame.Infrastructure.Clients.Steam; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Mods; +using PG.StarWarsGame.Infrastructure.Services; +using PG.StarWarsGame.Infrastructure.Services.Dependencies; +using PG.StarWarsGame.Infrastructure.Services.Detection; +using PG.StarWarsGame.Infrastructure.Services.Name; var sp = SetupApplication(); diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibraryFinder.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibraryFinder.cs index 22af4f29..c1fdbec1 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibraryFinder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibraryFinder.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc; namespace PG.StarWarsGame.Infrastructure.Clients.Steam; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamVdfReader.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamVdfReader.cs index 687499c1..091d6401 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamVdfReader.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamVdfReader.cs @@ -7,7 +7,6 @@ using Gameloop.Vdf.JsonConverter; using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json.Linq; -using PetroGlyph.Games.EawFoc; namespace PG.StarWarsGame.Infrastructure.Clients.Steam; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamWrapper.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamWrapper.cs index f2ad4f3e..12670053 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamWrapper.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamWrapper.cs @@ -9,7 +9,6 @@ using Gameloop.Vdf; using Gameloop.Vdf.JsonConverter; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc; using PG.StarWarsGame.Infrastructure.Clients.Processes; using PG.StarWarsGame.Infrastructure.Clients.Steam.NativeMethods; using PG.StarWarsGame.Infrastructure.Clients.Steam.Threading; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryFinderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryFinderTest.cs index 4a63aca1..704f08ca 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryFinderTest.cs @@ -3,7 +3,6 @@ using System.Linq; using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamVdfReaderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamVdfReaderTest.cs index b0047ccf..c5ed43f5 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamVdfReaderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamVdfReaderTest.cs @@ -2,7 +2,6 @@ using System.Linq; using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/DefaultGameClientFactory.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/DefaultGameClientFactory.cs index 1d3f3a0b..a2290219 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/DefaultGameClientFactory.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/DefaultGameClientFactory.cs @@ -1,5 +1,5 @@ using System; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; namespace PG.StarWarsGame.Infrastructure.Clients.Steam; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamWrapper.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamWrapper.cs index 98672551..15fe5cf1 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamWrapper.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamWrapper.cs @@ -1,6 +1,5 @@ using System.Threading; using System.Threading.Tasks; -using PetroGlyph.Games.EawFoc; #if NET using System.Diagnostics.CodeAnalysis; #endif diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameClient.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameClient.cs index da768218..2569c2a5 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameClient.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameClient.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Games; using PG.StarWarsGame.Infrastructure.Clients.Processes; +using PG.StarWarsGame.Infrastructure.Games; namespace PG.StarWarsGame.Infrastructure.Clients.Steam; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameLanguageFinder.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameLanguageFinder.cs index b64c9c74..8cd9dc96 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameLanguageFinder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameLanguageFinder.cs @@ -3,8 +3,8 @@ using EawModinfo.Model; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Services.Language; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Services.Language; namespace PG.StarWarsGame.Infrastructure.Clients.Steam; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamPetroglyphStarWarsGameDetector.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamPetroglyphStarWarsGameDetector.cs index 5a9e7cc1..0a54b88e 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamPetroglyphStarWarsGameDetector.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamPetroglyphStarWarsGameDetector.cs @@ -1,9 +1,9 @@ using System; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Games.Registry; -using PetroGlyph.Games.EawFoc.Services.Detection; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Games.Registry; +using PG.StarWarsGame.Infrastructure.Services.Detection; namespace PG.StarWarsGame.Infrastructure.Clients.Steam; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameClientTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameClientTest.cs index ee92b0ea..e4b228b3 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameClientTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameClientTest.cs @@ -1,8 +1,8 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc.Games; using PG.StarWarsGame.Infrastructure.Clients.Processes; +using PG.StarWarsGame.Infrastructure.Games; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameLanguageFinderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameLanguageFinderTest.cs index 4ed0d373..25dbcccb 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameLanguageFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameLanguageFinderTest.cs @@ -4,7 +4,7 @@ using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamPetroglyphStarWarsGameDetectorTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamPetroglyphStarWarsGameDetectorTest.cs index bd5d1189..6a738fa5 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamPetroglyphStarWarsGameDetectorTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamPetroglyphStarWarsGameDetectorTest.cs @@ -3,9 +3,9 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Games.Registry; -using PetroGlyph.Games.EawFoc.Services.Detection; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Games.Registry; +using PG.StarWarsGame.Infrastructure.Services.Detection; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArgumentException.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArgumentException.cs index 8f623e30..a6c3d39f 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArgumentException.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArgumentException.cs @@ -1,6 +1,4 @@ -using PetroGlyph.Games.EawFoc; - -namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; +namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; /// /// The exception that is thrown when a or handling it caused an error. diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArguments/GameArguments.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArguments/GameArguments.cs index cfc2ac98..9d4a7daa 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArguments/GameArguments.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/GameArguments/GameArguments.cs @@ -1,6 +1,6 @@ using System.IO.Abstractions; using EawModinfo.Spec; -using PetroGlyph.Games.EawFoc.Services.Language; +using PG.StarWarsGame.Infrastructure.Services.Language; namespace PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IModArgumentListFactory.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IModArgumentListFactory.cs index c6ae5fdb..bbd057c7 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IModArgumentListFactory.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/IModArgumentListFactory.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -using PetroGlyph.Games.EawFoc.Mods; using PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments; +using PG.StarWarsGame.Infrastructure.Mods; namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ModArgumentListFactory.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ModArgumentListFactory.cs index b32f0210..854cc0f1 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ModArgumentListFactory.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ModArgumentListFactory.cs @@ -3,11 +3,10 @@ using System.Linq; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc; -using PetroGlyph.Games.EawFoc.Mods; -using PetroGlyph.Games.EawFoc.Services.Dependencies; -using PetroGlyph.Games.EawFoc.Services.Steam; using PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments; +using PG.StarWarsGame.Infrastructure.Mods; +using PG.StarWarsGame.Infrastructure.Services.Dependencies; +using PG.StarWarsGame.Infrastructure.Services.Steam; namespace PG.StarWarsGame.Infrastructure.Clients.Arguments; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/ClientBase.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/ClientBase.cs index 38792d93..e11d60a1 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/ClientBase.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/ClientBase.cs @@ -2,11 +2,10 @@ using System.Collections.Generic; using System.Linq; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Mods; using PG.StarWarsGame.Infrastructure.Clients.Arguments; using PG.StarWarsGame.Infrastructure.Clients.Processes; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Mods; namespace PG.StarWarsGame.Infrastructure.Clients; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/DebugableClientBase.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/DebugableClientBase.cs index e6210c30..49766b70 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/DebugableClientBase.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/DebugableClientBase.cs @@ -1,6 +1,5 @@ using System; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc; using PG.StarWarsGame.Infrastructure.Clients.Arguments; using PG.StarWarsGame.Infrastructure.Clients.Processes; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/DefaultClient.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/DefaultClient.cs index ca496b87..0fd1700c 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/DefaultClient.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/DefaultClient.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Games; using PG.StarWarsGame.Infrastructure.Clients.Processes; +using PG.StarWarsGame.Infrastructure.Games; namespace PG.StarWarsGame.Infrastructure.Clients; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/GameExecutableFileService.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/GameExecutableFileService.cs index d422b68d..9310fa88 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/GameExecutableFileService.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/GameExecutableFileService.cs @@ -3,7 +3,7 @@ using System.IO.Abstractions; using System.Linq; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; namespace PG.StarWarsGame.Infrastructure.Clients; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/GameExecutableNameBuilder.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/GameExecutableNameBuilder.cs index d5e0016e..bc0f9133 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/GameExecutableNameBuilder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/GameExecutableNameBuilder.cs @@ -1,5 +1,5 @@ using System; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; namespace PG.StarWarsGame.Infrastructure.Clients; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/GameStartException.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/GameStartException.cs index d23cabed..6786e680 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/GameStartException.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/GameStartException.cs @@ -1,5 +1,4 @@ using System; -using PetroGlyph.Games.EawFoc; namespace PG.StarWarsGame.Infrastructure.Clients; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/GameStartingEventArgs.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/GameStartingEventArgs.cs index e28491a1..a8b0ecdd 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/GameStartingEventArgs.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/GameStartingEventArgs.cs @@ -1,5 +1,4 @@ using System.ComponentModel; -using PetroGlyph.Games.EawFoc; using PG.StarWarsGame.Infrastructure.Clients.Arguments; namespace PG.StarWarsGame.Infrastructure.Clients; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/IDebugableGameClient.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/IDebugableGameClient.cs index d03652f1..1e66f789 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/IDebugableGameClient.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/IDebugableGameClient.cs @@ -1,7 +1,6 @@ -using PetroGlyph.Games.EawFoc; -using PetroGlyph.Games.EawFoc.Mods; -using PG.StarWarsGame.Infrastructure.Clients.Arguments; +using PG.StarWarsGame.Infrastructure.Clients.Arguments; using PG.StarWarsGame.Infrastructure.Clients.Processes; +using PG.StarWarsGame.Infrastructure.Mods; namespace PG.StarWarsGame.Infrastructure.Clients; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/IGameClient.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/IGameClient.cs index 451f2d0a..8f881f8e 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/IGameClient.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/IGameClient.cs @@ -1,10 +1,9 @@ using System; using System.Collections.Generic; -using PetroGlyph.Games.EawFoc; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Mods; using PG.StarWarsGame.Infrastructure.Clients.Arguments; using PG.StarWarsGame.Infrastructure.Clients.Processes; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Mods; namespace PG.StarWarsGame.Infrastructure.Clients; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/IGameClientFactory.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/IGameClientFactory.cs index ccaca126..1067d24d 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/IGameClientFactory.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/IGameClientFactory.cs @@ -1,5 +1,5 @@ using System; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; namespace PG.StarWarsGame.Infrastructure.Clients; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/IGameExecutableFileService.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/IGameExecutableFileService.cs index 756cb434..f0dd7340 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/IGameExecutableFileService.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/IGameExecutableFileService.cs @@ -1,5 +1,5 @@ using System.IO.Abstractions; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; namespace PG.StarWarsGame.Infrastructure.Clients; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/IGameExecutableNameBuilder.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/IGameExecutableNameBuilder.cs index db8b407c..156acd30 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/IGameExecutableNameBuilder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/IGameExecutableNameBuilder.cs @@ -1,4 +1,4 @@ -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; namespace PG.StarWarsGame.Infrastructure.Clients; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcessInfo.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcessInfo.cs index 9ac48b5c..a77a1a9f 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcessInfo.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/GameProcessInfo.cs @@ -1,5 +1,4 @@ using System; -using PetroGlyph.Games.EawFoc; using PG.StarWarsGame.Infrastructure.Clients.Arguments; namespace PG.StarWarsGame.Infrastructure.Clients.Processes; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListFactoryTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListFactoryTest.cs index 284a8309..529f5214 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListFactoryTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListFactoryTest.cs @@ -2,16 +2,15 @@ using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Mods; -using PetroGlyph.Games.EawFoc.Services.Dependencies; -using PetroGlyph.Games.EawFoc.Services.Steam; using Testably.Abstractions.Testing; using Xunit; using System.Runtime.InteropServices; using PG.StarWarsGame.Infrastructure.Clients.Arguments; using PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Mods; +using PG.StarWarsGame.Infrastructure.Services.Dependencies; +using PG.StarWarsGame.Infrastructure.Services.Steam; namespace PG.StarWarsGame.Infrastructure.Clients.Test.Arguments; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/ClientBaseTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/ClientBaseTest.cs index d708ecf7..c359cc3f 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/ClientBaseTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/ClientBaseTest.cs @@ -3,12 +3,11 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Mods; using PG.StarWarsGame.Infrastructure.Clients.Arguments; using PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments; using PG.StarWarsGame.Infrastructure.Clients.Processes; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Mods; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/DebugableClientBaseTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/DebugableClientBaseTest.cs index 9c085fac..280744cc 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/DebugableClientBaseTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/DebugableClientBaseTest.cs @@ -3,9 +3,9 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc.Games; using PG.StarWarsGame.Infrastructure.Clients.Arguments; using PG.StarWarsGame.Infrastructure.Clients.Processes; +using PG.StarWarsGame.Infrastructure.Games; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/DefaultClientTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/DefaultClientTest.cs index b8a800da..8092c662 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/DefaultClientTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/DefaultClientTest.cs @@ -1,8 +1,8 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc.Games; using PG.StarWarsGame.Infrastructure.Clients.Processes; +using PG.StarWarsGame.Infrastructure.Games; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableFileServiceTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableFileServiceTest.cs index 54a32044..571d5099 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableFileServiceTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableFileServiceTest.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableNameBuilderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableNameBuilderTest.cs index 1571286a..c0b0fffc 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableNameBuilderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/GameExecutableNameBuilderTest.cs @@ -1,5 +1,5 @@ using Moq; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; using Xunit; namespace PG.StarWarsGame.Infrastructure.Clients.Test; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/DefaultGameProcessLauncherTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/DefaultGameProcessLauncherTest.cs index 464eb8d8..c9e2af67 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/DefaultGameProcessLauncherTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/DefaultGameProcessLauncherTest.cs @@ -1,8 +1,8 @@ using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc.Games; using PG.StarWarsGame.Infrastructure.Clients.Arguments; using PG.StarWarsGame.Infrastructure.Clients.Processes; +using PG.StarWarsGame.Infrastructure.Games; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/GameProcessTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/GameProcessTest.cs index f92af242..647c7f43 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/GameProcessTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/GameProcessTest.cs @@ -3,9 +3,9 @@ using System.Threading; using System.Threading.Tasks; using Moq; -using PetroGlyph.Games.EawFoc.Games; using PG.StarWarsGame.Infrastructure.Clients.Arguments; using PG.StarWarsGame.Infrastructure.Clients.Processes; +using PG.StarWarsGame.Infrastructure.Games; using Xunit; namespace PG.StarWarsGame.Infrastructure.Clients.Test.Processes; diff --git a/src/PetroGlyph.Games.EawFoc/src/Games/GameException.cs b/src/PetroGlyph.Games.EawFoc/src/Games/GameException.cs index e753d278..673bab81 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Games/GameException.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Games/GameException.cs @@ -1,6 +1,6 @@ using System; -namespace PetroGlyph.Games.EawFoc.Games; +namespace PG.StarWarsGame.Infrastructure.Games; /// /// for anything related to an diff --git a/src/PetroGlyph.Games.EawFoc/src/Games/GameIdentity.cs b/src/PetroGlyph.Games.EawFoc/src/Games/GameIdentity.cs index bfdc237c..77ef3892 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Games/GameIdentity.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Games/GameIdentity.cs @@ -1,4 +1,4 @@ -namespace PetroGlyph.Games.EawFoc.Games; +namespace PG.StarWarsGame.Infrastructure.Games; /// /// Minimal information to identify and distinguish Petroglyph Star Wars games from each other. diff --git a/src/PetroGlyph.Games.EawFoc/src/Games/GamePlatform.cs b/src/PetroGlyph.Games.EawFoc/src/Games/GamePlatform.cs index bd5c5234..bff970ec 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Games/GamePlatform.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Games/GamePlatform.cs @@ -1,4 +1,4 @@ -namespace PetroGlyph.Games.EawFoc.Games; +namespace PG.StarWarsGame.Infrastructure.Games; /// /// The platform the game was packaged for. diff --git a/src/PetroGlyph.Games.EawFoc/src/Games/GameType.cs b/src/PetroGlyph.Games.EawFoc/src/Games/GameType.cs index 2b0d0f05..54accda0 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Games/GameType.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Games/GameType.cs @@ -1,4 +1,4 @@ -namespace PetroGlyph.Games.EawFoc.Games; +namespace PG.StarWarsGame.Infrastructure.Games; /// /// The type of the game can be either "Empire at War" of "Forces of Corruption" diff --git a/src/PetroGlyph.Games.EawFoc/src/Games/IGame.cs b/src/PetroGlyph.Games.EawFoc/src/Games/IGame.cs index a806d13a..376db99c 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Games/IGame.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Games/IGame.cs @@ -1,7 +1,7 @@ using System; using System.IO.Abstractions; -namespace PetroGlyph.Games.EawFoc.Games; +namespace PG.StarWarsGame.Infrastructure.Games; /// /// Representation of a Petroglyph Star Wars Game. diff --git a/src/PetroGlyph.Games.EawFoc/src/Games/IGameIdentity.cs b/src/PetroGlyph.Games.EawFoc/src/Games/IGameIdentity.cs index 233fb437..c369ccef 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Games/IGameIdentity.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Games/IGameIdentity.cs @@ -1,4 +1,4 @@ -namespace PetroGlyph.Games.EawFoc.Games; +namespace PG.StarWarsGame.Infrastructure.Games; /// /// Minimal information to identify and distinguish Petroglyph Star Wars games from each other. diff --git a/src/PetroGlyph.Games.EawFoc/src/Games/PetroglyphStarWarsGame.cs b/src/PetroGlyph.Games.EawFoc/src/Games/PetroglyphStarWarsGame.cs index 27bbe671..ec9b92a6 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Games/PetroglyphStarWarsGame.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Games/PetroglyphStarWarsGame.cs @@ -7,13 +7,13 @@ using AnakinRaW.CommonUtilities.FileSystem.Normalization; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Mods; -using PetroGlyph.Games.EawFoc.Services.Detection; -using PetroGlyph.Games.EawFoc.Services.FileService; -using PetroGlyph.Games.EawFoc.Services.Icon; -using PetroGlyph.Games.EawFoc.Services.Language; +using PG.StarWarsGame.Infrastructure.Mods; +using PG.StarWarsGame.Infrastructure.Services.Detection; +using PG.StarWarsGame.Infrastructure.Services.FileService; +using PG.StarWarsGame.Infrastructure.Services.Icon; +using PG.StarWarsGame.Infrastructure.Services.Language; -namespace PetroGlyph.Games.EawFoc.Games; +namespace PG.StarWarsGame.Infrastructure.Games; /// /// Represents a Petroglyph Star War Game, which is either Empire at War or Forces of Corruption. diff --git a/src/PetroGlyph.Games.EawFoc/src/Games/PetroglyphStarWarsGameConstants.cs b/src/PetroGlyph.Games.EawFoc/src/Games/PetroglyphStarWarsGameConstants.cs index f64ad844..37b7e167 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Games/PetroglyphStarWarsGameConstants.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Games/PetroglyphStarWarsGameConstants.cs @@ -1,4 +1,4 @@ -namespace PetroGlyph.Games.EawFoc.Games; +namespace PG.StarWarsGame.Infrastructure.Games; /// /// Common constants for Petroglyph Star Wars game. diff --git a/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryBase.cs b/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryBase.cs index f50f002b..4517ceff 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryBase.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryBase.cs @@ -1,12 +1,10 @@ using System; +using System.Diagnostics.CodeAnalysis; using System.IO.Abstractions; using AnakinRaW.CommonUtilities.Registry; using Microsoft.Extensions.DependencyInjection; -#if NET -using System.Diagnostics.CodeAnalysis; -#endif -namespace PetroGlyph.Games.EawFoc.Games.Registry; +namespace PG.StarWarsGame.Infrastructure.Games.Registry; /// /// Windows only registry wrapper for an Petroglyph Star Wars game. diff --git a/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryFactory.cs b/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryFactory.cs index 7901b045..dcfbdd39 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryFactory.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryFactory.cs @@ -1,7 +1,8 @@ using System; using AnakinRaW.CommonUtilities.Registry; using Microsoft.Extensions.DependencyInjection; -namespace PetroGlyph.Games.EawFoc.Games.Registry; + +namespace PG.StarWarsGame.Infrastructure.Games.Registry; /// public class GameRegistryFactory : IGameRegistryFactory diff --git a/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryNotFoundException.cs b/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryNotFoundException.cs index 6853c8d9..0266e09d 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryNotFoundException.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Games/Registry/GameRegistryNotFoundException.cs @@ -1,6 +1,6 @@ using System; -namespace PetroGlyph.Games.EawFoc.Games.Registry; +namespace PG.StarWarsGame.Infrastructure.Games.Registry; /// /// The exception that is thrown when a could not be found. diff --git a/src/PetroGlyph.Games.EawFoc/src/Games/Registry/IGameRegistry.cs b/src/PetroGlyph.Games.EawFoc/src/Games/Registry/IGameRegistry.cs index 8b75ca64..7f36bb95 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Games/Registry/IGameRegistry.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Games/Registry/IGameRegistry.cs @@ -1,7 +1,7 @@ using System; using System.IO.Abstractions; -namespace PetroGlyph.Games.EawFoc.Games.Registry; +namespace PG.StarWarsGame.Infrastructure.Games.Registry; /// /// A Registry wrapper for an . diff --git a/src/PetroGlyph.Games.EawFoc/src/Games/Registry/IGameRegistryFactory.cs b/src/PetroGlyph.Games.EawFoc/src/Games/Registry/IGameRegistryFactory.cs index 162d8414..26b99fa3 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Games/Registry/IGameRegistryFactory.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Games/Registry/IGameRegistryFactory.cs @@ -1,6 +1,6 @@ using System; -namespace PetroGlyph.Games.EawFoc.Games.Registry; +namespace PG.StarWarsGame.Infrastructure.Games.Registry; /// /// Factory service to create an diff --git a/src/PetroGlyph.Games.EawFoc/src/IModContainer.cs b/src/PetroGlyph.Games.EawFoc/src/IModContainer.cs index 451fe672..dcf25797 100644 --- a/src/PetroGlyph.Games.EawFoc/src/IModContainer.cs +++ b/src/PetroGlyph.Games.EawFoc/src/IModContainer.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; using EawModinfo.Spec; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc; +namespace PG.StarWarsGame.Infrastructure; /// /// This instance can be parent for one or many mods. diff --git a/src/PetroGlyph.Games.EawFoc/src/IPhysicalPlayableObject.cs b/src/PetroGlyph.Games.EawFoc/src/IPhysicalPlayableObject.cs index 0c7a65b4..04b5776b 100644 --- a/src/PetroGlyph.Games.EawFoc/src/IPhysicalPlayableObject.cs +++ b/src/PetroGlyph.Games.EawFoc/src/IPhysicalPlayableObject.cs @@ -1,8 +1,8 @@ using System.IO; using System.IO.Abstractions; -using PetroGlyph.Games.EawFoc.Services.FileService; +using PG.StarWarsGame.Infrastructure.Services.FileService; -namespace PetroGlyph.Games.EawFoc; +namespace PG.StarWarsGame.Infrastructure; /// /// An which has a file system and usually is installed on a machine. diff --git a/src/PetroGlyph.Games.EawFoc/src/IPlayableObject.cs b/src/PetroGlyph.Games.EawFoc/src/IPlayableObject.cs index 5ba8a0e7..14a346c3 100644 --- a/src/PetroGlyph.Games.EawFoc/src/IPlayableObject.cs +++ b/src/PetroGlyph.Games.EawFoc/src/IPlayableObject.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using EawModinfo.Spec; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc; +namespace PG.StarWarsGame.Infrastructure; /// /// Flag interface to identify an object which can be played in some sort. diff --git a/src/PetroGlyph.Games.EawFoc/src/ModCollectionChangedAction.cs b/src/PetroGlyph.Games.EawFoc/src/ModCollectionChangedAction.cs index 0805e4f8..3b37dd20 100644 --- a/src/PetroGlyph.Games.EawFoc/src/ModCollectionChangedAction.cs +++ b/src/PetroGlyph.Games.EawFoc/src/ModCollectionChangedAction.cs @@ -1,4 +1,4 @@ -namespace PetroGlyph.Games.EawFoc; +namespace PG.StarWarsGame.Infrastructure; /// /// Action for . diff --git a/src/PetroGlyph.Games.EawFoc/src/ModCollectionChangedEventArgs.cs b/src/PetroGlyph.Games.EawFoc/src/ModCollectionChangedEventArgs.cs index 0fecd3e6..69bf537e 100644 --- a/src/PetroGlyph.Games.EawFoc/src/ModCollectionChangedEventArgs.cs +++ b/src/PetroGlyph.Games.EawFoc/src/ModCollectionChangedEventArgs.cs @@ -1,7 +1,7 @@ using System; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc; +namespace PG.StarWarsGame.Infrastructure; /// /// for a event. diff --git a/src/PetroGlyph.Games.EawFoc/src/Mods/IMod.cs b/src/PetroGlyph.Games.EawFoc/src/Mods/IMod.cs index d049d7bf..79eb4ae6 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Mods/IMod.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Mods/IMod.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using System.ComponentModel; using EawModinfo.Spec; -using PetroGlyph.Games.EawFoc.Services.Dependencies; +using PG.StarWarsGame.Infrastructure.Services.Dependencies; -namespace PetroGlyph.Games.EawFoc.Mods; +namespace PG.StarWarsGame.Infrastructure.Mods; /// /// This instance represents a mod for a Petroglyph Star Wars game. diff --git a/src/PetroGlyph.Games.EawFoc/src/Mods/IPhysicalMod.cs b/src/PetroGlyph.Games.EawFoc/src/Mods/IPhysicalMod.cs index b674556a..f38d2352 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Mods/IPhysicalMod.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Mods/IPhysicalMod.cs @@ -1,4 +1,4 @@ -namespace PetroGlyph.Games.EawFoc.Mods; +namespace PG.StarWarsGame.Infrastructure.Mods; /// /// Represents an which is bound to a real location on the file system. diff --git a/src/PetroGlyph.Games.EawFoc/src/Mods/IVirtualMod.cs b/src/PetroGlyph.Games.EawFoc/src/Mods/IVirtualMod.cs index 14dd58e0..70c3d8ad 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Mods/IVirtualMod.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Mods/IVirtualMod.cs @@ -1,4 +1,4 @@ -namespace PetroGlyph.Games.EawFoc.Mods; +namespace PG.StarWarsGame.Infrastructure.Mods; /// /// Represents an which only exists at runtime and in memory (virtual mod). diff --git a/src/PetroGlyph.Games.EawFoc/src/Mods/Mod.cs b/src/PetroGlyph.Games.EawFoc/src/Mods/Mod.cs index 5dc70fe5..b84af41a 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Mods/Mod.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Mods/Mod.cs @@ -2,11 +2,11 @@ using System.IO.Abstractions; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Services.Detection; -using PetroGlyph.Games.EawFoc.Services.FileService; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Services.Detection; +using PG.StarWarsGame.Infrastructure.Services.FileService; -namespace PetroGlyph.Games.EawFoc.Mods; +namespace PG.StarWarsGame.Infrastructure.Mods; /// /// An ordinary, physical mod. diff --git a/src/PetroGlyph.Games.EawFoc/src/Mods/ModBase.cs b/src/PetroGlyph.Games.EawFoc/src/Mods/ModBase.cs index b0b81461..02b71c7e 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Mods/ModBase.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Mods/ModBase.cs @@ -7,13 +7,13 @@ using EawModinfo.Spec; using EawModinfo.Utilities; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Services.Dependencies; -using PetroGlyph.Games.EawFoc.Services.Icon; -using PetroGlyph.Games.EawFoc.Services.Language; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Services.Dependencies; +using PG.StarWarsGame.Infrastructure.Services.Icon; +using PG.StarWarsGame.Infrastructure.Services.Language; using Semver; -namespace PetroGlyph.Games.EawFoc.Mods; +namespace PG.StarWarsGame.Infrastructure.Mods; /// /// Base implementation for Mods diff --git a/src/PetroGlyph.Games.EawFoc/src/Mods/ModDependenciesChangedEventArgs.cs b/src/PetroGlyph.Games.EawFoc/src/Mods/ModDependenciesChangedEventArgs.cs index d3750ea1..6649b87f 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Mods/ModDependenciesChangedEventArgs.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Mods/ModDependenciesChangedEventArgs.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using EawModinfo.Spec; -namespace PetroGlyph.Games.EawFoc.Mods; +namespace PG.StarWarsGame.Infrastructure.Mods; /// /// Events arguments used for . diff --git a/src/PetroGlyph.Games.EawFoc/src/Mods/ModDependencyCycleException.cs b/src/PetroGlyph.Games.EawFoc/src/Mods/ModDependencyCycleException.cs index 17c27512..222d4f23 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Mods/ModDependencyCycleException.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Mods/ModDependencyCycleException.cs @@ -1,6 +1,6 @@ using EawModinfo.Spec; -namespace PetroGlyph.Games.EawFoc.Mods; +namespace PG.StarWarsGame.Infrastructure.Mods; /// /// A which gets thrown whenever a dependency cycle was detected. diff --git a/src/PetroGlyph.Games.EawFoc/src/Mods/ModDependencyEntry.cs b/src/PetroGlyph.Games.EawFoc/src/Mods/ModDependencyEntry.cs index f74765fd..91c12c6d 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Mods/ModDependencyEntry.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Mods/ModDependencyEntry.cs @@ -2,7 +2,7 @@ using EawModinfo.Spec; using Semver; -namespace PetroGlyph.Games.EawFoc.Mods; +namespace PG.StarWarsGame.Infrastructure.Mods; /// /// Object which represents an in a list, diff --git a/src/PetroGlyph.Games.EawFoc/src/Mods/ModEqualityComparer.cs b/src/PetroGlyph.Games.EawFoc/src/Mods/ModEqualityComparer.cs index cb188aaf..bf348b09 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Mods/ModEqualityComparer.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Mods/ModEqualityComparer.cs @@ -5,7 +5,7 @@ using EawModinfo.Spec; using EawModinfo.Utilities; -namespace PetroGlyph.Games.EawFoc.Mods; +namespace PG.StarWarsGame.Infrastructure.Mods; /// /// for , and . diff --git a/src/PetroGlyph.Games.EawFoc/src/Mods/ModException.cs b/src/PetroGlyph.Games.EawFoc/src/Mods/ModException.cs index 1806addc..1c56b6f5 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Mods/ModException.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Mods/ModException.cs @@ -1,7 +1,7 @@ using System; using EawModinfo.Spec; -namespace PetroGlyph.Games.EawFoc.Mods; +namespace PG.StarWarsGame.Infrastructure.Mods; /// /// for anything related to or . diff --git a/src/PetroGlyph.Games.EawFoc/src/Mods/ModNotFoundException.cs b/src/PetroGlyph.Games.EawFoc/src/Mods/ModNotFoundException.cs index 7fd6b2d3..d92ed8e1 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Mods/ModNotFoundException.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Mods/ModNotFoundException.cs @@ -1,6 +1,6 @@ using EawModinfo.Spec; -namespace PetroGlyph.Games.EawFoc.Mods; +namespace PG.StarWarsGame.Infrastructure.Mods; /// /// Exception indicating a queried mod, or was not found in some instance. diff --git a/src/PetroGlyph.Games.EawFoc/src/Mods/ModinfoResolvedEventArgs.cs b/src/PetroGlyph.Games.EawFoc/src/Mods/ModinfoResolvedEventArgs.cs index e19b1da3..4d857ade 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Mods/ModinfoResolvedEventArgs.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Mods/ModinfoResolvedEventArgs.cs @@ -1,7 +1,7 @@ using System; using EawModinfo.Spec; -namespace PetroGlyph.Games.EawFoc.Mods; +namespace PG.StarWarsGame.Infrastructure.Mods; /// /// Event arguments used for . diff --git a/src/PetroGlyph.Games.EawFoc/src/Mods/ResolvingModinfoEventArgs.cs b/src/PetroGlyph.Games.EawFoc/src/Mods/ResolvingModinfoEventArgs.cs index d0e297b6..93aa24fb 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Mods/ResolvingModinfoEventArgs.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Mods/ResolvingModinfoEventArgs.cs @@ -1,6 +1,6 @@ using System.ComponentModel; -namespace PetroGlyph.Games.EawFoc.Mods; +namespace PG.StarWarsGame.Infrastructure.Mods; /// /// Cancellable event args when an was raised. diff --git a/src/PetroGlyph.Games.EawFoc/src/Mods/VirtualMod.cs b/src/PetroGlyph.Games.EawFoc/src/Mods/VirtualMod.cs index 9cc5093a..5b3e1431 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Mods/VirtualMod.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Mods/VirtualMod.cs @@ -3,11 +3,11 @@ using System.Linq; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Services.Dependencies; -using PetroGlyph.Games.EawFoc.Services.Detection; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Services.Dependencies; +using PG.StarWarsGame.Infrastructure.Services.Detection; -namespace PetroGlyph.Games.EawFoc.Mods; +namespace PG.StarWarsGame.Infrastructure.Mods; /// /// An in-memory mod diff --git a/src/PetroGlyph.Games.EawFoc/src/PetroglyphException.cs b/src/PetroGlyph.Games.EawFoc/src/PetroglyphException.cs index ab65d0cd..5d5cef80 100644 --- a/src/PetroGlyph.Games.EawFoc/src/PetroglyphException.cs +++ b/src/PetroGlyph.Games.EawFoc/src/PetroglyphException.cs @@ -1,6 +1,6 @@ using System; -namespace PetroGlyph.Games.EawFoc; +namespace PG.StarWarsGame.Infrastructure; /// /// General exception for anything Petroglyph related. diff --git a/src/PetroGlyph.Games.EawFoc/src/PetroglyphGameInfrastructureLibrary.cs b/src/PetroGlyph.Games.EawFoc/src/PetroglyphGameInfrastructureLibrary.cs index 21b34ce8..05d41b09 100644 --- a/src/PetroGlyph.Games.EawFoc/src/PetroglyphGameInfrastructureLibrary.cs +++ b/src/PetroGlyph.Games.EawFoc/src/PetroglyphGameInfrastructureLibrary.cs @@ -1,9 +1,9 @@ using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Games.Registry; -using PetroGlyph.Games.EawFoc.Services.Detection; -using PetroGlyph.Games.EawFoc.Services.Steam; +using PG.StarWarsGame.Infrastructure.Games.Registry; +using PG.StarWarsGame.Infrastructure.Services.Detection; +using PG.StarWarsGame.Infrastructure.Services.Steam; -namespace PetroGlyph.Games.EawFoc; +namespace PG.StarWarsGame.Infrastructure; /// /// Provides initialization routines for this library. diff --git a/src/PetroGlyph.Games.EawFoc/src/PlayableObject.cs b/src/PetroGlyph.Games.EawFoc/src/PlayableObject.cs index 57c87405..368f7d1e 100644 --- a/src/PetroGlyph.Games.EawFoc/src/PlayableObject.cs +++ b/src/PetroGlyph.Games.EawFoc/src/PlayableObject.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using EawModinfo.Spec; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc; +namespace PG.StarWarsGame.Infrastructure; /// /// Base class for which supports one-time initialization diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/CompositeGameDetector.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/CompositeGameDetector.cs index ae38a7e9..8b943198 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/CompositeGameDetector.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/CompositeGameDetector.cs @@ -4,7 +4,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -namespace PetroGlyph.Games.EawFoc.Services.Detection; +namespace PG.StarWarsGame.Infrastructure.Services.Detection; /// /// Game detector which take multiple other detectors in a sorted order and searches for a game installation. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/DirectoryGameDetector.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/DirectoryGameDetector.cs index cc983381..ececcac9 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/DirectoryGameDetector.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/DirectoryGameDetector.cs @@ -3,9 +3,9 @@ using System.IO.Abstractions; using System.Linq; using Microsoft.Extensions.Logging; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc.Services.Detection; +namespace PG.StarWarsGame.Infrastructure.Services.Detection; /// /// Detects whether a given directory contains a Petroglyph Star Wars Game diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetectionResult.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetectionResult.cs index d0e84894..d80ca566 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetectionResult.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetectionResult.cs @@ -1,8 +1,8 @@ using System; using System.IO.Abstractions; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc.Services.Detection; +namespace PG.StarWarsGame.Infrastructure.Services.Detection; /// /// Result object used by containing all necessary information to create a game instance. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetector.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetector.cs index 245fce0b..3eae7094 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetector.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetector.cs @@ -2,10 +2,10 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Services.Detection.Platform; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Services.Detection.Platform; -namespace PetroGlyph.Games.EawFoc.Services.Detection; +namespace PG.StarWarsGame.Infrastructure.Services.Detection; /// /// Base implementation for an diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetectorOptions.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetectorOptions.cs index 0e2999d6..9f3a2782 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetectorOptions.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameDetectorOptions.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; using System.Linq; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc.Services.Detection; +namespace PG.StarWarsGame.Infrastructure.Services.Detection; /// /// Query options for game detections. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameInitializeRequestEventArgs.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameInitializeRequestEventArgs.cs index 0bdd035b..a0ba12b8 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameInitializeRequestEventArgs.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/GameInitializeRequestEventArgs.cs @@ -1,6 +1,6 @@ using System; -namespace PetroGlyph.Games.EawFoc.Services.Detection; +namespace PG.StarWarsGame.Infrastructure.Services.Detection; /// /// Event argument for game initialization request. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/IGameDetector.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/IGameDetector.cs index 44344204..53cd2bce 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/IGameDetector.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/IGameDetector.cs @@ -1,6 +1,6 @@ using System; -namespace PetroGlyph.Games.EawFoc.Services.Detection; +namespace PG.StarWarsGame.Infrastructure.Services.Detection; /// /// Service that detects installed PG Star Wars game installations on this machine. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/DiskGoldIdentifier.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/DiskGoldIdentifier.cs index cbb96967..673cd8d8 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/DiskGoldIdentifier.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/DiskGoldIdentifier.cs @@ -1,8 +1,8 @@ using System; using System.IO.Abstractions; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc.Services.Detection.Platform; +namespace PG.StarWarsGame.Infrastructure.Services.Detection.Platform; internal class DiskGoldIdentifier : SpecificPlatformIdentifier { diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/DiskIdentifier.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/DiskIdentifier.cs index ba5cb384..0f3a65cb 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/DiskIdentifier.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/DiskIdentifier.cs @@ -1,8 +1,8 @@ using System; using System.IO.Abstractions; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc.Services.Detection.Platform; +namespace PG.StarWarsGame.Infrastructure.Services.Detection.Platform; internal class DiskIdentifier : SpecificPlatformIdentifier { diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/GamePlatformIdentifier.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/GamePlatformIdentifier.cs index 617db426..f4aa629e 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/GamePlatformIdentifier.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/GamePlatformIdentifier.cs @@ -4,9 +4,9 @@ using System.Linq; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc.Services.Detection.Platform; +namespace PG.StarWarsGame.Infrastructure.Services.Detection.Platform; /// /// Default implementation of the service. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/GamePlatformIdentifierFactory.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/GamePlatformIdentifierFactory.cs index a75831f0..9ed6c3fe 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/GamePlatformIdentifierFactory.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/GamePlatformIdentifierFactory.cs @@ -1,7 +1,7 @@ using System; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc.Services.Detection.Platform; +namespace PG.StarWarsGame.Infrastructure.Services.Detection.Platform; internal static class GamePlatformIdentifierFactory { diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/GogIdentifier.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/GogIdentifier.cs index ecbb8b89..91cd7475 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/GogIdentifier.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/GogIdentifier.cs @@ -1,8 +1,8 @@ using System; using System.IO.Abstractions; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc.Services.Detection.Platform; +namespace PG.StarWarsGame.Infrastructure.Services.Detection.Platform; internal class GogIdentifier : SpecificPlatformIdentifier { diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/IGamePlatformIdentifier.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/IGamePlatformIdentifier.cs index d3e5e38f..2e1b3cb5 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/IGamePlatformIdentifier.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/IGamePlatformIdentifier.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using System.IO.Abstractions; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc.Services.Detection.Platform; +namespace PG.StarWarsGame.Infrastructure.Services.Detection.Platform; /// /// Service that identifies which is present at a given installation location. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/ISpecificPlatformIdentifier.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/ISpecificPlatformIdentifier.cs index 5dafc453..9d6d60cf 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/ISpecificPlatformIdentifier.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/ISpecificPlatformIdentifier.cs @@ -1,7 +1,7 @@ using System.IO.Abstractions; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc.Services.Detection.Platform; +namespace PG.StarWarsGame.Infrastructure.Services.Detection.Platform; internal interface ISpecificPlatformIdentifier { diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/OriginIdentifier.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/OriginIdentifier.cs index 361da489..14a3d5bf 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/OriginIdentifier.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/OriginIdentifier.cs @@ -1,9 +1,9 @@ using System; using System.IO.Abstractions; using Microsoft.Extensions.Logging; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc.Services.Detection.Platform; +namespace PG.StarWarsGame.Infrastructure.Services.Detection.Platform; internal class OriginIdentifier : SpecificPlatformIdentifier { diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/SpecificPlatformIdentifier.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/SpecificPlatformIdentifier.cs index ecf28e87..12e674e5 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/SpecificPlatformIdentifier.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/SpecificPlatformIdentifier.cs @@ -2,11 +2,11 @@ using System.Collections.Generic; using System.IO.Abstractions; using System.Linq; -using Microsoft.Extensions.Logging; -using PetroGlyph.Games.EawFoc.Games; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc.Services.Detection.Platform; +namespace PG.StarWarsGame.Infrastructure.Services.Detection.Platform; internal abstract class SpecificPlatformIdentifier : ISpecificPlatformIdentifier { diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/SteamIdentifier.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/SteamIdentifier.cs index 4ce9b2a7..4c33b4d3 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/SteamIdentifier.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/Platform/SteamIdentifier.cs @@ -1,8 +1,8 @@ using System; using System.IO.Abstractions; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc.Services.Detection.Platform; +namespace PG.StarWarsGame.Infrastructure.Services.Detection.Platform; internal class SteamIdentifier : SpecificPlatformIdentifier { diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/RegistryGameDetector.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/RegistryGameDetector.cs index 078ed55a..a5c7d9e0 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/RegistryGameDetector.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Detection/RegistryGameDetector.cs @@ -1,9 +1,9 @@ using System; using Microsoft.Extensions.Logging; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Games.Registry; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Games.Registry; -namespace PetroGlyph.Games.EawFoc.Services.Detection; +namespace PG.StarWarsGame.Infrastructure.Services.Detection; /// /// Finds installed games from the registry. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/GameFactory.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/GameFactory.cs index 42a3f237..0f420afc 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/GameFactory.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/GameFactory.cs @@ -1,11 +1,11 @@ using System; using System.Globalization; using System.IO.Abstractions; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Services.Detection; -using PetroGlyph.Games.EawFoc.Services.Name; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Services.Detection; +using PG.StarWarsGame.Infrastructure.Services.Name; -namespace PetroGlyph.Games.EawFoc.Services; +namespace PG.StarWarsGame.Infrastructure.Services; /// public class GameFactory : IGameFactory diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/IGameFactory.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/IGameFactory.cs index 41f60658..b7ce4835 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/IGameFactory.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/IGameFactory.cs @@ -1,8 +1,8 @@ using System.IO.Abstractions; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Services.Detection; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Services.Detection; -namespace PetroGlyph.Games.EawFoc.Services; +namespace PG.StarWarsGame.Infrastructure.Services; /// /// Factory service to create game instances. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Icon/CompositeGameIconFinder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Icon/CompositeGameIconFinder.cs index cc151454..e3d42d32 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Icon/CompositeGameIconFinder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Icon/CompositeGameIconFinder.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc.Services.Icon; +namespace PG.StarWarsGame.Infrastructure.Services.Icon; /// /// Instance which takes other s and returns the first found icon. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Icon/FallbackGameIconFinder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Icon/FallbackGameIconFinder.cs index 990f5844..5e967084 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Icon/FallbackGameIconFinder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Icon/FallbackGameIconFinder.cs @@ -1,8 +1,8 @@ using System; using System.Linq; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc.Services.Icon; +namespace PG.StarWarsGame.Infrastructure.Services.Icon; /// /// Provides a fallback implementation which searches a game's icon file in its root directory. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Icon/IGameIconFinder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Icon/IGameIconFinder.cs index e4a6f599..f8a09b92 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Icon/IGameIconFinder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Icon/IGameIconFinder.cs @@ -1,6 +1,6 @@ -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc.Services.Icon; +namespace PG.StarWarsGame.Infrastructure.Services.Icon; /// /// Service to find the game's icon. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Language/GameLanguageFinder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Language/GameLanguageFinder.cs index eb149b22..e51e2312 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Language/GameLanguageFinder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Language/GameLanguageFinder.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc.Services.Language; +namespace PG.StarWarsGame.Infrastructure.Services.Language; /// /// Search for installed game languages by analyzing installed game files, such as .meg archives. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Language/IGameLanguageFinder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Language/IGameLanguageFinder.cs index 4ab67398..63ec2a4b 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Language/IGameLanguageFinder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Language/IGameLanguageFinder.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using EawModinfo.Spec; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc.Services.Language; +namespace PG.StarWarsGame.Infrastructure.Services.Language; /// /// Service to identify which languages a game has installed. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Name/EnglishGameNameResolver.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Name/EnglishGameNameResolver.cs index 9cd4744e..6eed285f 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Name/EnglishGameNameResolver.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Name/EnglishGameNameResolver.cs @@ -1,8 +1,8 @@ using System; using System.Globalization; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc.Services.Name; +namespace PG.StarWarsGame.Infrastructure.Services.Name; /// /// English name resolver for games . diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Name/IGameNameResolver.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Name/IGameNameResolver.cs index 9a97644d..2d12b63d 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Name/IGameNameResolver.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Name/IGameNameResolver.cs @@ -1,7 +1,7 @@ using System.Globalization; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc.Services.Name; +namespace PG.StarWarsGame.Infrastructure.Services.Name; /// /// Service to resolve a game's name diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/ISteamGameHelpers.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/ISteamGameHelpers.cs index 2378b5b4..e14d0f51 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/ISteamGameHelpers.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/ISteamGameHelpers.cs @@ -1,8 +1,8 @@ using System; using System.IO.Abstractions; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc.Services.Steam; +namespace PG.StarWarsGame.Infrastructure.Services.Steam; /// /// Common helpers for Steam-based Games diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/ISteamWorkshopWebpageDownloader.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/ISteamWorkshopWebpageDownloader.cs index edd0dc1e..e6612195 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/ISteamWorkshopWebpageDownloader.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/ISteamWorkshopWebpageDownloader.cs @@ -2,7 +2,7 @@ using System.Threading.Tasks; using HtmlAgilityPack; -namespace PetroGlyph.Games.EawFoc.Services.Steam; +namespace PG.StarWarsGame.Infrastructure.Services.Steam; internal interface ISteamWorkshopWebpageDownloader { diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/SteamGameHelpers.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/SteamGameHelpers.cs index c22635d8..e486418a 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/SteamGameHelpers.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/SteamGameHelpers.cs @@ -1,12 +1,12 @@ using System; using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; #if NETSTANDARD2_0 using AnakinRaW.CommonUtilities.FileSystem; #endif -namespace PetroGlyph.Games.EawFoc.Services.Steam; +namespace PG.StarWarsGame.Infrastructure.Services.Steam; /// public class SteamGameHelpers : ISteamGameHelpers diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/SteamWorkshopWebpageDownloader.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/SteamWorkshopWebpageDownloader.cs index e94796a4..b9b9e9f7 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/SteamWorkshopWebpageDownloader.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/SteamWorkshopWebpageDownloader.cs @@ -4,7 +4,7 @@ using System.Web; using HtmlAgilityPack; -namespace PetroGlyph.Games.EawFoc.Services.Steam; +namespace PG.StarWarsGame.Infrastructure.Services.Steam; internal class SteamWorkshopWebpageDownloader : ISteamWorkshopWebpageDownloader { diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/DependencyResolveStatus.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/DependencyResolveStatus.cs index ef3fed69..384ef612 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/DependencyResolveStatus.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/DependencyResolveStatus.cs @@ -1,6 +1,6 @@ -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc.Services.Dependencies; +namespace PG.StarWarsGame.Infrastructure.Services.Dependencies; /// /// Indicates the resolve state of an diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/DependencyResolverOptions.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/DependencyResolverOptions.cs index de3f5670..b5180a87 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/DependencyResolverOptions.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/DependencyResolverOptions.cs @@ -1,6 +1,6 @@ using EawModinfo.Spec; -namespace PetroGlyph.Games.EawFoc.Services.Dependencies; +namespace PG.StarWarsGame.Infrastructure.Services.Dependencies; /// /// Options used by an . diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/IDependencyResolver.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/IDependencyResolver.cs index 6df28a26..fe4bd03d 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/IDependencyResolver.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/IDependencyResolver.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using EawModinfo.Spec; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc.Services.Dependencies; +namespace PG.StarWarsGame.Infrastructure.Services.Dependencies; /// /// Resolves mod dependencies specified in and returns them as an . diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/IModDependencyGraph.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/IModDependencyGraph.cs index dee2cb0e..63136dcc 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/IModDependencyGraph.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/IModDependencyGraph.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc.Services.Dependencies; +namespace PG.StarWarsGame.Infrastructure.Services.Dependencies; /// /// Data Structure which represents a mod's dependency graph. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/IModDependencyGraphBuilder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/IModDependencyGraphBuilder.cs index 878413a4..1692f67b 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/IModDependencyGraphBuilder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/IModDependencyGraphBuilder.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using EawModinfo.Spec; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc.Services.Dependencies; +namespace PG.StarWarsGame.Infrastructure.Services.Dependencies; /// /// Service to build an for a given diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/IModDependencyTraverser.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/IModDependencyTraverser.cs index 83862bb2..5b790e45 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/IModDependencyTraverser.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/IModDependencyTraverser.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc.Services.Dependencies; +namespace PG.StarWarsGame.Infrastructure.Services.Dependencies; /// /// Service which flattens the dependencies of a given as specified in diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyGraph.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyGraph.cs index 7a7b2a58..56fcf35c 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyGraph.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyGraph.cs @@ -1,11 +1,11 @@ using System.Collections; using System.Collections.Generic; using System.Linq; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Mods; using QuikGraph; using QuikGraph.Algorithms; -namespace PetroGlyph.Games.EawFoc.Services.Dependencies; +namespace PG.StarWarsGame.Infrastructure.Services.Dependencies; internal class ModDependencyGraph : AdjacencyGraph>, IModDependencyGraph { diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyGraphBuilder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyGraphBuilder.cs index e8b17e87..584599f7 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyGraphBuilder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyGraphBuilder.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using System.Linq; using EawModinfo.Spec; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc.Services.Dependencies; +namespace PG.StarWarsGame.Infrastructure.Services.Dependencies; /// public class ModDependencyGraphBuilder : IModDependencyGraphBuilder diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyResolver.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyResolver.cs index 5804b86a..f0fc49fa 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyResolver.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyResolver.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc.Services.Dependencies; +namespace PG.StarWarsGame.Infrastructure.Services.Dependencies; /// /// Resolves mod dependencies specified in and returns them as an . diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyTraverser.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyTraverser.cs index c5785830..7a16cf4d 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyTraverser.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/ModDependencyTraverser.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using System.Linq; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc.Services.Dependencies; +namespace PG.StarWarsGame.Infrastructure.Services.Dependencies; /// public class ModDependencyTraverser : IModDependencyTraverser diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/MultiModDependencyResolver.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/MultiModDependencyResolver.cs index 9e2a8429..e793643a 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/MultiModDependencyResolver.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Dependencies/MultiModDependencyResolver.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; using System.Linq; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc.Services.Dependencies; +namespace PG.StarWarsGame.Infrastructure.Services.Dependencies; /// /// Service which resolves dependencies of many mods coordinated by minimizing workload. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/FileSystemModFinder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/FileSystemModFinder.cs index b068480c..2bdd2040 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/FileSystemModFinder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/FileSystemModFinder.cs @@ -5,10 +5,10 @@ using EawModinfo.Model; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Services.Steam; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Services.Steam; -namespace PetroGlyph.Games.EawFoc.Services.Detection; +namespace PG.StarWarsGame.Infrastructure.Services.Detection; /// /// Searches for s on the file system. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/IModIdentiferNormalizer.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/IModIdentiferNormalizer.cs index f673fdc3..6acc2917 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/IModIdentiferNormalizer.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/IModIdentiferNormalizer.cs @@ -1,9 +1,9 @@ using System.IO.Abstractions; using EawModinfo.Model; using EawModinfo.Spec; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc.Services.Detection; +namespace PG.StarWarsGame.Infrastructure.Services.Detection; internal interface IModIdentifierBuilder { diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/IModReferenceFinder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/IModReferenceFinder.cs index b6558126..0b8abe5e 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/IModReferenceFinder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/IModReferenceFinder.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using EawModinfo.Spec; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc.Services.Detection; +namespace PG.StarWarsGame.Infrastructure.Services.Detection; /// /// Service to search for s. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/IModReferenceLocationResolver.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/IModReferenceLocationResolver.cs index 1397fc5f..c21d1be9 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/IModReferenceLocationResolver.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/IModReferenceLocationResolver.cs @@ -1,9 +1,9 @@ using System; using System.IO.Abstractions; using EawModinfo.Spec; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; -namespace PetroGlyph.Games.EawFoc.Services.Detection; +namespace PG.StarWarsGame.Infrastructure.Services.Detection; /// /// Service to search for a physical location of a given . diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/ModIdentifierBuilder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/ModIdentifierBuilder.cs index 38729d95..e98bef0c 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/ModIdentifierBuilder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/ModIdentifierBuilder.cs @@ -6,9 +6,9 @@ using EawModinfo.Model; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc.Services.Detection; +namespace PG.StarWarsGame.Infrastructure.Services.Detection; internal class ModIdentifierBuilder : IModIdentifierBuilder { diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/ModReferenceLocationResolver.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/ModReferenceLocationResolver.cs index dd4b03cb..d38f94bf 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/ModReferenceLocationResolver.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/ModReferenceLocationResolver.cs @@ -1,14 +1,16 @@ using System; using System.IO.Abstractions; using System.Linq; -using AnakinRaW.CommonUtilities.FileSystem; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Mods; -using PetroGlyph.Games.EawFoc.Services.Steam; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Mods; +using PG.StarWarsGame.Infrastructure.Services.Steam; +#if NETSTANDARD2_0 +using AnakinRaW.CommonUtilities.FileSystem; +#endif -namespace PetroGlyph.Games.EawFoc.Services.Detection; +namespace PG.StarWarsGame.Infrastructure.Services.Detection; /// public sealed class ModReferenceLocationResolver : IModReferenceLocationResolver diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/IModFactory.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/IModFactory.cs index fc63b508..3c7bb3da 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/IModFactory.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/IModFactory.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; using System.IO; using EawModinfo.Spec; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc.Services; +namespace PG.StarWarsGame.Infrastructure.Services; /// /// Factory to create one or more diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Icon/CompositeModIconFinder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Icon/CompositeModIconFinder.cs index 3c824272..673d4cd2 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Icon/CompositeModIconFinder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Icon/CompositeModIconFinder.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc.Services.Icon; +namespace PG.StarWarsGame.Infrastructure.Services.Icon; /// /// Instance which takes other s and returns the first found icon. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Icon/IModIconFinder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Icon/IModIconFinder.cs index 952fc562..9b877b8a 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Icon/IModIconFinder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Icon/IModIconFinder.cs @@ -1,6 +1,6 @@ -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc.Services.Icon; +namespace PG.StarWarsGame.Infrastructure.Services.Icon; /// /// Service to find icons for s. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Icon/SimpleModIconFinder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Icon/SimpleModIconFinder.cs index aa1114ed..9ac669dd 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Icon/SimpleModIconFinder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Icon/SimpleModIconFinder.cs @@ -1,9 +1,9 @@ using System; using System.Linq; using EawModinfo.Spec; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc.Services.Icon; +namespace PG.StarWarsGame.Infrastructure.Services.Icon; /// /// Provides a very simple implementation which searches returns the first .ico file in a mod's directory. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/IModLanguageFinder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/IModLanguageFinder.cs index e342adc6..ae38f46d 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/IModLanguageFinder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/IModLanguageFinder.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using EawModinfo.Spec; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc.Services.Language; +namespace PG.StarWarsGame.Infrastructure.Services.Language; /// /// Service to get installed mods. Implementations are aware of the modinfo specification diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/IModLanguageFinderFactory.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/IModLanguageFinderFactory.cs index 901a4e31..3a344585 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/IModLanguageFinderFactory.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/IModLanguageFinderFactory.cs @@ -1,7 +1,7 @@ using System; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc.Services.Language; +namespace PG.StarWarsGame.Infrastructure.Services.Language; /// /// Factory service to create the correct for a given . diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/ModLanguageFinderBase.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/ModLanguageFinderBase.cs index 4e34626d..ae54d80a 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/ModLanguageFinderBase.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/ModLanguageFinderBase.cs @@ -4,10 +4,10 @@ using EawModinfo.Model; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Mods; -using PetroGlyph.Games.EawFoc.Services.Dependencies; +using PG.StarWarsGame.Infrastructure.Mods; +using PG.StarWarsGame.Infrastructure.Services.Dependencies; -namespace PetroGlyph.Games.EawFoc.Services.Language; +namespace PG.StarWarsGame.Infrastructure.Services.Language; /// /// Base implementation for a service. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/ModLanguageFinderFactory.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/ModLanguageFinderFactory.cs index 72b8bfde..68eda75a 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/ModLanguageFinderFactory.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/ModLanguageFinderFactory.cs @@ -1,8 +1,8 @@ using System; using EawModinfo.Spec; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc.Services.Language; +namespace PG.StarWarsGame.Infrastructure.Services.Language; /// /// Default factory implementation which returns separate for Virtual and Physical Mods. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/PhysicalModLanguageFinder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/PhysicalModLanguageFinder.cs index 1d86d362..337ffd42 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/PhysicalModLanguageFinder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/PhysicalModLanguageFinder.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; using EawModinfo.Spec; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc.Services.Language; +namespace PG.StarWarsGame.Infrastructure.Services.Language; /// /// Searches the mod's files for evidences of installed languages. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/VirtualModLanguageFinder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/VirtualModLanguageFinder.cs index ba5621a9..23d9c20a 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/VirtualModLanguageFinder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Language/VirtualModLanguageFinder.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; using EawModinfo.Spec; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc.Services.Language; +namespace PG.StarWarsGame.Infrastructure.Services.Language; /// /// Searches installed languages for non-virtual mod dependencies. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/ModFactory.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/ModFactory.cs index 2adc3d49..8223598e 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/ModFactory.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/ModFactory.cs @@ -8,12 +8,12 @@ using EawModinfo.Spec; using EawModinfo.Utilities; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Mods; -using PetroGlyph.Games.EawFoc.Services.Detection; -using PetroGlyph.Games.EawFoc.Services.Name; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Mods; +using PG.StarWarsGame.Infrastructure.Services.Detection; +using PG.StarWarsGame.Infrastructure.Services.Name; -namespace PetroGlyph.Games.EawFoc.Services; +namespace PG.StarWarsGame.Infrastructure.Services; /// public class ModFactory : IModFactory diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/CompositeModNameResolver.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/CompositeModNameResolver.cs index 943526e4..a3af2fb6 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/CompositeModNameResolver.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/CompositeModNameResolver.cs @@ -5,7 +5,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -namespace PetroGlyph.Games.EawFoc.Services.Name; +namespace PG.StarWarsGame.Infrastructure.Services.Name; /// /// which takes a sorted list of and returns the first valid result. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/DirectoryModNameResolver.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/DirectoryModNameResolver.cs index 265ec828..4cde255f 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/DirectoryModNameResolver.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/DirectoryModNameResolver.cs @@ -3,9 +3,9 @@ using System.IO.Abstractions; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Mods; -namespace PetroGlyph.Games.EawFoc.Services.Name; +namespace PG.StarWarsGame.Infrastructure.Services.Name; /// /// Resolves a mod's name by it's directory name. The name will be beautified by removing separator characters like '_'. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/IModNameResolver.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/IModNameResolver.cs index 9d820521..45c9df2c 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/IModNameResolver.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/IModNameResolver.cs @@ -1,7 +1,7 @@ using System.Globalization; using EawModinfo.Spec; -namespace PetroGlyph.Games.EawFoc.Services.Name; +namespace PG.StarWarsGame.Infrastructure.Services.Name; /// /// Service to resolve a mods's name diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/ModNameResolverBase.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/ModNameResolverBase.cs index 1580421f..53dbb45a 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/ModNameResolverBase.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/ModNameResolverBase.cs @@ -4,7 +4,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -namespace PetroGlyph.Games.EawFoc.Services.Name; +namespace PG.StarWarsGame.Infrastructure.Services.Name; /// /// Abstract base class for an . diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/OnlineWorkshopNameResolver.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/OnlineWorkshopNameResolver.cs index 63358bee..6a9ba0a9 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/OnlineWorkshopNameResolver.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Name/OnlineWorkshopNameResolver.cs @@ -3,9 +3,9 @@ using EawModinfo.Spec; using HtmlAgilityPack; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Services.Steam; +using PG.StarWarsGame.Infrastructure.Services.Steam; -namespace PetroGlyph.Games.EawFoc.Services.Name; +namespace PG.StarWarsGame.Infrastructure.Services.Name; /// /// Resolves a mod's name by crawling the name from the mod's steam workshop page. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Shared/FileService/DefaultFileService.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Shared/FileService/DefaultFileService.cs index 63e4cc8c..3dc54bc0 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Shared/FileService/DefaultFileService.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Shared/FileService/DefaultFileService.cs @@ -1,13 +1,12 @@ -#if NET -using System.Linq; -#endif + using System; using System.Collections.Generic; using System.IO; using System.IO.Abstractions; +using System.Linq; using System.Runtime.InteropServices; -namespace PetroGlyph.Games.EawFoc.Services.FileService; +namespace PG.StarWarsGame.Infrastructure.Services.FileService; /// public sealed class DefaultFileService : IPhysicalFileService diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Shared/FileService/IPhysicalFileService.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Shared/FileService/IPhysicalFileService.cs index dc621efd..7087a678 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Shared/FileService/IPhysicalFileService.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Shared/FileService/IPhysicalFileService.cs @@ -2,7 +2,7 @@ using System.IO; using System.IO.Abstractions; -namespace PetroGlyph.Games.EawFoc.Services.FileService; +namespace PG.StarWarsGame.Infrastructure.Services.FileService; /// /// Service to query files and directories of an diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Shared/Language/FileBasedLanguageFinder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Shared/Language/FileBasedLanguageFinder.cs index 0106651c..551f1ae1 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Shared/Language/FileBasedLanguageFinder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Shared/Language/FileBasedLanguageFinder.cs @@ -6,7 +6,7 @@ using EawModinfo.Model; using EawModinfo.Spec; -namespace PetroGlyph.Games.EawFoc.Services.Language; +namespace PG.StarWarsGame.Infrastructure.Services.Language; /// /// Finds installed languages based on well-known file locations and names. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Shared/Language/ILanguageFinder.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Shared/Language/ILanguageFinder.cs index cb453d44..4332dd5d 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Shared/Language/ILanguageFinder.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Shared/Language/ILanguageFinder.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using EawModinfo.Spec; -namespace PetroGlyph.Games.EawFoc.Services.Language; +namespace PG.StarWarsGame.Infrastructure.Services.Language; /// /// Service to find evidence of installed languages for s. diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Shared/Language/LanguageInfoUtilities.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Shared/Language/LanguageInfoUtilities.cs index 84841f17..1443566b 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Shared/Language/LanguageInfoUtilities.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Shared/Language/LanguageInfoUtilities.cs @@ -4,7 +4,7 @@ using EawModinfo.Model; using EawModinfo.Spec; -namespace PetroGlyph.Games.EawFoc.Services.Language; +namespace PG.StarWarsGame.Infrastructure.Services.Language; /// /// Utilities for . diff --git a/src/PetroGlyph.Games.EawFoc/src/SteamException.cs b/src/PetroGlyph.Games.EawFoc/src/SteamException.cs index 07519a9e..a650ce80 100644 --- a/src/PetroGlyph.Games.EawFoc/src/SteamException.cs +++ b/src/PetroGlyph.Games.EawFoc/src/SteamException.cs @@ -1,6 +1,6 @@ using System; -namespace PetroGlyph.Games.EawFoc; +namespace PG.StarWarsGame.Infrastructure; /// /// Exception which gets thrown if anything Steam related failed. diff --git a/src/PetroGlyph.Games.EawFoc/src/ThrowHelper.cs b/src/PetroGlyph.Games.EawFoc/src/ThrowHelper.cs index 6ffcddaa..82240b29 100644 --- a/src/PetroGlyph.Games.EawFoc/src/ThrowHelper.cs +++ b/src/PetroGlyph.Games.EawFoc/src/ThrowHelper.cs @@ -4,7 +4,7 @@ using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; -namespace PetroGlyph.Games.EawFoc; +namespace PG.StarWarsGame.Infrastructure; /// /// Contains helpers for throwing common exceptions. diff --git a/src/PetroGlyph.Games.EawFoc/test/FileBasedLanguageFinderTest.cs b/src/PetroGlyph.Games.EawFoc/test/FileBasedLanguageFinderTest.cs index 85ab7d99..80fade52 100644 --- a/src/PetroGlyph.Games.EawFoc/test/FileBasedLanguageFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/FileBasedLanguageFinderTest.cs @@ -3,9 +3,9 @@ using EawModinfo.Model; using EawModinfo.Spec; using Moq; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Services.FileService; -using PetroGlyph.Games.EawFoc.Services.Language; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Services.FileService; +using PG.StarWarsGame.Infrastructure.Services.Language; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc/test/GameRegistryFactoryTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameRegistryFactoryTest.cs index 046ffebd..dabfe9c0 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameRegistryFactoryTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameRegistryFactoryTest.cs @@ -1,8 +1,8 @@ using System.IO.Abstractions; using AnakinRaW.CommonUtilities.Registry; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Games.Registry; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Games.Registry; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/CompositeGameIconFinderTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/CompositeGameIconFinderTest.cs index d7680db8..7345828e 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/CompositeGameIconFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/CompositeGameIconFinderTest.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; using Moq; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Services.Icon; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Services.Icon; using Xunit; namespace PG.StarWarsGame.Infrastructure.Test.GameServices; diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/CompositeDetectorTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/CompositeDetectorTest.cs index a88e69fa..237475ae 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/CompositeDetectorTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/CompositeDetectorTest.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; using Moq; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Services.Detection; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Services.Detection; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/DirectoryGameDetectorTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/DirectoryGameDetectorTest.cs index 1bab3425..7aeed9eb 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/DirectoryGameDetectorTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/DirectoryGameDetectorTest.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using System.IO.Abstractions; using Moq; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Services.Detection; -using PetroGlyph.Games.EawFoc.Services.Detection.Platform; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Services.Detection; +using PG.StarWarsGame.Infrastructure.Services.Detection.Platform; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GameDetectorTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GameDetectorTest.cs index e4fb3c05..ac24c84f 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GameDetectorTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GameDetectorTest.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using System.IO.Abstractions; using Moq; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Services.Detection; -using PetroGlyph.Games.EawFoc.Services.Detection.Platform; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Services.Detection; +using PG.StarWarsGame.Infrastructure.Services.Detection.Platform; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GamePlatformIdentifierTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GamePlatformIdentifierTest.cs index 24301c26..57d28713 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GamePlatformIdentifierTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/GamePlatformIdentifierTest.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.IO.Abstractions; using Moq; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Services.Detection.Platform; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Services.Detection.Platform; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/RegistryGameDetectorTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/RegistryGameDetectorTest.cs index 4c9eab03..b23ed7ac 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/RegistryGameDetectorTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/Detection/RegistryGameDetectorTest.cs @@ -1,9 +1,9 @@ using System; using System.IO.Abstractions; using Moq; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Games.Registry; -using PetroGlyph.Games.EawFoc.Services.Detection; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Games.Registry; +using PG.StarWarsGame.Infrastructure.Services.Detection; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/EnglishGameNameResolverTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/EnglishGameNameResolverTest.cs index be46b955..a7de006f 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/EnglishGameNameResolverTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/EnglishGameNameResolverTest.cs @@ -1,6 +1,6 @@ using System.Globalization; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Services.Name; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Services.Name; using Xunit; namespace PG.StarWarsGame.Infrastructure.Test.GameServices; diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/FallbackIconFinderTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/FallbackIconFinderTest.cs index 65b7c98a..43aa695a 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/FallbackIconFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/FallbackIconFinderTest.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using System.IO.Abstractions; using Moq; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Services.FileService; -using PetroGlyph.Games.EawFoc.Services.Icon; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Services.FileService; +using PG.StarWarsGame.Infrastructure.Services.Icon; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/GameFactoryTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/GameFactoryTest.cs index d3a6cae2..d5d9bf4e 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/GameFactoryTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/GameFactoryTest.cs @@ -2,10 +2,10 @@ using System.Globalization; using System.IO.Abstractions; using Moq; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Services; -using PetroGlyph.Games.EawFoc.Services.Detection; -using PetroGlyph.Games.EawFoc.Services.Name; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Services; +using PG.StarWarsGame.Infrastructure.Services.Detection; +using PG.StarWarsGame.Infrastructure.Services.Name; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/GameHelperTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/GameHelperTest.cs index 696ab02a..6932392a 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/GameHelperTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/GameHelperTest.cs @@ -1,9 +1,8 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Services.Steam; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Services.Steam; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/GameLanguageFinderTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/GameLanguageFinderTest.cs index 49a78fc0..4d281ac7 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/GameLanguageFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/GameLanguageFinderTest.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using EawModinfo.Spec; using Moq; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Services.Language; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Services.Language; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/SteamWorkshopWebpageDownloaderTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/SteamWorkshopWebpageDownloaderTest.cs index e5429861..fe4d2fee 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/SteamWorkshopWebpageDownloaderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/SteamWorkshopWebpageDownloaderTest.cs @@ -1,5 +1,5 @@ using System.Globalization; -using PetroGlyph.Games.EawFoc.Services.Steam; +using PG.StarWarsGame.Infrastructure.Services.Steam; using Xunit; namespace PG.StarWarsGame.Infrastructure.Test.GameServices; diff --git a/src/PetroGlyph.Games.EawFoc/test/GameTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameTest.cs index 234f9f36..df9b10ed 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameTest.cs @@ -2,10 +2,9 @@ using EawModinfo.Model; using EawModinfo.Spec; using Moq; -using PetroGlyph.Games.EawFoc; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Mods; -using PetroGlyph.Games.EawFoc.Services.Detection; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Mods; +using PG.StarWarsGame.Infrastructure.Services.Detection; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc/test/LanguageInfoUtilitiesTest.cs b/src/PetroGlyph.Games.EawFoc/test/LanguageInfoUtilitiesTest.cs index 8faa64cc..3848b11e 100644 --- a/src/PetroGlyph.Games.EawFoc/test/LanguageInfoUtilitiesTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/LanguageInfoUtilitiesTest.cs @@ -1,6 +1,6 @@ using EawModinfo.Model; using EawModinfo.Spec; -using PetroGlyph.Games.EawFoc.Services.Language; +using PG.StarWarsGame.Infrastructure.Services.Language; using Xunit; namespace PG.StarWarsGame.Infrastructure.Test; diff --git a/src/PetroGlyph.Games.EawFoc/test/ModBaseTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModBaseTest.cs index dc080e78..a3e767a7 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModBaseTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModBaseTest.cs @@ -4,12 +4,11 @@ using EawModinfo.Model; using EawModinfo.Spec; using Moq; -using PetroGlyph.Games.EawFoc; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Mods; -using PetroGlyph.Games.EawFoc.Services.Dependencies; -using PetroGlyph.Games.EawFoc.Services.Icon; -using PetroGlyph.Games.EawFoc.Services.Language; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Mods; +using PG.StarWarsGame.Infrastructure.Services.Dependencies; +using PG.StarWarsGame.Infrastructure.Services.Icon; +using PG.StarWarsGame.Infrastructure.Services.Language; using Semver; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc/test/ModDependencyEntryTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModDependencyEntryTest.cs index 48fe5ee4..1d33c03f 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModDependencyEntryTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModDependencyEntryTest.cs @@ -1,6 +1,6 @@ using System; using Moq; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Mods; using Semver; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc/test/ModEqualityComparerTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModEqualityComparerTest.cs index 948905f0..4a363661 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModEqualityComparerTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModEqualityComparerTest.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using EawModinfo.Spec; using Moq; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Mods; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Mods; using Semver; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/CompositeModIconFinderTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/CompositeModIconFinderTest.cs index 19f5186c..88260850 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/CompositeModIconFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/CompositeModIconFinderTest.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; using Moq; -using PetroGlyph.Games.EawFoc.Mods; -using PetroGlyph.Games.EawFoc.Services.Icon; +using PG.StarWarsGame.Infrastructure.Mods; +using PG.StarWarsGame.Infrastructure.Services.Icon; using Xunit; namespace PG.StarWarsGame.Infrastructure.Test.ModServices; diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/CompositeModNameResolverTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/CompositeModNameResolverTest.cs index c688c1ec..58d98aef 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/CompositeModNameResolverTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/CompositeModNameResolverTest.cs @@ -4,8 +4,7 @@ using EawModinfo.Model; using EawModinfo.Spec; using Moq; -using PetroGlyph.Games.EawFoc; -using PetroGlyph.Games.EawFoc.Services.Name; +using PG.StarWarsGame.Infrastructure.Services.Name; using Xunit; namespace PG.StarWarsGame.Infrastructure.Test.ModServices; diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/DirectoryModNameResolverTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/DirectoryModNameResolverTest.cs index 0aa52458..ad7244e3 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/DirectoryModNameResolverTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/DirectoryModNameResolverTest.cs @@ -4,7 +4,7 @@ using EawModinfo.Model; using EawModinfo.Spec; using Moq; -using PetroGlyph.Games.EawFoc.Services.Name; +using PG.StarWarsGame.Infrastructure.Services.Name; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/FileSystemModFinderTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/FileSystemModFinderTest.cs index 89fe98fb..382faa23 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/FileSystemModFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/FileSystemModFinderTest.cs @@ -3,9 +3,9 @@ using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Services.Detection; -using PetroGlyph.Games.EawFoc.Services.Steam; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Services.Detection; +using PG.StarWarsGame.Infrastructure.Services.Steam; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyGraphBuilderIntegrationTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyGraphBuilderIntegrationTest.cs index 45996df7..1cefd9f5 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyGraphBuilderIntegrationTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyGraphBuilderIntegrationTest.cs @@ -4,9 +4,9 @@ using System.Linq; using EawModinfo.Spec; using Moq; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Mods; -using PetroGlyph.Games.EawFoc.Services.Dependencies; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Mods; +using PG.StarWarsGame.Infrastructure.Services.Dependencies; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyGraphBuilderTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyGraphBuilderTest.cs index d2666efe..dde13eb9 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyGraphBuilderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyGraphBuilderTest.cs @@ -3,9 +3,9 @@ using EawModinfo.Model; using EawModinfo.Spec; using Moq; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Mods; -using PetroGlyph.Games.EawFoc.Services.Dependencies; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Mods; +using PG.StarWarsGame.Infrastructure.Services.Dependencies; using Xunit; namespace PG.StarWarsGame.Infrastructure.Test.ModServices; diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverIntegrationTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverIntegrationTest.cs index eb02c5f3..e2c8a3c4 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverIntegrationTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverIntegrationTest.cs @@ -5,10 +5,9 @@ using EawModinfo.Model; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Mods; -using PetroGlyph.Games.EawFoc.Services.Dependencies; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Mods; +using PG.StarWarsGame.Infrastructure.Services.Dependencies; using Semver; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverTest.cs index 384ac8fe..cf745b7c 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverTest.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; using Moq; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Mods; -using PetroGlyph.Games.EawFoc.Services.Dependencies; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Mods; +using PG.StarWarsGame.Infrastructure.Services.Dependencies; using Xunit; namespace PG.StarWarsGame.Infrastructure.Test.ModServices; diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyTraverserIntegrationTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyTraverserIntegrationTest.cs index 53147b10..ef9c956a 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyTraverserIntegrationTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyTraverserIntegrationTest.cs @@ -5,10 +5,10 @@ using System.Linq; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Mods; -using PetroGlyph.Games.EawFoc.Services.Dependencies; -using PetroGlyph.Games.EawFoc.Services.Detection; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Mods; +using PG.StarWarsGame.Infrastructure.Services.Dependencies; +using PG.StarWarsGame.Infrastructure.Services.Detection; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyTraverserTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyTraverserTest.cs index a7f32a32..b0c30dde 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyTraverserTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyTraverserTest.cs @@ -1,7 +1,7 @@ using System; using Moq; -using PetroGlyph.Games.EawFoc.Mods; -using PetroGlyph.Games.EawFoc.Services.Dependencies; +using PG.StarWarsGame.Infrastructure.Mods; +using PG.StarWarsGame.Infrastructure.Services.Dependencies; using Xunit; namespace PG.StarWarsGame.Infrastructure.Test.ModServices; diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModFactoryTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModFactoryTest.cs index 762885f1..3bf3582f 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModFactoryTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModFactoryTest.cs @@ -7,10 +7,10 @@ using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Services; -using PetroGlyph.Games.EawFoc.Services.Detection; -using PetroGlyph.Games.EawFoc.Services.Name; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Services; +using PG.StarWarsGame.Infrastructure.Services.Detection; +using PG.StarWarsGame.Infrastructure.Services.Name; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModIdentifierBuilderTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModIdentifierBuilderTest.cs index da0540f6..12f8761b 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModIdentifierBuilderTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModIdentifierBuilderTest.cs @@ -4,8 +4,8 @@ using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; using Moq; -using PetroGlyph.Games.EawFoc.Mods; -using PetroGlyph.Games.EawFoc.Services.Detection; +using PG.StarWarsGame.Infrastructure.Mods; +using PG.StarWarsGame.Infrastructure.Services.Detection; using PG.TestingUtilities; using Semver; using Testably.Abstractions.Testing; diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModLanguageFinderBaseTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModLanguageFinderBaseTest.cs index b05361d4..c5d363a3 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModLanguageFinderBaseTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModLanguageFinderBaseTest.cs @@ -4,9 +4,9 @@ using EawModinfo.Model; using EawModinfo.Spec; using Moq; -using PetroGlyph.Games.EawFoc.Mods; -using PetroGlyph.Games.EawFoc.Services.Dependencies; -using PetroGlyph.Games.EawFoc.Services.Language; +using PG.StarWarsGame.Infrastructure.Mods; +using PG.StarWarsGame.Infrastructure.Services.Dependencies; +using PG.StarWarsGame.Infrastructure.Services.Language; using Xunit; namespace PG.StarWarsGame.Infrastructure.Test.ModServices; diff --git a/src/PetroGlyph.Games.EawFoc/test/ModTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModTest.cs index 5974441d..b5784f2d 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModTest.cs @@ -3,9 +3,9 @@ using EawModinfo.Model; using EawModinfo.Spec; using Moq; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Mods; -using PetroGlyph.Games.EawFoc.Services.Detection; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Mods; +using PG.StarWarsGame.Infrastructure.Services.Detection; using Testably.Abstractions.Testing; using Xunit; diff --git a/src/PetroGlyph.Games.EawFoc/test/PlayableObjectTest.cs b/src/PetroGlyph.Games.EawFoc/test/PlayableObjectTest.cs index c596e65a..3dfa028b 100644 --- a/src/PetroGlyph.Games.EawFoc/test/PlayableObjectTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/PlayableObjectTest.cs @@ -1,8 +1,7 @@ using System; using System.Collections.Generic; using EawModinfo.Spec; -using PetroGlyph.Games.EawFoc; -using PetroGlyph.Games.EawFoc.Games; +using PG.StarWarsGame.Infrastructure.Games; using Xunit; namespace PG.StarWarsGame.Infrastructure.Test; diff --git a/src/PetroGlyph.Games.EawFoc/test/VirtualModTest.cs b/src/PetroGlyph.Games.EawFoc/test/VirtualModTest.cs index b88c4969..6d322a25 100644 --- a/src/PetroGlyph.Games.EawFoc/test/VirtualModTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/VirtualModTest.cs @@ -4,11 +4,10 @@ using EawModinfo.Model; using EawModinfo.Spec; using Moq; -using PetroGlyph.Games.EawFoc; -using PetroGlyph.Games.EawFoc.Games; -using PetroGlyph.Games.EawFoc.Mods; -using PetroGlyph.Games.EawFoc.Services.Dependencies; -using PetroGlyph.Games.EawFoc.Services.Detection; +using PG.StarWarsGame.Infrastructure.Games; +using PG.StarWarsGame.Infrastructure.Mods; +using PG.StarWarsGame.Infrastructure.Services.Dependencies; +using PG.StarWarsGame.Infrastructure.Services.Detection; using Xunit; namespace PG.StarWarsGame.Infrastructure.Test; From 3dd93185d31360f84597a6ecd83068f5de524e50 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Fri, 15 Mar 2024 10:24:12 +0100 Subject: [PATCH 15/41] remove steam exception from infrastructure --- .../Services/Games/Steam/ISteamGameHelpers.cs | 2 +- .../Services/Games/Steam/SteamGameHelpers.cs | 4 ++-- .../IModReferenceLocationResolver.cs | 1 - .../Detection/ModReferenceLocationResolver.cs | 4 ++-- .../src/SteamException.cs | 24 ------------------- .../test/GameServices/GameHelperTest.cs | 2 +- 6 files changed, 6 insertions(+), 31 deletions(-) delete mode 100644 src/PetroGlyph.Games.EawFoc/src/SteamException.cs diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/ISteamGameHelpers.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/ISteamGameHelpers.cs index e14d0f51..b8d494be 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/ISteamGameHelpers.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/ISteamGameHelpers.cs @@ -14,7 +14,7 @@ public interface ISteamGameHelpers /// /// The target game /// If the game is not a Steam game - /// If it was impossible to compute the workshop location. + /// If it was impossible to compute the workshop location. /// If the game's directory info is not absolute. IDirectoryInfo GetWorkshopsLocation(IGame game); diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/SteamGameHelpers.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/SteamGameHelpers.cs index e486418a..b7285f22 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/SteamGameHelpers.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Games/Steam/SteamGameHelpers.cs @@ -39,7 +39,7 @@ public IDirectoryInfo GetWorkshopsLocation(IGame game) var commonParent = gameDir.Parent?.Parent?.Parent; if (commonParent is null) - throw new SteamException("Unable to compute workshops location"); + throw new GameException("Unable to compute workshops location"); var fs = game.Directory.FileSystem; var workshopDirPath = fs.Path.Combine(commonParent.FullName, "workshop/content/32470"); @@ -55,7 +55,7 @@ public bool TryGetWorkshopsLocation(IGame game, out IDirectoryInfo? workshopsLoc workshopsLocation = GetWorkshopsLocation(game); return true; } - catch (Exception e) when (e is PetroglyphException or SteamException) + catch (PetroglyphException) { return false; } diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/IModReferenceLocationResolver.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/IModReferenceLocationResolver.cs index c21d1be9..0f92b7ae 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/IModReferenceLocationResolver.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/IModReferenceLocationResolver.cs @@ -18,6 +18,5 @@ public interface IModReferenceLocationResolver /// The location information of the . /// If the is a virtual mod. /// If some constraints of the given params do not hold. - /// If something Steam-related fails. IDirectoryInfo ResolveLocation(IModReference mod, IGame game); } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/ModReferenceLocationResolver.cs b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/ModReferenceLocationResolver.cs index d38f94bf..44909a16 100644 --- a/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/ModReferenceLocationResolver.cs +++ b/src/PetroGlyph.Games.EawFoc/src/Services/Mods/Detection/ModReferenceLocationResolver.cs @@ -48,10 +48,10 @@ private IDirectoryInfo ResolveWorkshopsMod(IModReference mod, IGame game) { var workshopPath = _steamHelper.GetWorkshopsLocation(game); if (!workshopPath.Exists) - throw new SteamException("Could not find workshops location"); + throw new GameException("Could not find workshops location"); if (!_steamHelper.ToSteamWorkshopsId(mod.Identifier, out var steamId)) - throw new SteamException("Mod identifier cannot be interpreted as an Steam-ID"); + throw new GameException("Mod identifier cannot be interpreted as an Steam-ID"); var modLocation = workshopPath.EnumerateDirectories(steamId.ToString()).FirstOrDefault(); if (modLocation is null || !modLocation.Exists) diff --git a/src/PetroGlyph.Games.EawFoc/src/SteamException.cs b/src/PetroGlyph.Games.EawFoc/src/SteamException.cs deleted file mode 100644 index a650ce80..00000000 --- a/src/PetroGlyph.Games.EawFoc/src/SteamException.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; - -namespace PG.StarWarsGame.Infrastructure; - -/// -/// Exception which gets thrown if anything Steam related failed. -/// -public class SteamException : Exception -{ - /// - public SteamException() - { - } - - /// - public SteamException(string message) : base(message) - { - } - - /// - public SteamException(string message, Exception exception) : base(message, exception) - { - } -} \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/test/GameServices/GameHelperTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameServices/GameHelperTest.cs index 6932392a..92e902a7 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameServices/GameHelperTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameServices/GameHelperTest.cs @@ -43,7 +43,7 @@ public void GetWorkshopDir_FailNotExisting() var mock = new Mock(); mock.Setup(g => g.Directory).Returns(_fileSystem.DirectoryInfo.New("Game")); mock.Setup(g => g.Platform).Returns(GamePlatform.SteamGold); - Assert.Throws(() => _service.GetWorkshopsLocation(mock.Object)); + Assert.Throws(() => _service.GetWorkshopsLocation(mock.Object)); } [Fact] From 12187bc080ec6fac2b10b280dc01f49674df7835 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Fri, 15 Mar 2024 11:26:01 +0100 Subject: [PATCH 16/41] move steam code new package --- PetroGlyphGameInfrastructure.sln | 42 ++--- sample/SampleApplication/Program.cs | 1 - .../SampleApplication.csproj | 3 +- .../AET.SteamAbstraction.Test.csproj | 38 +++++ .../SteamGameFinderTest.cs | 6 +- .../SteamLibraryFinderTest.cs | 7 +- .../SteamLibraryTest.cs | 10 +- .../SteamVdfReaderTest.cs | 4 +- .../SteamWrapperIntegrationTest.cs | 9 +- .../SteamWrapperTest.cs | 142 +++++++++++++++++ .../AET - Backup.SteamAbstraction.csproj | 40 +++++ .../AET.SteamAbstraction.csproj | 38 +++++ .../AET.SteamAbstraction.csproj.DotSettings | 4 + .../Games}/ISteamAppManifestReader.cs | 2 +- .../Games}/ISteamGameLocationFinder.cs | 2 +- .../Games}/SteamAppManifest.cs | 2 +- .../Games}/SteamAppState.cs | 2 +- .../Games}/SteamGameFinder.cs | 4 +- .../AET.SteamAbstraction}/ISteamRegistry.cs | 2 +- .../AET.SteamAbstraction}/ISteamWrapper.cs | 11 +- .../ISteamWrapperFactory.cs | 8 + .../Library}/ILibraryConfigReader.cs | 2 +- .../Library}/ISteamLibrary.cs | 2 +- .../Library}/ISteamLibraryFinder.cs | 2 +- .../Library}/SteamLibrary.cs | 2 +- .../Library}/SteamLibraryFinder.cs | 2 +- .../NativeMethods/Advapi32.cs | 4 +- .../NativeMethods/Kernel32.cs | 2 +- .../NativeMethods/User32.cs | 2 +- .../NativeMethods/WindowHandleInfo.cs | 2 +- .../Properties/AssemblyInfo.cs | 5 + .../AET.SteamAbstraction/SteamException.cs | 24 +++ .../AET.SteamAbstraction/SteamRegistry.cs | 143 +++++++++++++++++ .../AET.SteamAbstraction}/SteamVdfReader.cs | 5 +- .../AET.SteamAbstraction}/SteamWrapper.cs | 93 +++-------- .../SteamWrapperFactory.cs | 16 ++ .../Threading/AwaitExtensions.cs | 8 +- .../Threading/EmptyStruct.cs | 2 +- .../Threading/NoMessagePumpSyncContext.cs | 4 +- .../RegistryChangeNotificationFilters.cs | 2 +- .../Threading/SpecializedSyncContext.cs | 2 +- .../Threading/ThreadingTools.cs | 2 +- .../Threading/TplExtensions.cs | 2 +- .../Utilities}/IProcessHelper.cs | 2 +- .../Utilities}/ProcessHelper.cs | 2 +- .../Wrappers/LinuxSteamWrapper.cs | 18 +++ .../Wrappers/WindowsSteamWrapper.cs | 51 ++++++ ...nfrastructure.Clients.Steam.Windows.csproj | 1 - .../src/SteamRegistry.cs | 144 ----------------- ...tructure.Clients.Steam.Windows.Test.csproj | 1 - .../test/Steam/SteamWrapperTest.cs | 145 ------------------ ...e.Infrastructure.Clients.Steam.Test.csproj | 1 - .../src/Arguments/ModArgumentListFactory.cs | 1 + .../src/DefaultGameClientFactory.cs | 46 ++++++ ...StarWarsGame.Infrastructure.Clients.csproj | 1 + .../src/PetroglyphClientsLibrary.cs | 3 - .../src/Steam}/SteamGameClient.cs | 1 + .../src/Steam}/SteamGameLanguageFinder.cs | 1 + .../SteamPetroglyphStarWarsGameDetector.cs | 1 + .../Arguments/ModArgumentListFactoryTest.cs | 1 + .../test/Steam}/SteamGameClientTest.cs | 4 +- .../Steam}/SteamGameLanguageFinderTest.cs | 4 +- ...SteamPetroglyphStarWarsGameDetectorTest.cs | 4 +- 63 files changed, 674 insertions(+), 463 deletions(-) create mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam => AET.SteamAbstraction/AET.SteamAbstraction.Test}/SteamGameFinderTest.cs (91%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam => AET.SteamAbstraction/AET.SteamAbstraction.Test}/SteamLibraryFinderTest.cs (96%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam => AET.SteamAbstraction/AET.SteamAbstraction.Test}/SteamLibraryTest.cs (95%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam => AET.SteamAbstraction/AET.SteamAbstraction.Test}/SteamVdfReaderTest.cs (97%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam => AET.SteamAbstraction/AET.SteamAbstraction.Test}/SteamWrapperIntegrationTest.cs (69%) create mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs create mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/AET - Backup.SteamAbstraction.csproj create mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj create mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj.DotSettings rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src => AET.SteamAbstraction/AET.SteamAbstraction/Games}/ISteamAppManifestReader.cs (74%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src => AET.SteamAbstraction/AET.SteamAbstraction/Games}/ISteamGameLocationFinder.cs (59%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam/src => AET.SteamAbstraction/AET.SteamAbstraction/Games}/SteamAppManifest.cs (98%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam/src => AET.SteamAbstraction/AET.SteamAbstraction/Games}/SteamAppState.cs (97%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src => AET.SteamAbstraction/AET.SteamAbstraction/Games}/SteamGameFinder.cs (93%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam/src => AET.SteamAbstraction/AET.SteamAbstraction}/ISteamRegistry.cs (94%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam/src => AET.SteamAbstraction/AET.SteamAbstraction}/ISteamWrapper.cs (91%) create mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamWrapperFactory.cs rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src => AET.SteamAbstraction/AET.SteamAbstraction/Library}/ILibraryConfigReader.cs (77%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam/src => AET.SteamAbstraction/AET.SteamAbstraction/Library}/ISteamLibrary.cs (94%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src => AET.SteamAbstraction/AET.SteamAbstraction/Library}/ISteamLibraryFinder.cs (69%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src => AET.SteamAbstraction/AET.SteamAbstraction/Library}/SteamLibrary.cs (98%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src => AET.SteamAbstraction/AET.SteamAbstraction/Library}/SteamLibraryFinder.cs (97%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src => AET.SteamAbstraction/AET.SteamAbstraction}/NativeMethods/Advapi32.cs (82%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src => AET.SteamAbstraction/AET.SteamAbstraction}/NativeMethods/Kernel32.cs (82%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src => AET.SteamAbstraction/AET.SteamAbstraction}/NativeMethods/User32.cs (92%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src => AET.SteamAbstraction/AET.SteamAbstraction}/NativeMethods/WindowHandleInfo.cs (94%) create mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/Properties/AssemblyInfo.cs create mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/SteamException.cs create mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/SteamRegistry.cs rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src => AET.SteamAbstraction/AET.SteamAbstraction}/SteamVdfReader.cs (97%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src => AET.SteamAbstraction/AET.SteamAbstraction}/SteamWrapper.cs (62%) create mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src => AET.SteamAbstraction/AET.SteamAbstraction}/Threading/AwaitExtensions.cs (97%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src => AET.SteamAbstraction/AET.SteamAbstraction}/Threading/EmptyStruct.cs (67%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src => AET.SteamAbstraction/AET.SteamAbstraction}/Threading/NoMessagePumpSyncContext.cs (91%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src => AET.SteamAbstraction/AET.SteamAbstraction}/Threading/RegistryChangeNotificationFilters.cs (94%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src => AET.SteamAbstraction/AET.SteamAbstraction}/Threading/SpecializedSyncContext.cs (94%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src => AET.SteamAbstraction/AET.SteamAbstraction}/Threading/ThreadingTools.cs (84%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src => AET.SteamAbstraction/AET.SteamAbstraction}/Threading/TplExtensions.cs (98%) rename src/{PetroGlyph.Games.EawFoc.Clients/src/Processes => AET.SteamAbstraction/AET.SteamAbstraction/Utilities}/IProcessHelper.cs (71%) rename src/{PetroGlyph.Games.EawFoc.Clients/src/Processes => AET.SteamAbstraction/AET.SteamAbstraction/Utilities}/ProcessHelper.cs (87%) create mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/Wrappers/LinuxSteamWrapper.cs create mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/Wrappers/WindowsSteamWrapper.cs delete mode 100644 src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamRegistry.cs delete mode 100644 src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperTest.cs create mode 100644 src/PetroGlyph.Games.EawFoc.Clients/src/DefaultGameClientFactory.cs rename src/{PetroGlyph.Games.EawFoc.Clients.Steam/src => PetroGlyph.Games.EawFoc.Clients/src/Steam}/SteamGameClient.cs (98%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam/src => PetroGlyph.Games.EawFoc.Clients/src/Steam}/SteamGameLanguageFinder.cs (98%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam/src => PetroGlyph.Games.EawFoc.Clients/src/Steam}/SteamPetroglyphStarWarsGameDetector.cs (99%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam/test => PetroGlyph.Games.EawFoc.Clients/test/Steam}/SteamGameClientTest.cs (94%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam/test => PetroGlyph.Games.EawFoc.Clients/test/Steam}/SteamGameLanguageFinderTest.cs (95%) rename src/{PetroGlyph.Games.EawFoc.Clients.Steam/test => PetroGlyph.Games.EawFoc.Clients/test/Steam}/SteamPetroglyphStarWarsGameDetectorTest.cs (98%) diff --git a/PetroGlyphGameInfrastructure.sln b/PetroGlyphGameInfrastructure.sln index ab118a90..bb4b8677 100644 --- a/PetroGlyphGameInfrastructure.sln +++ b/PetroGlyphGameInfrastructure.sln @@ -9,24 +9,20 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PG.StarWarsGame.Infrastruct EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PG.StarWarsGame.Infrastructure.Clients", "src\PetroGlyph.Games.EawFoc.Clients\src\PG.StarWarsGame.Infrastructure.Clients.csproj", "{F622B36D-E5C9-4C14-B4B1-8871DCF1FF46}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PG.StarWarsGame.Infrastructure.Clients.Steam.Windows", "src\PetroGlyph.Games.EawFoc.Clients.Steam.Windows\src\PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.csproj", "{3EB69B97-AD3F-4D72-BE49-D17547EE0895}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PG.StarWarsGame.Infrastructure", "src\PetroGlyph.Games.EawFoc\src\PG.StarWarsGame.Infrastructure.csproj", "{6A14A57C-60E6-4DDE-B8F0-55ADB3A20758}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{91EC3980-0C87-484F-91E5-0FE684C1D2E0}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test", "src\PetroGlyph.Games.EawFoc.Clients.Steam.Windows\test\PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.csproj", "{9F5EB615-86CB-4AF1-88B9-A1DAF4EAF9F2}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PG.StarWarsGame.Infrastructure.Clients.Test", "src\PetroGlyph.Games.EawFoc.Clients\test\PG.StarWarsGame.Infrastructure.Clients.Test.csproj", "{0D5DAC91-BB5F-46F4-9145-4296E9151DC3}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PG.StarWarsGame.Infrastructure.Clients.Steam", "src\PetroGlyph.Games.EawFoc.Clients.Steam\src\PG.StarWarsGame.Infrastructure.Clients.Steam.csproj", "{179786D1-8C85-46B3-9943-30A1902D92B4}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PG.StarWarsGame.Infrastructure.Clients.Steam.Test", "src\PetroGlyph.Games.EawFoc.Clients.Steam\test\PG.StarWarsGame.Infrastructure.Clients.Steam.Test.csproj", "{69666FB7-7F44-451B-8ABF-7F18DEC3AD45}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleApplication", "sample\SampleApplication\SampleApplication.csproj", "{8F295344-3D7B-4983-88FD-D0E5C692CBAB}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PG.TestingUtilities", "src\Testing\PG.TestingUtilities\PG.TestingUtilities.csproj", "{C8F51821-F25D-4C4E-8050-5C559ADD39DB}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AET.SteamAbstraction", "src\AET.SteamAbstraction\AET.SteamAbstraction\AET.SteamAbstraction.csproj", "{24CA9F24-E6DC-4908-B586-E7C14515628C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AET.SteamAbstraction.Test", "src\AET.SteamAbstraction\AET.SteamAbstraction.Test\AET.SteamAbstraction.Test.csproj", "{38FE318C-F775-4318-859C-DCAB3C6FCD71}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -41,30 +37,14 @@ Global {F622B36D-E5C9-4C14-B4B1-8871DCF1FF46}.Debug|Any CPU.Build.0 = Debug|Any CPU {F622B36D-E5C9-4C14-B4B1-8871DCF1FF46}.Release|Any CPU.ActiveCfg = Release|Any CPU {F622B36D-E5C9-4C14-B4B1-8871DCF1FF46}.Release|Any CPU.Build.0 = Release|Any CPU - {3EB69B97-AD3F-4D72-BE49-D17547EE0895}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3EB69B97-AD3F-4D72-BE49-D17547EE0895}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3EB69B97-AD3F-4D72-BE49-D17547EE0895}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3EB69B97-AD3F-4D72-BE49-D17547EE0895}.Release|Any CPU.Build.0 = Release|Any CPU {6A14A57C-60E6-4DDE-B8F0-55ADB3A20758}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6A14A57C-60E6-4DDE-B8F0-55ADB3A20758}.Debug|Any CPU.Build.0 = Debug|Any CPU {6A14A57C-60E6-4DDE-B8F0-55ADB3A20758}.Release|Any CPU.ActiveCfg = Release|Any CPU {6A14A57C-60E6-4DDE-B8F0-55ADB3A20758}.Release|Any CPU.Build.0 = Release|Any CPU - {9F5EB615-86CB-4AF1-88B9-A1DAF4EAF9F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9F5EB615-86CB-4AF1-88B9-A1DAF4EAF9F2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9F5EB615-86CB-4AF1-88B9-A1DAF4EAF9F2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9F5EB615-86CB-4AF1-88B9-A1DAF4EAF9F2}.Release|Any CPU.Build.0 = Release|Any CPU {0D5DAC91-BB5F-46F4-9145-4296E9151DC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0D5DAC91-BB5F-46F4-9145-4296E9151DC3}.Debug|Any CPU.Build.0 = Debug|Any CPU {0D5DAC91-BB5F-46F4-9145-4296E9151DC3}.Release|Any CPU.ActiveCfg = Release|Any CPU {0D5DAC91-BB5F-46F4-9145-4296E9151DC3}.Release|Any CPU.Build.0 = Release|Any CPU - {179786D1-8C85-46B3-9943-30A1902D92B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {179786D1-8C85-46B3-9943-30A1902D92B4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {179786D1-8C85-46B3-9943-30A1902D92B4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {179786D1-8C85-46B3-9943-30A1902D92B4}.Release|Any CPU.Build.0 = Release|Any CPU - {69666FB7-7F44-451B-8ABF-7F18DEC3AD45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {69666FB7-7F44-451B-8ABF-7F18DEC3AD45}.Debug|Any CPU.Build.0 = Debug|Any CPU - {69666FB7-7F44-451B-8ABF-7F18DEC3AD45}.Release|Any CPU.ActiveCfg = Release|Any CPU - {69666FB7-7F44-451B-8ABF-7F18DEC3AD45}.Release|Any CPU.Build.0 = Release|Any CPU {8F295344-3D7B-4983-88FD-D0E5C692CBAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8F295344-3D7B-4983-88FD-D0E5C692CBAB}.Debug|Any CPU.Build.0 = Debug|Any CPU {8F295344-3D7B-4983-88FD-D0E5C692CBAB}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -73,6 +53,14 @@ Global {C8F51821-F25D-4C4E-8050-5C559ADD39DB}.Debug|Any CPU.Build.0 = Debug|Any CPU {C8F51821-F25D-4C4E-8050-5C559ADD39DB}.Release|Any CPU.ActiveCfg = Release|Any CPU {C8F51821-F25D-4C4E-8050-5C559ADD39DB}.Release|Any CPU.Build.0 = Release|Any CPU + {24CA9F24-E6DC-4908-B586-E7C14515628C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {24CA9F24-E6DC-4908-B586-E7C14515628C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {24CA9F24-E6DC-4908-B586-E7C14515628C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {24CA9F24-E6DC-4908-B586-E7C14515628C}.Release|Any CPU.Build.0 = Release|Any CPU + {38FE318C-F775-4318-859C-DCAB3C6FCD71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {38FE318C-F775-4318-859C-DCAB3C6FCD71}.Debug|Any CPU.Build.0 = Debug|Any CPU + {38FE318C-F775-4318-859C-DCAB3C6FCD71}.Release|Any CPU.ActiveCfg = Release|Any CPU + {38FE318C-F775-4318-859C-DCAB3C6FCD71}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -80,13 +68,11 @@ Global GlobalSection(NestedProjects) = preSolution {90490B07-F4E3-4D1E-B3E3-FD059A0DAB8D} = {91EC3980-0C87-484F-91E5-0FE684C1D2E0} {F622B36D-E5C9-4C14-B4B1-8871DCF1FF46} = {DDF4836A-1257-4323-A288-B5F277242010} - {3EB69B97-AD3F-4D72-BE49-D17547EE0895} = {DDF4836A-1257-4323-A288-B5F277242010} {6A14A57C-60E6-4DDE-B8F0-55ADB3A20758} = {DDF4836A-1257-4323-A288-B5F277242010} - {9F5EB615-86CB-4AF1-88B9-A1DAF4EAF9F2} = {91EC3980-0C87-484F-91E5-0FE684C1D2E0} {0D5DAC91-BB5F-46F4-9145-4296E9151DC3} = {91EC3980-0C87-484F-91E5-0FE684C1D2E0} - {179786D1-8C85-46B3-9943-30A1902D92B4} = {DDF4836A-1257-4323-A288-B5F277242010} - {69666FB7-7F44-451B-8ABF-7F18DEC3AD45} = {91EC3980-0C87-484F-91E5-0FE684C1D2E0} {C8F51821-F25D-4C4E-8050-5C559ADD39DB} = {91EC3980-0C87-484F-91E5-0FE684C1D2E0} + {24CA9F24-E6DC-4908-B586-E7C14515628C} = {DDF4836A-1257-4323-A288-B5F277242010} + {38FE318C-F775-4318-859C-DCAB3C6FCD71} = {91EC3980-0C87-484F-91E5-0FE684C1D2E0} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {76D00646-2467-4997-A19B-8299D8724D38} diff --git a/sample/SampleApplication/Program.cs b/sample/SampleApplication/Program.cs index 8d091de8..a08c10d5 100644 --- a/sample/SampleApplication/Program.cs +++ b/sample/SampleApplication/Program.cs @@ -67,7 +67,6 @@ IServiceProvider SetupApplication() var sc = new ServiceCollection(); PetroglyphGameInfrastructureLibrary.InitializeLibraryWithDefaultServices(sc); PetroglyphClientsLibrary.InitializeLibraryWithDefaultServices(sc); - PetroglyphWindowsSteamClientsLibrary.InitializeLibraryWithDefaultServices(sc); sc.AddSingleton(WindowsRegistry.Default); sc.AddTransient(sp => new SteamPetroglyphStarWarsGameDetector(sp)); diff --git a/sample/SampleApplication/SampleApplication.csproj b/sample/SampleApplication/SampleApplication.csproj index e82cb188..d4fa4e40 100644 --- a/sample/SampleApplication/SampleApplication.csproj +++ b/sample/SampleApplication/SampleApplication.csproj @@ -8,11 +8,10 @@ + - - diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj new file mode 100644 index 00000000..eccdc13a --- /dev/null +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj @@ -0,0 +1,38 @@ + + + + net8.0 + $(TargetFrameworks);net48 + enable + enable + + false + true + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamGameFinderTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamGameFinderTest.cs similarity index 91% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamGameFinderTest.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamGameFinderTest.cs index cd20ae5e..1c7b27a1 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamGameFinderTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamGameFinderTest.cs @@ -1,11 +1,9 @@ -using System.Collections.Generic; -using System.IO.Abstractions; +using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; using Testably.Abstractions.Testing; -using Xunit; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.Steam; +namespace AET.SteamAbstraction.Test; public class SteamGameFinderTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryFinderTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryFinderTest.cs similarity index 96% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryFinderTest.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryFinderTest.cs index 704f08ca..844af8c9 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryFinderTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryFinderTest.cs @@ -1,12 +1,9 @@ -using System.Collections.Generic; -using System.IO.Abstractions; -using System.Linq; +using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; using Testably.Abstractions.Testing; -using Xunit; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.Steam; +namespace AET.SteamAbstraction.Test; public class SteamLibraryFinderTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryTest.cs similarity index 95% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryTest.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryTest.cs index 3ebe7250..7d8a9a72 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamLibraryTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryTest.cs @@ -1,13 +1,11 @@ -using System; -using System.Collections.Generic; +using System.Collections; using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; using Moq; using PG.TestingUtilities; using Testably.Abstractions.Testing; -using Xunit; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.Steam; +namespace AET.SteamAbstraction.Test; public class SteamLibraryTest { @@ -100,7 +98,7 @@ public void TestApps() .Returns(app); var apps = lib.GetApps(); - var result = Assert.Single(apps); + var result = Assert.Single((IEnumerable)apps); Assert.Same(app, result); } @@ -121,7 +119,7 @@ public void TestNoDuplicatesApps() .Returns(app); var apps = lib.GetApps(); - var result = Assert.Single(apps); + var result = Assert.Single((IEnumerable)apps); Assert.Same(app, result); } diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamVdfReaderTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamVdfReaderTest.cs similarity index 97% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamVdfReaderTest.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamVdfReaderTest.cs index c5ed43f5..09ddf0f6 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamVdfReaderTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamVdfReaderTest.cs @@ -1,11 +1,9 @@ using System.IO.Abstractions; -using System.Linq; using Microsoft.Extensions.DependencyInjection; using Moq; using Testably.Abstractions.Testing; -using Xunit; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.Steam; +namespace AET.SteamAbstraction.Test; public class SteamVdfReaderTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperIntegrationTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperIntegrationTest.cs similarity index 69% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperIntegrationTest.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperIntegrationTest.cs index cd492a91..dbbc7ea7 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperIntegrationTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperIntegrationTest.cs @@ -1,9 +1,6 @@ -using System; -using System.Threading.Tasks; -using Microsoft.Extensions.DependencyInjection; -using Xunit; +using Microsoft.Extensions.DependencyInjection; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.Steam; +namespace AET.SteamAbstraction.Test; public class SteamWrapperIntegrationTest { @@ -13,8 +10,6 @@ public class SteamWrapperIntegrationTest public SteamWrapperIntegrationTest() { var sc = new ServiceCollection(); - PetroglyphClientsLibrary.InitializeLibraryWithDefaultServices(sc); - PetroglyphWindowsSteamClientsLibrary.InitializeLibraryWithDefaultServices(sc); _sp = sc.BuildServiceProvider(); _service = _sp.GetRequiredService() as SteamWrapper ?? throw new InvalidOperationException(); diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs new file mode 100644 index 00000000..969dd2d7 --- /dev/null +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs @@ -0,0 +1,142 @@ +using System.Diagnostics; +using System.IO.Abstractions; +using AET.SteamAbstraction.Utilities; +using Microsoft.Extensions.DependencyInjection; +using Moq; +using Testably.Abstractions.Testing; + +namespace AET.SteamAbstraction.Test; + +//public class SteamWrapperTest +//{ +// private readonly SteamWrapper _service; +// private readonly Mock _steamRegistry; +// private readonly MockFileSystem _fileSystem; +// private readonly Mock _processHelper; +// private readonly Mock _gameFinder; + +// public SteamWrapperTest() +// { +// var sc = new ServiceCollection(); +// _steamRegistry = new Mock(); +// _fileSystem = new MockFileSystem(); +// _processHelper = new Mock(); +// _gameFinder = new Mock(); +// sc.AddTransient(_ => _steamRegistry.Object); +// sc.AddTransient(_ => _processHelper.Object); +// sc.AddTransient(_ => _gameFinder.Object); +// sc.AddTransient(_ => _fileSystem); +// _service = new SteamWrapper(sc.BuildServiceProvider()); +// } + +// [Fact] +// public void TestInvalidArgs_Throws() +// { +// Assert.Throws(() => new SteamWrapper(null)); +// } + +// [Fact] +// public void TestRunning() +// { +// _processHelper.SetupSequence(h => h.GetProcessByPid(It.IsAny())) +// .Returns((Process)null) +// .Returns(Process.GetCurrentProcess); +// _steamRegistry.SetupSequence(r => r.ProcessId) +// .Returns((int?)null) +// .Returns(0) +// .Returns(123) +// .Returns(123); + +// Assert.False(_service.IsRunning); +// Assert.False(_service.IsRunning); +// Assert.False(_service.IsRunning); +// Assert.True(_service.IsRunning); +// } + +// [Fact] +// public void TestInstalled() +// { +// _steamRegistry.SetupSequence(r => r.ExeFile) +// .Returns((IFileInfo?)null) +// .Returns(() => _fileSystem.FileInfo.New("steam.exe")) +// .Returns(() => _fileSystem.FileInfo.New("steam.exe")); + +// Assert.False(_service.Installed); +// Assert.False(_service.Installed); + +// _fileSystem.Initialize().WithFile("steam.exe"); + +// Assert.True(_service.Installed); +// } + +// [Fact] +// public void TestUserLoggedIn() +// { +// _steamRegistry.SetupSequence(r => r.ActiveUserId) +// .Returns((int?)null) +// .Returns(0) +// .Returns(123); + +// Assert.False(_service.IsUserLoggedIn); +// Assert.False(_service.IsUserLoggedIn); +// Assert.True(_service.IsUserLoggedIn); +// } + +// [Fact] +// public void TestGameInstalled() +// { +// _fileSystem.Initialize(); + +// SetupInstalledRegistry(); +// var mFile = _fileSystem.FileInfo.New("manifest.acf"); + +// var expectedApp = new SteamAppManifest(new Mock().Object, mFile, 1234, "name", +// _fileSystem.DirectoryInfo.New("Game"), SteamAppState.StateFullyInstalled, +// new HashSet()); + +// _gameFinder.SetupSequence(f => f.FindGame(It.IsAny())) +// .Returns((SteamAppManifest?)null) +// .Returns(expectedApp); +// _steamRegistry.Setup(r => r.InstalledApps).Returns(new HashSet { 1, 2, 3 }); +// _steamRegistry.Setup(r => r.InstallationDirectory).Returns(_fileSystem.DirectoryInfo.New("Steam")); + +// Assert.False(_service.IsGameInstalled(0, out _)); +// Assert.False(_service.IsGameInstalled(1, out _)); +// Assert.True(_service.IsGameInstalled(1, out var app)); +// } + +// [Fact] +// public void TestWantsOffline() +// { +// SetupInstalledRegistry(); + +// _steamRegistry.Setup(r => r.InstallationDirectory).Returns(_fileSystem.DirectoryInfo.New(".")); + +// Assert.Null((object?)_service.WantOfflineMode); + +// _fileSystem.Initialize().WithFile("config/loginusers.vdf"); +// Assert.Null((object?)_service.WantOfflineMode); + +// _fileSystem.File.WriteAllText("config/loginusers.vdf", WantsNotOffline()); +// Assert.False(_service.WantOfflineMode); + +// _fileSystem.File.WriteAllText("config/loginusers.vdf", WantsOffline()); +// Assert.True(_service.WantOfflineMode); +// } + +// private void SetupInstalledRegistry() +// { +// _fileSystem.Initialize().WithFile("steam.exe"); +// _steamRegistry.Setup(r => r.ExeFile).Returns(_fileSystem.FileInfo.New("steam.exe")); +// } + +// private static string WantsNotOffline() +// { +// return "\"users\"\n{\n\t\"123\"\n\t{\n\t\t\"AccountName\"\t\t\"user_name\"\n\t\t\"PersonaName\"\t\t\"User Name\"\n\t\t\"RememberPassword\"\t\t\"1\"\n\t\t\"MostRecent\"\t\t\"1\"\n\t\t\"Timestamp\"\t\t\"0000000000\"\n\t\t\"WantsOfflineMode\"\t\t\"0\"\n\t\t\"SkipOfflineModeWarning\"\t\t\"0\"\n\t}\n}"; +// } + +// private static string WantsOffline() +// { +// return "\"users\"\n{\n\t\"123\"\n\t{\n\t\t\"AccountName\"\t\t\"user_name\"\n\t\t\"PersonaName\"\t\t\"User Name\"\n\t\t\"RememberPassword\"\t\t\"1\"\n\t\t\"MostRecent\"\t\t\"1\"\n\t\t\"Timestamp\"\t\t\"0000000000\"\n\t\t\"WantsOfflineMode\"\t\t\"1\"\n\t\t\"SkipOfflineModeWarning\"\t\t\"0\"\n\t}\n}"; +// } +//} \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/AET - Backup.SteamAbstraction.csproj b/src/AET.SteamAbstraction/AET.SteamAbstraction/AET - Backup.SteamAbstraction.csproj new file mode 100644 index 00000000..87056389 --- /dev/null +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/AET - Backup.SteamAbstraction.csproj @@ -0,0 +1,40 @@ + + + netstandard2.0 + + + AET.SteamAbstraction + .NET abstraction layer for Valve Steam. + AlamoEngineTools.SteamAbstraction + alamo,petroglyph,glyphx + en + + + true + true + true + + + true + snupkg + true + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj b/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj new file mode 100644 index 00000000..485a9834 --- /dev/null +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj @@ -0,0 +1,38 @@ + + + netstandard2.0 + + + AET.SteamAbstraction + .NET abstraction layer for Valve Steam. + AlamoEngineTools.SteamAbstraction + alamo,petroglyph,glyphx + en + + + true + true + true + + + true + snupkg + true + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj.DotSettings b/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj.DotSettings new file mode 100644 index 00000000..92922eaf --- /dev/null +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj.DotSettings @@ -0,0 +1,4 @@ + + True + True + True \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamAppManifestReader.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/ISteamAppManifestReader.cs similarity index 74% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamAppManifestReader.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/Games/ISteamAppManifestReader.cs index 0fb60f5a..818e88ea 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamAppManifestReader.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/ISteamAppManifestReader.cs @@ -1,6 +1,6 @@ using System.IO.Abstractions; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam; +namespace AET.SteamAbstraction; internal interface ISteamAppManifestReader { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamGameLocationFinder.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/ISteamGameLocationFinder.cs similarity index 59% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamGameLocationFinder.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/Games/ISteamGameLocationFinder.cs index f622c217..9f4597b9 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamGameLocationFinder.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/ISteamGameLocationFinder.cs @@ -1,4 +1,4 @@ -namespace PG.StarWarsGame.Infrastructure.Clients.Steam; +namespace AET.SteamAbstraction; internal interface ISteamGameFinder { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamAppManifest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamAppManifest.cs similarity index 98% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamAppManifest.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamAppManifest.cs index 4ee2eb50..8ff840be 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamAppManifest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamAppManifest.cs @@ -3,7 +3,7 @@ using System.IO.Abstractions; using AnakinRaW.CommonUtilities; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam; +namespace AET.SteamAbstraction; /// /// Manifest representing an installed Steam game. diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamAppState.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamAppState.cs similarity index 97% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamAppState.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamAppState.cs index fdf862d4..f6452c9a 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamAppState.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamAppState.cs @@ -1,6 +1,6 @@ using System; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam; +namespace AET.SteamAbstraction; /// /// Indicates the State of a Steam game. diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamGameFinder.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamGameFinder.cs similarity index 93% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamGameFinder.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamGameFinder.cs index fa6cd08b..ff1999f1 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamGameFinder.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamGameFinder.cs @@ -1,8 +1,8 @@ using System; -using Microsoft.Extensions.DependencyInjection; using System.Linq; +using Microsoft.Extensions.DependencyInjection; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam; +namespace AET.SteamAbstraction; internal class SteamGameFinder : ISteamGameFinder { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamRegistry.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamRegistry.cs similarity index 94% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamRegistry.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamRegistry.cs index 1b7c5597..3b29af56 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamRegistry.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamRegistry.cs @@ -3,7 +3,7 @@ using System.IO.Abstractions; using AnakinRaW.CommonUtilities.Registry; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam; +namespace AET.SteamAbstraction; /// /// Registry representation for the Steam Client. diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamWrapper.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamWrapper.cs similarity index 91% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamWrapper.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamWrapper.cs index 15fe5cf1..1e525f58 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamWrapper.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamWrapper.cs @@ -1,10 +1,11 @@ -using System.Threading; +using System.Diagnostics.CodeAnalysis; +using System.Threading; using System.Threading.Tasks; #if NET using System.Diagnostics.CodeAnalysis; #endif -namespace PG.StarWarsGame.Infrastructure.Clients.Steam; +namespace AET.SteamAbstraction; /// /// .NET Wrapper to interact with the Steam Client @@ -28,11 +29,7 @@ public interface ISteamWrapper /// The manifest of the installed game or . /// is the game is installed; otherwise. /// if Steam is not installed. -#if NET - bool IsGameInstalled(uint gameId, [NotNullWhen(true)] out SteamAppManifest manifest); -#else - bool IsGameInstalled(uint gameId, out SteamAppManifest? manifest); -#endif + bool IsGameInstalled(uint gameId, [NotNullWhen(true)] out SteamAppManifest? manifest); /// /// Starts the Steam client. diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamWrapperFactory.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamWrapperFactory.cs new file mode 100644 index 00000000..47b7073a --- /dev/null +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamWrapperFactory.cs @@ -0,0 +1,8 @@ +using System; + +namespace AET.SteamAbstraction; + +internal interface ISteamWrapperFactory +{ + ISteamWrapper CreateWrapper(IServiceProvider serviceProvider); +} \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ILibraryConfigReader.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ILibraryConfigReader.cs similarity index 77% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ILibraryConfigReader.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ILibraryConfigReader.cs index 976aa0b3..d1314f6d 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ILibraryConfigReader.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ILibraryConfigReader.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.IO.Abstractions; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam; +namespace AET.SteamAbstraction; internal interface ILibraryConfigReader { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamLibrary.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ISteamLibrary.cs similarity index 94% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamLibrary.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ISteamLibrary.cs index 65f4f7d5..c9f24e32 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/ISteamLibrary.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ISteamLibrary.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.IO.Abstractions; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam; +namespace AET.SteamAbstraction; /// /// Represents a Steam Library location. diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamLibraryFinder.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ISteamLibraryFinder.cs similarity index 69% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamLibraryFinder.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ISteamLibraryFinder.cs index 338d7989..778d2340 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/ISteamLibraryFinder.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ISteamLibraryFinder.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam; +namespace AET.SteamAbstraction; internal interface ISteamLibraryFinder { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibrary.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/SteamLibrary.cs similarity index 98% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibrary.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/Library/SteamLibrary.cs index 74ef4fe0..ad485d94 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibrary.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/SteamLibrary.cs @@ -6,7 +6,7 @@ using AnakinRaW.CommonUtilities.FileSystem.Normalization; using Microsoft.Extensions.DependencyInjection; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam; +namespace AET.SteamAbstraction; internal class SteamLibrary : ISteamLibrary { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibraryFinder.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/SteamLibraryFinder.cs similarity index 97% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibraryFinder.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/Library/SteamLibraryFinder.cs index c1fdbec1..dc52bcb4 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamLibraryFinder.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/SteamLibraryFinder.cs @@ -3,7 +3,7 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam; +namespace AET.SteamAbstraction; internal class SteamLibraryFinder : ISteamLibraryFinder { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/Advapi32.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/Advapi32.cs similarity index 82% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/Advapi32.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/Advapi32.cs index 0a6912fc..c9ac9fce 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/Advapi32.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/Advapi32.cs @@ -1,8 +1,8 @@ using System.Runtime.InteropServices; +using AET.SteamAbstraction.Threading; using Microsoft.Win32.SafeHandles; -using PG.StarWarsGame.Infrastructure.Clients.Steam.Threading; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam.NativeMethods; +namespace AET.SteamAbstraction.NativeMethods; internal static class Advapi32 { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/Kernel32.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/Kernel32.cs similarity index 82% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/Kernel32.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/Kernel32.cs index 5c4f9ede..5d5f177d 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/Kernel32.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/Kernel32.cs @@ -1,7 +1,7 @@ using System; using System.Runtime.InteropServices; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam.NativeMethods; +namespace AET.SteamAbstraction.NativeMethods; internal static class Kernel32 { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/User32.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/User32.cs similarity index 92% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/User32.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/User32.cs index 4b96d1d5..1e0d122a 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/User32.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/User32.cs @@ -2,7 +2,7 @@ using System.Runtime.InteropServices; using System.Text; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam.NativeMethods; +namespace AET.SteamAbstraction.NativeMethods; internal static class User32 { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/WindowHandleInfo.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/WindowHandleInfo.cs similarity index 94% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/WindowHandleInfo.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/WindowHandleInfo.cs index faee7c71..1b1ed50a 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/NativeMethods/WindowHandleInfo.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/WindowHandleInfo.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Runtime.InteropServices; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam.NativeMethods; +namespace AET.SteamAbstraction.NativeMethods; internal class WindowHandleInfo { diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Properties/AssemblyInfo.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..962c487b --- /dev/null +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Properties/AssemblyInfo.cs @@ -0,0 +1,5 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("AET.SteamAbstraction.Test")] +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] + diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamException.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamException.cs new file mode 100644 index 00000000..b85a9f79 --- /dev/null +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamException.cs @@ -0,0 +1,24 @@ +using System; + +namespace AET.SteamAbstraction; + +/// +/// Exception which gets thrown if anything Steam related failed. +/// +public class SteamException : Exception +{ + /// + public SteamException() + { + } + + /// + public SteamException(string message) : base(message) + { + } + + /// + public SteamException(string message, Exception exception) : base(message, exception) + { + } +} \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamRegistry.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamRegistry.cs new file mode 100644 index 00000000..2b30852a --- /dev/null +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamRegistry.cs @@ -0,0 +1,143 @@ +using AnakinRaW.CommonUtilities.Registry; +using System.Collections.Generic; +using System.IO.Abstractions; +using System; +using System.Linq; +using Microsoft.Extensions.DependencyInjection; + +namespace AET.SteamAbstraction; + +internal sealed class SteamRegistry : ISteamRegistry +{ + private const string SteamExeKey = "SteamExe"; + private const string SteamPathKey = "SteamPath"; + private const string SteamProcessIdKey = "pid"; + private const string SteamActiveUserKey = "ActiveUser"; + + private const string SteamProcessNode = "ActiveProcess"; + private const string SteamAppsNode = "Apps"; + + private IRegistryKey? _registryKey; + private bool _disposed; + private readonly IFileSystem _fileSystem; + + public IRegistryKey? ActiveProcessKey + { + get + { + ThrowIfDisposed(); + return _registryKey!.GetKey(SteamProcessNode); + } + } + + int? ISteamRegistry.ActiveUserId + { + get + { + ThrowIfDisposed(); + return !_registryKey!.GetValue(SteamActiveUserKey, SteamProcessNode, out int? userId) ? null : userId; + } + set + { + ThrowIfDisposed(); + value ??= 0; + _registryKey!.WriteValue(SteamActiveUserKey, SteamProcessNode, value); + } + } + + public int? ProcessId + { + get + { + ThrowIfDisposed(); + return !_registryKey!.GetValue(SteamProcessIdKey, SteamProcessNode, out int? pid) ? null : pid; + } + } + + public IFileInfo? ExeFile + { + get + { + ThrowIfDisposed(); + return !_registryKey!.GetValue(SteamExeKey, out string? filePath) + ? null + : _fileSystem.FileInfo.New(filePath!); + } + } + + public IDirectoryInfo? InstallationDirectory + { + get + { + ThrowIfDisposed(); + return !_registryKey!.GetValue(SteamPathKey, out string? path) + ? null + : _fileSystem.DirectoryInfo.New(path!); + } + } + + public ISet? InstalledApps + { + get + { + ThrowIfDisposed(); + var keyNames = _registryKey!.GetSubKeyNames(SteamAppsNode); + if (keyNames is null) + return null; + var ids = keyNames + .Select(n => !uint.TryParse(n, out var id) ? (uint?)0 : id) + .OfType(); + return new HashSet(ids); + } + } + + + public SteamRegistry(IServiceProvider serviceProvider) + { + _registryKey = serviceProvider.GetRequiredService() + .OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default) + .CreateSubKey("Software\\Valve\\Steam"); + _fileSystem = serviceProvider.GetRequiredService(); + } + + + /// + ~SteamRegistry() + { + Dispose(false); + } + + /// + /// Disposed all managed resources acquired by this instance. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Disposed all managed resources acquired by this instance. + /// + /// if called from the destructor; otherwise. + private void Dispose(bool disposing) + { + if (disposing) + { + _registryKey?.Dispose(); + _registryKey = null; + _disposed = true; + } + } + +#if NET + [MemberNotNull(nameof(_registryKey))] +#endif + private void ThrowIfDisposed() + { + if (_disposed) + throw new ObjectDisposedException(ToString()); + if (_registryKey is null) + throw new Exception("registry must not be null in non-disposed state"); + } +} \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamVdfReader.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamVdfReader.cs similarity index 97% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamVdfReader.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/SteamVdfReader.cs index 091d6401..009ff53e 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamVdfReader.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamVdfReader.cs @@ -8,7 +8,7 @@ using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json.Linq; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam; +namespace AET.SteamAbstraction; internal class SteamVdfReader : ISteamAppManifestReader, ILibraryConfigReader { @@ -83,8 +83,7 @@ state is null || var installLocation = _fileSystem.DirectoryInfo.New( _fileSystem.Path.Combine(library.CommonLocation.FullName, installDir!)); - return new SteamAppManifest(library, manifestFile, id.Value, name!, installLocation, state.Value, - depots.ToHashSet()); + return new SteamAppManifest(library, manifestFile, id.Value, name!, installLocation, state.Value, new HashSet(depots)); } public IEnumerable ReadLibraryLocationsFromConfig(IFileInfo configFile) diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamWrapper.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapper.cs similarity index 62% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamWrapper.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapper.cs index 12670053..ce8be878 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamWrapper.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapper.cs @@ -5,29 +5,30 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using AnakinRaW.CommonUtilities.Registry.Windows; +using AET.SteamAbstraction.NativeMethods; +using AET.SteamAbstraction.Utilities; using Gameloop.Vdf; using Gameloop.Vdf.JsonConverter; using Microsoft.Extensions.DependencyInjection; -using PG.StarWarsGame.Infrastructure.Clients.Processes; -using PG.StarWarsGame.Infrastructure.Clients.Steam.NativeMethods; -using PG.StarWarsGame.Infrastructure.Clients.Steam.Threading; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam; +namespace AET.SteamAbstraction; -internal class SteamWrapper : ISteamWrapper +internal abstract class SteamWrapper(IServiceProvider serviceProvider) : ISteamWrapper { - private readonly ISteamRegistry _registry; - private readonly IServiceProvider _serviceProvider; - private readonly IProcessHelper _processHelper; - private readonly IFileSystem _fileSystem; - public bool Installed => _registry.ExeFile?.Exists ?? false; + private readonly IProcessHelper _processHelper = serviceProvider.GetRequiredService(); + + protected ISteamRegistry Registry { get; } = serviceProvider.GetRequiredService(); + protected IServiceProvider ServiceProvider { get; } = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); + protected IFileSystem FileSystem { get; } = serviceProvider.GetRequiredService(); + + public bool Installed => Registry.ExeFile?.Exists ?? false; + public bool IsRunning { get { - var pid = _registry.ProcessId; + var pid = Registry.ProcessId; if (pid is null or 0) return false; return _processHelper.GetProcessByPid(pid.Value) != null; @@ -38,17 +39,17 @@ public bool? WantOfflineMode { get { - var steamDirectory = _registry.InstallationDirectory; + var steamDirectory = Registry.InstallationDirectory; if (steamDirectory is null || !steamDirectory.Exists) return null; - var configFile = _fileSystem.Path.Combine(steamDirectory.FullName, "config/loginusers.vdf"); - if (!_fileSystem.File.Exists(configFile)) + var configFile = FileSystem.Path.Combine(steamDirectory.FullName, "config/loginusers.vdf"); + if (!FileSystem.File.Exists(configFile)) return null; try { - var config = VdfConvert.Deserialize(_fileSystem.File.ReadAllText(configFile)).ToJson(); + var config = VdfConvert.Deserialize(FileSystem.File.ReadAllText(configFile)).ToJson(); var usersWantingOffline = config.SelectTokens("$..[?(@.WantsOfflineMode=='1')]").ToList(); if (!usersWantingOffline.Any()) return false; @@ -71,35 +72,23 @@ internal bool IsUserLoggedIn { get { - var userId = _registry.ActiveUserId; + var userId = Registry.ActiveUserId; return userId is not (null or 0); } } - public SteamWrapper(IServiceProvider serviceProvider) - { - _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); - _registry = serviceProvider.GetRequiredService(); - _processHelper = serviceProvider.GetRequiredService(); - _fileSystem = serviceProvider.GetRequiredService(); - } - -#if NET public bool IsGameInstalled(uint gameId, [NotNullWhen(true)] out SteamAppManifest? game) -#else - public bool IsGameInstalled(uint gameId, out SteamAppManifest? game) -#endif { ThrowIfSteamNotInstalled(); game = null; - var apps = _registry.InstalledApps; + var apps = Registry.InstalledApps; if (apps is null) return false; if (!apps.Contains(gameId)) return false; - var gameFinder = _serviceProvider.GetRequiredService(); + var gameFinder = ServiceProvider.GetRequiredService(); game = gameFinder.FindGame(gameId); return game is not null; } @@ -113,7 +102,7 @@ public void StartSteam() { StartInfo = { - FileName = _registry.ExeFile!.FullName, + FileName = Registry.ExeFile!.FullName, UseShellExecute = false } }; @@ -128,7 +117,7 @@ public async Task WaitSteamRunningAndLoggedInAsync(bool startIfNotRunning, if (!running) { // Required because a taskmgr kill does not reset this value, so we have to do this manually - _registry.ActiveUserId = 0; + Registry.ActiveUserId = 0; if (startIfNotRunning) StartSteam(); await WaitSteamRunningAsync(cancellation); @@ -169,43 +158,9 @@ private async Task WaitSteamOfflineRunning(CancellationToken token) } } - private async Task WaitSteamUserLoggedInAsync(CancellationToken token) - { - token.ThrowIfCancellationRequested(); - if (IsUserLoggedIn) - return; - - while (!IsUserLoggedIn) - { - token.ThrowIfCancellationRequested(); - var processKey = _registry.ActiveProcessKey; - if (processKey is null) - return; - if (processKey is not WindowsRegistryKey windowsRegistryKey) - throw new InvalidOperationException("Expected Windows registry Key"); - - - await windowsRegistryKey.WindowsKey.WaitForChangeAsync(false, RegistryChangeNotificationFilters.Value, token); - } - } - - private async Task WaitSteamRunningAsync(CancellationToken token) - { - token.ThrowIfCancellationRequested(); - if (IsRunning) - return; + protected abstract Task WaitSteamUserLoggedInAsync(CancellationToken token); - while (!IsRunning) - { - token.ThrowIfCancellationRequested(); - var processKey = _registry.ActiveProcessKey; - if (processKey is null) - return; - if (processKey is not WindowsRegistryKey windowsRegistryKey) - throw new InvalidOperationException("Expected Windows registry Key"); - await windowsRegistryKey.WindowsKey.WaitForChangeAsync(false, RegistryChangeNotificationFilters.Value, token); - } - } + protected abstract Task WaitSteamRunningAsync(CancellationToken token); private async Task WaitMainWindowIsSteamClient(CancellationToken token) { diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs new file mode 100644 index 00000000..c9640bdc --- /dev/null +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs @@ -0,0 +1,16 @@ +using System; +using System.Runtime.InteropServices; + +namespace AET.SteamAbstraction; + +internal class SteamWrapperFactory : ISteamWrapperFactory +{ + public ISteamWrapper CreateWrapper(IServiceProvider serviceProvider) + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + return new WindowsSteamWrapper(serviceProvider); + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + return new LinuxSteamWrapper(serviceProvider); + throw new PlatformNotSupportedException($"The current platform is not supported."); + } +} \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/AwaitExtensions.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/AwaitExtensions.cs similarity index 97% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/AwaitExtensions.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/AwaitExtensions.cs index 48c05e36..700e3cd2 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/AwaitExtensions.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/AwaitExtensions.cs @@ -3,11 +3,11 @@ using System.ComponentModel; using System.Threading; using System.Threading.Tasks; +using AET.SteamAbstraction.NativeMethods; using Microsoft.Win32; using Microsoft.Win32.SafeHandles; -using PG.StarWarsGame.Infrastructure.Clients.Steam.NativeMethods; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Threading; +namespace AET.SteamAbstraction.Threading; // From https://github.com/microsoft/vs-threading internal static class AwaitExtensions @@ -33,7 +33,7 @@ public static Task WaitForChangeAsync(this RegistryKey registryKey, bool watchSu RegistryChangeNotificationFilters.Value | RegistryChangeNotificationFilters.Subkey, CancellationToken cancellationToken = default) { - if (registryKey == null) + if (registryKey == null) throw new ArgumentNullException(nameof(registryKey)); return WaitForRegistryChangeAsync(registryKey.Handle, watchSubtree, change, cancellationToken); @@ -94,7 +94,7 @@ private static class DownlevelRegistryWatcherSupport internal static async Task ExecuteOnDedicatedThreadAsync(Action action) { - if (action == null) + if (action == null) throw new ArgumentNullException(nameof(action)); var tcs = new TaskCompletionSource(); diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/EmptyStruct.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/EmptyStruct.cs similarity index 67% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/EmptyStruct.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/EmptyStruct.cs index 609e18bc..2643f304 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/EmptyStruct.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/EmptyStruct.cs @@ -1,4 +1,4 @@ -namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Threading; +namespace AET.SteamAbstraction.Threading; // From https://github.com/microsoft/vs-threading internal readonly struct EmptyStruct diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/NoMessagePumpSyncContext.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/NoMessagePumpSyncContext.cs similarity index 91% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/NoMessagePumpSyncContext.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/NoMessagePumpSyncContext.cs index 1a71821a..05a2a1f1 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/NoMessagePumpSyncContext.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/NoMessagePumpSyncContext.cs @@ -1,9 +1,9 @@ using System; using System.Runtime.InteropServices; using System.Threading; -using PG.StarWarsGame.Infrastructure.Clients.Steam.NativeMethods; +using AET.SteamAbstraction.NativeMethods; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Threading; +namespace AET.SteamAbstraction.Threading; // From https://github.com/microsoft/vs-threading internal class NoMessagePumpSyncContext : SynchronizationContext diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/RegistryChangeNotificationFilters.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/RegistryChangeNotificationFilters.cs similarity index 94% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/RegistryChangeNotificationFilters.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/RegistryChangeNotificationFilters.cs index 3b29e6c1..3c8ed078 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/RegistryChangeNotificationFilters.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/RegistryChangeNotificationFilters.cs @@ -1,6 +1,6 @@ using System; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Threading; +namespace AET.SteamAbstraction.Threading; // From https://github.com/microsoft/vs-threading /// diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/SpecializedSyncContext.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/SpecializedSyncContext.cs similarity index 94% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/SpecializedSyncContext.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/SpecializedSyncContext.cs index a8cb9152..89d10356 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/SpecializedSyncContext.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/SpecializedSyncContext.cs @@ -1,7 +1,7 @@ using System; using System.Threading; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Threading; +namespace AET.SteamAbstraction.Threading; // From https://github.com/microsoft/vs-threading internal readonly struct SpecializedSyncContext : IDisposable diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/ThreadingTools.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/ThreadingTools.cs similarity index 84% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/ThreadingTools.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/ThreadingTools.cs index f435ce42..99a35b17 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/ThreadingTools.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/ThreadingTools.cs @@ -1,6 +1,6 @@ using System.Threading; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Threading; +namespace AET.SteamAbstraction.Threading; // From https://github.com/microsoft/vs-threading internal static class ThreadingTools diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/TplExtensions.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/TplExtensions.cs similarity index 98% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/TplExtensions.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/TplExtensions.cs index f1b2da8d..7d32e38a 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Threading/TplExtensions.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/TplExtensions.cs @@ -2,7 +2,7 @@ using System.Threading; using System.Threading.Tasks; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Threading; +namespace AET.SteamAbstraction.Threading; // From https://github.com/microsoft/vs-threading internal static class TplExtensions diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/IProcessHelper.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Utilities/IProcessHelper.cs similarity index 71% rename from src/PetroGlyph.Games.EawFoc.Clients/src/Processes/IProcessHelper.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/Utilities/IProcessHelper.cs index dc0d87c4..5b1056b4 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/IProcessHelper.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Utilities/IProcessHelper.cs @@ -1,6 +1,6 @@ using System.Diagnostics; -namespace PG.StarWarsGame.Infrastructure.Clients.Processes; +namespace AET.SteamAbstraction.Utilities; internal interface IProcessHelper { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/ProcessHelper.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Utilities/ProcessHelper.cs similarity index 87% rename from src/PetroGlyph.Games.EawFoc.Clients/src/Processes/ProcessHelper.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/Utilities/ProcessHelper.cs index e2d63317..af557d6b 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Processes/ProcessHelper.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Utilities/ProcessHelper.cs @@ -1,7 +1,7 @@ using System.Diagnostics; using System.Linq; -namespace PG.StarWarsGame.Infrastructure.Clients.Processes; +namespace AET.SteamAbstraction.Utilities; internal class ProcessHelper : IProcessHelper { diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Wrappers/LinuxSteamWrapper.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Wrappers/LinuxSteamWrapper.cs new file mode 100644 index 00000000..3f8c6fa3 --- /dev/null +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Wrappers/LinuxSteamWrapper.cs @@ -0,0 +1,18 @@ +using System; +using System.Threading; +using System.Threading.Tasks; + +namespace AET.SteamAbstraction; + +internal class LinuxSteamWrapper(IServiceProvider serviceProvider) : SteamWrapper(serviceProvider) +{ + protected override Task WaitSteamUserLoggedInAsync(CancellationToken token) + { + throw new NotImplementedException(); + } + + protected override Task WaitSteamRunningAsync(CancellationToken token) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Wrappers/WindowsSteamWrapper.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Wrappers/WindowsSteamWrapper.cs new file mode 100644 index 00000000..cb6f7ff0 --- /dev/null +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Wrappers/WindowsSteamWrapper.cs @@ -0,0 +1,51 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using AET.SteamAbstraction.Threading; + +namespace AET.SteamAbstraction; + +internal class WindowsSteamWrapper(IServiceProvider serviceProvider) : SteamWrapper(serviceProvider) +{ + protected override Task WaitSteamUserLoggedInAsync(CancellationToken token) + { + throw new NotImplementedException(); + + //token.ThrowIfCancellationRequested(); + //if (IsUserLoggedIn) + // return; + + //while (!IsUserLoggedIn) + //{ + // token.ThrowIfCancellationRequested(); + // var processKey = Registry.ActiveProcessKey; + // if (processKey is null) + // return; + // if (processKey is not WindowsRegistryKey windowsRegistryKey) + // throw new InvalidOperationException("Expected Windows registry Key"); + + + // await windowsRegistryKey.WindowsKey.WaitForChangeAsync(false, RegistryChangeNotificationFilters.Value, token); + //} + } + + protected override Task WaitSteamRunningAsync(CancellationToken token) + { + throw new NotImplementedException(); + + //token.ThrowIfCancellationRequested(); + //if (IsRunning) + // return; + + //while (!IsRunning) + //{ + // token.ThrowIfCancellationRequested(); + // var processKey = Registry.ActiveProcessKey; + // if (processKey is null) + // return; + // if (processKey is not WindowsRegistryKey windowsRegistryKey) + // throw new InvalidOperationException("Expected Windows registry Key"); + // await windowsRegistryKey.WindowsKey.WaitForChangeAsync(false, RegistryChangeNotificationFilters.Value, token); + //} + } +} \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.csproj index 344db389..74a8e2f6 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.csproj @@ -32,7 +32,6 @@ - diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamRegistry.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamRegistry.cs deleted file mode 100644 index d53a3e8c..00000000 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/SteamRegistry.cs +++ /dev/null @@ -1,144 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.IO.Abstractions; -using System.Linq; -using AnakinRaW.CommonUtilities.Registry; -using Microsoft.Extensions.DependencyInjection; - -namespace PG.StarWarsGame.Infrastructure.Clients.Steam; - -internal sealed class SteamRegistry : ISteamRegistry -{ - private const string SteamExeKey = "SteamExe"; - private const string SteamPathKey = "SteamPath"; - private const string SteamProcessIdKey = "pid"; - private const string SteamActiveUserKey = "ActiveUser"; - - private const string SteamProcessNode = "ActiveProcess"; - private const string SteamAppsNode = "Apps"; - - private IRegistryKey? _registryKey; - private bool _disposed; - private readonly IFileSystem _fileSystem; - - public IRegistryKey? ActiveProcessKey - { - get - { - ThrowIfDisposed(); - return _registryKey!.GetKey(SteamProcessNode); - } - } - - int? ISteamRegistry.ActiveUserId - { - get - { - ThrowIfDisposed(); - return !_registryKey!.GetValue(SteamActiveUserKey, SteamProcessNode, out int? userId) ? null : userId; - } - set - { - ThrowIfDisposed(); - value ??= 0; - _registryKey!.WriteValue(SteamActiveUserKey, SteamProcessNode, value); - } - } - - public int? ProcessId - { - get - { - ThrowIfDisposed(); - return !_registryKey!.GetValue(SteamProcessIdKey, SteamProcessNode, out int? pid) ? null : pid; - } - } - - public IFileInfo? ExeFile - { - get - { - ThrowIfDisposed(); - return !_registryKey!.GetValue(SteamExeKey, out string? filePath) - ? null - : _fileSystem.FileInfo.New(filePath!); - } - } - - public IDirectoryInfo? InstallationDirectory - { - get - { - ThrowIfDisposed(); - return !_registryKey!.GetValue(SteamPathKey, out string? path) - ? null - : _fileSystem.DirectoryInfo.New(path!); - } - } - - public ISet? InstalledApps - { - get - { - ThrowIfDisposed(); - var keyNames = _registryKey!.GetSubKeyNames(SteamAppsNode); - if (keyNames is null) - return null; - var ids = keyNames - .Select(n => !uint.TryParse(n, out var id) ? (uint?)0 : id) - .OfType(); - return new HashSet(ids); - } - } - - - public SteamRegistry(IServiceProvider serviceProvider) - { - _registryKey = serviceProvider.GetRequiredService() - .OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default) - .CreateSubKey("Software\\Valve\\Steam"); - _fileSystem = serviceProvider.GetRequiredService(); - } - - - /// - ~SteamRegistry() - { - Dispose(false); - } - - /// - /// Disposed all managed resources acquired by this instance. - /// - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - /// - /// Disposed all managed resources acquired by this instance. - /// - /// if called from the destructor; otherwise. - private void Dispose(bool disposing) - { - if (disposing) - { - _registryKey?.Dispose(); - _registryKey = null; - _disposed = true; - } - } - -#if NET - [MemberNotNull(nameof(_registryKey))] -#endif - private void ThrowIfDisposed() - { - if (_disposed) - throw new ObjectDisposedException(ToString()); - if (_registryKey is null) - throw new Exception("registry must not be null in non-disposed state"); - } -} \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.csproj index 13255144..e3e951d0 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.csproj @@ -34,7 +34,6 @@ - \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperTest.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperTest.cs deleted file mode 100644 index 204d9791..00000000 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/Steam/SteamWrapperTest.cs +++ /dev/null @@ -1,145 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO.Abstractions; -using Microsoft.Extensions.DependencyInjection; -using Moq; -using PG.StarWarsGame.Infrastructure.Clients.Processes; -using Testably.Abstractions.Testing; -using Xunit; - -namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.Steam; - -public class SteamWrapperTest -{ - private readonly SteamWrapper _service; - private readonly Mock _steamRegistry; - private readonly MockFileSystem _fileSystem; - private readonly Mock _processHelper; - private readonly Mock _gameFinder; - - public SteamWrapperTest() - { - var sc = new ServiceCollection(); - _steamRegistry = new Mock(); - _fileSystem = new MockFileSystem(); - _processHelper = new Mock(); - _gameFinder = new Mock(); - sc.AddTransient(_ => _steamRegistry.Object); - sc.AddTransient(_ => _processHelper.Object); - sc.AddTransient(_ => _gameFinder.Object); - sc.AddTransient(_ => _fileSystem); - _service = new SteamWrapper(sc.BuildServiceProvider()); - } - - [Fact] - public void TestInvalidArgs_Throws() - { - Assert.Throws(() => new SteamWrapper(null)); - } - - [Fact] - public void TestRunning() - { - _processHelper.SetupSequence(h => h.GetProcessByPid(It.IsAny())) - .Returns((Process)null) - .Returns(Process.GetCurrentProcess); - _steamRegistry.SetupSequence(r => r.ProcessId) - .Returns((int?)null) - .Returns(0) - .Returns(123) - .Returns(123); - - Assert.False(_service.IsRunning); - Assert.False(_service.IsRunning); - Assert.False(_service.IsRunning); - Assert.True(_service.IsRunning); - } - - [Fact] - public void TestInstalled() - { - _steamRegistry.SetupSequence(r => r.ExeFile) - .Returns((IFileInfo?)null) - .Returns(() => _fileSystem.FileInfo.New("steam.exe")) - .Returns(() => _fileSystem.FileInfo.New("steam.exe")); - - Assert.False(_service.Installed); - Assert.False(_service.Installed); - - _fileSystem.Initialize().WithFile("steam.exe"); - - Assert.True(_service.Installed); - } - - [Fact] - public void TestUserLoggedIn() - { - _steamRegistry.SetupSequence(r => r.ActiveUserId) - .Returns((int?)null) - .Returns(0) - .Returns(123); - - Assert.False(_service.IsUserLoggedIn); - Assert.False(_service.IsUserLoggedIn); - Assert.True(_service.IsUserLoggedIn); - } - - [Fact] - public void TestGameInstalled() - { - _fileSystem.Initialize(); - - SetupInstalledRegistry(); - var mFile = _fileSystem.FileInfo.New("manifest.acf"); - - var expectedApp = new SteamAppManifest(new Mock().Object, mFile, 1234, "name", - _fileSystem.DirectoryInfo.New("Game"), SteamAppState.StateFullyInstalled, - new HashSet()); - - _gameFinder.SetupSequence(f => f.FindGame(It.IsAny())) - .Returns((SteamAppManifest?)null) - .Returns(expectedApp); - _steamRegistry.Setup(r => r.InstalledApps).Returns(new HashSet { 1, 2, 3 }); - _steamRegistry.Setup(r => r.InstallationDirectory).Returns(_fileSystem.DirectoryInfo.New("Steam")); - - Assert.False(_service.IsGameInstalled(0, out _)); - Assert.False(_service.IsGameInstalled(1, out _)); - Assert.True(_service.IsGameInstalled(1, out var app)); - } - - [Fact] - public void TestWantsOffline() - { - SetupInstalledRegistry(); - - _steamRegistry.Setup(r => r.InstallationDirectory).Returns(_fileSystem.DirectoryInfo.New(".")); - - Assert.Null(_service.WantOfflineMode); - - _fileSystem.Initialize().WithFile("config/loginusers.vdf"); - Assert.Null(_service.WantOfflineMode); - - _fileSystem.File.WriteAllText("config/loginusers.vdf", WantsNotOffline()); - Assert.False(_service.WantOfflineMode); - - _fileSystem.File.WriteAllText("config/loginusers.vdf", WantsOffline()); - Assert.True(_service.WantOfflineMode); - } - - private void SetupInstalledRegistry() - { - _fileSystem.Initialize().WithFile("steam.exe"); - _steamRegistry.Setup(r => r.ExeFile).Returns(_fileSystem.FileInfo.New("steam.exe")); - } - - private static string WantsNotOffline() - { - return "\"users\"\n{\n\t\"123\"\n\t{\n\t\t\"AccountName\"\t\t\"user_name\"\n\t\t\"PersonaName\"\t\t\"User Name\"\n\t\t\"RememberPassword\"\t\t\"1\"\n\t\t\"MostRecent\"\t\t\"1\"\n\t\t\"Timestamp\"\t\t\"0000000000\"\n\t\t\"WantsOfflineMode\"\t\t\"0\"\n\t\t\"SkipOfflineModeWarning\"\t\t\"0\"\n\t}\n}"; - } - - private static string WantsOffline() - { - return "\"users\"\n{\n\t\"123\"\n\t{\n\t\t\"AccountName\"\t\t\"user_name\"\n\t\t\"PersonaName\"\t\t\"User Name\"\n\t\t\"RememberPassword\"\t\t\"1\"\n\t\t\"MostRecent\"\t\t\"1\"\n\t\t\"Timestamp\"\t\t\"0000000000\"\n\t\t\"WantsOfflineMode\"\t\t\"1\"\n\t\t\"SkipOfflineModeWarning\"\t\t\"0\"\n\t}\n}"; - } -} \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PG.StarWarsGame.Infrastructure.Clients.Steam.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PG.StarWarsGame.Infrastructure.Clients.Steam.Test.csproj index 60769d49..e5ef9638 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PG.StarWarsGame.Infrastructure.Clients.Steam.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PG.StarWarsGame.Infrastructure.Clients.Steam.Test.csproj @@ -33,7 +33,6 @@ - diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ModArgumentListFactory.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ModArgumentListFactory.cs index 854cc0f1..36b9583e 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ModArgumentListFactory.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Arguments/ModArgumentListFactory.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using AET.SteamAbstraction; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; using PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/DefaultGameClientFactory.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/DefaultGameClientFactory.cs new file mode 100644 index 00000000..0fedac67 --- /dev/null +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/DefaultGameClientFactory.cs @@ -0,0 +1,46 @@ +using System; +using PG.StarWarsGame.Infrastructure.Clients.Steam; +using PG.StarWarsGame.Infrastructure.Games; + +namespace PG.StarWarsGame.Infrastructure.Clients; + +/// +/// which creates a for the Steam platform +/// and otherwise. +/// +/// If this factory already created an instance for a matching it will reuse the instance. +/// +/// +public class DefaultGameClientFactory : IGameClientFactory +{ + private readonly IServiceProvider _serviceProvider; + + private IGameClient? _steamClient; + private IGameClient? _normalClient; + + /// + /// Creates a new instance. + /// + /// The service provider. + public DefaultGameClientFactory(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + } + + /// + /// Gets or creates an for the given . + /// + /// The requested game platform. + /// The service provider used to created the . + /// + public IGameClient CreateClient(GamePlatform gamePlatform, IServiceProvider serviceProvider) + { + if (gamePlatform == GamePlatform.SteamGold) + { + _steamClient ??= new SteamGameClient(_serviceProvider); + return _steamClient; + } + _normalClient ??= new DefaultClient(_serviceProvider); + return _normalClient; + } +} \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/PG.StarWarsGame.Infrastructure.Clients.csproj b/src/PetroGlyph.Games.EawFoc.Clients/src/PG.StarWarsGame.Infrastructure.Clients.csproj index 6a343f64..aed4764e 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/PG.StarWarsGame.Infrastructure.Clients.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/PG.StarWarsGame.Infrastructure.Clients.csproj @@ -22,6 +22,7 @@ + diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/PetroglyphClientsLibrary.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/PetroglyphClientsLibrary.cs index a4484ad7..824e1031 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/PetroglyphClientsLibrary.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/PetroglyphClientsLibrary.cs @@ -1,6 +1,5 @@ using Microsoft.Extensions.DependencyInjection; using PG.StarWarsGame.Infrastructure.Clients.Arguments; -using PG.StarWarsGame.Infrastructure.Clients.Processes; namespace PG.StarWarsGame.Infrastructure.Clients; @@ -16,8 +15,6 @@ public class PetroglyphClientsLibrary /// The service collection to be filled. public static void InitializeLibraryWithDefaultServices(IServiceCollection serviceCollection) { - serviceCollection.AddTransient(_ => new ProcessHelper()); - serviceCollection.AddTransient(sp => new GameExecutableFileService(sp)); serviceCollection.AddTransient(_ => new GameExecutableNameBuilder()); diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameClient.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Steam/SteamGameClient.cs similarity index 98% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameClient.cs rename to src/PetroGlyph.Games.EawFoc.Clients/src/Steam/SteamGameClient.cs index 2569c2a5..03ef795f 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameClient.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Steam/SteamGameClient.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO.Abstractions; +using AET.SteamAbstraction; using Microsoft.Extensions.DependencyInjection; using PG.StarWarsGame.Infrastructure.Clients.Processes; using PG.StarWarsGame.Infrastructure.Games; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameLanguageFinder.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Steam/SteamGameLanguageFinder.cs similarity index 98% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameLanguageFinder.cs rename to src/PetroGlyph.Games.EawFoc.Clients/src/Steam/SteamGameLanguageFinder.cs index 8cd9dc96..848c4bf6 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamGameLanguageFinder.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Steam/SteamGameLanguageFinder.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using AET.SteamAbstraction; using EawModinfo.Model; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamPetroglyphStarWarsGameDetector.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Steam/SteamPetroglyphStarWarsGameDetector.cs similarity index 99% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamPetroglyphStarWarsGameDetector.cs rename to src/PetroGlyph.Games.EawFoc.Clients/src/Steam/SteamPetroglyphStarWarsGameDetector.cs index 0a54b88e..8b52a558 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/SteamPetroglyphStarWarsGameDetector.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Steam/SteamPetroglyphStarWarsGameDetector.cs @@ -1,4 +1,5 @@ using System; +using AET.SteamAbstraction; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using PG.StarWarsGame.Infrastructure.Games; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListFactoryTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListFactoryTest.cs index 529f5214..1ac258b4 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListFactoryTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListFactoryTest.cs @@ -5,6 +5,7 @@ using Testably.Abstractions.Testing; using Xunit; using System.Runtime.InteropServices; +using AET.SteamAbstraction; using PG.StarWarsGame.Infrastructure.Clients.Arguments; using PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments; using PG.StarWarsGame.Infrastructure.Games; diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameClientTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamGameClientTest.cs similarity index 94% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameClientTest.cs rename to src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamGameClientTest.cs index e4b228b3..54137cde 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameClientTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamGameClientTest.cs @@ -1,12 +1,14 @@ using System.IO.Abstractions; +using AET.SteamAbstraction; using Microsoft.Extensions.DependencyInjection; using Moq; using PG.StarWarsGame.Infrastructure.Clients.Processes; +using PG.StarWarsGame.Infrastructure.Clients.Steam; using PG.StarWarsGame.Infrastructure.Games; using Testably.Abstractions.Testing; using Xunit; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Test; +namespace PG.StarWarsGame.Infrastructure.Clients.Test.Steam; public class SteamGameClientTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameLanguageFinderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamGameLanguageFinderTest.cs similarity index 95% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameLanguageFinderTest.cs rename to src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamGameLanguageFinderTest.cs index 25dbcccb..ceb038d4 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamGameLanguageFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamGameLanguageFinderTest.cs @@ -1,14 +1,16 @@ using System; using System.Collections.Generic; +using AET.SteamAbstraction; using EawModinfo.Model; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; using Moq; +using PG.StarWarsGame.Infrastructure.Clients.Steam; using PG.StarWarsGame.Infrastructure.Games; using Testably.Abstractions.Testing; using Xunit; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Test; +namespace PG.StarWarsGame.Infrastructure.Clients.Test.Steam; public class SteamGameLanguageFinderTest { diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamPetroglyphStarWarsGameDetectorTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamPetroglyphStarWarsGameDetectorTest.cs similarity index 98% rename from src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamPetroglyphStarWarsGameDetectorTest.cs rename to src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamPetroglyphStarWarsGameDetectorTest.cs index 6a738fa5..46080d32 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/SteamPetroglyphStarWarsGameDetectorTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamPetroglyphStarWarsGameDetectorTest.cs @@ -1,15 +1,17 @@ using System; using System.Collections.Generic; using System.IO.Abstractions; +using AET.SteamAbstraction; using Microsoft.Extensions.DependencyInjection; using Moq; +using PG.StarWarsGame.Infrastructure.Clients.Steam; using PG.StarWarsGame.Infrastructure.Games; using PG.StarWarsGame.Infrastructure.Games.Registry; using PG.StarWarsGame.Infrastructure.Services.Detection; using Testably.Abstractions.Testing; using Xunit; -namespace PG.StarWarsGame.Infrastructure.Clients.Steam.Test; +namespace PG.StarWarsGame.Infrastructure.Clients.Test.Steam; public class SteamPetroglyphStarWarsGameDetectorTest { From 117b9dffda5a1e9042a80eb3bf85d64940ecfd5f Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Fri, 15 Mar 2024 11:31:35 +0100 Subject: [PATCH 17/41] steam tests for windows for now --- .../AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj index eccdc13a..7c8d2669 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj @@ -1,7 +1,7 @@  - net8.0 + net8.0-windows $(TargetFrameworks);net48 enable enable From 1439a1d275ca24242cbd60eed811f8e0a1aae3ad Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Fri, 15 Mar 2024 11:34:02 +0100 Subject: [PATCH 18/41] remove leftovers --- ...nfrastructure.Clients.Steam.Windows.csproj | 39 ---------------- .../PetroglyphWindowsSteamClientsLibrary.cs | 27 ----------- .../src/Properties/AssemblyInfo.cs | 4 -- ...tructure.Clients.Steam.Windows.Test.csproj | 39 ---------------- .../src/DefaultGameClientFactory.cs | 45 ------------------- ...rsGame.Infrastructure.Clients.Steam.csproj | 28 ------------ .../src/Properties/AssemblyInfo.cs | 4 -- ...e.Infrastructure.Clients.Steam.Test.csproj | 38 ---------------- 8 files changed, 224 deletions(-) delete mode 100644 src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.csproj delete mode 100644 src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroglyphWindowsSteamClientsLibrary.cs delete mode 100644 src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Properties/AssemblyInfo.cs delete mode 100644 src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.csproj delete mode 100644 src/PetroGlyph.Games.EawFoc.Clients.Steam/src/DefaultGameClientFactory.cs delete mode 100644 src/PetroGlyph.Games.EawFoc.Clients.Steam/src/PG.StarWarsGame.Infrastructure.Clients.Steam.csproj delete mode 100644 src/PetroGlyph.Games.EawFoc.Clients.Steam/src/Properties/AssemblyInfo.cs delete mode 100644 src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PG.StarWarsGame.Infrastructure.Clients.Steam.Test.csproj diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.csproj deleted file mode 100644 index 74a8e2f6..00000000 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.csproj +++ /dev/null @@ -1,39 +0,0 @@ - - - net8.0-windows;net48 - PG.StarWarsGame.Infrastructure.Clients.Steam - PG.StarWarsGame.Infrastructure.Clients.Steam.Windows - - - - PG.StarWarsGame.Infrastructure.Clients.Steam.Windows - Provides tools for launching Petroglyph Star Wars games on various clients, such as Steam or Disk release. - AlamoEngineTools.PG.StarWarsGame.Infrastructure.Clients.Steam.Windows - alamo,petroglyph,glyphx - en - - - - - true - snupkg - true - true - true - - - - - - - - - - - - - - - - - diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroglyphWindowsSteamClientsLibrary.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroglyphWindowsSteamClientsLibrary.cs deleted file mode 100644 index 5cd2d596..00000000 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/PetroglyphWindowsSteamClientsLibrary.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; - -namespace PG.StarWarsGame.Infrastructure.Clients.Steam; - -/// -/// Provides initialization routines for this library. -/// -public class PetroglyphWindowsSteamClientsLibrary -{ - /// - /// Adds services provided by this library to the given - /// so that the library can be used in client applications. - /// - /// The service collection to be filled. - public static void InitializeLibraryWithDefaultServices(IServiceCollection serviceCollection) - { - // Singleton Services - serviceCollection.AddSingleton(sp => new SteamRegistry(sp)); - serviceCollection.AddSingleton(sp => new SteamWrapper(sp)); - - // Transient Services - serviceCollection.AddTransient(sp => new SteamGameFinder(sp)); - serviceCollection.AddTransient(sp => new SteamVdfReader(sp)); - serviceCollection.AddTransient(sp => new SteamVdfReader(sp)); - serviceCollection.AddTransient(sp => new SteamLibraryFinder(sp)); - } -} diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Properties/AssemblyInfo.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Properties/AssemblyInfo.cs deleted file mode 100644 index 791c6ea4..00000000 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/src/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,4 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test")] -[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.csproj deleted file mode 100644 index e3e951d0..00000000 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam.Windows/test/PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test.csproj +++ /dev/null @@ -1,39 +0,0 @@ - - - - PG.StarWarsGame.Infrastructure.Clients.Steam.Windows.Test - - - - net8.0-windows - $(TargetFrameworks);net48 - false - true - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - - \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/DefaultGameClientFactory.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/DefaultGameClientFactory.cs deleted file mode 100644 index a2290219..00000000 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/DefaultGameClientFactory.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using PG.StarWarsGame.Infrastructure.Games; - -namespace PG.StarWarsGame.Infrastructure.Clients.Steam; - -/// -/// which creates a for the Steam platform -/// and otherwise. -/// -/// If this factory already created an instance for a matching it will reuse the instance. -/// -/// -public class DefaultGameClientFactory : IGameClientFactory -{ - private readonly IServiceProvider _serviceProvider; - - private IGameClient? _steamClient; - private IGameClient? _normalClient; - - /// - /// Creates a new instance. - /// - /// The service provider. - public DefaultGameClientFactory(IServiceProvider serviceProvider) - { - _serviceProvider = serviceProvider; - } - - /// - /// Gets or creates an for the given . - /// - /// The requested game platform. - /// The service provider used to created the . - /// - public IGameClient CreateClient(GamePlatform gamePlatform, IServiceProvider serviceProvider) - { - if (gamePlatform == GamePlatform.SteamGold) - { - _steamClient ??= new SteamGameClient(_serviceProvider); - return _steamClient; - } - _normalClient ??= new DefaultClient(_serviceProvider); - return _normalClient; - } -} \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/PG.StarWarsGame.Infrastructure.Clients.Steam.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/PG.StarWarsGame.Infrastructure.Clients.Steam.csproj deleted file mode 100644 index a294655d..00000000 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/PG.StarWarsGame.Infrastructure.Clients.Steam.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - netstandard2.0 - PG.StarWarsGame.Infrastructure.Clients.Steam - PG.StarWarsGame.Infrastructure.Clients.Steam - - - PG.StarWarsGame.Infrastructure.Clients.Steam - Steam abstraction layer for Petroglyph Star Wars games. - AlamoEngineTools.PG.StarWarsGame.Infrastructure.Clients.Steam - alamo,petroglyph,glyphx - en - - - true - snupkg - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/Properties/AssemblyInfo.cs b/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/Properties/AssemblyInfo.cs deleted file mode 100644 index bc1d0a0b..00000000 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/src/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,4 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("PG.StarWarsGame.Infrastructure.Clients.Test")] -[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PG.StarWarsGame.Infrastructure.Clients.Steam.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PG.StarWarsGame.Infrastructure.Clients.Steam.Test.csproj deleted file mode 100644 index e5ef9638..00000000 --- a/src/PetroGlyph.Games.EawFoc.Clients.Steam/test/PG.StarWarsGame.Infrastructure.Clients.Steam.Test.csproj +++ /dev/null @@ -1,38 +0,0 @@ - - - - PG.StarWarsGame.Infrastructure.Clients.Steam.Test - - - - net8.0 - $(TargetFrameworks);net48 - false - true - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - From 2632dcfd1fcc7419d4825274ec0354d7de65ff3d Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Fri, 15 Mar 2024 11:39:07 +0100 Subject: [PATCH 19/41] no tests --- PetroGlyphGameInfrastructure.sln | 6 ------ .../AET.SteamAbstraction.Test.csproj | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/PetroGlyphGameInfrastructure.sln b/PetroGlyphGameInfrastructure.sln index bb4b8677..609c03ac 100644 --- a/PetroGlyphGameInfrastructure.sln +++ b/PetroGlyphGameInfrastructure.sln @@ -30,9 +30,7 @@ Global EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {90490B07-F4E3-4D1E-B3E3-FD059A0DAB8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {90490B07-F4E3-4D1E-B3E3-FD059A0DAB8D}.Debug|Any CPU.Build.0 = Debug|Any CPU {90490B07-F4E3-4D1E-B3E3-FD059A0DAB8D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {90490B07-F4E3-4D1E-B3E3-FD059A0DAB8D}.Release|Any CPU.Build.0 = Release|Any CPU {F622B36D-E5C9-4C14-B4B1-8871DCF1FF46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F622B36D-E5C9-4C14-B4B1-8871DCF1FF46}.Debug|Any CPU.Build.0 = Debug|Any CPU {F622B36D-E5C9-4C14-B4B1-8871DCF1FF46}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -42,9 +40,7 @@ Global {6A14A57C-60E6-4DDE-B8F0-55ADB3A20758}.Release|Any CPU.ActiveCfg = Release|Any CPU {6A14A57C-60E6-4DDE-B8F0-55ADB3A20758}.Release|Any CPU.Build.0 = Release|Any CPU {0D5DAC91-BB5F-46F4-9145-4296E9151DC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0D5DAC91-BB5F-46F4-9145-4296E9151DC3}.Debug|Any CPU.Build.0 = Debug|Any CPU {0D5DAC91-BB5F-46F4-9145-4296E9151DC3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0D5DAC91-BB5F-46F4-9145-4296E9151DC3}.Release|Any CPU.Build.0 = Release|Any CPU {8F295344-3D7B-4983-88FD-D0E5C692CBAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8F295344-3D7B-4983-88FD-D0E5C692CBAB}.Debug|Any CPU.Build.0 = Debug|Any CPU {8F295344-3D7B-4983-88FD-D0E5C692CBAB}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -58,9 +54,7 @@ Global {24CA9F24-E6DC-4908-B586-E7C14515628C}.Release|Any CPU.ActiveCfg = Release|Any CPU {24CA9F24-E6DC-4908-B586-E7C14515628C}.Release|Any CPU.Build.0 = Release|Any CPU {38FE318C-F775-4318-859C-DCAB3C6FCD71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {38FE318C-F775-4318-859C-DCAB3C6FCD71}.Debug|Any CPU.Build.0 = Debug|Any CPU {38FE318C-F775-4318-859C-DCAB3C6FCD71}.Release|Any CPU.ActiveCfg = Release|Any CPU - {38FE318C-F775-4318-859C-DCAB3C6FCD71}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj index 7c8d2669..eccdc13a 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj @@ -1,7 +1,7 @@  - net8.0-windows + net8.0 $(TargetFrameworks);net48 enable enable From 57a5e39d204b17a01436abd47ca95853db4185ca Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Tue, 19 Mar 2024 12:28:49 +0100 Subject: [PATCH 20/41] update deps and enable tests partially --- PetroGlyphGameInfrastructure.sln | 2 + .../SampleApplication.csproj | 2 +- .../AET.SteamAbstraction.csproj | 8 +- .../NativeMethods/Advapi32.cs | 18 -- .../NativeMethods/Kernel32.cs | 10 - .../Threading/AwaitExtensions.cs | 237 ------------------ .../Threading/EmptyStruct.cs | 7 - .../Threading/NoMessagePumpSyncContext.cs | 36 --- .../RegistryChangeNotificationFilters.cs | 41 --- .../Threading/SpecializedSyncContext.cs | 35 --- .../Threading/ThreadingTools.cs | 13 - .../Threading/TplExtensions.cs | 91 ------- .../Wrappers/WindowsSteamWrapper.cs | 75 +++--- .../src/PG.StarWarsGame.Infrastructure.csproj | 8 +- 14 files changed, 48 insertions(+), 535 deletions(-) delete mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/Advapi32.cs delete mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/Kernel32.cs delete mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/AwaitExtensions.cs delete mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/EmptyStruct.cs delete mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/NoMessagePumpSyncContext.cs delete mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/RegistryChangeNotificationFilters.cs delete mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/SpecializedSyncContext.cs delete mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/ThreadingTools.cs delete mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/TplExtensions.cs diff --git a/PetroGlyphGameInfrastructure.sln b/PetroGlyphGameInfrastructure.sln index 609c03ac..05ba6360 100644 --- a/PetroGlyphGameInfrastructure.sln +++ b/PetroGlyphGameInfrastructure.sln @@ -30,7 +30,9 @@ Global EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {90490B07-F4E3-4D1E-B3E3-FD059A0DAB8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {90490B07-F4E3-4D1E-B3E3-FD059A0DAB8D}.Debug|Any CPU.Build.0 = Debug|Any CPU {90490B07-F4E3-4D1E-B3E3-FD059A0DAB8D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {90490B07-F4E3-4D1E-B3E3-FD059A0DAB8D}.Release|Any CPU.Build.0 = Release|Any CPU {F622B36D-E5C9-4C14-B4B1-8871DCF1FF46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F622B36D-E5C9-4C14-B4B1-8871DCF1FF46}.Debug|Any CPU.Build.0 = Debug|Any CPU {F622B36D-E5C9-4C14-B4B1-8871DCF1FF46}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/sample/SampleApplication/SampleApplication.csproj b/sample/SampleApplication/SampleApplication.csproj index d4fa4e40..5f302bfb 100644 --- a/sample/SampleApplication/SampleApplication.csproj +++ b/sample/SampleApplication/SampleApplication.csproj @@ -8,7 +8,7 @@ - + diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj b/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj index 485a9834..5c7de8b2 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj @@ -20,18 +20,16 @@ true - + - - + + - all runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/Advapi32.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/Advapi32.cs deleted file mode 100644 index c9ac9fce..00000000 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/Advapi32.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Runtime.InteropServices; -using AET.SteamAbstraction.Threading; -using Microsoft.Win32.SafeHandles; - -namespace AET.SteamAbstraction.NativeMethods; - -internal static class Advapi32 -{ - internal const RegistryChangeNotificationFilters RegNotifyThreadAgnostic = (RegistryChangeNotificationFilters)0x10000000L; - - [DllImport("Advapi32.dll", ExactSpelling = true, SetLastError = true)] - internal static extern int RegNotifyChangeKeyValue( - SafeRegistryHandle hKey, - [MarshalAs(UnmanagedType.Bool)] bool watchSubtree, - RegistryChangeNotificationFilters notifyFilter, - SafeWaitHandle hEvent, - [MarshalAs(UnmanagedType.Bool)] bool asynchronous); -} \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/Kernel32.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/Kernel32.cs deleted file mode 100644 index 5d5f177d..00000000 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/Kernel32.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace AET.SteamAbstraction.NativeMethods; - -internal static class Kernel32 -{ - [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)] - internal static extern int WaitForMultipleObjects(uint handleCount, IntPtr[] waitHandles, [MarshalAs(UnmanagedType.Bool)] bool waitAll, uint millisecondsTimeout); -} \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/AwaitExtensions.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/AwaitExtensions.cs deleted file mode 100644 index 700e3cd2..00000000 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/AwaitExtensions.cs +++ /dev/null @@ -1,237 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Threading; -using System.Threading.Tasks; -using AET.SteamAbstraction.NativeMethods; -using Microsoft.Win32; -using Microsoft.Win32.SafeHandles; - -namespace AET.SteamAbstraction.Threading; - -// From https://github.com/microsoft/vs-threading -internal static class AwaitExtensions -{ - private static readonly Version Windows8Version = new(6, 2, 9200); - private static bool IsWindows8OrLater => Environment.OSVersion.Platform == PlatformID.Win32NT - && Environment.OSVersion.Version >= Windows8Version; - - /// - /// Returns a Task that completes when the specified registry key changes. - /// - /// The registry key to watch for changes. - /// true to watch the keys descendent keys as well; - /// false to watch only this key without descendents. - /// Indicates the kinds of changes to watch for. - /// A token that may be canceled to release the resources from watching - /// for changes and complete the returned Task as canceled. - /// - /// A task that completes when the registry key changes, the handle is closed, or upon cancellation. - /// - public static Task WaitForChangeAsync(this RegistryKey registryKey, bool watchSubtree = true, - RegistryChangeNotificationFilters change = - RegistryChangeNotificationFilters.Value | RegistryChangeNotificationFilters.Subkey, - CancellationToken cancellationToken = default) - { - if (registryKey == null) - throw new ArgumentNullException(nameof(registryKey)); - - return WaitForRegistryChangeAsync(registryKey.Handle, watchSubtree, change, cancellationToken); - } - - private static async Task WaitForRegistryChangeAsync(SafeRegistryHandle registryKeyHandle, bool watchSubtree, - RegistryChangeNotificationFilters change, CancellationToken cancellationToken) - { - IDisposable? dedicatedThreadReleaser = null; - try - { - using var evt = new ManualResetEventSlim(); - - void RegisterAction() - { - var win32Error = Advapi32.RegNotifyChangeKeyValue(registryKeyHandle, watchSubtree, change, evt.WaitHandle.SafeWaitHandle, true); - if (win32Error != 0) - { - throw new Win32Exception(win32Error); - } - } - - if (IsWindows8OrLater) - { - change |= Advapi32.RegNotifyThreadAgnostic; - RegisterAction(); - } - else - { - // Engage our downlevel support by using a single, dedicated thread to guarantee - // that we request notification on a thread that will not be destroyed later. - // Although we *could* await this, we synchronously block because our caller expects - // subscription to have begun before we return: for the async part to simply be notification. - // This async method we're calling uses .ConfigureAwait(false) internally so this won't - // deadlock if we're called on a thread with a single-thread SynchronizationContext. - dedicatedThreadReleaser = DownlevelRegistryWatcherSupport - .ExecuteOnDedicatedThreadAsync(RegisterAction).GetAwaiter().GetResult(); - } - - await evt.WaitHandle.ToTask(cancellationToken: cancellationToken).ConfigureAwait(false); - } - finally - { - dedicatedThreadReleaser?.Dispose(); - } - } - - - private static class DownlevelRegistryWatcherSupport - { - private const int SmallThreadStackSize = 100 * 1024; - - private static readonly object SyncObject = new(); - private static readonly Queue>> PendingWork = new(); - private static int _keepAliveCount; - private static Thread? _liveThread; - - - internal static async Task ExecuteOnDedicatedThreadAsync(Action action) - { - if (action == null) - throw new ArgumentNullException(nameof(action)); - - var tcs = new TaskCompletionSource(); - var keepAliveCountIncremented = false; - try - { - lock (SyncObject) - { - PendingWork.Enqueue(Tuple.Create(action, tcs)); - - try - { - // This block intentionally left blank. - } - finally - { - // We make these two assignments within a finally block - // to guard against an untimely ThreadAbortException causing - // us to execute just one of them. - keepAliveCountIncremented = true; - ++_keepAliveCount; - } - - if (_keepAliveCount == 1) - { - if (_liveThread is not null) - throw new InvalidOperationException("Internal error."); - - _liveThread = new Thread(Worker, SmallThreadStackSize) - { - IsBackground = true, - Name = "Registry watcher", - }; - _liveThread.Start(); - } - else - { - // There *could* temporarily be multiple threads in some race conditions. - // Pulse all of them so that the live one is sure to get the message. - Monitor.PulseAll(SyncObject); - } - } - - await tcs.Task.ConfigureAwait(false); - return new ThreadHandleRelease(); - } - catch - { - if (keepAliveCountIncremented) - { - // Our caller will never have a chance to release their claim on the dedicated thread, - // so do it for them. - ReleaseRefOnDedicatedThread(); - } - - throw; - } - } - - private static void ReleaseRefOnDedicatedThread() - { - lock (SyncObject) - { - if (--_keepAliveCount == 0) - { - _liveThread = null; - - // Wake up any obsolete thread(s) so they can go to exit. - Monitor.PulseAll(SyncObject); - } - } - } - - private static void Worker() - { - while (true) - { - Tuple>? work = null; - lock (SyncObject) - { - if (Thread.CurrentThread != _liveThread) - { - // Regardless of our PendingWork and keepAliveCount, - // it isn't meant for this thread any more. - // This happens when keepAliveCount (at least temporarily) - // hits 0, so this thread must be assumed to be on its exit path, - // and another thread will be spawned to process new requests. - if (_liveThread is null && (_keepAliveCount != 0 || PendingWork.Count != 0)) - throw new InvalidOperationException(); - return; - } - - if (PendingWork.Count > 0) - { - work = PendingWork.Dequeue(); - } - else if (_keepAliveCount == 0) - { - // No work, and no reason to stay alive. Exit the thread. - return; - } - else - { - // Sleep until another thread wants to wake us up with a Pulse. - Monitor.Wait(SyncObject); - } - } - - if (work is object) - { - try - { - work.Item1(); - work.Item2.SetResult(EmptyStruct.Instance); - } - catch (Exception ex) - { - work.Item2.SetException(ex); - } - } - } - } - - private class ThreadHandleRelease : IDisposable - { - private bool _disposed; - - public void Dispose() - { - lock (SyncObject) - { - if (_disposed) - return; - _disposed = true; - ReleaseRefOnDedicatedThread(); - } - } - } - } -} \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/EmptyStruct.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/EmptyStruct.cs deleted file mode 100644 index 2643f304..00000000 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/EmptyStruct.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace AET.SteamAbstraction.Threading; - -// From https://github.com/microsoft/vs-threading -internal readonly struct EmptyStruct -{ - internal static EmptyStruct Instance => default; -} \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/NoMessagePumpSyncContext.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/NoMessagePumpSyncContext.cs deleted file mode 100644 index 05a2a1f1..00000000 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/NoMessagePumpSyncContext.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using System.Threading; -using AET.SteamAbstraction.NativeMethods; - -namespace AET.SteamAbstraction.Threading; - -// From https://github.com/microsoft/vs-threading -internal class NoMessagePumpSyncContext : SynchronizationContext -{ - public NoMessagePumpSyncContext() - { - // This is required so that our override of Wait is invoked. - SetWaitNotificationRequired(); - } - - public static SynchronizationContext Default { get; } = new NoMessagePumpSyncContext(); - - public override int Wait(IntPtr[] waitHandles, bool waitAll, int millisecondsTimeout) - { - if (waitHandles == null) - throw new ArgumentNullException(nameof(waitHandles)); - - // On .NET Framework we must take special care to NOT end up in a call to CoWait (which lets in RPC calls). - // Off Windows, we can't p/invoke to kernel32, but it appears that .NET Core never calls CoWait, so we can rely on default behavior. - // We're just going to use the OS as the switch instead of the framework so that (one day) if we drop our .NET Framework specific target, - // and if .NET Core ever adds CoWait support on Windows, we'll still behave properly. - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - return Kernel32.WaitForMultipleObjects((uint)waitHandles.Length, waitHandles, waitAll, - (uint)millisecondsTimeout); - } - - return WaitHelper(waitHandles, waitAll, millisecondsTimeout); - } -} \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/RegistryChangeNotificationFilters.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/RegistryChangeNotificationFilters.cs deleted file mode 100644 index 3c8ed078..00000000 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/RegistryChangeNotificationFilters.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; - -namespace AET.SteamAbstraction.Threading; - -// From https://github.com/microsoft/vs-threading -/// -/// The various types of data within a registry key that generate notifications -/// when changed. -/// -/// -/// This enum matches the Win32 REG_NOTIFY_CHANGE_* constants. -/// -[Flags] -public enum RegistryChangeNotificationFilters -{ - /// - /// Notify the caller if a subkey is added or deleted. - /// Corresponds to Win32 value REG_NOTIFY_CHANGE_NAME. - /// - Subkey = 0x1, - - /// - /// Notify the caller of changes to the attributes of the key, - /// such as the security descriptor information. - /// Corresponds to Win32 value REG_NOTIFY_CHANGE_ATTRIBUTES. - /// - Attributes = 0x2, - - /// - /// Notify the caller of changes to a value of the key. This can - /// include adding or deleting a value, or changing an existing value. - /// Corresponds to Win32 value REG_NOTIFY_CHANGE_LAST_SET. - /// - Value = 0x4, - - /// - /// Notify the caller of changes to the security descriptor of the key. - /// Corresponds to Win32 value REG_NOTIFY_CHANGE_SECURITY. - /// - Security = 0x8, -} \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/SpecializedSyncContext.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/SpecializedSyncContext.cs deleted file mode 100644 index 89d10356..00000000 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/SpecializedSyncContext.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Threading; - -namespace AET.SteamAbstraction.Threading; - -// From https://github.com/microsoft/vs-threading -internal readonly struct SpecializedSyncContext : IDisposable -{ - private readonly bool _initialized; - private readonly SynchronizationContext? _prior; - private readonly SynchronizationContext? _appliedContext; - private readonly bool _checkForChangesOnRevert; - - private SpecializedSyncContext(SynchronizationContext? syncContext, bool checkForChangesOnRevert) - { - _initialized = true; - _prior = SynchronizationContext.Current; - _appliedContext = syncContext; - _checkForChangesOnRevert = checkForChangesOnRevert; - SynchronizationContext.SetSynchronizationContext(syncContext); - } - - public static SpecializedSyncContext Apply(SynchronizationContext? syncContext, bool checkForChangesOnRevert = true) - { - return new SpecializedSyncContext(syncContext, checkForChangesOnRevert); - } - - public void Dispose() - { - if (!_initialized) - return; - // TODO Report.If(_checkForChangesOnRevert && SynchronizationContext.Current != _appliedContext); - SynchronizationContext.SetSynchronizationContext(_prior); - } -} \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/ThreadingTools.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/ThreadingTools.cs deleted file mode 100644 index 99a35b17..00000000 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/ThreadingTools.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Threading; - -namespace AET.SteamAbstraction.Threading; - -// From https://github.com/microsoft/vs-threading -internal static class ThreadingTools -{ - public static SpecializedSyncContext Apply(this SynchronizationContext? syncContext, - bool checkForChangesOnRevert = true) - { - return SpecializedSyncContext.Apply(syncContext, checkForChangesOnRevert); - } -} \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/TplExtensions.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/TplExtensions.cs deleted file mode 100644 index 7d32e38a..00000000 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Threading/TplExtensions.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; -using System.Threading; -using System.Threading.Tasks; - -namespace AET.SteamAbstraction.Threading; - -// From https://github.com/microsoft/vs-threading -internal static class TplExtensions -{ - public static readonly Task TrueTask = Task.FromResult(true); - - public static readonly Task FalseTask = Task.FromResult(false); - - internal static Task ToTask(this WaitHandle handle, int timeout = Timeout.Infinite, - CancellationToken cancellationToken = default) - { - if (handle == null) - throw new ArgumentNullException(nameof(handle)); - - // Check whether the handle is already signaled as an optimization. - // But even for WaitOne(0) the CLR can pump messages if called on the UI thread, which the caller may not - // be expecting at this time, so be sure there is no message pump active by controlling the SynchronizationContext. - using (NoMessagePumpSyncContext.Default.Apply()) - { - if (handle.WaitOne(0)) - { - return TrueTask; - } - - if (timeout == 0) - { - return FalseTask; - } - } - - cancellationToken.ThrowIfCancellationRequested(); - var tcs = new TaskCompletionSource(); - - // Arrange that if the caller signals their cancellation token that we complete the task - // we return immediately. Because of the continuation we've scheduled on that task, this - // will automatically release the wait handle notification as well. - var cancellationRegistration = - cancellationToken.Register( - state => - { - var (taskCompletionSource, token) = - (Tuple, CancellationToken>)state!; - taskCompletionSource.TrySetCanceled(token); - }, - Tuple.Create(tcs, cancellationToken)); - - var callbackHandle = ThreadPool.RegisterWaitForSingleObject( - handle, - (state, timedOut) => ((TaskCompletionSource)state!).TrySetResult(!timedOut), - tcs, - timeout, - true); - - // It's important that we guarantee that when the returned task completes (whether cancelled, timed out, or signaled) - // that we release all resources. - if (cancellationToken.CanBeCanceled) - { - // We have a cancellation token registration and a wait handle registration to release. - // Use a tuple as a state object to avoid allocating delegates and closures each time this method is called. - tcs.Task.ContinueWith( - (_, state) => - { - var tuple = (Tuple)state!; - tuple.Item1.Unregister(null); // release resources for the async callback - tuple.Item2.Dispose(); // release memory for cancellation token registration - }, - Tuple.Create(callbackHandle, cancellationRegistration), - CancellationToken.None, - TaskContinuationOptions.ExecuteSynchronously, - TaskScheduler.Default); - } - else - { - // Since the cancellation token was the default one, the only thing we need to track is clearing the RegisteredWaitHandle, - // so do this such that we allocate as few objects as possible. - tcs.Task.ContinueWith( - (_, state) => ((RegisteredWaitHandle)state!).Unregister(null), - callbackHandle, - CancellationToken.None, - TaskContinuationOptions.ExecuteSynchronously, - TaskScheduler.Default); - } - - return tcs.Task; - } -} \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Wrappers/WindowsSteamWrapper.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Wrappers/WindowsSteamWrapper.cs index cb6f7ff0..b44a46d7 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Wrappers/WindowsSteamWrapper.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Wrappers/WindowsSteamWrapper.cs @@ -1,51 +1,52 @@ using System; +using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; -using AET.SteamAbstraction.Threading; +using AnakinRaW.CommonUtilities.Registry.Windows; namespace AET.SteamAbstraction; internal class WindowsSteamWrapper(IServiceProvider serviceProvider) : SteamWrapper(serviceProvider) { - protected override Task WaitSteamUserLoggedInAsync(CancellationToken token) + protected override async Task WaitSteamUserLoggedInAsync(CancellationToken token) { - throw new NotImplementedException(); - - //token.ThrowIfCancellationRequested(); - //if (IsUserLoggedIn) - // return; - - //while (!IsUserLoggedIn) - //{ - // token.ThrowIfCancellationRequested(); - // var processKey = Registry.ActiveProcessKey; - // if (processKey is null) - // return; - // if (processKey is not WindowsRegistryKey windowsRegistryKey) - // throw new InvalidOperationException("Expected Windows registry Key"); - - - // await windowsRegistryKey.WindowsKey.WaitForChangeAsync(false, RegistryChangeNotificationFilters.Value, token); - //} + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + throw new PlatformNotSupportedException(); + token.ThrowIfCancellationRequested(); + if (IsUserLoggedIn) + return; + + while (!IsUserLoggedIn) + { + token.ThrowIfCancellationRequested(); + var processKey = Registry.ActiveProcessKey; + if (processKey is null) + return; + if (processKey is not WindowsRegistryKey windowsRegistryKey) + throw new InvalidOperationException("Expected Windows registry Key"); + + + await windowsRegistryKey.WindowsKey.WaitForChangeAsync(false, RegistryChangeNotificationFilters.Value, token); + } } - protected override Task WaitSteamRunningAsync(CancellationToken token) + protected override async Task WaitSteamRunningAsync(CancellationToken token) { - throw new NotImplementedException(); - - //token.ThrowIfCancellationRequested(); - //if (IsRunning) - // return; - - //while (!IsRunning) - //{ - // token.ThrowIfCancellationRequested(); - // var processKey = Registry.ActiveProcessKey; - // if (processKey is null) - // return; - // if (processKey is not WindowsRegistryKey windowsRegistryKey) - // throw new InvalidOperationException("Expected Windows registry Key"); - // await windowsRegistryKey.WindowsKey.WaitForChangeAsync(false, RegistryChangeNotificationFilters.Value, token); - //} + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + throw new PlatformNotSupportedException(); + token.ThrowIfCancellationRequested(); + if (IsRunning) + return; + + while (!IsRunning) + { + token.ThrowIfCancellationRequested(); + var processKey = Registry.ActiveProcessKey; + if (processKey is null) + return; + if (processKey is not WindowsRegistryKey windowsRegistryKey) + throw new InvalidOperationException("Expected Windows registry Key"); + await windowsRegistryKey.WindowsKey.WaitForChangeAsync(false, RegistryChangeNotificationFilters.Value, token); + } } } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj b/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj index f72c0c93..c22f6517 100644 --- a/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj +++ b/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj @@ -22,9 +22,9 @@ true - - - + + + all @@ -39,6 +39,6 @@ - + \ No newline at end of file From b1e2a880cfecbdd5c765360e92b9f9bd6ccab596 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Tue, 19 Mar 2024 12:33:12 +0100 Subject: [PATCH 21/41] enable more tests --- PetroGlyphGameInfrastructure.sln | 4 ++++ src/PetroGlyph.Games.EawFoc/test/GameTest.cs | 10 +++++----- src/PetroGlyph.Games.EawFoc/test/ModBaseTest.cs | 10 +++++----- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/PetroGlyphGameInfrastructure.sln b/PetroGlyphGameInfrastructure.sln index 05ba6360..bb4b8677 100644 --- a/PetroGlyphGameInfrastructure.sln +++ b/PetroGlyphGameInfrastructure.sln @@ -42,7 +42,9 @@ Global {6A14A57C-60E6-4DDE-B8F0-55ADB3A20758}.Release|Any CPU.ActiveCfg = Release|Any CPU {6A14A57C-60E6-4DDE-B8F0-55ADB3A20758}.Release|Any CPU.Build.0 = Release|Any CPU {0D5DAC91-BB5F-46F4-9145-4296E9151DC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0D5DAC91-BB5F-46F4-9145-4296E9151DC3}.Debug|Any CPU.Build.0 = Debug|Any CPU {0D5DAC91-BB5F-46F4-9145-4296E9151DC3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0D5DAC91-BB5F-46F4-9145-4296E9151DC3}.Release|Any CPU.Build.0 = Release|Any CPU {8F295344-3D7B-4983-88FD-D0E5C692CBAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8F295344-3D7B-4983-88FD-D0E5C692CBAB}.Debug|Any CPU.Build.0 = Debug|Any CPU {8F295344-3D7B-4983-88FD-D0E5C692CBAB}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -56,7 +58,9 @@ Global {24CA9F24-E6DC-4908-B586-E7C14515628C}.Release|Any CPU.ActiveCfg = Release|Any CPU {24CA9F24-E6DC-4908-B586-E7C14515628C}.Release|Any CPU.Build.0 = Release|Any CPU {38FE318C-F775-4318-859C-DCAB3C6FCD71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {38FE318C-F775-4318-859C-DCAB3C6FCD71}.Debug|Any CPU.Build.0 = Debug|Any CPU {38FE318C-F775-4318-859C-DCAB3C6FCD71}.Release|Any CPU.ActiveCfg = Release|Any CPU + {38FE318C-F775-4318-859C-DCAB3C6FCD71}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/PetroGlyph.Games.EawFoc/test/GameTest.cs b/src/PetroGlyph.Games.EawFoc/test/GameTest.cs index df9b10ed..851c4680 100644 --- a/src/PetroGlyph.Games.EawFoc/test/GameTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/GameTest.cs @@ -37,7 +37,7 @@ public void AddRemoveMods() var name = "Name"; var game = new PetroglyphStarWarsGame(id, loc, name, sp.Object); - Assert.Equal(0, game.Mods.Count); + Assert.Empty(game.Mods); var modMock = new Mock(); modMock.Setup(m => m.Game).Returns(game); @@ -45,16 +45,16 @@ public void AddRemoveMods() var modA = modMock.Object; game.AddMod(modA); - Assert.Equal(1, game.Mods.Count); + Assert.Single(game.Mods); game.AddMod(modA); - Assert.Equal(1, game.Mods.Count); + Assert.Single(game.Mods); Assert.Single(game); game.RemoveMod(modA); - Assert.Equal(0, game.Mods.Count); + Assert.Empty(game.Mods); game.RemoveMod(modA); - Assert.Equal(0, game.Mods.Count); + Assert.Empty(game.Mods); Assert.Empty(game); } diff --git a/src/PetroGlyph.Games.EawFoc/test/ModBaseTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModBaseTest.cs index a3e767a7..a7c64bf0 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModBaseTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModBaseTest.cs @@ -168,7 +168,7 @@ public void AddRemoveMods() var sp = new Mock(); var mod = new ModMock(game.Object, ModType.Default, "Other", sp.Object); - Assert.Equal(0, mod.Mods.Count); + Assert.Empty(mod.Mods); var modMock = new Mock(); modMock.Setup(m => m.Game).Returns(game.Object); @@ -176,16 +176,16 @@ public void AddRemoveMods() var modA = modMock.Object; mod.AddMod(modA); - Assert.Equal(1, mod.Mods.Count); + Assert.Single( mod.Mods); mod.AddMod(modA); - Assert.Equal(1, mod.Mods.Count); + Assert.Single(mod.Mods); Assert.Single(mod); mod.RemoveMod(modA); - Assert.Equal(0, mod.Mods.Count); + Assert.Empty(mod.Mods); mod.RemoveMod(modA); - Assert.Equal(0, mod.Mods.Count); + Assert.Empty(mod.Mods); Assert.Empty(mod); } From 6fddca987cc36c84bd23a2c717bc8010903fbea2 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Tue, 19 Mar 2024 12:36:48 +0100 Subject: [PATCH 22/41] disable aet tests --- PetroGlyphGameInfrastructure.sln | 2 -- 1 file changed, 2 deletions(-) diff --git a/PetroGlyphGameInfrastructure.sln b/PetroGlyphGameInfrastructure.sln index bb4b8677..d6f593af 100644 --- a/PetroGlyphGameInfrastructure.sln +++ b/PetroGlyphGameInfrastructure.sln @@ -58,9 +58,7 @@ Global {24CA9F24-E6DC-4908-B586-E7C14515628C}.Release|Any CPU.ActiveCfg = Release|Any CPU {24CA9F24-E6DC-4908-B586-E7C14515628C}.Release|Any CPU.Build.0 = Release|Any CPU {38FE318C-F775-4318-859C-DCAB3C6FCD71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {38FE318C-F775-4318-859C-DCAB3C6FCD71}.Debug|Any CPU.Build.0 = Debug|Any CPU {38FE318C-F775-4318-859C-DCAB3C6FCD71}.Release|Any CPU.ActiveCfg = Release|Any CPU - {38FE318C-F775-4318-859C-DCAB3C6FCD71}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 2f213565a59e33e5536df62fbe9323b0f59abc6a Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Tue, 19 Mar 2024 12:51:53 +0100 Subject: [PATCH 23/41] remove some tag --- .../AET.SteamAbstraction.Test.csproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj index eccdc13a..3a891b39 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj @@ -31,8 +31,4 @@ - - - - From 380758cccd9e7f41c4c7fe309cd57d09b045a377 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Tue, 19 Mar 2024 18:15:04 +0100 Subject: [PATCH 24/41] update libs and ns --- .../SteamGameFinderTest.cs | 1 + .../SteamLibraryFinderTest.cs | 4 +- .../SteamLibraryTest.cs | 1 + .../SteamVdfReaderTest.cs | 1 + .../SteamWrapperTest.cs | 4 +- .../AET.SteamAbstraction.csproj.DotSettings | 6 +- .../Games/ISteamAppManifestReader.cs | 1 + .../Games/SteamAppManifest.cs | 1 + .../Games/SteamGameFinder.cs | 1 + .../AET.SteamAbstraction/ISteamRegistry.cs | 2 +- .../AET.SteamAbstraction/ISteamWrapper.cs | 5 +- .../ISteamWrapperFactory.cs | 6 +- .../Library/ILibraryConfigReader.cs | 2 +- .../Library/ISteamLibrary.cs | 2 +- .../Library/ISteamLibraryFinder.cs | 2 +- .../Library/SteamLibrary.cs | 2 +- .../Library/SteamLibraryFinder.cs | 2 +- .../Linux/LinuxSteamRegistry.cs | 29 +++++++++ .../{Wrappers => Linux}/LinuxSteamWrapper.cs | 2 +- .../NativeMethods/WindowHandleInfo.cs | 11 +--- .../SteamAbstractionLayer.cs | 13 ++++ .../AET.SteamAbstraction/SteamVdfReader.cs | 1 + .../AET.SteamAbstraction/SteamWrapper.cs | 18 ++++-- .../SteamWrapperFactory.cs | 10 +-- .../WindowsSteamRegistry.cs} | 63 ++++--------------- .../WindowsSteamWrapper.cs | 2 +- ...ntsLibrary.cs => PetroglyphGameClients.cs} | 4 +- .../ArgumentCommandLineBuilderTest.cs | 14 ++--- .../test/Arguments/ArgumentValidatorTest.cs | 56 ++++++++--------- .../test/Arguments/GameArgumentTest.cs | 21 +++---- .../test/Arguments/ModArgumentListTest.cs | 6 +- .../test/DebugableClientBaseTest.cs | 2 +- .../DefaultGameProcessLauncherTest.cs | 2 +- .../test/Processes/GameProcessTest.cs | 8 +-- .../test/Steam/SteamGameLanguageFinderTest.cs | 3 +- ...SteamPetroglyphStarWarsGameDetectorTest.cs | 3 +- ...ary.cs => PetroglyphGameInfrastructure.cs} | 4 +- 37 files changed, 163 insertions(+), 152 deletions(-) create mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/Linux/LinuxSteamRegistry.cs rename src/AET.SteamAbstraction/AET.SteamAbstraction/{Wrappers => Linux}/LinuxSteamWrapper.cs (73%) create mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/SteamAbstractionLayer.cs rename src/AET.SteamAbstraction/AET.SteamAbstraction/{SteamRegistry.cs => Windows/WindowsSteamRegistry.cs} (59%) rename src/AET.SteamAbstraction/AET.SteamAbstraction/{Wrappers => Windows}/WindowsSteamWrapper.cs (93%) rename src/PetroGlyph.Games.EawFoc.Clients/src/{PetroglyphClientsLibrary.cs => PetroglyphGameClients.cs} (87%) rename src/PetroGlyph.Games.EawFoc/src/{PetroglyphGameInfrastructureLibrary.cs => PetroglyphGameInfrastructure.cs} (85%) diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamGameFinderTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamGameFinderTest.cs index 1c7b27a1..25f4411e 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamGameFinderTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamGameFinderTest.cs @@ -1,4 +1,5 @@ using System.IO.Abstractions; +using AET.SteamAbstraction.Library; using Microsoft.Extensions.DependencyInjection; using Moq; using Testably.Abstractions.Testing; diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryFinderTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryFinderTest.cs index 844af8c9..7e02c385 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryFinderTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryFinderTest.cs @@ -1,7 +1,9 @@ using System.IO.Abstractions; +using AET.SteamAbstraction.Library; using Microsoft.Extensions.DependencyInjection; using Moq; using Testably.Abstractions.Testing; +using Xunit; namespace AET.SteamAbstraction.Test; @@ -17,7 +19,7 @@ public SteamLibraryFinderTest() var sc = new ServiceCollection(); _fileSystem = new MockFileSystem(); sc.AddSingleton(_fileSystem); - sc.AddSingleton(sp => new SteamRegistry(sp)); + sc.AddSingleton(sp => new WindowsSteamRegistry(sp)); _reader = new Mock(); sc.AddTransient(_ => _reader.Object); _registry = new Mock(); diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryTest.cs index 7d8a9a72..45ce75ac 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryTest.cs @@ -1,5 +1,6 @@ using System.Collections; using System.IO.Abstractions; +using AET.SteamAbstraction.Library; using Microsoft.Extensions.DependencyInjection; using Moq; using PG.TestingUtilities; diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamVdfReaderTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamVdfReaderTest.cs index 09ddf0f6..05d68bdd 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamVdfReaderTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamVdfReaderTest.cs @@ -1,4 +1,5 @@ using System.IO.Abstractions; +using AET.SteamAbstraction.Library; using Microsoft.Extensions.DependencyInjection; using Moq; using Testably.Abstractions.Testing; diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs index 969dd2d7..a7ed5cd8 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs @@ -56,7 +56,7 @@ namespace AET.SteamAbstraction.Test; // [Fact] // public void TestInstalled() // { -// _steamRegistry.SetupSequence(r => r.ExeFile) +// _steamRegistry.SetupSequence(r => r.ExecutableFile) // .Returns((IFileInfo?)null) // .Returns(() => _fileSystem.FileInfo.New("steam.exe")) // .Returns(() => _fileSystem.FileInfo.New("steam.exe")); @@ -127,7 +127,7 @@ namespace AET.SteamAbstraction.Test; // private void SetupInstalledRegistry() // { // _fileSystem.Initialize().WithFile("steam.exe"); -// _steamRegistry.Setup(r => r.ExeFile).Returns(_fileSystem.FileInfo.New("steam.exe")); +// _steamRegistry.Setup(r => r.ExecutableFile).Returns(_fileSystem.FileInfo.New("steam.exe")); // } // private static string WantsNotOffline() diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj.DotSettings b/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj.DotSettings index 92922eaf..c7099e49 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj.DotSettings +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj.DotSettings @@ -1,4 +1,6 @@  - True - True + False + False + True + True True \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/ISteamAppManifestReader.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/ISteamAppManifestReader.cs index 818e88ea..4b506e05 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/ISteamAppManifestReader.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/ISteamAppManifestReader.cs @@ -1,4 +1,5 @@ using System.IO.Abstractions; +using AET.SteamAbstraction.Library; namespace AET.SteamAbstraction; diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamAppManifest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamAppManifest.cs index 8ff840be..a6af8ccc 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamAppManifest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamAppManifest.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO.Abstractions; +using AET.SteamAbstraction.Library; using AnakinRaW.CommonUtilities; namespace AET.SteamAbstraction; diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamGameFinder.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamGameFinder.cs index ff1999f1..11ddddac 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamGameFinder.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamGameFinder.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using AET.SteamAbstraction.Library; using Microsoft.Extensions.DependencyInjection; namespace AET.SteamAbstraction; diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamRegistry.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamRegistry.cs index 3b29af56..086ef3ae 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamRegistry.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamRegistry.cs @@ -28,7 +28,7 @@ public interface ISteamRegistry : IDisposable /// /// The executable of the Steam client. /// - IFileInfo? ExeFile { get; } + IFileInfo? ExecutableFile { get; } /// /// The installation directory of the Steam client diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamWrapper.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamWrapper.cs index 1e525f58..86853a4e 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamWrapper.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamWrapper.cs @@ -1,4 +1,5 @@ -using System.Diagnostics.CodeAnalysis; +using System; +using System.Diagnostics.CodeAnalysis; using System.Threading; using System.Threading.Tasks; #if NET @@ -10,7 +11,7 @@ namespace AET.SteamAbstraction; /// /// .NET Wrapper to interact with the Steam Client /// -public interface ISteamWrapper +public interface ISteamWrapper : IDisposable { /// /// Returns is Steam is installed on this machine; otherwise. diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamWrapperFactory.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamWrapperFactory.cs index 47b7073a..15d1b99c 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamWrapperFactory.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamWrapperFactory.cs @@ -1,8 +1,6 @@ -using System; - -namespace AET.SteamAbstraction; +namespace AET.SteamAbstraction; internal interface ISteamWrapperFactory { - ISteamWrapper CreateWrapper(IServiceProvider serviceProvider); + ISteamWrapper CreateWrapper(); } \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ILibraryConfigReader.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ILibraryConfigReader.cs index d1314f6d..d3a3c6f5 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ILibraryConfigReader.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ILibraryConfigReader.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.IO.Abstractions; -namespace AET.SteamAbstraction; +namespace AET.SteamAbstraction.Library; internal interface ILibraryConfigReader { diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ISteamLibrary.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ISteamLibrary.cs index c9f24e32..c4babad3 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ISteamLibrary.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ISteamLibrary.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.IO.Abstractions; -namespace AET.SteamAbstraction; +namespace AET.SteamAbstraction.Library; /// /// Represents a Steam Library location. diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ISteamLibraryFinder.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ISteamLibraryFinder.cs index 778d2340..db843895 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ISteamLibraryFinder.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ISteamLibraryFinder.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace AET.SteamAbstraction; +namespace AET.SteamAbstraction.Library; internal interface ISteamLibraryFinder { diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/SteamLibrary.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/SteamLibrary.cs index ad485d94..69a4bf76 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/SteamLibrary.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/SteamLibrary.cs @@ -6,7 +6,7 @@ using AnakinRaW.CommonUtilities.FileSystem.Normalization; using Microsoft.Extensions.DependencyInjection; -namespace AET.SteamAbstraction; +namespace AET.SteamAbstraction.Library; internal class SteamLibrary : ISteamLibrary { diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/SteamLibraryFinder.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/SteamLibraryFinder.cs index dc52bcb4..e062f35f 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/SteamLibraryFinder.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/SteamLibraryFinder.cs @@ -3,7 +3,7 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; -namespace AET.SteamAbstraction; +namespace AET.SteamAbstraction.Library; internal class SteamLibraryFinder : ISteamLibraryFinder { diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Linux/LinuxSteamRegistry.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Linux/LinuxSteamRegistry.cs new file mode 100644 index 00000000..dfff574e --- /dev/null +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Linux/LinuxSteamRegistry.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.IO.Abstractions; +using AnakinRaW.CommonUtilities; +using AnakinRaW.CommonUtilities.Registry; + +namespace AET.SteamAbstraction; + +internal class LinuxSteamRegistry : DisposableObject, ISteamRegistry +{ + private readonly IServiceProvider _serviceProvider; + + public LinuxSteamRegistry(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); + } + + public IRegistryKey? ActiveProcessKey { get; } + + public int? ActiveUserId { get; set; } + + public int? ProcessId { get; } + + public IFileInfo? ExecutableFile { get; } + + public IDirectoryInfo? InstallationDirectory { get; } + + public ISet? InstalledApps { get; } +} \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Wrappers/LinuxSteamWrapper.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Linux/LinuxSteamWrapper.cs similarity index 73% rename from src/AET.SteamAbstraction/AET.SteamAbstraction/Wrappers/LinuxSteamWrapper.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/Linux/LinuxSteamWrapper.cs index 3f8c6fa3..c860848f 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Wrappers/LinuxSteamWrapper.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Linux/LinuxSteamWrapper.cs @@ -4,7 +4,7 @@ namespace AET.SteamAbstraction; -internal class LinuxSteamWrapper(IServiceProvider serviceProvider) : SteamWrapper(serviceProvider) +internal class LinuxSteamWrapper(ISteamRegistry registry, IServiceProvider serviceProvider) : SteamWrapper(registry, serviceProvider) { protected override Task WaitSteamUserLoggedInAsync(CancellationToken token) { diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/WindowHandleInfo.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/WindowHandleInfo.cs index 1b1ed50a..15ba5e45 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/WindowHandleInfo.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/NativeMethods/WindowHandleInfo.cs @@ -4,15 +4,8 @@ namespace AET.SteamAbstraction.NativeMethods; -internal class WindowHandleInfo +internal class WindowHandleInfo(IntPtr handle) { - private readonly IntPtr _mainHandle; - - public WindowHandleInfo(IntPtr handle) - { - _mainHandle = handle; - } - public List GetAllChildHandles() { List childHandles = new(); @@ -23,7 +16,7 @@ public List GetAllChildHandles() try { User32.EnumWindowProc childProc = EnumWindow; - User32.EnumChildWindows(_mainHandle, childProc, pointerChildHandlesList); + User32.EnumChildWindows(handle, childProc, pointerChildHandlesList); } finally { diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamAbstractionLayer.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamAbstractionLayer.cs new file mode 100644 index 00000000..7b18af24 --- /dev/null +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamAbstractionLayer.cs @@ -0,0 +1,13 @@ +using AET.SteamAbstraction.Utilities; +using Microsoft.Extensions.DependencyInjection; + +namespace AET.SteamAbstraction; + +internal class SteamAbstractionLayer +{ + public static void InitializeServices(IServiceCollection serviceCollection) + { + serviceCollection.AddSingleton(sp => new SteamWrapperFactory(sp)); + serviceCollection.AddSingleton(sp => new ProcessHelper()); + } +} \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamVdfReader.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamVdfReader.cs index 009ff53e..56c274cc 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamVdfReader.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamVdfReader.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO.Abstractions; using System.Linq; +using AET.SteamAbstraction.Library; using AnakinRaW.CommonUtilities.FileSystem; using Gameloop.Vdf; using Gameloop.Vdf.JsonConverter; diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapper.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapper.cs index ce8be878..7f8b30d0 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapper.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapper.cs @@ -7,22 +7,24 @@ using System.Threading.Tasks; using AET.SteamAbstraction.NativeMethods; using AET.SteamAbstraction.Utilities; +using AnakinRaW.CommonUtilities; using Gameloop.Vdf; using Gameloop.Vdf.JsonConverter; using Microsoft.Extensions.DependencyInjection; namespace AET.SteamAbstraction; -internal abstract class SteamWrapper(IServiceProvider serviceProvider) : ISteamWrapper +internal abstract class SteamWrapper(ISteamRegistry registry, IServiceProvider serviceProvider) : DisposableObject, ISteamWrapper { - private readonly IProcessHelper _processHelper = serviceProvider.GetRequiredService(); - protected ISteamRegistry Registry { get; } = serviceProvider.GetRequiredService(); + protected ISteamRegistry Registry { get; } = registry ?? throw new ArgumentNullException(nameof(registry)); + protected IServiceProvider ServiceProvider { get; } = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); + protected IFileSystem FileSystem { get; } = serviceProvider.GetRequiredService(); - public bool Installed => Registry.ExeFile?.Exists ?? false; + public bool Installed => Registry.ExecutableFile?.Exists ?? false; public bool IsRunning { @@ -102,7 +104,7 @@ public void StartSteam() { StartInfo = { - FileName = Registry.ExeFile!.FullName, + FileName = Registry.ExecutableFile!.FullName, UseShellExecute = false } }; @@ -207,4 +209,10 @@ private void ThrowIfSteamNotInstalled() if (!Installed) throw new SteamException("Steam is not installed!"); } + + protected override void DisposeManagedResources() + { + Registry.Dispose(); + base.DisposeManagedResources(); + } } \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs index c9640bdc..905941db 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs @@ -3,14 +3,16 @@ namespace AET.SteamAbstraction; -internal class SteamWrapperFactory : ISteamWrapperFactory +internal class SteamWrapperFactory(IServiceProvider serviceProvider) : ISteamWrapperFactory { - public ISteamWrapper CreateWrapper(IServiceProvider serviceProvider) + public ISteamWrapper CreateWrapper() { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - return new WindowsSteamWrapper(serviceProvider); + return new WindowsSteamWrapper(new WindowsSteamRegistry(serviceProvider), serviceProvider); + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - return new LinuxSteamWrapper(serviceProvider); + return new LinuxSteamWrapper(new LinuxSteamRegistry(serviceProvider), serviceProvider); + throw new PlatformNotSupportedException($"The current platform is not supported."); } } \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamRegistry.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Windows/WindowsSteamRegistry.cs similarity index 59% rename from src/AET.SteamAbstraction/AET.SteamAbstraction/SteamRegistry.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/Windows/WindowsSteamRegistry.cs index 2b30852a..34b8021e 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamRegistry.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Windows/WindowsSteamRegistry.cs @@ -3,11 +3,12 @@ using System.IO.Abstractions; using System; using System.Linq; +using AnakinRaW.CommonUtilities; using Microsoft.Extensions.DependencyInjection; namespace AET.SteamAbstraction; -internal sealed class SteamRegistry : ISteamRegistry +internal sealed class WindowsSteamRegistry(IServiceProvider serviceProvider) : DisposableObject, ISteamRegistry { private const string SteamExeKey = "SteamExe"; private const string SteamPathKey = "SteamPath"; @@ -17,9 +18,11 @@ internal sealed class SteamRegistry : ISteamRegistry private const string SteamProcessNode = "ActiveProcess"; private const string SteamAppsNode = "Apps"; - private IRegistryKey? _registryKey; - private bool _disposed; - private readonly IFileSystem _fileSystem; + private IRegistryKey? _registryKey = serviceProvider.GetRequiredService() + .OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default) + .CreateSubKey("Software\\Valve\\Steam"); + + private readonly IFileSystem _fileSystem = serviceProvider.GetRequiredService(); public IRegistryKey? ActiveProcessKey { @@ -54,7 +57,7 @@ public int? ProcessId } } - public IFileInfo? ExeFile + public IFileInfo? ExecutableFile { get { @@ -92,52 +95,10 @@ public ISet? InstalledApps } - public SteamRegistry(IServiceProvider serviceProvider) - { - _registryKey = serviceProvider.GetRequiredService() - .OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default) - .CreateSubKey("Software\\Valve\\Steam"); - _fileSystem = serviceProvider.GetRequiredService(); - } - - - /// - ~SteamRegistry() - { - Dispose(false); - } - - /// - /// Disposed all managed resources acquired by this instance. - /// - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - /// - /// Disposed all managed resources acquired by this instance. - /// - /// if called from the destructor; otherwise. - private void Dispose(bool disposing) - { - if (disposing) - { - _registryKey?.Dispose(); - _registryKey = null; - _disposed = true; - } - } - -#if NET - [MemberNotNull(nameof(_registryKey))] -#endif - private void ThrowIfDisposed() + protected override void DisposeManagedResources() { - if (_disposed) - throw new ObjectDisposedException(ToString()); - if (_registryKey is null) - throw new Exception("registry must not be null in non-disposed state"); + base.DisposeManagedResources(); + _registryKey?.Dispose(); + _registryKey = null; } } \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Wrappers/WindowsSteamWrapper.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Windows/WindowsSteamWrapper.cs similarity index 93% rename from src/AET.SteamAbstraction/AET.SteamAbstraction/Wrappers/WindowsSteamWrapper.cs rename to src/AET.SteamAbstraction/AET.SteamAbstraction/Windows/WindowsSteamWrapper.cs index b44a46d7..e19d093e 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Wrappers/WindowsSteamWrapper.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Windows/WindowsSteamWrapper.cs @@ -6,7 +6,7 @@ namespace AET.SteamAbstraction; -internal class WindowsSteamWrapper(IServiceProvider serviceProvider) : SteamWrapper(serviceProvider) +internal class WindowsSteamWrapper(ISteamRegistry registry, IServiceProvider serviceProvider) : SteamWrapper(registry, serviceProvider) { protected override async Task WaitSteamUserLoggedInAsync(CancellationToken token) { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/PetroglyphClientsLibrary.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/PetroglyphGameClients.cs similarity index 87% rename from src/PetroGlyph.Games.EawFoc.Clients/src/PetroglyphClientsLibrary.cs rename to src/PetroGlyph.Games.EawFoc.Clients/src/PetroglyphGameClients.cs index 824e1031..79c7c0c3 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/PetroglyphClientsLibrary.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/PetroglyphGameClients.cs @@ -6,14 +6,14 @@ namespace PG.StarWarsGame.Infrastructure.Clients; /// /// Provides initialization routines for this library. /// -public class PetroglyphClientsLibrary +public class PetroglyphGameClients { /// /// Adds services provided by this library to the given /// so that the library can be used in client applications. /// /// The service collection to be filled. - public static void InitializeLibraryWithDefaultServices(IServiceCollection serviceCollection) + public static void InitializeServices(IServiceCollection serviceCollection) { serviceCollection.AddTransient(sp => new GameExecutableFileService(sp)); serviceCollection.AddTransient(_ => new GameExecutableNameBuilder()); diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCommandLineBuilderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCommandLineBuilderTest.cs index 1a83b9b7..82ed9011 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCommandLineBuilderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentCommandLineBuilderTest.cs @@ -200,7 +200,7 @@ public InvalidModArg() : base("value") } public override ArgumentKind Kind => ArgumentKind.Flag; - public override string Name { get; } + public override string Name { get; } = null!; public override string ValueToCommandLine() { throw new NotImplementedException(); @@ -220,21 +220,21 @@ public InvalidModListArg() public bool Equals(IGameArgument? other) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public ArgumentKind Kind => ArgumentKind.ModList; - public bool DebugArgument { get; } - public string Name { get; } - public object Value { get; } + public bool DebugArgument { get; } = false; + public string Name { get; } = null!; + public object Value { get; } = null!; public string ValueToCommandLine() { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public bool IsValid(out ArgumentValidityStatus reason) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } } } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValidatorTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValidatorTest.cs index e16ea5fa..01c28f35 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValidatorTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ArgumentValidatorTest.cs @@ -30,15 +30,15 @@ public static IEnumerable GetIllegalCharData() { if (i is '\f' or '\n' or '\r' or '\t' or '\v' ) continue; - yield return new[] { $"abc{(char)i}" }; + yield return [$"abc{(char)i}"]; } - yield return new[] { "abc?" }; - yield return new[] { "abc*" }; - yield return new[] { "abc:" }; - yield return new[] { "abc|" }; - yield return new[] { "abc>" }; - yield return new[] { "abc<" }; - yield return new[] { $"abc{'\"'}" }; + yield return ["abc?"]; + yield return ["abc*"]; + yield return ["abc:"]; + yield return ["abc|"]; + yield return ["abc>"]; + yield return ["abc<"]; + yield return [$"abc{'\"'}"]; } [Theory] @@ -53,11 +53,11 @@ public void TestHasIllegalChar(string value) public static IEnumerable GetEmptyDataValues() { - yield return new object[] { new StringArg(""), true }; - yield return new object[] { new StringArg(string.Empty), true }; - yield return new object[] { new StringArg("\0"), false }; - yield return new object[] { new StringArg("abc"), false }; - yield return new object[] { new StringArg(" "), false }; + yield return [new StringArg(""), true]; + yield return [new StringArg(string.Empty), true]; + yield return [new StringArg("\0"), false]; + yield return [new StringArg("abc"), false]; + yield return [new StringArg(" "), false]; } [Theory] @@ -79,19 +79,19 @@ public void TestHasInvalidName() public static IEnumerable GetSpaceTestData() { - yield return new object[] { new StringArg(""), false }; - yield return new object[] { new StringArg("testvalue"), false }; - yield return new object[] { new StringArg(" "), true}; - yield return new object[] { new StringArg(" "), true }; - yield return new object[] { new StringArg("test\tvalue"), true }; - yield return new object[] { new StringArg("test\fvalue"), true }; - yield return new object[] { new StringArg("test\rvalue"), true }; - yield return new object[] { new StringArg("test\nvalue"), true }; - yield return new object[] { new StringArg("test\vvalue"), true }; - yield return new object[] { new StringArg("\0"), false }; - yield return new object[] { new StringArg("test value"), true }; - yield return new object[] { new StringArg("testvalue "), true }; - yield return new object[] { new StringArg("testvalue "), true }; + yield return [new StringArg(""), false]; + yield return [new StringArg("testvalue"), false]; + yield return [new StringArg(" "), true]; + yield return [new StringArg(" "), true]; + yield return [new StringArg("test\tvalue"), true]; + yield return [new StringArg("test\fvalue"), true]; + yield return [new StringArg("test\rvalue"), true]; + yield return [new StringArg("test\nvalue"), true]; + yield return [new StringArg("test\vvalue"), true]; + yield return [new StringArg("\0"), false]; + yield return [new StringArg("test value"), true]; + yield return [new StringArg("testvalue "), true]; + yield return [new StringArg("testvalue "), true]; } [Theory] @@ -146,12 +146,12 @@ public bool Equals(IGameArgument? other) } public ArgumentKind Kind => ArgumentKind.ModList; - public bool DebugArgument { get; } + public bool DebugArgument { get; } = false; public string Name => ArgumentNameCatalog.ModListArg; public object Value => "Some Value"; public string ValueToCommandLine() { - return Value.ToString(); + return Value.ToString()!; } public bool IsValid(out ArgumentValidityStatus reason) diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/GameArgumentTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/GameArgumentTest.cs index de88974a..a952bb4a 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/GameArgumentTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/GameArgumentTest.cs @@ -1,4 +1,5 @@ -using Moq; +using System; +using Moq; using PG.StarWarsGame.Infrastructure.Clients.Arguments; using Xunit; @@ -47,30 +48,24 @@ public void TestArgInvalidCustom() } - private class Argument : GameArgument + private class Argument(string value, bool isDebug = false) : GameArgument(value, isDebug) { - public Argument(string value, bool isDebug = false) : base(value, isDebug) - { - } - - public override ArgumentKind Kind { get; } - public override string Name { get; } + public override ArgumentKind Kind => ArgumentKind.Flag; + public override string Name => null!; protected override bool IsDataValid() { - if (Value == "valid") - return true; - return false; + return Value == "valid"; } public override string ValueToCommandLine() { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public override bool Equals(IGameArgument? other) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } } } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListTest.cs index 1b08b77d..4ffad082 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Arguments/ModArgumentListTest.cs @@ -56,9 +56,9 @@ public bool Equals(IGameArgument? other) } public ArgumentKind Kind => ArgumentKind.Flag; - public bool DebugArgument { get; } - public string Name { get; } - public string Value { get; } + public bool DebugArgument => false; + public string Name => null!; + public string Value => null!; object IGameArgument.Value => Value; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/DebugableClientBaseTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/DebugableClientBaseTest.cs index 280744cc..691327e4 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/DebugableClientBaseTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/DebugableClientBaseTest.cs @@ -34,7 +34,7 @@ public void TestIsDebugAvailable() var fs = new MockFileSystem(); _exeService.Setup(s => s.GetExecutableForGame(It.IsAny(), It.IsAny())) - .Returns((IFileInfo)null); + .Returns((IFileInfo)null!); Assert.False(_service.IsDebugAvailable(game.Object)); _exeService.Setup(s => s.GetExecutableForGame(It.IsAny(), It.IsAny())) .Returns(fs.FileInfo.New("test.exe")); diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/DefaultGameProcessLauncherTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/DefaultGameProcessLauncherTest.cs index c9e2af67..124cd17c 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/DefaultGameProcessLauncherTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/DefaultGameProcessLauncherTest.cs @@ -27,7 +27,7 @@ public void TestWrapsException_Throws() { var game = new Mock(); var process = new GameProcessInfo(game.Object, GameBuildType.Release, ArgumentCollection.Empty); - Assert.Throws(() => _service.StartGameProcess(null, process)); + Assert.Throws(() => _service.StartGameProcess(null!, process)); } [Fact] diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/GameProcessTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/GameProcessTest.cs index 647c7f43..9e43d44f 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/GameProcessTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Processes/GameProcessTest.cs @@ -28,9 +28,8 @@ public async Task TestOnExit() }; p.Kill(); var cts = new CancellationTokenSource(5000); - using (cts.Token.Register(() => tcs.TrySetCanceled(cts.Token))) - await tcs.Task.ConfigureAwait(false); - Assert.True(tcs.Task.Result); + using (cts.Token.Register(() => tcs.TrySetCanceled(cts.Token))) + Assert.True(await tcs.Task); } [Fact] @@ -47,7 +46,6 @@ public async Task TestAlreadyExited() { tcs.SetResult(true); }; - await tcs.Task.ConfigureAwait(false); - Assert.True(tcs.Task.Result); + Assert.True(await tcs.Task); } } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamGameLanguageFinderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamGameLanguageFinderTest.cs index ceb038d4..0008e6c3 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamGameLanguageFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamGameLanguageFinderTest.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using AET.SteamAbstraction; +using AET.SteamAbstraction.Library; using EawModinfo.Model; using EawModinfo.Spec; using Microsoft.Extensions.DependencyInjection; @@ -45,7 +46,7 @@ public void TestGameNotInstalled_Throws() { var game = new Mock(); game.Setup(g => g.Platform).Returns(GamePlatform.SteamGold); - _steam.Setup(s => s.IsGameInstalled(32470u, out It.Ref.IsAny)).Returns(false); + _steam.Setup(s => s.IsGameInstalled(32470u, out It.Ref.IsAny!)).Returns(false); Assert.Throws(() => _service.FindInstalledLanguages(game.Object)); } diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamPetroglyphStarWarsGameDetectorTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamPetroglyphStarWarsGameDetectorTest.cs index 46080d32..ec7bab84 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamPetroglyphStarWarsGameDetectorTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamPetroglyphStarWarsGameDetectorTest.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO.Abstractions; using AET.SteamAbstraction; +using AET.SteamAbstraction.Library; using Microsoft.Extensions.DependencyInjection; using Moq; using PG.StarWarsGame.Infrastructure.Clients.Steam; @@ -39,7 +40,7 @@ public SteamPetroglyphStarWarsGameDetectorTest() [Fact] public void TestInvalidCtor_Throws() { - Assert.Throws(() => new SteamPetroglyphStarWarsGameDetector(null)); + Assert.Throws(() => new SteamPetroglyphStarWarsGameDetector(null!)); } [Fact] diff --git a/src/PetroGlyph.Games.EawFoc/src/PetroglyphGameInfrastructureLibrary.cs b/src/PetroGlyph.Games.EawFoc/src/PetroglyphGameInfrastructure.cs similarity index 85% rename from src/PetroGlyph.Games.EawFoc/src/PetroglyphGameInfrastructureLibrary.cs rename to src/PetroGlyph.Games.EawFoc/src/PetroglyphGameInfrastructure.cs index 05d41b09..ff6bd28a 100644 --- a/src/PetroGlyph.Games.EawFoc/src/PetroglyphGameInfrastructureLibrary.cs +++ b/src/PetroGlyph.Games.EawFoc/src/PetroglyphGameInfrastructure.cs @@ -8,14 +8,14 @@ namespace PG.StarWarsGame.Infrastructure; /// /// Provides initialization routines for this library. /// -public static class PetroglyphGameInfrastructureLibrary +public static class PetroglyphGameInfrastructure { /// /// Adds services provided by this library to the given /// so that the library can be used in client applications. /// /// The service collection to be filled. - public static void InitializeLibraryWithDefaultServices(IServiceCollection serviceCollection) + public static void InitializeServices(IServiceCollection serviceCollection) { serviceCollection.AddTransient(_ => new GameRegistryFactory()); serviceCollection.AddTransient(sp => new ModIdentifierBuilder(sp)); From 1832b3d4970a252eeb1302543f4ddab1e04f4a0a Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Tue, 19 Mar 2024 18:29:03 +0100 Subject: [PATCH 25/41] fix build --- sample/SampleApplication/Program.cs | 2 -- .../test/ModServices/ModDependencyResolverIntegrationTest.cs | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/sample/SampleApplication/Program.cs b/sample/SampleApplication/Program.cs index a08c10d5..4a4f68a0 100644 --- a/sample/SampleApplication/Program.cs +++ b/sample/SampleApplication/Program.cs @@ -65,8 +65,6 @@ IGame FindGame() IServiceProvider SetupApplication() { var sc = new ServiceCollection(); - PetroglyphGameInfrastructureLibrary.InitializeLibraryWithDefaultServices(sc); - PetroglyphClientsLibrary.InitializeLibraryWithDefaultServices(sc); sc.AddSingleton(WindowsRegistry.Default); sc.AddTransient(sp => new SteamPetroglyphStarWarsGameDetector(sp)); diff --git a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverIntegrationTest.cs b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverIntegrationTest.cs index e2c8a3c4..76af9ee4 100644 --- a/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverIntegrationTest.cs +++ b/src/PetroGlyph.Games.EawFoc/test/ModServices/ModDependencyResolverIntegrationTest.cs @@ -24,9 +24,9 @@ public ModDependencyResolverIntegrationTest() { _fileSystem = new MockFileSystem(); var sc = new ServiceCollection(); + PetroglyphGameInfrastructure.InitializeServices(sc); sc.AddSingleton(_fileSystem); sc.AddSingleton(new ModDependencyGraphBuilder()); - PetroglyphGameInfrastructureLibrary.InitializeLibraryWithDefaultServices(sc); _serviceProvider = sc.BuildServiceProvider(); _game = SetupGame(_fileSystem, _serviceProvider); } From fc0a4fe3629e3890e7cca61d2e2cc0ca122368fa Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Tue, 19 Mar 2024 18:30:17 +0100 Subject: [PATCH 26/41] try aet enable tests --- PetroGlyphGameInfrastructure.sln | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PetroGlyphGameInfrastructure.sln b/PetroGlyphGameInfrastructure.sln index d6f593af..bb4b8677 100644 --- a/PetroGlyphGameInfrastructure.sln +++ b/PetroGlyphGameInfrastructure.sln @@ -58,7 +58,9 @@ Global {24CA9F24-E6DC-4908-B586-E7C14515628C}.Release|Any CPU.ActiveCfg = Release|Any CPU {24CA9F24-E6DC-4908-B586-E7C14515628C}.Release|Any CPU.Build.0 = Release|Any CPU {38FE318C-F775-4318-859C-DCAB3C6FCD71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {38FE318C-F775-4318-859C-DCAB3C6FCD71}.Debug|Any CPU.Build.0 = Debug|Any CPU {38FE318C-F775-4318-859C-DCAB3C6FCD71}.Release|Any CPU.ActiveCfg = Release|Any CPU + {38FE318C-F775-4318-859C-DCAB3C6FCD71}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 61b0eaff85b2bbbd91f3eca9cd981baac0bdaf67 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Tue, 19 Mar 2024 18:31:39 +0100 Subject: [PATCH 27/41] fix build --- .../AET.SteamAbstraction.Test/SteamLibraryTest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryTest.cs index 45ce75ac..00f5f701 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryTest.cs @@ -5,6 +5,7 @@ using Moq; using PG.TestingUtilities; using Testably.Abstractions.Testing; +using Xunit; namespace AET.SteamAbstraction.Test; From 0122de73ae7ada61e3a26d9dd1be7efa2188bd0b Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Tue, 19 Mar 2024 18:33:27 +0100 Subject: [PATCH 28/41] really fix build --- .../AET.SteamAbstraction.Test/SteamGameFinderTest.cs | 1 + .../AET.SteamAbstraction.Test/SteamVdfReaderTest.cs | 1 + .../AET.SteamAbstraction.Test/SteamWrapperIntegrationTest.cs | 1 + 3 files changed, 3 insertions(+) diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamGameFinderTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamGameFinderTest.cs index 25f4411e..64ab17ef 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamGameFinderTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamGameFinderTest.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.DependencyInjection; using Moq; using Testably.Abstractions.Testing; +using Xunit; namespace AET.SteamAbstraction.Test; diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamVdfReaderTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamVdfReaderTest.cs index 05d68bdd..221fe2d5 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamVdfReaderTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamVdfReaderTest.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.DependencyInjection; using Moq; using Testably.Abstractions.Testing; +using Xunit; namespace AET.SteamAbstraction.Test; diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperIntegrationTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperIntegrationTest.cs index dbbc7ea7..4d0a570d 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperIntegrationTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperIntegrationTest.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.DependencyInjection; +using Xunit; namespace AET.SteamAbstraction.Test; From d0867556554e5225356ad43a34dd066b901bfa3e Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Tue, 19 Mar 2024 18:36:01 +0100 Subject: [PATCH 29/41] verbose output --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 83e26e38..3e34baf6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,4 +26,4 @@ jobs: dotnet-version: '8.0.x' - name: Build & Test in Release Mode - run: dotnet test --configuration Release --logger "GitHubActions" \ No newline at end of file + run: dotnet test --configuration Release --logger "GitHubActions" -v:detailed \ No newline at end of file From 87e7962eec95c8b67292bd96c5d20e44e5664c9c Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Tue, 19 Mar 2024 18:40:05 +0100 Subject: [PATCH 30/41] change csproj --- .github/workflows/test.yml | 2 +- .../AET.SteamAbstraction.Test.csproj | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3e34baf6..83e26e38 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,4 +26,4 @@ jobs: dotnet-version: '8.0.x' - name: Build & Test in Release Mode - run: dotnet test --configuration Release --logger "GitHubActions" -v:detailed \ No newline at end of file + run: dotnet test --configuration Release --logger "GitHubActions" \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj index 3a891b39..ab2489dd 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj @@ -1,13 +1,14 @@  + + AET.SteamAbstraction.Test + + net8.0 $(TargetFrameworks);net48 - enable - enable - false - true + true From 10dc7bd4b4edfbeb7329847ab4a67a95c83d8660 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Tue, 19 Mar 2024 19:01:09 +0100 Subject: [PATCH 31/41] maybe this time... --- .../AET.SteamAbstraction.Test.csproj | 8 +++- .../SteamGameFinderTest.cs | 3 +- .../SteamLibraryFinderTest.cs | 4 +- .../SteamLibraryTest.cs | 4 +- .../SteamVdfReaderTest.cs | 1 + .../SteamWrapperIntegrationTest.cs | 4 +- .../AET - Backup.SteamAbstraction.csproj | 40 ------------------- 7 files changed, 18 insertions(+), 46 deletions(-) delete mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/AET - Backup.SteamAbstraction.csproj diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj index ab2489dd..966be0c7 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj @@ -12,19 +12,23 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive + + runtime; build; native; contentfiles; analyzers; buildtransitive all + + runtime; build; native; contentfiles; analyzers; buildtransitive + all - diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamGameFinderTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamGameFinderTest.cs index 64ab17ef..b84fd9e5 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamGameFinderTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamGameFinderTest.cs @@ -1,4 +1,5 @@ -using System.IO.Abstractions; +using System.Collections.Generic; +using System.IO.Abstractions; using AET.SteamAbstraction.Library; using Microsoft.Extensions.DependencyInjection; using Moq; diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryFinderTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryFinderTest.cs index 7e02c385..1d47bb8c 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryFinderTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryFinderTest.cs @@ -1,4 +1,6 @@ -using System.IO.Abstractions; +using System.Collections.Generic; +using System.IO.Abstractions; +using System.Linq; using AET.SteamAbstraction.Library; using Microsoft.Extensions.DependencyInjection; using Moq; diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryTest.cs index 00f5f701..43508bce 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryTest.cs @@ -1,4 +1,6 @@ -using System.Collections; +using System; +using System.Collections; +using System.Collections.Generic; using System.IO.Abstractions; using AET.SteamAbstraction.Library; using Microsoft.Extensions.DependencyInjection; diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamVdfReaderTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamVdfReaderTest.cs index 221fe2d5..c51cd5aa 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamVdfReaderTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamVdfReaderTest.cs @@ -1,4 +1,5 @@ using System.IO.Abstractions; +using System.Linq; using AET.SteamAbstraction.Library; using Microsoft.Extensions.DependencyInjection; using Moq; diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperIntegrationTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperIntegrationTest.cs index 4d0a570d..a209be11 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperIntegrationTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperIntegrationTest.cs @@ -1,4 +1,6 @@ -using Microsoft.Extensions.DependencyInjection; +using System; +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; using Xunit; namespace AET.SteamAbstraction.Test; diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/AET - Backup.SteamAbstraction.csproj b/src/AET.SteamAbstraction/AET.SteamAbstraction/AET - Backup.SteamAbstraction.csproj deleted file mode 100644 index 87056389..00000000 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/AET - Backup.SteamAbstraction.csproj +++ /dev/null @@ -1,40 +0,0 @@ - - - netstandard2.0 - - - AET.SteamAbstraction - .NET abstraction layer for Valve Steam. - AlamoEngineTools.SteamAbstraction - alamo,petroglyph,glyphx - en - - - true - true - true - - - true - snupkg - true - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - From 2adb765a16a8369b8e110c4720c4a93c9d734d18 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Tue, 19 Mar 2024 20:17:54 +0100 Subject: [PATCH 32/41] update tests --- .../SteamGameFinderTest.cs | 1 + .../SteamLibraryFinderTest.cs | 11 +- .../SteamLibraryTest.cs | 1 + .../SteamRegistryFactoryTest.cs | 41 +++ .../SteamVdfReaderTest.cs | 1 + .../SteamWrapperFactoryTest.cs | 40 +++ .../SteamWrapperIntegrationTest.cs | 19 +- .../SteamWrapperTest.cs | 327 +++++++++++------- .../Games/ISteamAppManifestReader.cs | 2 +- .../Games/ISteamGameLocationFinder.cs | 6 +- .../Games/SteamAppManifest.cs | 2 +- .../Games/SteamAppState.cs | 2 +- .../Games/SteamGameFinder.cs | 11 +- .../AET.SteamAbstraction/ISteamRegistry.cs | 2 +- .../ISteamRegistryFactory.cs | 6 + .../AET.SteamAbstraction/ISteamWrapper.cs | 13 + .../Library/ISteamLibrary.cs | 1 + .../Library/ISteamLibraryFinder.cs | 5 +- .../Library/SteamLibrary.cs | 1 + .../Library/SteamLibraryFinder.cs | 25 +- .../SteamAbstractionLayer.cs | 11 +- .../AET.SteamAbstraction/SteamException.cs | 9 + .../SteamRegistryFactory.cs | 18 + .../AET.SteamAbstraction/SteamVdfReader.cs | 1 + .../AET.SteamAbstraction/SteamWrapper.cs | 13 +- .../SteamWrapperFactory.cs | 8 +- .../SteamPetroglyphStarWarsGameDetector.cs | 1 + .../test/Steam/SteamGameLanguageFinderTest.cs | 1 + ...SteamPetroglyphStarWarsGameDetectorTest.cs | 1 + 29 files changed, 406 insertions(+), 174 deletions(-) create mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamRegistryFactoryTest.cs create mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperFactoryTest.cs create mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamRegistryFactory.cs create mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction/SteamRegistryFactory.cs diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamGameFinderTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamGameFinderTest.cs index b84fd9e5..e27a4319 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamGameFinderTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamGameFinderTest.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.IO.Abstractions; +using AET.SteamAbstraction.Games; using AET.SteamAbstraction.Library; using Microsoft.Extensions.DependencyInjection; using Moq; diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryFinderTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryFinderTest.cs index 1d47bb8c..0524ec7a 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryFinderTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryFinderTest.cs @@ -21,11 +21,16 @@ public SteamLibraryFinderTest() var sc = new ServiceCollection(); _fileSystem = new MockFileSystem(); sc.AddSingleton(_fileSystem); - sc.AddSingleton(sp => new WindowsSteamRegistry(sp)); + + _registry = new Mock(); + + var regFactory = new Mock(); + regFactory.Setup(f => f.CreateRegistry()).Returns(_registry.Object); + + sc.AddSingleton(sp => regFactory.Object); _reader = new Mock(); sc.AddTransient(_ => _reader.Object); - _registry = new Mock(); - sc.AddTransient(_ => _registry.Object); + _service = new SteamLibraryFinder(sc.BuildServiceProvider()); } diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryTest.cs index 43508bce..c545619a 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamLibraryTest.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.IO.Abstractions; +using AET.SteamAbstraction.Games; using AET.SteamAbstraction.Library; using Microsoft.Extensions.DependencyInjection; using Moq; diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamRegistryFactoryTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamRegistryFactoryTest.cs new file mode 100644 index 00000000..2e57e57e --- /dev/null +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamRegistryFactoryTest.cs @@ -0,0 +1,41 @@ +using System; +using System.IO.Abstractions; +using System.Runtime.InteropServices; +using AET.SteamAbstraction.Utilities; +using AnakinRaW.CommonUtilities.Registry; +using Microsoft.Extensions.DependencyInjection; +using Moq; +using Testably.Abstractions.Testing; +using Xunit; + +namespace AET.SteamAbstraction.Test; + +public class SteamRegistryFactoryTest +{ + [Fact] + public void Test_CreateWrapper() + { + var reg = new Mock(); + reg.Setup(r => r.OpenBaseKey(It.IsAny(), It.IsAny())) + .Returns(new Mock().Object); + + var sc = new ServiceCollection(); + sc.AddSingleton(_ => reg.Object); + sc.AddSingleton(new Mock().Object); + sc.AddSingleton(new MockFileSystem()); + var factory = new SteamRegistryFactory(sc.BuildServiceProvider()); + + var registry = factory.CreateRegistry(); + + Type? expectedType = null; + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + expectedType = typeof(WindowsSteamRegistry); + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + expectedType = typeof(LinuxSteamRegistry); + + if (expectedType is null) + Assert.Fail("Platform was not supported"); + + Assert.IsType(expectedType, registry); + } +} \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamVdfReaderTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamVdfReaderTest.cs index c51cd5aa..7d77d830 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamVdfReaderTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamVdfReaderTest.cs @@ -1,5 +1,6 @@ using System.IO.Abstractions; using System.Linq; +using AET.SteamAbstraction.Games; using AET.SteamAbstraction.Library; using Microsoft.Extensions.DependencyInjection; using Moq; diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperFactoryTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperFactoryTest.cs new file mode 100644 index 00000000..3ed72a84 --- /dev/null +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperFactoryTest.cs @@ -0,0 +1,40 @@ +using System; +using System.IO.Abstractions; +using System.Resources; +using System.Runtime.InteropServices; +using AET.SteamAbstraction.Utilities; +using Microsoft.Extensions.DependencyInjection; +using Moq; +using Testably.Abstractions.Testing; +using Xunit; + +namespace AET.SteamAbstraction.Test; + +public class SteamWrapperFactoryTest +{ + [Fact] + public void Test_CreateWrapper() + { + var regFactory = new Mock(); + regFactory.Setup(f => f.CreateRegistry()).Returns(new Mock().Object); + + var sc = new ServiceCollection(); + sc.AddSingleton(_ => regFactory.Object); + sc.AddSingleton(new Mock().Object); + sc.AddSingleton(new MockFileSystem()); + var factory = new SteamWrapperFactory(sc.BuildServiceProvider()); + + var wrapper = factory.CreateWrapper(); + + Type? expectedType = null; + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + expectedType = typeof(WindowsSteamWrapper); + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + expectedType = typeof(LinuxSteamWrapper); + + if (expectedType is null) + Assert.Fail("Platform was not supported"); + + Assert.IsType(expectedType, wrapper); + } +} \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperIntegrationTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperIntegrationTest.cs index a209be11..45e91d97 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperIntegrationTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperIntegrationTest.cs @@ -1,5 +1,8 @@ -using System; +using System.IO.Abstractions; +using System.Runtime.InteropServices; using System.Threading.Tasks; +using AnakinRaW.CommonUtilities.Registry; +using AnakinRaW.CommonUtilities.Registry.Windows; using Microsoft.Extensions.DependencyInjection; using Xunit; @@ -7,15 +10,21 @@ namespace AET.SteamAbstraction.Test; public class SteamWrapperIntegrationTest { - private readonly SteamWrapper _service; - private readonly IServiceProvider _sp; + private readonly ISteamWrapper _service; public SteamWrapperIntegrationTest() { var sc = new ServiceCollection(); + // Use actual FS + sc.AddSingleton(new FileSystem()); + SteamAbstractionLayer.InitializeServices(sc); - _sp = sc.BuildServiceProvider(); - _service = _sp.GetRequiredService() as SteamWrapper ?? throw new InvalidOperationException(); + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + sc.AddSingleton(new WindowsRegistry()); + else + sc.AddSingleton(new InMemoryRegistry()); + + _service = sc.BuildServiceProvider().GetRequiredService().CreateWrapper(); } //[Fact] diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs index a7ed5cd8..c8f01558 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs @@ -1,142 +1,201 @@ -using System.Diagnostics; +using System; +using System.Collections.Generic; +using System.Diagnostics; using System.IO.Abstractions; +using AET.SteamAbstraction.Games; +using AET.SteamAbstraction.Library; using AET.SteamAbstraction.Utilities; using Microsoft.Extensions.DependencyInjection; using Moq; using Testably.Abstractions.Testing; +using Xunit; namespace AET.SteamAbstraction.Test; -//public class SteamWrapperTest -//{ -// private readonly SteamWrapper _service; -// private readonly Mock _steamRegistry; -// private readonly MockFileSystem _fileSystem; -// private readonly Mock _processHelper; -// private readonly Mock _gameFinder; - -// public SteamWrapperTest() -// { -// var sc = new ServiceCollection(); -// _steamRegistry = new Mock(); -// _fileSystem = new MockFileSystem(); -// _processHelper = new Mock(); -// _gameFinder = new Mock(); -// sc.AddTransient(_ => _steamRegistry.Object); -// sc.AddTransient(_ => _processHelper.Object); -// sc.AddTransient(_ => _gameFinder.Object); -// sc.AddTransient(_ => _fileSystem); -// _service = new SteamWrapper(sc.BuildServiceProvider()); -// } - -// [Fact] -// public void TestInvalidArgs_Throws() -// { -// Assert.Throws(() => new SteamWrapper(null)); -// } - -// [Fact] -// public void TestRunning() -// { -// _processHelper.SetupSequence(h => h.GetProcessByPid(It.IsAny())) -// .Returns((Process)null) -// .Returns(Process.GetCurrentProcess); -// _steamRegistry.SetupSequence(r => r.ProcessId) -// .Returns((int?)null) -// .Returns(0) -// .Returns(123) -// .Returns(123); - -// Assert.False(_service.IsRunning); -// Assert.False(_service.IsRunning); -// Assert.False(_service.IsRunning); -// Assert.True(_service.IsRunning); -// } - -// [Fact] -// public void TestInstalled() -// { -// _steamRegistry.SetupSequence(r => r.ExecutableFile) -// .Returns((IFileInfo?)null) -// .Returns(() => _fileSystem.FileInfo.New("steam.exe")) -// .Returns(() => _fileSystem.FileInfo.New("steam.exe")); - -// Assert.False(_service.Installed); -// Assert.False(_service.Installed); - -// _fileSystem.Initialize().WithFile("steam.exe"); - -// Assert.True(_service.Installed); -// } - -// [Fact] -// public void TestUserLoggedIn() -// { -// _steamRegistry.SetupSequence(r => r.ActiveUserId) -// .Returns((int?)null) -// .Returns(0) -// .Returns(123); - -// Assert.False(_service.IsUserLoggedIn); -// Assert.False(_service.IsUserLoggedIn); -// Assert.True(_service.IsUserLoggedIn); -// } - -// [Fact] -// public void TestGameInstalled() -// { -// _fileSystem.Initialize(); - -// SetupInstalledRegistry(); -// var mFile = _fileSystem.FileInfo.New("manifest.acf"); - -// var expectedApp = new SteamAppManifest(new Mock().Object, mFile, 1234, "name", -// _fileSystem.DirectoryInfo.New("Game"), SteamAppState.StateFullyInstalled, -// new HashSet()); - -// _gameFinder.SetupSequence(f => f.FindGame(It.IsAny())) -// .Returns((SteamAppManifest?)null) -// .Returns(expectedApp); -// _steamRegistry.Setup(r => r.InstalledApps).Returns(new HashSet { 1, 2, 3 }); -// _steamRegistry.Setup(r => r.InstallationDirectory).Returns(_fileSystem.DirectoryInfo.New("Steam")); - -// Assert.False(_service.IsGameInstalled(0, out _)); -// Assert.False(_service.IsGameInstalled(1, out _)); -// Assert.True(_service.IsGameInstalled(1, out var app)); -// } - -// [Fact] -// public void TestWantsOffline() -// { -// SetupInstalledRegistry(); - -// _steamRegistry.Setup(r => r.InstallationDirectory).Returns(_fileSystem.DirectoryInfo.New(".")); - -// Assert.Null((object?)_service.WantOfflineMode); - -// _fileSystem.Initialize().WithFile("config/loginusers.vdf"); -// Assert.Null((object?)_service.WantOfflineMode); - -// _fileSystem.File.WriteAllText("config/loginusers.vdf", WantsNotOffline()); -// Assert.False(_service.WantOfflineMode); - -// _fileSystem.File.WriteAllText("config/loginusers.vdf", WantsOffline()); -// Assert.True(_service.WantOfflineMode); -// } - -// private void SetupInstalledRegistry() -// { -// _fileSystem.Initialize().WithFile("steam.exe"); -// _steamRegistry.Setup(r => r.ExecutableFile).Returns(_fileSystem.FileInfo.New("steam.exe")); -// } - -// private static string WantsNotOffline() -// { -// return "\"users\"\n{\n\t\"123\"\n\t{\n\t\t\"AccountName\"\t\t\"user_name\"\n\t\t\"PersonaName\"\t\t\"User Name\"\n\t\t\"RememberPassword\"\t\t\"1\"\n\t\t\"MostRecent\"\t\t\"1\"\n\t\t\"Timestamp\"\t\t\"0000000000\"\n\t\t\"WantsOfflineMode\"\t\t\"0\"\n\t\t\"SkipOfflineModeWarning\"\t\t\"0\"\n\t}\n}"; -// } - -// private static string WantsOffline() -// { -// return "\"users\"\n{\n\t\"123\"\n\t{\n\t\t\"AccountName\"\t\t\"user_name\"\n\t\t\"PersonaName\"\t\t\"User Name\"\n\t\t\"RememberPassword\"\t\t\"1\"\n\t\t\"MostRecent\"\t\t\"1\"\n\t\t\"Timestamp\"\t\t\"0000000000\"\n\t\t\"WantsOfflineMode\"\t\t\"1\"\n\t\t\"SkipOfflineModeWarning\"\t\t\"0\"\n\t}\n}"; -// } -//} \ No newline at end of file +public class SteamWrapperTest +{ + private readonly IServiceProvider _serviceProvider; + private readonly Mock _steamRegistry; + private readonly MockFileSystem _fileSystem; + private readonly Mock _processHelper; + private readonly Mock _gameFinder; + + public SteamWrapperTest() + { + var sc = new ServiceCollection(); + _steamRegistry = new Mock(); + _fileSystem = new MockFileSystem(); + _processHelper = new Mock(); + _gameFinder = new Mock(); + sc.AddTransient(_ => _steamRegistry.Object); + sc.AddTransient(_ => _processHelper.Object); + sc.AddTransient(_ => _gameFinder.Object); + sc.AddTransient(_ => _fileSystem); + _serviceProvider = sc.BuildServiceProvider(); + } + + [Fact] + public void TestInvalidArgs_Throws() + { + Assert.Throws(() => new WindowsSteamWrapper(null!, _serviceProvider)); + Assert.Throws(() => new WindowsSteamWrapper(_steamRegistry.Object, null!)); + Assert.Throws(() => new LinuxSteamWrapper(null!, _serviceProvider)); + Assert.Throws(() => new LinuxSteamWrapper(_steamRegistry.Object, null!)); + } + + [Fact] + public void TestRunning() + { + foreach (var steamWrapper in GetSteamWrappers()) + { + _processHelper.SetupSequence(h => h.GetProcessByPid(It.IsAny())) + .Returns((Process)null) + .Returns(Process.GetCurrentProcess); + _steamRegistry.SetupSequence(r => r.ProcessId) + .Returns((int?)null) + .Returns(0) + .Returns(123) + .Returns(123); + + Assert.False(steamWrapper.IsRunning); + Assert.False(steamWrapper.IsRunning); + Assert.False(steamWrapper.IsRunning); + Assert.True(steamWrapper.IsRunning); + } + } + + [Fact] + public void TestInstalled() + { + _steamRegistry.Setup(r => r.ExecutableFile).Returns((IFileInfo?)null); + + foreach (var steamWrapper in GetSteamWrappers()) + { + _steamRegistry.Setup(r => r.ExecutableFile).Returns((IFileInfo?)null); + Assert.False(steamWrapper.Installed); + + _steamRegistry.Setup(r => r.ExecutableFile).Returns(_fileSystem.FileInfo.New("steam.exe")); + Assert.False(steamWrapper.Installed); + } + + _fileSystem.Initialize().WithFile("steam.exe"); + + foreach (var steamWrapper in GetSteamWrappers()) + { + _steamRegistry.Setup(r => r.ExecutableFile).Returns(_fileSystem.FileInfo.New("steam.exe")); + Assert.True(steamWrapper.Installed); + } + } + + [Fact] + public void TestDisposed() + { + var counter = 0; + foreach (var steamWrapper in GetSteamWrappers()) + { + steamWrapper.Dispose(); + _steamRegistry.Verify(r => r.Dispose(), Times.Exactly(++counter)); + } + } + + + [Fact] + public void TestUserLoggedIn() + { + foreach (var steamWrapper in GetSteamWrappers()) + { + _steamRegistry.SetupSequence(r => r.ActiveUserId) + .Returns((int?)null) + .Returns(0) + .Returns(123); + + Assert.False(steamWrapper.IsUserLoggedIn); + Assert.False(steamWrapper.IsUserLoggedIn); + Assert.True(steamWrapper.IsUserLoggedIn); + } + } + + [Fact] + public void TestGameInstalled() + { + foreach (var steamWrapper in GetSteamWrappers()) + Assert.Throws(() => steamWrapper.IsGameInstalled(0, out _)); + + _fileSystem.Initialize(); + _fileSystem.Initialize().WithFile("steam.exe"); + + _steamRegistry.Setup(r => r.ExecutableFile).Returns(_fileSystem.FileInfo.New("steam.exe")); + _steamRegistry.Setup(r => r.InstallationDirectory).Returns(_fileSystem.DirectoryInfo.New(".")); + + + var mFile = _fileSystem.FileInfo.New("manifest.acf"); + + var expectedApp = new SteamAppManifest(new Mock().Object, mFile, 1234, "name", + _fileSystem.DirectoryInfo.New("Game"), SteamAppState.StateFullyInstalled, + new HashSet()); + + _steamRegistry.Setup(r => r.InstalledApps).Returns(new HashSet { 1, 2, 3 }); + _steamRegistry.Setup(r => r.InstallationDirectory).Returns(_fileSystem.DirectoryInfo.New("Steam")); + + foreach (var steamWrapper in GetSteamWrappers()) + { + _gameFinder.SetupSequence(f => f.FindGame(It.IsAny())) + .Returns((SteamAppManifest?)null) + .Returns(expectedApp); + + Assert.False(steamWrapper.IsGameInstalled(0, out _)); + Assert.False(steamWrapper.IsGameInstalled(1, out _)); + Assert.True(steamWrapper.IsGameInstalled(1, out var app)); + + Assert.Same(expectedApp, app); + } + } + + [Fact] + public void TestStartStream_Throws() + { + foreach (var steamWrapper in GetSteamWrappers()) + Assert.Throws(() => steamWrapper.StartSteam()); + } + + [Fact] + public void TestWantsOffline() + { + _fileSystem.Initialize().WithFile("steam.exe"); + _fileSystem.Initialize().WithSubdirectory("config"); + + _steamRegistry.Setup(r => r.ExecutableFile).Returns(_fileSystem.FileInfo.New("steam.exe")); + _steamRegistry.Setup(r => r.InstallationDirectory).Returns(_fileSystem.DirectoryInfo.New(".")); + + foreach (var steamWrapper in GetSteamWrappers()) + Assert.Null((object?)steamWrapper.UserWantsOfflineMode); + + foreach (var steamWrapper in GetSteamWrappers()) + { + _fileSystem.File.Create("config/loginusers.vdf").Dispose(); + Assert.Null((object?)steamWrapper.UserWantsOfflineMode); + + _fileSystem.File.WriteAllText("config/loginusers.vdf", WantsNotOffline()); + Assert.False(steamWrapper.UserWantsOfflineMode); + + _fileSystem.File.WriteAllText("config/loginusers.vdf", WantsOffline()); + Assert.True(steamWrapper.UserWantsOfflineMode); + } + } + + public IEnumerable GetSteamWrappers() + { + yield return new WindowsSteamWrapper(_steamRegistry.Object, _serviceProvider); + yield return new LinuxSteamWrapper(_steamRegistry.Object, _serviceProvider); + } + + private static string WantsNotOffline() + { + return "\"users\"\n{\n\t\"123\"\n\t{\n\t\t\"AccountName\"\t\t\"user_name\"\n\t\t\"PersonaName\"\t\t\"User Name\"\n\t\t\"RememberPassword\"\t\t\"1\"\n\t\t\"MostRecent\"\t\t\"1\"\n\t\t\"Timestamp\"\t\t\"0000000000\"\n\t\t\"WantsOfflineMode\"\t\t\"0\"\n\t\t\"SkipOfflineModeWarning\"\t\t\"0\"\n\t}\n}"; + } + + private static string WantsOffline() + { + return "\"users\"\n{\n\t\"123\"\n\t{\n\t\t\"AccountName\"\t\t\"user_name\"\n\t\t\"PersonaName\"\t\t\"User Name\"\n\t\t\"RememberPassword\"\t\t\"1\"\n\t\t\"MostRecent\"\t\t\"1\"\n\t\t\"Timestamp\"\t\t\"0000000000\"\n\t\t\"WantsOfflineMode\"\t\t\"1\"\n\t\t\"SkipOfflineModeWarning\"\t\t\"0\"\n\t}\n}"; + } +} \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/ISteamAppManifestReader.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/ISteamAppManifestReader.cs index 4b506e05..f2659292 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/ISteamAppManifestReader.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/ISteamAppManifestReader.cs @@ -1,7 +1,7 @@ using System.IO.Abstractions; using AET.SteamAbstraction.Library; -namespace AET.SteamAbstraction; +namespace AET.SteamAbstraction.Games; internal interface ISteamAppManifestReader { diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/ISteamGameLocationFinder.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/ISteamGameLocationFinder.cs index 9f4597b9..1b8073da 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/ISteamGameLocationFinder.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/ISteamGameLocationFinder.cs @@ -1,6 +1,8 @@ -namespace AET.SteamAbstraction; +using System; -internal interface ISteamGameFinder +namespace AET.SteamAbstraction.Games; + +internal interface ISteamGameFinder : IDisposable { SteamAppManifest? FindGame(uint gameId); } \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamAppManifest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamAppManifest.cs index a6af8ccc..021cbc08 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamAppManifest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamAppManifest.cs @@ -4,7 +4,7 @@ using AET.SteamAbstraction.Library; using AnakinRaW.CommonUtilities; -namespace AET.SteamAbstraction; +namespace AET.SteamAbstraction.Games; /// /// Manifest representing an installed Steam game. diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamAppState.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamAppState.cs index f6452c9a..044bd526 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamAppState.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamAppState.cs @@ -1,6 +1,6 @@ using System; -namespace AET.SteamAbstraction; +namespace AET.SteamAbstraction.Games; /// /// Indicates the State of a Steam game. diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamGameFinder.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamGameFinder.cs index 11ddddac..6e3b865a 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamGameFinder.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Games/SteamGameFinder.cs @@ -1,11 +1,12 @@ using System; using System.Linq; using AET.SteamAbstraction.Library; +using AnakinRaW.CommonUtilities; using Microsoft.Extensions.DependencyInjection; -namespace AET.SteamAbstraction; +namespace AET.SteamAbstraction.Games; -internal class SteamGameFinder : ISteamGameFinder +internal class SteamGameFinder : DisposableObject, ISteamGameFinder { private readonly ISteamLibraryFinder _libraryFinder; @@ -25,4 +26,10 @@ public SteamGameFinder(IServiceProvider serviceProvider) .FirstOrDefault(matching => matching is not null); return game; } + + protected override void DisposeManagedResources() + { + base.DisposeManagedResources(); + _libraryFinder.Dispose(); + } } \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamRegistry.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamRegistry.cs index 086ef3ae..3942db2b 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamRegistry.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamRegistry.cs @@ -8,7 +8,7 @@ namespace AET.SteamAbstraction; /// /// Registry representation for the Steam Client. /// -public interface ISteamRegistry : IDisposable +internal interface ISteamRegistry : IDisposable { /// /// Key to the ActiveProcess node diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamRegistryFactory.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamRegistryFactory.cs new file mode 100644 index 00000000..c2cbcccd --- /dev/null +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamRegistryFactory.cs @@ -0,0 +1,6 @@ +namespace AET.SteamAbstraction; + +internal interface ISteamRegistryFactory +{ + ISteamRegistry CreateRegistry(); +} \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamWrapper.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamWrapper.cs index 86853a4e..503d29e3 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamWrapper.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamWrapper.cs @@ -2,6 +2,7 @@ using System.Diagnostics.CodeAnalysis; using System.Threading; using System.Threading.Tasks; +using AET.SteamAbstraction.Games; #if NET using System.Diagnostics.CodeAnalysis; #endif @@ -23,6 +24,18 @@ public interface ISteamWrapper : IDisposable /// bool IsRunning { get; } + + /// + /// Gets whether a user is logged in. + /// + bool IsUserLoggedIn { get; } + + /// + /// Gets whether the current logged-in user has activated the offline mode. + /// if Steam is not installed or the status could not be retrieved. + /// + bool? UserWantsOfflineMode { get; } + /// /// Checks whether a given game is installed. /// diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ISteamLibrary.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ISteamLibrary.cs index c4babad3..ad1972c7 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ISteamLibrary.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ISteamLibrary.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO.Abstractions; +using AET.SteamAbstraction.Games; namespace AET.SteamAbstraction.Library; diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ISteamLibraryFinder.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ISteamLibraryFinder.cs index db843895..0bdd74cd 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ISteamLibraryFinder.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/ISteamLibraryFinder.cs @@ -1,8 +1,9 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; namespace AET.SteamAbstraction.Library; -internal interface ISteamLibraryFinder +internal interface ISteamLibraryFinder : IDisposable { IEnumerable FindLibraries(); } \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/SteamLibrary.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/SteamLibrary.cs index 69a4bf76..8e052c33 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/SteamLibrary.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/SteamLibrary.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.IO.Abstractions; +using AET.SteamAbstraction.Games; using AnakinRaW.CommonUtilities.FileSystem.Normalization; using Microsoft.Extensions.DependencyInjection; diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/SteamLibraryFinder.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/SteamLibraryFinder.cs index e062f35f..448c708f 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/SteamLibraryFinder.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Library/SteamLibraryFinder.cs @@ -1,24 +1,17 @@ using System; using System.Collections.Generic; using System.IO.Abstractions; +using AnakinRaW.CommonUtilities; using Microsoft.Extensions.DependencyInjection; namespace AET.SteamAbstraction.Library; -internal class SteamLibraryFinder : ISteamLibraryFinder +internal class SteamLibraryFinder(IServiceProvider serviceProvider) : DisposableObject, ISteamLibraryFinder { - private readonly IServiceProvider _serviceProvider; - private readonly ISteamRegistry _registry; - private readonly IFileSystem _fileSystem; - private readonly ILibraryConfigReader _configReader; - - public SteamLibraryFinder(IServiceProvider serviceProvider) - { - _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); - _registry = serviceProvider.GetRequiredService(); - _fileSystem = serviceProvider.GetRequiredService(); - _configReader = serviceProvider.GetRequiredService(); - } + private readonly IServiceProvider _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); + private readonly ISteamRegistry _registry = serviceProvider.GetRequiredService().CreateRegistry(); + private readonly IFileSystem _fileSystem = serviceProvider.GetRequiredService(); + private readonly ILibraryConfigReader _configReader = serviceProvider.GetRequiredService(); public IEnumerable FindLibraries() { @@ -63,4 +56,10 @@ private bool TryCreateLibraryFromLocation(IDirectoryInfo libraryLocation, out St return libraryLocationsFile.Exists ? libraryLocationsFile : null; } + + protected override void DisposeManagedResources() + { + base.DisposeManagedResources(); + _registry.Dispose(); + } } \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamAbstractionLayer.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamAbstractionLayer.cs index 7b18af24..3e050571 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamAbstractionLayer.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamAbstractionLayer.cs @@ -1,4 +1,6 @@ -using AET.SteamAbstraction.Utilities; +using AET.SteamAbstraction.Games; +using AET.SteamAbstraction.Library; +using AET.SteamAbstraction.Utilities; using Microsoft.Extensions.DependencyInjection; namespace AET.SteamAbstraction; @@ -8,6 +10,13 @@ internal class SteamAbstractionLayer public static void InitializeServices(IServiceCollection serviceCollection) { serviceCollection.AddSingleton(sp => new SteamWrapperFactory(sp)); + serviceCollection.AddSingleton(sp => new SteamRegistryFactory(sp)); serviceCollection.AddSingleton(sp => new ProcessHelper()); + + serviceCollection.AddSingleton(sp => new SteamVdfReader(sp)); + serviceCollection.AddSingleton(sp => new SteamVdfReader(sp)); + + serviceCollection.AddTransient(sp => new SteamLibraryFinder(sp)); + serviceCollection.AddTransient(sp => new SteamGameFinder(sp)); } } \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamException.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamException.cs index b85a9f79..09c6011d 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamException.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamException.cs @@ -21,4 +21,13 @@ public SteamException(string message) : base(message) public SteamException(string message, Exception exception) : base(message, exception) { } +} + + +/// +/// +/// +public sealed class SteamNotFoundException : SteamException +{ + } \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamRegistryFactory.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamRegistryFactory.cs new file mode 100644 index 00000000..ef05e234 --- /dev/null +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamRegistryFactory.cs @@ -0,0 +1,18 @@ +using System; +using System.Runtime.InteropServices; + +namespace AET.SteamAbstraction; + +internal class SteamRegistryFactory(IServiceProvider serviceProvider) : ISteamRegistryFactory +{ + public ISteamRegistry CreateRegistry() + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + return new WindowsSteamRegistry(serviceProvider); + + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + return new LinuxSteamRegistry(serviceProvider); + + throw new PlatformNotSupportedException($"The current platform is not supported."); + } +} \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamVdfReader.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamVdfReader.cs index 56c274cc..69a46833 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamVdfReader.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamVdfReader.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO.Abstractions; using System.Linq; +using AET.SteamAbstraction.Games; using AET.SteamAbstraction.Library; using AnakinRaW.CommonUtilities.FileSystem; using Gameloop.Vdf; diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapper.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapper.cs index 7f8b30d0..9f0f85ce 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapper.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapper.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; +using AET.SteamAbstraction.Games; using AET.SteamAbstraction.NativeMethods; using AET.SteamAbstraction.Utilities; using AnakinRaW.CommonUtilities; @@ -37,7 +38,7 @@ public bool IsRunning } } - public bool? WantOfflineMode + public bool? UserWantsOfflineMode { get { @@ -70,7 +71,7 @@ public bool? WantOfflineMode } } - internal bool IsUserLoggedIn + public bool IsUserLoggedIn { get { @@ -90,7 +91,7 @@ public bool IsGameInstalled(uint gameId, [NotNullWhen(true)] out SteamAppManifes if (!apps.Contains(gameId)) return false; - var gameFinder = ServiceProvider.GetRequiredService(); + using var gameFinder = ServiceProvider.GetRequiredService(); game = gameFinder.FindGame(gameId); return game is not null; } @@ -118,7 +119,7 @@ public async Task WaitSteamRunningAndLoggedInAsync(bool startIfNotRunning, var running = IsRunning; if (!running) { - // Required because a taskmgr kill does not reset this value, so we have to do this manually + // Required because an external kill (e.g. by taskmgr) does not reset this value, so we have to do this manually Registry.ActiveUserId = 0; if (startIfNotRunning) StartSteam(); @@ -128,7 +129,7 @@ public async Task WaitSteamRunningAndLoggedInAsync(bool startIfNotRunning, if (IsUserLoggedIn) return; - var wantsOffline = WantOfflineMode; + var wantsOffline = UserWantsOfflineMode; if (wantsOffline != null && wantsOffline.Value) { await Task.Delay(2000, cancellation); @@ -207,7 +208,7 @@ static bool GetSteamMainWindowHandle() private void ThrowIfSteamNotInstalled() { if (!Installed) - throw new SteamException("Steam is not installed!"); + throw new SteamNotFoundException(); } protected override void DisposeManagedResources() diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs index 905941db..2caf0fb6 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs @@ -1,17 +1,21 @@ using System; using System.Runtime.InteropServices; +using Microsoft.Extensions.DependencyInjection; namespace AET.SteamAbstraction; internal class SteamWrapperFactory(IServiceProvider serviceProvider) : ISteamWrapperFactory { + private readonly ISteamRegistryFactory _registryFactory = serviceProvider.GetRequiredService(); + public ISteamWrapper CreateWrapper() { + var registry = _registryFactory.CreateRegistry(); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - return new WindowsSteamWrapper(new WindowsSteamRegistry(serviceProvider), serviceProvider); + return new WindowsSteamWrapper(registry, serviceProvider); if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - return new LinuxSteamWrapper(new LinuxSteamRegistry(serviceProvider), serviceProvider); + return new LinuxSteamWrapper(registry, serviceProvider); throw new PlatformNotSupportedException($"The current platform is not supported."); } diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Steam/SteamPetroglyphStarWarsGameDetector.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Steam/SteamPetroglyphStarWarsGameDetector.cs index 8b52a558..38144ef9 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Steam/SteamPetroglyphStarWarsGameDetector.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Steam/SteamPetroglyphStarWarsGameDetector.cs @@ -1,5 +1,6 @@ using System; using AET.SteamAbstraction; +using AET.SteamAbstraction.Games; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using PG.StarWarsGame.Infrastructure.Games; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamGameLanguageFinderTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamGameLanguageFinderTest.cs index 0008e6c3..eb4cc6b2 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamGameLanguageFinderTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamGameLanguageFinderTest.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using AET.SteamAbstraction; +using AET.SteamAbstraction.Games; using AET.SteamAbstraction.Library; using EawModinfo.Model; using EawModinfo.Spec; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamPetroglyphStarWarsGameDetectorTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamPetroglyphStarWarsGameDetectorTest.cs index ec7bab84..c42cc4e6 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamPetroglyphStarWarsGameDetectorTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamPetroglyphStarWarsGameDetectorTest.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO.Abstractions; using AET.SteamAbstraction; +using AET.SteamAbstraction.Games; using AET.SteamAbstraction.Library; using Microsoft.Extensions.DependencyInjection; using Moq; From d491775112670c2780b2195826262a74a536ff3d Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Wed, 20 Mar 2024 19:09:43 +0100 Subject: [PATCH 33/41] update test and extract windows intrinsics from shared wrapper code --- .../SteamWrapperTest.cs | 218 ++++++++++++++---- .../WindowsSteamWrapperTest.cs | 58 +++++ .../Linux/LinuxSteamWrapper.cs | 7 + .../AET.SteamAbstraction/SteamWrapper.cs | 95 ++------ .../Windows/WindowsSteamWrapper.cs | 75 ++++++ 5 files changed, 329 insertions(+), 124 deletions(-) create mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction.Test/WindowsSteamWrapperTest.cs diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs index c8f01558..eaf9c22b 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs @@ -1,12 +1,15 @@ using System; using System.Collections.Generic; -using System.Diagnostics; +using System.ComponentModel; using System.IO.Abstractions; +using System.Threading; +using System.Threading.Tasks; using AET.SteamAbstraction.Games; using AET.SteamAbstraction.Library; using AET.SteamAbstraction.Utilities; using Microsoft.Extensions.DependencyInjection; using Moq; +using Moq.Protected; using Testably.Abstractions.Testing; using Xunit; @@ -17,7 +20,6 @@ public class SteamWrapperTest private readonly IServiceProvider _serviceProvider; private readonly Mock _steamRegistry; private readonly MockFileSystem _fileSystem; - private readonly Mock _processHelper; private readonly Mock _gameFinder; public SteamWrapperTest() @@ -25,10 +27,9 @@ public SteamWrapperTest() var sc = new ServiceCollection(); _steamRegistry = new Mock(); _fileSystem = new MockFileSystem(); - _processHelper = new Mock(); _gameFinder = new Mock(); sc.AddTransient(_ => _steamRegistry.Object); - sc.AddTransient(_ => _processHelper.Object); + sc.AddTransient(_ => new Mock().Object); sc.AddTransient(_ => _gameFinder.Object); sc.AddTransient(_ => _fileSystem); _serviceProvider = sc.BuildServiceProvider(); @@ -43,27 +44,6 @@ public void TestInvalidArgs_Throws() Assert.Throws(() => new LinuxSteamWrapper(_steamRegistry.Object, null!)); } - [Fact] - public void TestRunning() - { - foreach (var steamWrapper in GetSteamWrappers()) - { - _processHelper.SetupSequence(h => h.GetProcessByPid(It.IsAny())) - .Returns((Process)null) - .Returns(Process.GetCurrentProcess); - _steamRegistry.SetupSequence(r => r.ProcessId) - .Returns((int?)null) - .Returns(0) - .Returns(123) - .Returns(123); - - Assert.False(steamWrapper.IsRunning); - Assert.False(steamWrapper.IsRunning); - Assert.False(steamWrapper.IsRunning); - Assert.True(steamWrapper.IsRunning); - } - } - [Fact] public void TestInstalled() { @@ -98,30 +78,12 @@ public void TestDisposed() } } - - [Fact] - public void TestUserLoggedIn() - { - foreach (var steamWrapper in GetSteamWrappers()) - { - _steamRegistry.SetupSequence(r => r.ActiveUserId) - .Returns((int?)null) - .Returns(0) - .Returns(123); - - Assert.False(steamWrapper.IsUserLoggedIn); - Assert.False(steamWrapper.IsUserLoggedIn); - Assert.True(steamWrapper.IsUserLoggedIn); - } - } - [Fact] public void TestGameInstalled() { foreach (var steamWrapper in GetSteamWrappers()) Assert.Throws(() => steamWrapper.IsGameInstalled(0, out _)); - _fileSystem.Initialize(); _fileSystem.Initialize().WithFile("steam.exe"); _steamRegistry.Setup(r => r.ExecutableFile).Returns(_fileSystem.FileInfo.New("steam.exe")); @@ -161,8 +123,9 @@ public void TestStartStream_Throws() [Fact] public void TestWantsOffline() { - _fileSystem.Initialize().WithFile("steam.exe"); - _fileSystem.Initialize().WithSubdirectory("config"); + _fileSystem.Initialize() + .WithFile("steam.exe") + .WithSubdirectory("config"); _steamRegistry.Setup(r => r.ExecutableFile).Returns(_fileSystem.FileInfo.New("steam.exe")); _steamRegistry.Setup(r => r.InstallationDirectory).Returns(_fileSystem.DirectoryInfo.New(".")); @@ -183,6 +146,171 @@ public void TestWantsOffline() } } + [Fact] + public void TestUserLoggedIn() + { + var wrapper = new Mock(_steamRegistry.Object, _serviceProvider); + + wrapper.Setup(s => s.IsRunning).Returns(false); + + _steamRegistry.Setup(r => r.ActiveUserId).Returns((int?)null); + Assert.False(wrapper.Object.IsUserLoggedIn); + + _steamRegistry.Setup(r => r.ActiveUserId).Returns(0); + Assert.False(wrapper.Object.IsUserLoggedIn); + + _steamRegistry.Setup(r => r.ActiveUserId).Returns(456); + Assert.False(wrapper.Object.IsUserLoggedIn); + + wrapper.Setup(s => s.IsRunning).Returns(true); + + _steamRegistry.Setup(r => r.ActiveUserId).Returns((int?)null); + Assert.False(wrapper.Object.IsUserLoggedIn); + + _steamRegistry.Setup(r => r.ActiveUserId).Returns(0); + Assert.False(wrapper.Object.IsUserLoggedIn); + + _steamRegistry.Setup(r => r.ActiveUserId).Returns(456); + Assert.True(wrapper.Object.IsUserLoggedIn); + } + + [Fact] + public async Task TestWaitSteamRunningAndLoggedInAsync_SteamNotRunning_ThrowsSteamException() + { + _fileSystem.Initialize().WithFile("steam.exe"); + _steamRegistry.Setup(r => r.ExecutableFile).Returns(_fileSystem.FileInfo.New("steam.exe")); + _steamRegistry.Setup(r => r.ActiveUserId).Returns(123); + + var wrapper = new Mock(_steamRegistry.Object, _serviceProvider); + + await Assert.ThrowsAsync(async() => await wrapper.Object.WaitSteamRunningAndLoggedInAsync(false)); + } + + [Fact] + public async Task TestWaitSteamRunningAndLoggedInAsync_LoggedIn() + { + _fileSystem.Initialize().WithFile("steam.exe"); + _steamRegistry.Setup(r => r.ExecutableFile).Returns(_fileSystem.FileInfo.New("steam.exe")); + _steamRegistry.Setup(r => r.ActiveUserId).Returns(123); + + var wrapper = new Mock(_steamRegistry.Object, _serviceProvider); + wrapper.Setup(s => s.IsRunning).Returns(true); + + await wrapper.Object.WaitSteamRunningAndLoggedInAsync(false); + } + + + [Fact] + public async Task TestWaitSteamRunningAndLoggedInAsync_SteamNotRunning_StartSteam() + { + _fileSystem.Initialize().WithFile("steam.exe"); + _steamRegistry.Setup(r => r.ExecutableFile).Returns(_fileSystem.FileInfo.New("steam.exe")); + _steamRegistry.Setup(r => r.ActiveUserId).Returns(123); + + var wrapper = new Mock(_steamRegistry.Object, _serviceProvider); + + // We cannot start the process, so we just catch the exception that the process was attempted to start. + await Assert.ThrowsAsync(async () => await wrapper.Object.WaitSteamRunningAndLoggedInAsync(true)); + } + + [Fact] + public async Task TestWaitSteamRunningAndLoggedInAsync_Login() + { + _fileSystem.Initialize().WithFile("steam.exe"); + _steamRegistry.Setup(r => r.ExecutableFile).Returns(_fileSystem.FileInfo.New("steam.exe")); + + var wrapper = new Mock(_steamRegistry.Object, _serviceProvider); + wrapper.Setup(s => s.IsRunning).Returns(true); + + wrapper.Protected().Setup("WaitSteamUserLoggedInAsync", CancellationToken.None) + .Callback((CancellationToken _) => + { + _steamRegistry.Setup(r => r.ActiveUserId).Returns(456); + }) + .Returns(Task.Delay(500)); + + var task = wrapper.Object.WaitSteamRunningAndLoggedInAsync(false); + Assert.False(task.IsCompleted); + + var completedTask = await Task.WhenAny(task, Task.Delay(5000)); + Assert.Same(task, completedTask); + } + + [Fact] + public async Task TestWaitSteamRunningAndLoggedInAsync_NoLogin() + { + _fileSystem.Initialize().WithFile("steam.exe"); + _steamRegistry.Setup(r => r.ExecutableFile).Returns(_fileSystem.FileInfo.New("steam.exe")); + + var wrapper = new Mock(_steamRegistry.Object, _serviceProvider); + wrapper.Setup(s => s.IsRunning).Returns(true); + + wrapper.Protected().Setup("WaitSteamUserLoggedInAsync", CancellationToken.None) + .Returns(Task.Delay(5000)); + + var task = wrapper.Object.WaitSteamRunningAndLoggedInAsync(false); + Assert.False(task.IsCompleted); + + var completedTask = await Task.WhenAny(task, Task.Delay(500)); + Assert.NotSame(task, completedTask); + } + + + [Fact] + public async Task TestWaitSteamRunningAndLoggedInAsync_WithOfflineMore() + { + _fileSystem.Initialize() + .WithFile("steam.exe") + .WithFile("config/loginusers.vdf").Which(a => a.HasStringContent(WantsOffline())); + + _steamRegistry.Setup(r => r.InstallationDirectory).Returns(_fileSystem.DirectoryInfo.New(".")); + _steamRegistry.Setup(r => r.ExecutableFile).Returns(_fileSystem.FileInfo.New("steam.exe")); + + var wrapper = new Mock(_steamRegistry.Object, _serviceProvider); + wrapper.Setup(s => s.IsRunning).Returns(true); + + wrapper.Protected().Setup("WaitSteamOfflineRunning", CancellationToken.None) + .Returns(Task.Delay(500)); + + var task = wrapper.Object.WaitSteamRunningAndLoggedInAsync(false); + Assert.False(task.IsCompleted); + + var completedTask = await Task.WhenAny(task, Task.Delay(5000)); + Assert.Same(task, completedTask); + } + + + [Fact] + public async Task TestWaitSteamRunningAndLoggedInAsync_Cancelled() + { + _fileSystem.Initialize().WithFile("steam.exe"); + _steamRegistry.Setup(r => r.ExecutableFile).Returns(_fileSystem.FileInfo.New("steam.exe")); + + var wrapper = new Mock(_steamRegistry.Object, _serviceProvider); + wrapper.Setup(s => s.IsRunning).Returns(true); + + var cts = new CancellationTokenSource(); + + wrapper.Protected().Setup("WaitSteamUserLoggedInAsync", cts.Token) + .Returns(Task.Delay(5000, cts.Token)); + + + var task = wrapper.Object.WaitSteamRunningAndLoggedInAsync(false, cts.Token); + Assert.False(task.IsCompleted); + + cts.Cancel(); + + try + { + await task; + Assert.Fail("Expected exception not thrown."); + } + catch (OperationCanceledException ex) + { + Assert.Equal(cts.Token, ex.CancellationToken); + } + } + public IEnumerable GetSteamWrappers() { yield return new WindowsSteamWrapper(_steamRegistry.Object, _serviceProvider); diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/WindowsSteamWrapperTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/WindowsSteamWrapperTest.cs new file mode 100644 index 00000000..9051f2bb --- /dev/null +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/WindowsSteamWrapperTest.cs @@ -0,0 +1,58 @@ +using System; +using System.Diagnostics; +using System.IO.Abstractions; +using AET.SteamAbstraction.Games; +using AET.SteamAbstraction.Utilities; +using Microsoft.Extensions.DependencyInjection; +using Moq; +using PG.TestingUtilities; +using Testably.Abstractions.Testing; +using Xunit; + +namespace AET.SteamAbstraction.Test; + +public class WindowsSteamWrapperTest +{ + private readonly IServiceProvider _serviceProvider; + private readonly Mock _steamRegistry; + private readonly MockFileSystem _fileSystem; + private readonly Mock _processHelper; + private readonly Mock _gameFinder; + + private readonly WindowsSteamWrapper _steamWrapper; + + public WindowsSteamWrapperTest() + { + var sc = new ServiceCollection(); + _steamRegistry = new Mock(); + _fileSystem = new MockFileSystem(); + _gameFinder = new Mock(); + _processHelper = new Mock(); + sc.AddTransient(_ => _steamRegistry.Object); + sc.AddTransient(_ => _processHelper.Object); + sc.AddTransient(_ => _gameFinder.Object); + sc.AddTransient(_ => _fileSystem); + _serviceProvider = sc.BuildServiceProvider(); + + _steamWrapper = new WindowsSteamWrapper(_steamRegistry.Object, _serviceProvider); + } + + [PlatformSpecificFact(TestPlatformIdentifier.Windows)] + public void TestRunning() + { + _steamRegistry.SetupSequence(r => r.ProcessId) + .Returns((int?)null) + .Returns(0) + .Returns(123) + .Returns(123); + + Assert.False(_steamWrapper.IsRunning); + Assert.False(_steamWrapper.IsRunning); + Assert.False(_steamWrapper.IsRunning); + + _processHelper.SetupSequence(h => h.GetProcessByPid(It.IsAny())) + .Returns(Process.GetCurrentProcess); + + Assert.True(_steamWrapper.IsRunning); + } +} \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Linux/LinuxSteamWrapper.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Linux/LinuxSteamWrapper.cs index c860848f..a749317a 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Linux/LinuxSteamWrapper.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Linux/LinuxSteamWrapper.cs @@ -6,6 +6,13 @@ namespace AET.SteamAbstraction; internal class LinuxSteamWrapper(ISteamRegistry registry, IServiceProvider serviceProvider) : SteamWrapper(registry, serviceProvider) { + public override bool IsRunning => throw new NotImplementedException(); + + protected override Task WaitSteamOfflineRunning(CancellationToken token) + { + throw new NotImplementedException(); + } + protected override Task WaitSteamUserLoggedInAsync(CancellationToken token) { throw new NotImplementedException(); diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapper.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapper.cs index 9f0f85ce..80605173 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapper.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapper.cs @@ -7,7 +7,6 @@ using System.Threading.Tasks; using AET.SteamAbstraction.Games; using AET.SteamAbstraction.NativeMethods; -using AET.SteamAbstraction.Utilities; using AnakinRaW.CommonUtilities; using Gameloop.Vdf; using Gameloop.Vdf.JsonConverter; @@ -17,7 +16,6 @@ namespace AET.SteamAbstraction; internal abstract class SteamWrapper(ISteamRegistry registry, IServiceProvider serviceProvider) : DisposableObject, ISteamWrapper { - private readonly IProcessHelper _processHelper = serviceProvider.GetRequiredService(); protected ISteamRegistry Registry { get; } = registry ?? throw new ArgumentNullException(nameof(registry)); @@ -27,16 +25,7 @@ internal abstract class SteamWrapper(ISteamRegistry registry, IServiceProvider s public bool Installed => Registry.ExecutableFile?.Exists ?? false; - public bool IsRunning - { - get - { - var pid = Registry.ProcessId; - if (pid is null or 0) - return false; - return _processHelper.GetProcessByPid(pid.Value) != null; - } - } + public abstract bool IsRunning { get; } public bool? UserWantsOfflineMode { @@ -75,8 +64,9 @@ public bool IsUserLoggedIn { get { - var userId = Registry.ActiveUserId; - return userId is not (null or 0); + if (!IsRunning) + return false; + return Registry.ActiveUserId is not (null or 0); } } @@ -116,14 +106,18 @@ public async Task WaitSteamRunningAndLoggedInAsync(bool startIfNotRunning, CancellationToken cancellation = default) { ThrowIfSteamNotInstalled(); - var running = IsRunning; - if (!running) + if (!IsRunning) { // Required because an external kill (e.g. by taskmgr) does not reset this value, so we have to do this manually Registry.ActiveUserId = 0; if (startIfNotRunning) + { StartSteam(); - await WaitSteamRunningAsync(cancellation); + await WaitSteamRunningAsync(cancellation).ConfigureAwait(false); + } + + if (!IsRunning) + throw new SteamException("Steam is not running anymore."); } if (IsUserLoggedIn) @@ -132,79 +126,22 @@ public async Task WaitSteamRunningAndLoggedInAsync(bool startIfNotRunning, var wantsOffline = UserWantsOfflineMode; if (wantsOffline != null && wantsOffline.Value) { - await Task.Delay(2000, cancellation); - await WaitSteamOfflineRunning(cancellation); - cancellation.ThrowIfCancellationRequested(); - if (!IsRunning) - throw new SteamException("Steam is not running anymore."); + await WaitSteamOfflineRunning(cancellation).ConfigureAwait(false); } else { - await WaitSteamUserLoggedInAsync(cancellation); + await WaitSteamUserLoggedInAsync(cancellation).ConfigureAwait(false); + if (Registry.ActiveUserId == 0) + throw new SteamException("Login was not completed."); } } - private async Task WaitSteamOfflineRunning(CancellationToken token) - { - var linkedCts = CancellationTokenSource.CreateLinkedTokenSource(token); - var linkedToken = linkedCts.Token; - try - { - var mainWindowTask = Task.Run(() => WaitMainWindowIsSteamClient(linkedToken), token); - var userLoginTask = Task.Run(() => WaitSteamUserLoggedInAsync(linkedToken), token); - await Task.WhenAny(mainWindowTask, userLoginTask).ConfigureAwait(false); - } - finally - { - linkedCts.Cancel(); - linkedCts.Dispose(); - } - } + protected abstract Task WaitSteamOfflineRunning(CancellationToken token); protected abstract Task WaitSteamUserLoggedInAsync(CancellationToken token); protected abstract Task WaitSteamRunningAsync(CancellationToken token); - private async Task WaitMainWindowIsSteamClient(CancellationToken token) - { - while (IsRunning) - { - token.ThrowIfCancellationRequested(); - var mainWindowHasChildren = GetSteamMainWindowHandle(); - if (mainWindowHasChildren) - return; - // Just some arbitrary waiting - await Task.Delay(750, token); - } - - - // If anybody knows a smarter way, let me know! - static bool GetSteamMainWindowHandle() - { - var p = Process.GetProcessesByName("steam").FirstOrDefault(); - try - { - var handle = p?.MainWindowHandle; - if (handle is null) - return false; - var c = new WindowHandleInfo(handle.Value).GetAllChildHandles(); - var text = User32.GetWindowTitle(handle.Value); - - // Empty string typically is the Installer/Updater dialog. - // We don't want to early-exit on this one! - if (string.IsNullOrEmpty(text)) - return false; - - // The Steam-Client has children while the selection dialog (Go Online/Stay Offline) has none. - return c.Any(); - } - finally - { - p?.Dispose(); - } - } - } - private void ThrowIfSteamNotInstalled() { if (!Installed) diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Windows/WindowsSteamWrapper.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Windows/WindowsSteamWrapper.cs index e19d093e..82c4dd72 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Windows/WindowsSteamWrapper.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Windows/WindowsSteamWrapper.cs @@ -1,13 +1,31 @@ using System; +using System.Diagnostics; +using System.Linq; using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; +using AET.SteamAbstraction.NativeMethods; +using AET.SteamAbstraction.Utilities; using AnakinRaW.CommonUtilities.Registry.Windows; +using Microsoft.Extensions.DependencyInjection; namespace AET.SteamAbstraction; internal class WindowsSteamWrapper(ISteamRegistry registry, IServiceProvider serviceProvider) : SteamWrapper(registry, serviceProvider) { + private readonly IProcessHelper _processHelper = serviceProvider.GetRequiredService(); + + public override bool IsRunning + { + get + { + var pid = Registry.ProcessId; + if (pid is null or 0) + return false; + return _processHelper.GetProcessByPid(pid.Value) != null; + } + } + protected override async Task WaitSteamUserLoggedInAsync(CancellationToken token) { if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) @@ -49,4 +67,61 @@ protected override async Task WaitSteamRunningAsync(CancellationToken token) await windowsRegistryKey.WindowsKey.WaitForChangeAsync(false, RegistryChangeNotificationFilters.Value, token); } } + + protected override async Task WaitSteamOfflineRunning(CancellationToken token) + { + var linkedCts = CancellationTokenSource.CreateLinkedTokenSource(token); + var linkedToken = linkedCts.Token; + try + { + var mainWindowTask = Task.Run(() => WaitMainWindowIsSteamClient(linkedToken), token); + var userLoginTask = Task.Run(() => WaitSteamUserLoggedInAsync(linkedToken), token); + await Task.WhenAny(mainWindowTask, userLoginTask).ConfigureAwait(false); + } + finally + { + linkedCts.Cancel(); + linkedCts.Dispose(); + } + } + + private async Task WaitMainWindowIsSteamClient(CancellationToken token) + { + while (IsRunning) + { + token.ThrowIfCancellationRequested(); + var mainWindowHasChildren = GetSteamMainWindowHandle(); + if (mainWindowHasChildren) + return; + // Just some arbitrary waiting + await Task.Delay(750, token); + } + + + // If anybody knows a smarter way, let me know! + static bool GetSteamMainWindowHandle() + { + var p = Process.GetProcessesByName("steam").FirstOrDefault(); + try + { + var handle = p?.MainWindowHandle; + if (handle is null) + return false; + var c = new WindowHandleInfo(handle.Value).GetAllChildHandles(); + var text = User32.GetWindowTitle(handle.Value); + + // Empty string typically is the Installer/Updater dialog. + // We don't want to early-exit on this one! + if (string.IsNullOrEmpty(text)) + return false; + + // The Steam-Client has children while the selection dialog (Go Online/Stay Offline) has none. + return c.Any(); + } + finally + { + p?.Dispose(); + } + } + } } \ No newline at end of file From 5a99fea2230e9169973c57805dc27a88def7f5d4 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Fri, 29 Mar 2024 17:14:05 +0100 Subject: [PATCH 34/41] fix race --- .../AET.SteamAbstraction.Test/SteamWrapperTest.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs index eaf9c22b..9784f8a3 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs @@ -255,9 +255,8 @@ public async Task TestWaitSteamRunningAndLoggedInAsync_NoLogin() Assert.NotSame(task, completedTask); } - [Fact] - public async Task TestWaitSteamRunningAndLoggedInAsync_WithOfflineMore() + public async Task TestWaitSteamRunningAndLoggedInAsync_WithOfflineMode() { _fileSystem.Initialize() .WithFile("steam.exe") @@ -269,16 +268,19 @@ public async Task TestWaitSteamRunningAndLoggedInAsync_WithOfflineMore() var wrapper = new Mock(_steamRegistry.Object, _serviceProvider); wrapper.Setup(s => s.IsRunning).Returns(true); + var tsc = new TaskCompletionSource(); + wrapper.Protected().Setup("WaitSteamOfflineRunning", CancellationToken.None) - .Returns(Task.Delay(500)); + .Returns(tsc.Task); var task = wrapper.Object.WaitSteamRunningAndLoggedInAsync(false); Assert.False(task.IsCompleted); - var completedTask = await Task.WhenAny(task, Task.Delay(5000)); - Assert.Same(task, completedTask); - } + _ = Task.Run(async () => await Task.Delay(1000).ContinueWith(_ => tsc.SetResult(1))); + await task; + Assert.True(tsc.Task.IsCompleted); + } [Fact] public async Task TestWaitSteamRunningAndLoggedInAsync_Cancelled() From 9f348d921c3fda16513dd98187cb3b1513bb29c5 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Fri, 29 Mar 2024 17:22:04 +0100 Subject: [PATCH 35/41] update deps --- .../AET.SteamAbstraction.Test.csproj | 2 +- .../AET.SteamAbstraction.Test/SteamWrapperFactoryTest.cs | 1 - .../AET.SteamAbstraction/Linux/LinuxSteamRegistry.cs | 9 ++------- .../AET.SteamAbstraction/SteamWrapper.cs | 1 - .../PG.StarWarsGame.Infrastructure.Clients.Test.csproj | 2 +- .../src/PG.StarWarsGame.Infrastructure.csproj | 2 +- .../test/PG.StarWarsGame.Infrastructure.Test.csproj | 2 +- 7 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj index 966be0c7..268ca287 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj @@ -19,7 +19,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperFactoryTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperFactoryTest.cs index 3ed72a84..b95bba32 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperFactoryTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperFactoryTest.cs @@ -1,6 +1,5 @@ using System; using System.IO.Abstractions; -using System.Resources; using System.Runtime.InteropServices; using AET.SteamAbstraction.Utilities; using Microsoft.Extensions.DependencyInjection; diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Linux/LinuxSteamRegistry.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Linux/LinuxSteamRegistry.cs index dfff574e..60f62f8c 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Linux/LinuxSteamRegistry.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Linux/LinuxSteamRegistry.cs @@ -6,14 +6,9 @@ namespace AET.SteamAbstraction; -internal class LinuxSteamRegistry : DisposableObject, ISteamRegistry +internal class LinuxSteamRegistry(IServiceProvider serviceProvider) : DisposableObject, ISteamRegistry { - private readonly IServiceProvider _serviceProvider; - - public LinuxSteamRegistry(IServiceProvider serviceProvider) - { - _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); - } + private readonly IServiceProvider _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); public IRegistryKey? ActiveProcessKey { get; } diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapper.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapper.cs index 80605173..56b45ffe 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapper.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapper.cs @@ -6,7 +6,6 @@ using System.Threading; using System.Threading.Tasks; using AET.SteamAbstraction.Games; -using AET.SteamAbstraction.NativeMethods; using AnakinRaW.CommonUtilities; using Gameloop.Vdf; using Gameloop.Vdf.JsonConverter; diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/PG.StarWarsGame.Infrastructure.Clients.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients/test/PG.StarWarsGame.Infrastructure.Clients.Test.csproj index 2a12dc93..737a605b 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/PG.StarWarsGame.Infrastructure.Clients.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/PG.StarWarsGame.Infrastructure.Clients.Test.csproj @@ -19,7 +19,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj b/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj index c22f6517..cbfb4d23 100644 --- a/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj +++ b/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj @@ -35,7 +35,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/PetroGlyph.Games.EawFoc/test/PG.StarWarsGame.Infrastructure.Test.csproj b/src/PetroGlyph.Games.EawFoc/test/PG.StarWarsGame.Infrastructure.Test.csproj index 4ace9d3a..26b82403 100644 --- a/src/PetroGlyph.Games.EawFoc/test/PG.StarWarsGame.Infrastructure.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc/test/PG.StarWarsGame.Infrastructure.Test.csproj @@ -20,7 +20,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive From a1010a8c31b18c3395b83d2e955a000012ddd9cd Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Sat, 30 Mar 2024 12:52:23 +0100 Subject: [PATCH 36/41] Separate Windows registry --- .../LinuxSteamWrapperTest.cs | 36 ++++++++++++++++ .../SteamWrapperIntegrationTest.cs | 1 + .../SteamWrapperTest.cs | 43 +++++++++++++------ .../WindowsSteamWrapperTest.cs | 4 +- .../AET.SteamAbstraction/ISteamRegistry.cs | 20 +++------ .../ISteamWrapperFactory.cs | 9 +++- .../Linux/LinuxSteamRegistry.cs | 8 ---- .../AET.SteamAbstraction/SteamWrapper.cs | 15 ++----- .../SteamWrapperFactory.cs | 6 ++- .../Windows/WindowsSteamRegistry.cs | 2 +- .../Windows/WindowsSteamWrapper.cs | 31 ++++++++++--- 11 files changed, 119 insertions(+), 56 deletions(-) create mode 100644 src/AET.SteamAbstraction/AET.SteamAbstraction.Test/LinuxSteamWrapperTest.cs diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/LinuxSteamWrapperTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/LinuxSteamWrapperTest.cs new file mode 100644 index 00000000..39000c1d --- /dev/null +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/LinuxSteamWrapperTest.cs @@ -0,0 +1,36 @@ +using System; +using System.IO.Abstractions; +using AET.SteamAbstraction.Games; +using AET.SteamAbstraction.Utilities; +using Microsoft.Extensions.DependencyInjection; +using Moq; +using Testably.Abstractions.Testing; + +namespace AET.SteamAbstraction.Test; + +public class LinuxSteamWrapperTest +{ + private readonly IServiceProvider _serviceProvider; + private readonly Mock _steamRegistry; + private readonly MockFileSystem _fileSystem; + private readonly Mock _processHelper; + private readonly Mock _gameFinder; + + private readonly LinuxSteamWrapper _steamWrapper; + + public LinuxSteamWrapperTest() + { + var sc = new ServiceCollection(); + _steamRegistry = new Mock(); + _fileSystem = new MockFileSystem(); + _gameFinder = new Mock(); + _processHelper = new Mock(); + sc.AddTransient(_ => _steamRegistry.Object); + sc.AddTransient(_ => _processHelper.Object); + sc.AddTransient(_ => _gameFinder.Object); + sc.AddTransient(_ => _fileSystem); + _serviceProvider = sc.BuildServiceProvider(); + + _steamWrapper = new LinuxSteamWrapper(_steamRegistry.Object, _serviceProvider); + } +} \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperIntegrationTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperIntegrationTest.cs index 45e91d97..82cc07b1 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperIntegrationTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperIntegrationTest.cs @@ -38,6 +38,7 @@ public void TestGameInstalled() public void Running() { var running = _service.IsRunning; + Assert.True(running); } //[Fact] diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs index 9784f8a3..3e4a0651 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperTest.cs @@ -19,6 +19,7 @@ public class SteamWrapperTest { private readonly IServiceProvider _serviceProvider; private readonly Mock _steamRegistry; + private readonly Mock _windowsSteamRegistry; private readonly MockFileSystem _fileSystem; private readonly Mock _gameFinder; @@ -26,6 +27,7 @@ public SteamWrapperTest() { var sc = new ServiceCollection(); _steamRegistry = new Mock(); + _windowsSteamRegistry = new Mock(); _fileSystem = new MockFileSystem(); _gameFinder = new Mock(); sc.AddTransient(_ => _steamRegistry.Object); @@ -39,7 +41,7 @@ public SteamWrapperTest() public void TestInvalidArgs_Throws() { Assert.Throws(() => new WindowsSteamWrapper(null!, _serviceProvider)); - Assert.Throws(() => new WindowsSteamWrapper(_steamRegistry.Object, null!)); + Assert.Throws(() => new WindowsSteamWrapper(_windowsSteamRegistry.Object, null!)); Assert.Throws(() => new LinuxSteamWrapper(null!, _serviceProvider)); Assert.Throws(() => new LinuxSteamWrapper(_steamRegistry.Object, null!)); } @@ -63,6 +65,7 @@ public void TestInstalled() foreach (var steamWrapper in GetSteamWrappers()) { _steamRegistry.Setup(r => r.ExecutableFile).Returns(_fileSystem.FileInfo.New("steam.exe")); + _windowsSteamRegistry.Setup(r => r.ExecutableFile).Returns(_fileSystem.FileInfo.New("steam.exe")); Assert.True(steamWrapper.Installed); } } @@ -70,12 +73,12 @@ public void TestInstalled() [Fact] public void TestDisposed() { - var counter = 0; foreach (var steamWrapper in GetSteamWrappers()) { steamWrapper.Dispose(); - _steamRegistry.Verify(r => r.Dispose(), Times.Exactly(++counter)); } + _steamRegistry.Verify(r => r.Dispose(), Times.Once); + _windowsSteamRegistry.Verify(r => r.Dispose(), Times.Once); } [Fact] @@ -88,6 +91,9 @@ public void TestGameInstalled() _steamRegistry.Setup(r => r.ExecutableFile).Returns(_fileSystem.FileInfo.New("steam.exe")); _steamRegistry.Setup(r => r.InstallationDirectory).Returns(_fileSystem.DirectoryInfo.New(".")); + + _windowsSteamRegistry.Setup(r => r.ExecutableFile).Returns(_fileSystem.FileInfo.New("steam.exe")); + _windowsSteamRegistry.Setup(r => r.InstallationDirectory).Returns(_fileSystem.DirectoryInfo.New(".")); var mFile = _fileSystem.FileInfo.New("manifest.acf"); @@ -95,20 +101,28 @@ public void TestGameInstalled() var expectedApp = new SteamAppManifest(new Mock().Object, mFile, 1234, "name", _fileSystem.DirectoryInfo.New("Game"), SteamAppState.StateFullyInstalled, new HashSet()); - - _steamRegistry.Setup(r => r.InstalledApps).Returns(new HashSet { 1, 2, 3 }); + _steamRegistry.Setup(r => r.InstallationDirectory).Returns(_fileSystem.DirectoryInfo.New("Steam")); + _windowsSteamRegistry.Setup(r => r.InstallationDirectory).Returns(_fileSystem.DirectoryInfo.New("Steam")); foreach (var steamWrapper in GetSteamWrappers()) { - _gameFinder.SetupSequence(f => f.FindGame(It.IsAny())) - .Returns((SteamAppManifest?)null) - .Returns(expectedApp); - - Assert.False(steamWrapper.IsGameInstalled(0, out _)); + _gameFinder.Setup(f => f.FindGame(1u)) + .Returns((SteamAppManifest?)null); + Assert.False(steamWrapper.IsGameInstalled(1, out _)); - Assert.True(steamWrapper.IsGameInstalled(1, out var app)); + if (steamWrapper is WindowsSteamWrapper) + { + _windowsSteamRegistry.Setup(r => r.InstalledApps).Returns(new HashSet { 1 }); + _gameFinder.Setup(f => f.FindGame(1u)).Returns((SteamAppManifest?)null); + Assert.False(steamWrapper.IsGameInstalled(1, out _)); + } + + _gameFinder.Setup(f => f.FindGame(1u)) + .Returns(expectedApp); + + Assert.True(steamWrapper.IsGameInstalled(1, out var app)); Assert.Same(expectedApp, app); } } @@ -129,6 +143,9 @@ public void TestWantsOffline() _steamRegistry.Setup(r => r.ExecutableFile).Returns(_fileSystem.FileInfo.New("steam.exe")); _steamRegistry.Setup(r => r.InstallationDirectory).Returns(_fileSystem.DirectoryInfo.New(".")); + + _windowsSteamRegistry.Setup(r => r.ExecutableFile).Returns(_fileSystem.FileInfo.New("steam.exe")); + _windowsSteamRegistry.Setup(r => r.InstallationDirectory).Returns(_fileSystem.DirectoryInfo.New(".")); foreach (var steamWrapper in GetSteamWrappers()) Assert.Null((object?)steamWrapper.UserWantsOfflineMode); @@ -313,9 +330,9 @@ public async Task TestWaitSteamRunningAndLoggedInAsync_Cancelled() } } - public IEnumerable GetSteamWrappers() + private IEnumerable GetSteamWrappers() { - yield return new WindowsSteamWrapper(_steamRegistry.Object, _serviceProvider); + yield return new WindowsSteamWrapper(_windowsSteamRegistry.Object, _serviceProvider); yield return new LinuxSteamWrapper(_steamRegistry.Object, _serviceProvider); } diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/WindowsSteamWrapperTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/WindowsSteamWrapperTest.cs index 9051f2bb..81cc13d1 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/WindowsSteamWrapperTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/WindowsSteamWrapperTest.cs @@ -14,7 +14,7 @@ namespace AET.SteamAbstraction.Test; public class WindowsSteamWrapperTest { private readonly IServiceProvider _serviceProvider; - private readonly Mock _steamRegistry; + private readonly Mock _steamRegistry; private readonly MockFileSystem _fileSystem; private readonly Mock _processHelper; private readonly Mock _gameFinder; @@ -24,7 +24,7 @@ public class WindowsSteamWrapperTest public WindowsSteamWrapperTest() { var sc = new ServiceCollection(); - _steamRegistry = new Mock(); + _steamRegistry = new Mock(); _fileSystem = new MockFileSystem(); _gameFinder = new Mock(); _processHelper = new Mock(); diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamRegistry.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamRegistry.cs index 3942db2b..3dd2bf82 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamRegistry.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamRegistry.cs @@ -10,21 +10,11 @@ namespace AET.SteamAbstraction; /// internal interface ISteamRegistry : IDisposable { - /// - /// Key to the ActiveProcess node - /// - IRegistryKey? ActiveProcessKey { get; } - /// /// Id of the logged-in user. /// int? ActiveUserId { get; set; } - /// - /// PID of the Steam process. - /// - int? ProcessId { get; } - /// /// The executable of the Steam client. /// @@ -34,9 +24,13 @@ internal interface ISteamRegistry : IDisposable /// The installation directory of the Steam client /// IDirectoryInfo? InstallationDirectory { get; } +} - /// - /// Set of installed app IDs. - /// +internal interface IWindowsSteamRegistry : ISteamRegistry +{ + IRegistryKey? ActiveProcessKey { get; } + + int? ProcessId { get; } + ISet? InstalledApps { get; } } \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamWrapperFactory.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamWrapperFactory.cs index 15d1b99c..b49b8744 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamWrapperFactory.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/ISteamWrapperFactory.cs @@ -1,6 +1,13 @@ namespace AET.SteamAbstraction; -internal interface ISteamWrapperFactory +/// +/// Factory to create a platform dependent . +/// +public interface ISteamWrapperFactory { + /// + /// Creates a new for the current platform. + /// + /// The for the current platform. ISteamWrapper CreateWrapper(); } \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Linux/LinuxSteamRegistry.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Linux/LinuxSteamRegistry.cs index 60f62f8c..089c8ea0 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Linux/LinuxSteamRegistry.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Linux/LinuxSteamRegistry.cs @@ -1,8 +1,6 @@ using System; -using System.Collections.Generic; using System.IO.Abstractions; using AnakinRaW.CommonUtilities; -using AnakinRaW.CommonUtilities.Registry; namespace AET.SteamAbstraction; @@ -10,15 +8,9 @@ internal class LinuxSteamRegistry(IServiceProvider serviceProvider) : Disposable { private readonly IServiceProvider _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); - public IRegistryKey? ActiveProcessKey { get; } - public int? ActiveUserId { get; set; } - public int? ProcessId { get; } - public IFileInfo? ExecutableFile { get; } public IDirectoryInfo? InstallationDirectory { get; } - - public ISet? InstalledApps { get; } } \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapper.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapper.cs index 56b45ffe..7feefc1e 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapper.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapper.cs @@ -14,8 +14,7 @@ namespace AET.SteamAbstraction; internal abstract class SteamWrapper(ISteamRegistry registry, IServiceProvider serviceProvider) : DisposableObject, ISteamWrapper -{ - +{ protected ISteamRegistry Registry { get; } = registry ?? throw new ArgumentNullException(nameof(registry)); protected IServiceProvider ServiceProvider { get; } = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); @@ -69,17 +68,9 @@ public bool IsUserLoggedIn } } - public bool IsGameInstalled(uint gameId, [NotNullWhen(true)] out SteamAppManifest? game) + public virtual bool IsGameInstalled(uint gameId, [NotNullWhen(true)] out SteamAppManifest? game) { ThrowIfSteamNotInstalled(); - game = null; - var apps = Registry.InstalledApps; - if (apps is null) - return false; - - if (!apps.Contains(gameId)) - return false; - using var gameFinder = ServiceProvider.GetRequiredService(); game = gameFinder.FindGame(gameId); return game is not null; @@ -141,7 +132,7 @@ public async Task WaitSteamRunningAndLoggedInAsync(bool startIfNotRunning, protected abstract Task WaitSteamRunningAsync(CancellationToken token); - private void ThrowIfSteamNotInstalled() + protected void ThrowIfSteamNotInstalled() { if (!Installed) throw new SteamNotFoundException(); diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs index 2caf0fb6..61bd88af 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs @@ -12,7 +12,11 @@ public ISteamWrapper CreateWrapper() { var registry = _registryFactory.CreateRegistry(); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - return new WindowsSteamWrapper(registry, serviceProvider); + { + if (registry is not WindowsSteamRegistry windowsRegistry) + throw new InvalidOperationException("Expected Windows Registry on Windows systems."); + return new WindowsSteamWrapper(windowsRegistry, serviceProvider); + } if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) return new LinuxSteamWrapper(registry, serviceProvider); diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Windows/WindowsSteamRegistry.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Windows/WindowsSteamRegistry.cs index 34b8021e..45678e7c 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Windows/WindowsSteamRegistry.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Windows/WindowsSteamRegistry.cs @@ -8,7 +8,7 @@ namespace AET.SteamAbstraction; -internal sealed class WindowsSteamRegistry(IServiceProvider serviceProvider) : DisposableObject, ISteamRegistry +internal sealed class WindowsSteamRegistry(IServiceProvider serviceProvider) : DisposableObject, IWindowsSteamRegistry { private const string SteamExeKey = "SteamExe"; private const string SteamPathKey = "SteamPath"; diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/Windows/WindowsSteamWrapper.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/Windows/WindowsSteamWrapper.cs index 82c4dd72..90c740ef 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/Windows/WindowsSteamWrapper.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/Windows/WindowsSteamWrapper.cs @@ -1,9 +1,11 @@ using System; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; +using AET.SteamAbstraction.Games; using AET.SteamAbstraction.NativeMethods; using AET.SteamAbstraction.Utilities; using AnakinRaW.CommonUtilities.Registry.Windows; @@ -11,21 +13,40 @@ namespace AET.SteamAbstraction; -internal class WindowsSteamWrapper(ISteamRegistry registry, IServiceProvider serviceProvider) : SteamWrapper(registry, serviceProvider) +internal class WindowsSteamWrapper : SteamWrapper { - private readonly IProcessHelper _processHelper = serviceProvider.GetRequiredService(); + private readonly IWindowsSteamRegistry _windowsRegistry; + private readonly IProcessHelper _processHelper; public override bool IsRunning { get { - var pid = Registry.ProcessId; + var pid = _windowsRegistry.ProcessId; if (pid is null or 0) return false; return _processHelper.GetProcessByPid(pid.Value) != null; } } + public WindowsSteamWrapper(IWindowsSteamRegistry registry, IServiceProvider serviceProvider) : base(registry, serviceProvider) + { + _windowsRegistry = registry; + _processHelper = serviceProvider.GetRequiredService(); + } + + public override bool IsGameInstalled(uint gameId, [NotNullWhen(true)] out SteamAppManifest? game) + { + ThrowIfSteamNotInstalled(); + + game = null; + var apps = _windowsRegistry.InstalledApps; + if (apps is null || !apps.Contains(gameId)) + return false; + + return base.IsGameInstalled(gameId, out game); + } + protected override async Task WaitSteamUserLoggedInAsync(CancellationToken token) { if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) @@ -37,7 +58,7 @@ protected override async Task WaitSteamUserLoggedInAsync(CancellationToken token while (!IsUserLoggedIn) { token.ThrowIfCancellationRequested(); - var processKey = Registry.ActiveProcessKey; + var processKey = _windowsRegistry.ActiveProcessKey; if (processKey is null) return; if (processKey is not WindowsRegistryKey windowsRegistryKey) @@ -59,7 +80,7 @@ protected override async Task WaitSteamRunningAsync(CancellationToken token) while (!IsRunning) { token.ThrowIfCancellationRequested(); - var processKey = Registry.ActiveProcessKey; + var processKey = _windowsRegistry.ActiveProcessKey; if (processKey is null) return; if (processKey is not WindowsRegistryKey windowsRegistryKey) From bb0d5fc5bdc46e431352cfa8e716a6ec6137df34 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Sat, 30 Mar 2024 13:00:39 +0100 Subject: [PATCH 37/41] fix tests windows --- .../SteamWrapperFactoryTest.cs | 23 ++++++++++++++++++- .../SteamWrapperFactory.cs | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperFactoryTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperFactoryTest.cs index b95bba32..7da3638f 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperFactoryTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperFactoryTest.cs @@ -4,6 +4,7 @@ using AET.SteamAbstraction.Utilities; using Microsoft.Extensions.DependencyInjection; using Moq; +using PG.TestingUtilities; using Testably.Abstractions.Testing; using Xunit; @@ -15,7 +16,11 @@ public class SteamWrapperFactoryTest public void Test_CreateWrapper() { var regFactory = new Mock(); - regFactory.Setup(f => f.CreateRegistry()).Returns(new Mock().Object); + + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + regFactory.Setup(f => f.CreateRegistry()).Returns(new Mock().Object); + else + regFactory.Setup(f => f.CreateRegistry()).Returns(new Mock().Object); var sc = new ServiceCollection(); sc.AddSingleton(_ => regFactory.Object); @@ -36,4 +41,20 @@ public void Test_CreateWrapper() Assert.IsType(expectedType, wrapper); } + + [PlatformSpecificFact(TestPlatformIdentifier.Windows)] + public void Test_CreateWrapper_ThrowsWrongType_Windows() + { + var regFactory = new Mock(); + + regFactory.Setup(f => f.CreateRegistry()).Returns(new Mock().Object); + + var sc = new ServiceCollection(); + sc.AddSingleton(_ => regFactory.Object); + sc.AddSingleton(new Mock().Object); + sc.AddSingleton(new MockFileSystem()); + var factory = new SteamWrapperFactory(sc.BuildServiceProvider()); + + Assert.Throws(() => factory.CreateWrapper()); + } } \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs index 61bd88af..96e0703a 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs @@ -13,7 +13,7 @@ public ISteamWrapper CreateWrapper() var registry = _registryFactory.CreateRegistry(); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (registry is not WindowsSteamRegistry windowsRegistry) + if (registry is not IWindowsSteamRegistry windowsRegistry) throw new InvalidOperationException("Expected Windows Registry on Windows systems."); return new WindowsSteamWrapper(windowsRegistry, serviceProvider); } From 85aadd81a7984e2f8a2d877033b2bd3dbe39307f Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Sat, 30 Mar 2024 14:48:31 +0100 Subject: [PATCH 38/41] do not support ubuntu in this version and update some tests and contracts --- sample/SampleApplication/Program.cs | 17 +++++++++-------- .../AET.SteamAbstraction.Test.csproj | 2 +- .../SteamWrapperFactoryTest.cs | 19 ++++--------------- .../AET.SteamAbstraction.csproj.DotSettings | 2 +- .../SteamAbstractionLayer.cs | 9 ++++++++- .../SteamWrapperFactory.cs | 4 +++- .../src/DefaultGameClientFactory.cs | 2 +- ...ph.Games.EawFoc.Clients.csproj.DotSettings | 2 -- .../src/PetroglyphGameClients.cs | 7 ++++++- .../src/Steam/SteamGameClient.cs | 2 +- .../SteamPetroglyphStarWarsGameDetector.cs | 10 ++++++---- ...arsGame.Infrastructure.Clients.Test.csproj | 2 +- .../test/Steam/SteamGameClientTest.cs | 15 +++++++++++---- ...SteamPetroglyphStarWarsGameDetectorTest.cs | 5 +++++ ...PetroGlyph.Games.EawFoc.csproj.DotSettings | 4 ---- .../src/PetroglyphGameInfrastructure.cs | 14 ++++++++++++++ ...PG.StarWarsGame.Infrastructure.Test.csproj | 2 +- version.json | 2 +- 18 files changed, 73 insertions(+), 47 deletions(-) delete mode 100644 src/PetroGlyph.Games.EawFoc.Clients/src/PetroGlyph.Games.EawFoc.Clients.csproj.DotSettings delete mode 100644 src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj.DotSettings diff --git a/sample/SampleApplication/Program.cs b/sample/SampleApplication/Program.cs index 4a4f68a0..52d8f8a9 100644 --- a/sample/SampleApplication/Program.cs +++ b/sample/SampleApplication/Program.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.IO.Abstractions; using System.Linq; +using AET.SteamAbstraction; using AnakinRaW.CommonUtilities.Registry.Windows; using Microsoft.Extensions.DependencyInjection; using PG.StarWarsGame.Infrastructure; @@ -11,7 +13,6 @@ using PG.StarWarsGame.Infrastructure.Services; using PG.StarWarsGame.Infrastructure.Services.Dependencies; using PG.StarWarsGame.Infrastructure.Services.Detection; -using PG.StarWarsGame.Infrastructure.Services.Name; var sp = SetupApplication(); @@ -67,14 +68,14 @@ IServiceProvider SetupApplication() var sc = new ServiceCollection(); sc.AddSingleton(WindowsRegistry.Default); + sc.AddSingleton(_ => new FileSystem()); + + PetroglyphGameInfrastructure.InitializeServices(sc); + SteamAbstractionLayer.InitializeServices(sc); + PetroglyphGameClients.InitializeServices(sc); + + // The game detector to use for this application. sc.AddTransient(sp => new SteamPetroglyphStarWarsGameDetector(sp)); - sc.AddTransient(sp => new GameFactory(sp)); - sc.AddTransient(sp => new FileSystemModFinder(sp)); - sc.AddTransient(sp => new ModFactory(sp)); - sc.AddTransient(sp => new ModReferenceLocationResolver(sp)); - sc.AddTransient(sp => new DirectoryModNameResolver(sp)); - sc.AddTransient(sp => new ModDependencyResolver(sp)); - sc.AddTransient(sp => new DefaultGameClientFactory(sp)); return sc.BuildServiceProvider(); } \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj index 268ca287..35934c9f 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj @@ -19,7 +19,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperFactoryTest.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperFactoryTest.cs index 7da3638f..42f8d14b 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperFactoryTest.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/SteamWrapperFactoryTest.cs @@ -12,15 +12,12 @@ namespace AET.SteamAbstraction.Test; public class SteamWrapperFactoryTest { - [Fact] - public void Test_CreateWrapper() + [PlatformSpecificFact(TestPlatformIdentifier.Windows)] + public void Test_CreateWrapper_Windows() { var regFactory = new Mock(); - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - regFactory.Setup(f => f.CreateRegistry()).Returns(new Mock().Object); - else - regFactory.Setup(f => f.CreateRegistry()).Returns(new Mock().Object); + regFactory.Setup(f => f.CreateRegistry()).Returns(new Mock().Object); var sc = new ServiceCollection(); sc.AddSingleton(_ => regFactory.Object); @@ -30,15 +27,7 @@ public void Test_CreateWrapper() var wrapper = factory.CreateWrapper(); - Type? expectedType = null; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - expectedType = typeof(WindowsSteamWrapper); - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - expectedType = typeof(LinuxSteamWrapper); - - if (expectedType is null) - Assert.Fail("Platform was not supported"); - + var expectedType = typeof(WindowsSteamWrapper); Assert.IsType(expectedType, wrapper); } diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj.DotSettings b/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj.DotSettings index c7099e49..1e442269 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj.DotSettings +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj.DotSettings @@ -3,4 +3,4 @@ False True True - True \ No newline at end of file + \ No newline at end of file diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamAbstractionLayer.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamAbstractionLayer.cs index 3e050571..43beb95e 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamAbstractionLayer.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamAbstractionLayer.cs @@ -5,8 +5,15 @@ namespace AET.SteamAbstraction; -internal class SteamAbstractionLayer +/// +/// +/// +public class SteamAbstractionLayer { + /// + /// + /// + /// public static void InitializeServices(IServiceCollection serviceCollection) { serviceCollection.AddSingleton(sp => new SteamWrapperFactory(sp)); diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs index 96e0703a..fec30612 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/SteamWrapperFactory.cs @@ -19,7 +19,9 @@ public ISteamWrapper CreateWrapper() } if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - return new LinuxSteamWrapper(registry, serviceProvider); + { + throw new NotImplementedException("Steam wrapper for Linux is not yet implemented."); + } throw new PlatformNotSupportedException($"The current platform is not supported."); } diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/DefaultGameClientFactory.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/DefaultGameClientFactory.cs index 0fedac67..1a781c97 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/DefaultGameClientFactory.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/DefaultGameClientFactory.cs @@ -31,7 +31,7 @@ public DefaultGameClientFactory(IServiceProvider serviceProvider) /// Gets or creates an for the given . /// /// The requested game platform. - /// The service provider used to created the . + /// The service provider used to create the . /// public IGameClient CreateClient(GamePlatform gamePlatform, IServiceProvider serviceProvider) { diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/PetroGlyph.Games.EawFoc.Clients.csproj.DotSettings b/src/PetroGlyph.Games.EawFoc.Clients/src/PetroGlyph.Games.EawFoc.Clients.csproj.DotSettings deleted file mode 100644 index 9e07e2fd..00000000 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/PetroGlyph.Games.EawFoc.Clients.csproj.DotSettings +++ /dev/null @@ -1,2 +0,0 @@ - - True \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/PetroglyphGameClients.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/PetroglyphGameClients.cs index 79c7c0c3..ea0f73a4 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/PetroglyphGameClients.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/PetroglyphGameClients.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.DependencyInjection; using PG.StarWarsGame.Infrastructure.Clients.Arguments; +using PG.StarWarsGame.Infrastructure.Clients.Processes; namespace PG.StarWarsGame.Infrastructure.Clients; @@ -15,9 +16,13 @@ public class PetroglyphGameClients /// The service collection to be filled. public static void InitializeServices(IServiceCollection serviceCollection) { + serviceCollection.AddTransient(sp => new DefaultGameProcessLauncher(sp)); serviceCollection.AddTransient(sp => new GameExecutableFileService(sp)); serviceCollection.AddTransient(_ => new GameExecutableNameBuilder()); - + + serviceCollection.AddTransient(sp => new DefaultGameClientFactory(sp)); + serviceCollection.AddTransient(sp => new ModArgumentListFactory(sp)); + serviceCollection.AddTransient(sp => new KeyBasedArgumentCollectionBuilder()); serviceCollection.AddTransient(_ => new ArgumentValidator()); serviceCollection.AddTransient(sp => new ArgumentCommandLineBuilder(sp)); } diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Steam/SteamGameClient.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Steam/SteamGameClient.cs index 03ef795f..6a82797a 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Steam/SteamGameClient.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Steam/SteamGameClient.cs @@ -44,7 +44,7 @@ public SteamGameLauncher(IServiceProvider serviceProvider) { if (serviceProvider == null) throw new ArgumentNullException(nameof(serviceProvider)); - _steamWrapper = serviceProvider.GetRequiredService(); + _steamWrapper = serviceProvider.GetRequiredService().CreateWrapper(); _internalLauncher = serviceProvider.GetRequiredService(); } diff --git a/src/PetroGlyph.Games.EawFoc.Clients/src/Steam/SteamPetroglyphStarWarsGameDetector.cs b/src/PetroGlyph.Games.EawFoc.Clients/src/Steam/SteamPetroglyphStarWarsGameDetector.cs index 38144ef9..f5fbf102 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/src/Steam/SteamPetroglyphStarWarsGameDetector.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/src/Steam/SteamPetroglyphStarWarsGameDetector.cs @@ -21,7 +21,7 @@ public sealed class SteamPetroglyphStarWarsGameDetector : GameDetector private const uint EaWGameId = 32470; private const uint FocDepotId = 32472; - private readonly ISteamWrapper _steamWrapper; + private readonly ISteamWrapperFactory _steamWrapperFactory; private readonly IGameRegistryFactory _registryFactory; /// @@ -31,16 +31,18 @@ public sealed class SteamPetroglyphStarWarsGameDetector : GameDetector public SteamPetroglyphStarWarsGameDetector(IServiceProvider serviceProvider) : base(serviceProvider, true) { _registryFactory = ServiceProvider.GetRequiredService(); - _steamWrapper = ServiceProvider.GetRequiredService(); + _steamWrapperFactory = ServiceProvider.GetRequiredService(); } /// protected override GameLocationData FindGameLocation(GameDetectorOptions options) { - if (!_steamWrapper.Installed) + using var steam = _steamWrapperFactory.CreateWrapper(); + + if (!steam.Installed) return default; - if (!_steamWrapper.IsGameInstalled(EaWGameId, out var game)) + if (!steam.IsGameInstalled(EaWGameId, out var game)) return default; if (!game!.State.HasFlag(SteamAppState.StateFullyInstalled)) diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/PG.StarWarsGame.Infrastructure.Clients.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients/test/PG.StarWarsGame.Infrastructure.Clients.Test.csproj index 737a605b..7a8a7c3c 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/PG.StarWarsGame.Infrastructure.Clients.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/PG.StarWarsGame.Infrastructure.Clients.Test.csproj @@ -19,7 +19,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamGameClientTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamGameClientTest.cs index 54137cde..94bb16f3 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamGameClientTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamGameClientTest.cs @@ -13,7 +13,7 @@ namespace PG.StarWarsGame.Infrastructure.Clients.Test.Steam; public class SteamGameClientTest { private readonly SteamGameClient _service; - private readonly Mock _steam; + private readonly Mock _steamFactory; private readonly Mock _game; private readonly Mock _launcher; @@ -23,8 +23,8 @@ public SteamGameClientTest() var fs = new MockFileSystem(); fs.Initialize().WithFile("test.exe"); var sc = new ServiceCollection(); - _steam = new Mock(); - sc.AddTransient(_ => _steam.Object); + _steamFactory = new Mock(); + sc.AddTransient(_ => _steamFactory.Object); var fileService = new Mock(); fileService.Setup(s => s.GetExecutableForGame(It.IsAny(), It.IsAny())) .Returns(fs.FileInfo.New("test.exe")); @@ -49,6 +49,10 @@ public void TestNotCompatiblePlatform_Throws() [Fact] public void TestSteamNotRunning_Throws() { + var steam = new Mock(); + steam.SetupGet(s => s.IsRunning).Returns(false); + _steamFactory.Setup(s => s.CreateWrapper()).Returns(steam.Object); + _game.Setup(g => g.Platform).Returns(GamePlatform.SteamGold); _game.Setup(g => g.Game).Returns(_game.Object); Assert.Throws(() => _service.Play(_game.Object)); @@ -57,9 +61,12 @@ public void TestSteamNotRunning_Throws() [Fact] public void TestProcessCreated() { + var steam = new Mock(); + steam.SetupGet(s => s.IsRunning).Returns(true); + _steamFactory.Setup(s => s.CreateWrapper()).Returns(steam.Object); + _game.Setup(g => g.Platform).Returns(GamePlatform.SteamGold); _game.Setup(g => g.Game).Returns(_game.Object); - _steam.Setup(s => s.IsRunning).Returns(true); var process = new Mock(); process.Setup(p => p.State).Returns(GameProcessState.Closed); diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamPetroglyphStarWarsGameDetectorTest.cs b/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamPetroglyphStarWarsGameDetectorTest.cs index c42cc4e6..09158a71 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamPetroglyphStarWarsGameDetectorTest.cs +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/Steam/SteamPetroglyphStarWarsGameDetectorTest.cs @@ -29,6 +29,11 @@ public SteamPetroglyphStarWarsGameDetectorTest() var sc = new ServiceCollection(); _fileSystem = new MockFileSystem(); _steamWrapper = new Mock(); + + var steamFactory = new Mock(); + steamFactory.Setup(f => f.CreateWrapper()).Returns(_steamWrapper.Object); + sc.AddSingleton(steamFactory.Object); + _gameRegistryFactory = new Mock(); _gameRegistry = new Mock(); sc.AddTransient(_ => _fileSystem); diff --git a/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj.DotSettings b/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj.DotSettings deleted file mode 100644 index 2c647cc2..00000000 --- a/src/PetroGlyph.Games.EawFoc/src/PetroGlyph.Games.EawFoc.csproj.DotSettings +++ /dev/null @@ -1,4 +0,0 @@ - - True - True - True \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/src/PetroglyphGameInfrastructure.cs b/src/PetroGlyph.Games.EawFoc/src/PetroglyphGameInfrastructure.cs index ff6bd28a..9facfc28 100644 --- a/src/PetroGlyph.Games.EawFoc/src/PetroglyphGameInfrastructure.cs +++ b/src/PetroGlyph.Games.EawFoc/src/PetroglyphGameInfrastructure.cs @@ -1,6 +1,9 @@ using Microsoft.Extensions.DependencyInjection; using PG.StarWarsGame.Infrastructure.Games.Registry; +using PG.StarWarsGame.Infrastructure.Services; +using PG.StarWarsGame.Infrastructure.Services.Dependencies; using PG.StarWarsGame.Infrastructure.Services.Detection; +using PG.StarWarsGame.Infrastructure.Services.Name; using PG.StarWarsGame.Infrastructure.Services.Steam; namespace PG.StarWarsGame.Infrastructure; @@ -20,5 +23,16 @@ public static void InitializeServices(IServiceCollection serviceCollection) serviceCollection.AddTransient(_ => new GameRegistryFactory()); serviceCollection.AddTransient(sp => new ModIdentifierBuilder(sp)); serviceCollection.AddTransient(sp => new SteamGameHelpers(sp)); + + serviceCollection.AddTransient(sp => new GameFactory(sp)); + serviceCollection.AddTransient(sp => new GameRegistryFactory()); + serviceCollection.AddTransient(sp => new FileSystemModFinder(sp)); + serviceCollection.AddTransient(sp => new ModFactory(sp)); + serviceCollection.AddTransient(sp => new ModReferenceLocationResolver(sp)); + serviceCollection.AddTransient(sp => new DirectoryModNameResolver(sp)); + + serviceCollection.AddTransient(sp => new ModDependencyResolver(sp)); + serviceCollection.AddTransient(sp => new ModDependencyGraphBuilder()); + serviceCollection.AddTransient(sp => new ModDependencyTraverser(sp)); } } \ No newline at end of file diff --git a/src/PetroGlyph.Games.EawFoc/test/PG.StarWarsGame.Infrastructure.Test.csproj b/src/PetroGlyph.Games.EawFoc/test/PG.StarWarsGame.Infrastructure.Test.csproj index 26b82403..b35948dd 100644 --- a/src/PetroGlyph.Games.EawFoc/test/PG.StarWarsGame.Infrastructure.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc/test/PG.StarWarsGame.Infrastructure.Test.csproj @@ -20,7 +20,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/version.json b/version.json index c5b97804..f2afe889 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "2.0", + "version": "3.0", "publicReleaseRefSpec": [ "^refs/heads/main" ], From f0b11cd0a4f03c580bb8f7334719c16d4015d016 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Sun, 7 Apr 2024 17:38:18 +0200 Subject: [PATCH 39/41] udpate deps --- sample/SampleApplication/SampleApplication.csproj | 2 +- .../AET.SteamAbstraction.Test.csproj | 2 +- .../AET.SteamAbstraction/AET.SteamAbstraction.csproj | 6 +++--- .../test/PG.StarWarsGame.Infrastructure.Clients.Test.csproj | 2 +- .../src/PG.StarWarsGame.Infrastructure.csproj | 6 +++--- .../test/PG.StarWarsGame.Infrastructure.Test.csproj | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sample/SampleApplication/SampleApplication.csproj b/sample/SampleApplication/SampleApplication.csproj index 5f302bfb..c7a4b0d9 100644 --- a/sample/SampleApplication/SampleApplication.csproj +++ b/sample/SampleApplication/SampleApplication.csproj @@ -8,7 +8,7 @@ - + diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj index 35934c9f..fc9f7d01 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction.Test/AET.SteamAbstraction.Test.csproj @@ -19,7 +19,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj b/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj index 5c7de8b2..88fdce87 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj @@ -20,10 +20,10 @@ true - + - - + + diff --git a/src/PetroGlyph.Games.EawFoc.Clients/test/PG.StarWarsGame.Infrastructure.Clients.Test.csproj b/src/PetroGlyph.Games.EawFoc.Clients/test/PG.StarWarsGame.Infrastructure.Clients.Test.csproj index 7a8a7c3c..0f564ca9 100644 --- a/src/PetroGlyph.Games.EawFoc.Clients/test/PG.StarWarsGame.Infrastructure.Clients.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc.Clients/test/PG.StarWarsGame.Infrastructure.Clients.Test.csproj @@ -19,7 +19,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj b/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj index cbfb4d23..77d41515 100644 --- a/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj +++ b/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj @@ -22,9 +22,9 @@ true - - - + + + all diff --git a/src/PetroGlyph.Games.EawFoc/test/PG.StarWarsGame.Infrastructure.Test.csproj b/src/PetroGlyph.Games.EawFoc/test/PG.StarWarsGame.Infrastructure.Test.csproj index b35948dd..c78a27b5 100644 --- a/src/PetroGlyph.Games.EawFoc/test/PG.StarWarsGame.Infrastructure.Test.csproj +++ b/src/PetroGlyph.Games.EawFoc/test/PG.StarWarsGame.Infrastructure.Test.csproj @@ -20,7 +20,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive From 685ee3eaf6bb65b3e489d1273a91a665f88da6de Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Sun, 7 Apr 2024 17:41:10 +0200 Subject: [PATCH 40/41] update deps --- .../src/PG.StarWarsGame.Infrastructure.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj b/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj index 77d41515..29593703 100644 --- a/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj +++ b/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj @@ -25,7 +25,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive From 163296425f99c330f5fd7643fa1fe79deda09fe1 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Sun, 7 Apr 2024 19:01:39 +0200 Subject: [PATCH 41/41] update deps --- .../AET.SteamAbstraction/AET.SteamAbstraction.csproj | 4 ++-- .../src/PG.StarWarsGame.Infrastructure.csproj | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj b/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj index 88fdce87..5943dfc4 100644 --- a/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj +++ b/src/AET.SteamAbstraction/AET.SteamAbstraction/AET.SteamAbstraction.csproj @@ -22,8 +22,8 @@ - - + + diff --git a/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj b/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj index 29593703..a0f0507f 100644 --- a/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj +++ b/src/PetroGlyph.Games.EawFoc/src/PG.StarWarsGame.Infrastructure.csproj @@ -22,8 +22,8 @@ true - - + +