Version-gate some more newer syntax

This commit is contained in:
Matt Nadareski
2023-10-11 13:07:45 -04:00
parent c55d5183fb
commit b68ec78184
5 changed files with 36 additions and 22 deletions

View File

@@ -17,6 +17,7 @@
- Var-ify many instances
- Version-gate some newer syntax
- Fix Check always showing Help text
- Version-gate some more newer syntax
### 2.7.0 (2023-10-11)

View File

@@ -38,7 +38,11 @@ namespace MPF.Core.UI.ViewModels
/// <summary>
/// List of Redump-supported Regions
/// </summary>
#if NET48
private static readonly List<Region> RedumpRegions = new List<Region>
#else
private static readonly List<Region> RedumpRegions = new()
#endif
{
Region.Argentina,
Region.Asia,
@@ -129,7 +133,11 @@ namespace MPF.Core.UI.ViewModels
/// <summary>
/// List of Redump-supported Languages
/// </summary>
#if NET48
private static readonly List<Language> RedumpLanguages = new List<Language>
#else
private static readonly List<Language> RedumpLanguages = new()
#endif
{
Language.Afrikaans,
Language.Albanian,

View File

@@ -589,8 +589,7 @@ namespace MPF.Core.UI.ViewModels
DisableEventHandlers();
// If the property change event is initialized
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
// Reenable event handlers, if necessary
if (cachedCanExecuteSelectionChanged) EnableEventHandlers();
@@ -1116,8 +1115,7 @@ namespace MPF.Core.UI.ViewModels
/// <param name="text">Text to write to the log</param>
private void Log(string text)
{
if (_logger != null)
_logger(LogLevel.USER, text);
_logger?.Invoke(LogLevel.USER, text);
}
/// <summary>
@@ -1132,8 +1130,7 @@ namespace MPF.Core.UI.ViewModels
/// <param name="text">Text to write to the log</param>
private void ErrorLog(string text)
{
if (_logger != null)
_logger(LogLevel.ERROR, text);
_logger?.Invoke(LogLevel.ERROR, text);
}
/// <summary>
@@ -1148,8 +1145,7 @@ namespace MPF.Core.UI.ViewModels
/// <param name="text">Text to write to the log</param>
private void SecretLog(string text)
{
if (_logger != null)
_logger(LogLevel.SECRET, text);
_logger?.Invoke(LogLevel.SECRET, text);
}
/// <summary>
@@ -1433,7 +1429,7 @@ namespace MPF.Core.UI.ViewModels
// Catch this in case there's an input path issue
try
{
int driveIndex = Drives.Select(d => d.Letter).ToList().IndexOf(_environment.Parameters?.InputPath?[0] ?? default(char));
int driveIndex = Drives.Select(d => d.Letter).ToList().IndexOf(_environment.Parameters?.InputPath?[0] ?? default);
this.CurrentDrive = (driveIndex != -1 ? Drives[driveIndex] : Drives[0]);
}
catch { }
@@ -1470,8 +1466,12 @@ namespace MPF.Core.UI.ViewModels
#endif
{
// Determine current environment, just in case
#if NET48
if (_environment == null)
_environment = DetermineEnvironment();
#else
_environment ??= DetermineEnvironment();
#endif
// If we don't have a valid drive
if (this.CurrentDrive == null || this.CurrentDrive.Letter == default(char))
@@ -1789,7 +1789,7 @@ namespace MPF.Core.UI.ViewModels
return true;
}
#endregion
#endregion
#region Progress Reporting
@@ -1804,7 +1804,11 @@ namespace MPF.Core.UI.ViewModels
{
try
{
#if NET48
value = value ?? string.Empty;
#else
value ??= string.Empty;
#endif
LogLn(value);
}
catch { }

View File

@@ -228,17 +228,18 @@ namespace MPF.Core.Utilities
/// </summary>
public static List<string> PrintSupportedArguments()
{
var supportedArguments = new List<string>();
supportedArguments.Add("-u, --use <program> Dumping program output type [REQUIRED]");
supportedArguments.Add("-c, --credentials <user> <pw> Redump username and password");
supportedArguments.Add("-a, --pull-all Pull all information from Redump (requires --credentials)");
supportedArguments.Add("-p, --path <drivepath> Physical drive path for additional checks");
supportedArguments.Add("-s, --scan Enable copy protection scan (requires --path)");
supportedArguments.Add("-f, --protect-file Output protection to separate file (requires --scan)");
supportedArguments.Add("-l, --load-seed <path> Load a seed submission JSON for user information");
supportedArguments.Add("-j, --json Enable submission JSON output");
supportedArguments.Add("-z, --zip Enable log file compression");
var supportedArguments = new List<string>
{
"-u, --use <program> Dumping program output type [REQUIRED]",
"-c, --credentials <user> <pw> Redump username and password",
"-a, --pull-all Pull all information from Redump (requires --credentials)",
"-p, --path <drivepath> Physical drive path for additional checks",
"-s, --scan Enable copy protection scan (requires --path)",
"-f, --protect-file Output protection to separate file (requires --scan)",
"-l, --load-seed <path> Load a seed submission JSON for user information",
"-j, --json Enable submission JSON output",
"-z, --zip Enable log file compression"
};
return supportedArguments;
}

View File

@@ -37,7 +37,7 @@ namespace WPFCustomMessageBox
const int SWP_NOMOVE = 0x0002;
const int SWP_NOZORDER = 0x0004;
const int SWP_FRAMECHANGED = 0x0020;
const uint WM_SETICON = 0x0080;
//const uint WM_SETICON = 0x0080;
internal static ImageSource ToImageSource(this Icon icon)