mirror of
https://github.com/Ryubing/Ryujinx.git
synced 2025-03-10 17:14:25 +00:00
misc: chore: Change Analyzer AddSpec logic to log the non-hexadecimal value and ignore the added entry instead of throwing an exception
This commit is contained in:
parent
744d813b87
commit
395bbd144a
@ -1,5 +1,6 @@
|
|||||||
using Gommon;
|
using Gommon;
|
||||||
using Ryujinx.Ava.Utilities.AppLibrary;
|
using Ryujinx.Ava.Utilities.AppLibrary;
|
||||||
|
using Ryujinx.Common.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
@ -27,10 +28,12 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
/// <returns>The current <see cref="Analyzer"/>, for chaining convenience.</returns>
|
/// <returns>The current <see cref="Analyzer"/>, for chaining convenience.</returns>
|
||||||
public Analyzer AddSpec(string titleId, Func<GameSpec, GameSpec> transform)
|
public Analyzer AddSpec(string titleId, Func<GameSpec, GameSpec> transform)
|
||||||
{
|
{
|
||||||
Guard.Ensure(ulong.TryParse(titleId, NumberStyles.HexNumber, null, out _),
|
if (ulong.TryParse(titleId, NumberStyles.HexNumber, null, out _))
|
||||||
$"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
|
|
||||||
|
|
||||||
return AddSpec(transform(GameSpec.Create(titleId)));
|
return AddSpec(transform(GameSpec.Create(titleId)));
|
||||||
|
|
||||||
|
Logger.Notice.PrintMsg(LogClass.Application,
|
||||||
|
$"Tried to add a {nameof(GameSpec)} with a non-hexadecimal title ID value. Input: '{titleId}'");
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -41,10 +44,12 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
/// <returns>The current <see cref="Analyzer"/>, for chaining convenience.</returns>
|
/// <returns>The current <see cref="Analyzer"/>, for chaining convenience.</returns>
|
||||||
public Analyzer AddSpec(string titleId, Action<GameSpec> transform)
|
public Analyzer AddSpec(string titleId, Action<GameSpec> transform)
|
||||||
{
|
{
|
||||||
Guard.Ensure(ulong.TryParse(titleId, NumberStyles.HexNumber, null, out _),
|
if (ulong.TryParse(titleId, NumberStyles.HexNumber, null, out _))
|
||||||
$"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
|
|
||||||
|
|
||||||
return AddSpec(GameSpec.Create(titleId).Apply(transform));
|
return AddSpec(GameSpec.Create(titleId).Apply(transform));
|
||||||
|
|
||||||
|
Logger.Notice.PrintMsg(LogClass.Application,
|
||||||
|
$"Tried to add a {nameof(GameSpec)} with a non-hexadecimal title ID value. Input: '{titleId}'");
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -57,10 +62,19 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
Func<GameSpec, GameSpec> transform)
|
Func<GameSpec, GameSpec> transform)
|
||||||
{
|
{
|
||||||
string[] tids = titleIds.ToArray();
|
string[] tids = titleIds.ToArray();
|
||||||
Guard.Ensure(tids.All(x => ulong.TryParse(x, NumberStyles.HexNumber, null, out _)),
|
if (tids.All(x => ulong.TryParse(x, NumberStyles.HexNumber, null, out _) && !string.IsNullOrEmpty(x)))
|
||||||
$"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
|
|
||||||
|
|
||||||
return AddSpec(transform(GameSpec.Create(tids)));
|
return AddSpec(transform(GameSpec.Create(tids)));
|
||||||
|
|
||||||
|
Logger.Notice.PrintMsg(LogClass.Application,
|
||||||
|
$"Tried to add a {nameof(GameSpec)} with a non-hexadecimal title ID value. Input: '{
|
||||||
|
tids.FormatCollection(
|
||||||
|
x => x,
|
||||||
|
separator: ", ",
|
||||||
|
prefix: "[",
|
||||||
|
suffix: "]"
|
||||||
|
)
|
||||||
|
}'");
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -72,10 +86,19 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
public Analyzer AddSpec(IEnumerable<string> titleIds, Action<GameSpec> transform)
|
public Analyzer AddSpec(IEnumerable<string> titleIds, Action<GameSpec> transform)
|
||||||
{
|
{
|
||||||
string[] tids = titleIds.ToArray();
|
string[] tids = titleIds.ToArray();
|
||||||
Guard.Ensure(tids.All(x => ulong.TryParse(x, NumberStyles.HexNumber, null, out _)),
|
if (tids.All(x => ulong.TryParse(x, NumberStyles.HexNumber, null, out _) && !string.IsNullOrEmpty(x)))
|
||||||
$"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
|
|
||||||
|
|
||||||
return AddSpec(GameSpec.Create(tids).Apply(transform));
|
return AddSpec(GameSpec.Create(tids).Apply(transform));
|
||||||
|
|
||||||
|
Logger.Notice.PrintMsg(LogClass.Application,
|
||||||
|
$"Tried to add a {nameof(GameSpec)} with a non-hexadecimal title ID value. Input: '{
|
||||||
|
tids.FormatCollection(
|
||||||
|
x => x,
|
||||||
|
separator: ", ",
|
||||||
|
prefix: "[",
|
||||||
|
suffix: "]"
|
||||||
|
)
|
||||||
|
}'");
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user