Skip to content

Commit

Permalink
Merge pull request #137 from AlamoEngine-Tools/develop
Browse files Browse the repository at this point in the history
Steam Name resolver do not throw on non-steam mods
  • Loading branch information
AnakinRaW authored Aug 3, 2024
2 parents add1bd3 + 4c13d9a commit ff2ffd4
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 14 deletions.
1 change: 0 additions & 1 deletion sample/SampleApplication/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using PG.StarWarsGame.Infrastructure.Services.Dependencies;
using PG.StarWarsGame.Infrastructure.Services.Detection;
using PG.StarWarsGame.Infrastructure.Services.Name;
using PG.StarWarsGame.Infrastructure.Services.Steam;


var services = SetupApplication();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
using System.Threading;
using System.Threading.Tasks;
using AET.SteamAbstraction.Games;
#if NET
using System.Diagnostics.CodeAnalysis;
#endif

namespace AET.SteamAbstraction;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal class GameExecutableFileService(IServiceProvider serviceProvider) : IGa
if (string.IsNullOrEmpty(exeFileName))
return null;

#if NETSTANDARD2_1_OR_GREATER
#if NETSTANDARD2_1_OR_GREATER || NET
return game.Directory
.EnumerateFiles(exeFileName, new EnumerationOptions { MatchCasing = MatchCasing.CaseInsensitive })
.FirstOrDefault();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Threading;
using System.Threading.Tasks;
#if NETSTANDARD2_0_OR_GREATER
#endif

namespace PG.StarWarsGame.Infrastructure.Clients.Processes;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<RootNamespace>PG.StarWarsGame.Infrastructure</RootNamespace>
<AssemblyName>PG.StarWarsGame.Infrastructure</AssemblyName>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected internal override GameLocationData FindGameLocation(GameDetectorOption
private IDirectoryInfo? FindSuitableSubDirectory(GameType type)
{
var subDirectories = type switch
#if NET
#if NET || NETSTANDARD2_1_OR_GREATER
{
GameType.Eaw => _directory.EnumerateDirectories(KnownEawSubDirName,
new EnumerationOptions { MatchCasing = MatchCasing.CaseInsensitive, RecurseSubdirectories = true }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ public CompositeModNameResolver(IServiceProvider serviceProvider, Func<IServiceP
{
try
{
_logger?.LogDebug($"Resolving mod name with {nameResolver}");
_logger?.LogTrace($"Resolving mod name with {nameResolver}");
var name = nameResolver.ResolveName(modReference, culture);
if (!string.IsNullOrEmpty(name))
return name;
}
catch (Exception e)
{
_logger?.LogDebug(e, $"Error while resolving mod name for '{modReference}' with resolver {nameResolver.GetType()}: {e.Message}");
_logger?.LogError(e, $"Error while resolving mod name for '{modReference}' with resolver {nameResolver.GetType()}: {e.Message}");
throw;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public OfflineWorkshopNameResolver(IServiceProvider serviceProvider) : base(serv
protected internal override string? ResolveCore(IModReference modReference, CultureInfo culture)
{
if (modReference.Type != ModType.Workshops)
throw new NotSupportedException("Can only resolve for Steam Workshop mods!");
return null;

if (!_steamHelper.ToSteamWorkshopsId(modReference.Identifier, out var modId))
throw new ModException(modReference, $"Cannot get SteamID from workshops object {modReference.Identifier}");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ namespace PG.StarWarsGame.Infrastructure.Services.Name;
public sealed class OnlineWorkshopNameResolver : ModNameResolverBase
{
private readonly ISteamGameHelpers _steamHelper;

private readonly ConcurrentDictionary<ulong, string?> _nameCache;

/// <inheritdoc/>
Expand All @@ -30,7 +29,7 @@ public OnlineWorkshopNameResolver(IServiceProvider serviceProvider) : base(servi
protected internal override string? ResolveCore(IModReference modReference, CultureInfo culture)
{
if (modReference.Type != ModType.Workshops)
throw new NotSupportedException("Can only resolve for Steam Workshop mods!");
return null;

if (!_steamHelper.ToSteamWorkshopsId(modReference.Identifier, out var modId))
throw new ModException(modReference, $"Cannot get SteamID from workshops object {modReference.Identifier}");
Expand Down

0 comments on commit ff2ffd4

Please sign in to comment.