Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sampleApp/SampleApplication.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/AET.SteamAbstraction/AET.SteamAbstraction.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
<PackageReference Include="Microsoft.Bcl.HashCode" Version="6.0.0" />
<PackageReference Include="AnakinRaW.CommonUtilities" Version="12.3.9" />
<PackageReference Include="AnakinRaW.CommonUtilities.FileSystem" Version="12.3.9" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.1" />
<PackageReference Include="Nullable" Version="1.3.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Text.Json" Version="10.0.0" />
<PackageReference Include="System.Text.Json" Version="10.0.1" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/AET.SteamAbstraction/SteamAbstractionLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static void InitializeServices(IServiceCollection serviceCollection)
{
serviceCollection.AddSingleton<ISteamWrapperFactory>(sp => new SteamWrapperFactory(sp));
serviceCollection.AddSingleton<ISteamRegistryFactory>(sp => new SteamRegistryFactory(sp));
serviceCollection.AddSingleton<IProcessHelper>(sp => new ProcessHelper());
serviceCollection.AddSingleton<IProcessHelper>(new ProcessHelper());
serviceCollection.AddSingleton<ISteamLibraryFinder>(sp => new SteamLibraryFinder(sp));
}
}
2 changes: 1 addition & 1 deletion src/AET.SteamAbstraction/SteamWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public bool? UserWantsOfflineMode
try
{
var config = SteamVdfReader.ReadLoginUsers(FileSystem.FileInfo.New(configFile));
return config.Users.Any(user => user.MostRecent && user.UserWantsOffline);
return config.Users.Any(user => user is { MostRecent: true, UserWantsOffline: true });
}
catch (SteamException)
{
Expand Down
2 changes: 1 addition & 1 deletion src/AET.SteamAbstraction/Vdf/Linq/VConditional.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace AET.SteamAbstraction.Vdf.Linq;

internal class VConditional : VToken
{
private readonly List<Token> _tokens = new();
private readonly List<Token> _tokens = [];

public override VTokenType Type => VTokenType.Conditional;

Expand Down
2 changes: 1 addition & 1 deletion src/AET.SteamAbstraction/Vdf/Linq/VObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public VToken? this[string key]

public VObject()
{
_children = new List<VToken>();
_children = [];
}

public VObject(VObject other)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace PG.StarWarsGame.Infrastructure.Clients.Arguments;
/// </summary>
public static class GameArgumentNames
{
// ReSharper disable InconsistentNaming
internal const string ModListArg = "MODLIST";
internal const string WindowedArg = "WINDOWED";
internal const string MCEArg = "MCE";
Expand Down Expand Up @@ -68,6 +69,7 @@ public static class GameArgumentNames
internal const string ConsoleCommandFileArg = "CONSOLECOMMANDFILE";
internal const string ConnectPortArg = "CONNECTPORT";
internal const string ConnectIPArg = "CONNECTIP";
// ReSharper enable InconsistentNaming

internal static readonly IReadOnlyCollection<string> SupportedFlagArgumentNames =
new ReadOnlyCollection<string>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments;

// ReSharper disable once InconsistentNaming
/// <summary>
/// Level of detail of LUA logging.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

namespace PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments;

// ReSharper disable InconsistentNaming

#region Flags Normal

/// <summary>
Expand Down Expand Up @@ -304,7 +306,7 @@ internal override string ValueToCommandLine()
/// File location where LUA logging shall be stored to.
/// </summary>
/// <remarks>
/// The directory of the file must already exists.
/// The directory of the file must already exist.
/// </remarks>
public sealed class AILogFileArgument(IFileInfo value, IDirectoryInfo gameDir) : NamedArgument<IFileInfo>(GameArgumentNames.AILogFileArg, value, true)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,43 @@

namespace PG.StarWarsGame.Infrastructure.Clients.Utilities;

internal class GameExecutableFileUtilities
/// <summary>
/// Provides utility methods for locating game executable files for different game platforms and build types.
/// </summary>
public static class GameExecutableFileUtilities
{
private const string SteamFileNameBase = "StarWars";
private const string SteamReleaseSuffix = "G";
private const string SteamDebugSuffix = "I";

/// <summary>
/// Gets the executable file for the specified game and build type or <see langword="null"/> if not found.
/// </summary>
/// <param name="game">The game for which to locate the executable file.</param>
/// <param name="buildType">The build type of the game executable to locate.</param>
/// <returns>An <see cref="IFileInfo"/> representing the executable file if found; otherwise, <see langword="null"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="game"/> is <see langword="null"/>.</exception>
public static IFileInfo? GetExecutableForGame(IGame game, GameBuildType buildType)
{
var exeFileName = GetExecutableFileName(game, buildType);
if (game == null)
throw new ArgumentNullException(nameof(game));

if (string.IsNullOrEmpty(exeFileName))
// Only SteamGold supports debug builds
if (buildType == GameBuildType.Debug && game.Platform != GamePlatform.SteamGold)
return null;

var exeFileName = GetExecutableFileName(game, buildType);

return game.Directory
.EnumerateFiles(exeFileName!, SearchOption.TopDirectoryOnly)
.EnumerateFiles(exeFileName, SearchOption.TopDirectoryOnly)
.FirstOrDefault();
}

private static string? GetExecutableFileName(IGame game, GameBuildType buildType)
private static string GetExecutableFileName(IGame game, GameBuildType buildType)
{
if (game.Platform == GamePlatform.SteamGold)
return GetSteamFileName(buildType);

if (buildType is GameBuildType.Debug)
return null;

return game.Type switch
{
GameType.Eaw => PetroglyphStarWarsGameConstants.EmpireAtWarExeFileName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ namespace PG.StarWarsGame.Infrastructure.Games;
public class PetroglyphStarWarsGame : PlayableModContainer, IGame
{
private readonly string _normalizedPath;
private IDirectoryInfo? _modLocation;


/// <summary>
/// Gets the file system of this game.
/// </summary>
Expand All @@ -40,13 +39,13 @@ public IDirectoryInfo ModsLocation
{
get
{
if (_modLocation is null)
if (field is null)
{
var fs = Directory.FileSystem;
var modsPath = fs.Path.Combine(Directory.FullName, "Mods");
_modLocation = fs.DirectoryInfo.New(modsPath);
field = fs.DirectoryInfo.New(modsPath);
}
return _modLocation;
return field;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace PG.StarWarsGame.Infrastructure.Games.Registry;

internal sealed class GameRegistry : IGameRegistry
{
// ReSharper disable InconsistentNaming
internal const string VersionKey = "1.0";
internal const string CDKeyProperty = "CD Key";
internal const string EawGoldProperty = "EAWGold";
Expand All @@ -15,6 +16,7 @@ internal sealed class GameRegistry : IGameRegistry
internal const string InstallPathProperty = "InstallPath";
internal const string LauncherProperty = "Launcher";
internal const string RevisionProperty = "Revision";
// ReSharper enable InconsistentNaming

private static readonly Version VersionInstance = new(1, 0);

Expand Down
3 changes: 2 additions & 1 deletion src/PG.StarWarsGame.Infrastructure/IModContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
namespace PG.StarWarsGame.Infrastructure;

/// <summary>
/// This instance can be parent for one or many mods.
/// Defines a container for managing a collection of mods, providing methods to add, remove, and search for mods, as
/// well as an event for tracking modifications to the mod collection.
/// </summary>
public interface IModContainer : IEnumerable<IMod>
{
Expand Down
4 changes: 1 addition & 3 deletions src/PG.StarWarsGame.Infrastructure/Mods/ModBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public abstract class ModBase : PlayableModContainer, IMod
/// <inheritdoc/>
public event EventHandler? DependenciesResolved;

private SemVersion? _modVersion;

/// <inheritdoc/>
public string Identifier { get; }

Expand All @@ -48,7 +46,7 @@ public abstract class ModBase : PlayableModContainer, IMod
public IModinfo? ModInfo { get; protected init; }

/// <inheritdoc/>
public SemVersion? Version => _modVersion ??= InitializeVersion();
public SemVersion? Version => field ??= InitializeVersion();

/// <summary>
/// Gets the mod's dependency list from the modinfo data or an empty list if no modinfo data is specified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AlamoEngineTools.Modinfo" Version="7.0.18" />
<PackageReference Include="AlamoEngineTools.Modinfo" Version="8.0.1" />
<PackageReference Include="AnakinRaW.CommonUtilities" Version="12.3.9" />
<PackageReference Include="AnakinRaW.CommonUtilities.FileSystem" Version="12.3.9" />
<PackageReference Include="AnakinRaW.CommonUtilities.Registry" Version="12.3.9" />
Expand All @@ -36,9 +36,9 @@
</PackageReference>
<PackageReference Include="semver" Version="3.0.0" />
<PackageReference Include="HtmlAgilityPack" Version="1.12.4" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.1" />
<PackageReference Include="QuikGraph" Version="2.5.0" PrivateAssets="compile" />
<PackageReference Include="System.Text.Json" Version="10.0.0" />
<PackageReference Include="System.Text.Json" Version="10.0.1" />
</ItemGroup>
</Project>
17 changes: 7 additions & 10 deletions src/PG.StarWarsGame.Infrastructure/PlayableObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ namespace PG.StarWarsGame.Infrastructure;
/// </summary>
public abstract class PlayableObject(IServiceProvider serviceProvider) : IPlayableObject
{
private IReadOnlyCollection<ILanguageInfo>? _installedLanguages;
private string? _iconFile;

private bool _languageSearched;
private bool _iconSearched;

Expand All @@ -38,12 +35,12 @@ public IReadOnlyCollection<ILanguageInfo> InstalledLanguages
get
{
if (_languageSearched)
return _installedLanguages!;
_installedLanguages = ResolveInstalledLanguages();
if (_installedLanguages is null)
return field!;
field = ResolveInstalledLanguages();
if (field is null)
throw new PetroglyphException("Resolved languages must not be null.");
_languageSearched = true;
return _installedLanguages;
return field;
}
}

Expand All @@ -53,10 +50,10 @@ public string? IconFile
get
{
if (_iconSearched)
return _iconFile;
_iconFile = ResolveIconFile();
return field;
field = ResolveIconFile();
_iconSearched = true;
return _iconFile;
return field;
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/PG.StarWarsGame.Infrastructure/Services/ModFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public IVirtualMod CreateVirtualMod(IGame game, IModinfo virtualModInfo)
private string GetModName(DetectedModReference detectedMod, CultureInfo culture)
{
var name = _nameResolver.ResolveName(detectedMod, culture);
if (string.IsNullOrEmpty(name))
throw new ModException(detectedMod.ModReference, "Unable to create a mod with an empty name.");
return name!;
return string.IsNullOrEmpty(name)
? throw new ModException(detectedMod.ModReference, "Unable to create a mod with an empty name.")
: name;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#if !NET
#pragma warning disable IDE0130
namespace System.Runtime.CompilerServices;
#pragma warning restore IDE0130

[AttributeUsage(AttributeTargets.Parameter)]
internal sealed class CallerArgumentExpressionAttribute(string parameterName) : Attribute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="Testably.Abstractions.Testing" Version="5.0.1" />
<PackageReference Include="xunit" Version="2.9.3" />
Expand Down
2 changes: 1 addition & 1 deletion test/AET.SteamAbstraction.Test/SteamWrapperTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Threading.Tasks;
using AET.SteamAbstraction.Library;
using AET.SteamAbstraction.Registry;
using AET.SteamAbstraction.Test.TestUtilities;
using AET.SteamAbstraction.Testing;
using AET.SteamAbstraction.Testing.Installation;
using AET.SteamAbstraction.Utilities;
using AnakinRaW.CommonUtilities;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="Testably.Abstractions.Testing" Version="5.0.1" />
<PackageReference Include="xunit" Version="2.9.3" />
Expand Down
4 changes: 2 additions & 2 deletions test/AET.SteamAbstraction.Testing/TestProcessHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Microsoft.Extensions.DependencyInjection;
using Xunit;

namespace AET.SteamAbstraction.Test.TestUtilities;
namespace AET.SteamAbstraction.Testing;

public class TestProcessHelper(IServiceProvider sp) : IProcessHelper
{
Expand All @@ -32,7 +32,7 @@ public bool IsProcessRunning(int pid)
return pid == _pid;
}

public Process? StartProcess(ProcessStartInfo startInfo)
public Process StartProcess(ProcessStartInfo startInfo)
{
var registry = _registryFactory.CreateRegistry();
var expectedFileName = registry.ExecutableFile?.FullName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="HtmlAgilityPack" Version="1.12.4" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="Testably.Abstractions.Testing" Version="5.0.1" />
<PackageReference Include="xunit" Version="2.9.3" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Collections.Generic;
using AET.SteamAbstraction;
using AET.SteamAbstraction.Registry;
using AET.SteamAbstraction.Test.TestUtilities;
using AET.SteamAbstraction.Testing;
using AET.SteamAbstraction.Testing.Installation;
using AET.SteamAbstraction.Utilities;
using AnakinRaW.CommonUtilities.Registry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{
var empty = ArgumentCollection.Empty;
Assert.Empty(empty);
Assert.Equal(0, empty.Count);

Check warning on line 16 in test/PG.StarWarsGame.Infrastructure.Test/Clients/Arguments/ArgumentCollectionTest.cs

View workflow job for this annotation

GitHub Actions / Build & Test (windows-latest)

Do not use Assert.Equal() to check for collection size. Use Assert.Empty instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)

Check warning on line 16 in test/PG.StarWarsGame.Infrastructure.Test/Clients/Arguments/ArgumentCollectionTest.cs

View workflow job for this annotation

GitHub Actions / Build & Test (windows-latest)

Do not use Assert.Equal() to check for collection size. Use Assert.Empty instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)
}

[Fact]
Expand All @@ -24,12 +24,12 @@

args.Add(new MapArgument("Map"));

Assert.Equal(1, argList.Count);

Check warning on line 27 in test/PG.StarWarsGame.Infrastructure.Test/Clients/Arguments/ArgumentCollectionTest.cs

View workflow job for this annotation

GitHub Actions / Build & Test (windows-latest)

Do not use Assert.Equal() to check for collection size. Use Assert.Single instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)

Check warning on line 27 in test/PG.StarWarsGame.Infrastructure.Test/Clients/Arguments/ArgumentCollectionTest.cs

View workflow job for this annotation

GitHub Actions / Build & Test (windows-latest)

Do not use Assert.Equal() to check for collection size. Use Assert.Single instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)
var a = Assert.Single(argList);

var e = ((IEnumerable)argList).GetEnumerator();
Assert.True(e.MoveNext());
var o = (GameArgument)e.Current;
var o = (GameArgument)e.Current!;


Assert.Equal(new WindowedArgument(), a);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public static IEnumerable<object[]> GetValidArguments()
var relativeMod = fs.DirectoryInfo.New("with space/otherGame/mods/myMod");
var steamModDir = fs.DirectoryInfo.New("with space/game/mods/123456");

var gameFile = fs.FileInfo.New("game/file.txt");
fs.FileInfo.New("game/file.txt");

foreach (var value in GetValidStringValues)
yield return [TestNamedArg.FromValue(value)];
Expand Down
Loading