Support .NET Framework 2.0

This does not include the UI, as per the same reasons why .NET Framework 4.0 doesn't support it.
This commit is contained in:
Matt Nadareski
2023-11-22 23:38:59 -05:00
parent d2433e4749
commit d68bcfb96a
11 changed files with 22 additions and 23 deletions

View File

@@ -32,6 +32,7 @@
- Re-enable .NET Framework 4.0 building in Check
- Support .NET Framework 3.5
- Update compatibility libraries
- Support .NET Framework 2.0
### 3.0.0 (2023-11-14)

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<!-- Assembly Properties -->
<TargetFrameworks>net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
<OutputType>Exe</OutputType>
<CheckEolTargetFramework>false</CheckEolTargetFramework>

View File

@@ -74,7 +74,7 @@ namespace MPF.Check
var env = new DumpEnvironment(options, filepath, drive, knownSystem, mediaType, internalProgram: null, parameters: null);
// Finally, attempt to do the output dance
#if NET20 || NET35 || NET40
#if NET40
var resultTask = env.VerifyAndSaveDumpOutput(resultProgress, protectionProgress);
resultTask.Wait();
var result = resultTask.Result;

View File

@@ -219,7 +219,7 @@ namespace MPF.Core
/// Execute the initial invocation of the dumping programs
/// </summary>
/// <param name="progress">Optional result progress callback</param>
#if NET20 || NET40
#if NET40
public Result Run(IProgress<Result>? progress = null)
#else
public async Task<Result> Run(IProgress<Result>? progress = null)
@@ -249,7 +249,7 @@ namespace MPF.Core
if (!string.IsNullOrEmpty(directoryName))
Directory.CreateDirectory(directoryName);
#if NET20 || NET40
#if NET40
var executeTask = Task.Factory.StartNew(() => Parameters.ExecuteInternalProgram(Options.ToolsInSeparateWindow));
executeTask.Wait();
#else
@@ -447,7 +447,7 @@ namespace MPF.Core
private static async Task<string> ExecuteInternalProgram(BaseParameters parameters)
{
Process childProcess;
#if NET20 || NET40
#if NET40
string output = await Task.Factory.StartNew(() =>
#else
string output = await Task.Run(() =>

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<!-- Assembly Properties -->
<TargetFrameworks>net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<LangVersion>latest</LangVersion>

View File

@@ -23,7 +23,7 @@ namespace MPF.Core
{
try
{
#if NET20 || NET40
#if NET40
var found = await Task.Factory.StartNew(() =>
{
var scanner = new BinaryObjectScanner.Scanner(
@@ -117,7 +117,7 @@ namespace MPF.Core
if (string.IsNullOrEmpty(path))
return false;
#if NET20 || NET40
#if NET40
return await Task.Factory.StartNew(() =>
{
try

View File

@@ -99,7 +99,7 @@ namespace MPF.Core
// Get a list of matching IDs for each line in the DAT
if (!string.IsNullOrEmpty(info.TracksAndWriteOffsets!.ClrMameProData) && options.HasRedumpLogin)
#if NET20 || NET35 || NET40
#if NET40
_ = FillFromRedump(options, info, resultProgress);
#else
_ = await FillFromRedump(options, info, resultProgress);
@@ -445,7 +445,7 @@ namespace MPF.Core
/// <param name="options">Options object representing user-defined options</param>
/// <param name="info">Existing SubmissionInfo object to fill</param>
/// <param name="resultProgress">Optional result progress callback</param>
#if NET20 || NET40
#if NET40
public static bool FillFromRedump(Options options, SubmissionInfo info, IProgress<Result>? resultProgress = null)
#else
public async static Task<bool> FillFromRedump(Options options, SubmissionInfo info, IProgress<Result>? resultProgress = null)
@@ -510,7 +510,7 @@ namespace MPF.Core
continue;
}
#if NET20 || NET35 || NET40
#if NET40
var validateTask = Validator.ValidateSingleTrack(wc, info, hashData);
validateTask.Wait();
(bool singleFound, var foundIds, string? result) = validateTask.Result;
@@ -543,7 +543,7 @@ namespace MPF.Core
// If we don't have any matches but we have a universal hash
if (!info.PartiallyMatchedIDs.Any() && info.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.UniversalHash) == true)
{
#if NET20 || NET35 || NET40
#if NET40
var validateTask = Validator.ValidateUniversalHash(wc, info);
validateTask.Wait();
(bool singleFound, var foundIds, string? result) = validateTask.Result;
@@ -586,7 +586,7 @@ namespace MPF.Core
for (int i = 0; i < totalMatchedIDsCount; i++)
{
// Skip if the track count doesn't match
#if NET20 || NET35 || NET40
#if NET40
var validateTask = Validator.ValidateTrackCount(wc, fullyMatchedIDs[i], trackCount);
validateTask.Wait();
if (!validateTask.Result)
@@ -597,7 +597,7 @@ namespace MPF.Core
// Fill in the fields from the existing ID
resultProgress?.Report(Result.Success($"Filling fields from existing ID {fullyMatchedIDs[i]}..."));
#if NET20 || NET40
#if NET40
var fillTask = Task.Factory.StartNew(() => Builder.FillFromId(wc, info, fullyMatchedIDs[i], options.PullAllInformation));
fillTask.Wait();
_ = fillTask.Result;

View File

@@ -1419,7 +1419,7 @@ namespace MPF.Core.UI.ViewModels
/// <summary>
/// Scan and show copy protection for the current disc
/// </summary>
#if NET20 || NET35 || NET40
#if NET40
public (string?, string?) ScanAndShowProtection()
#else
public async Task<(string?, string?)> ScanAndShowProtection()
@@ -1443,7 +1443,7 @@ namespace MPF.Core.UI.ViewModels
var progress = new Progress<ProtectionProgress>();
progress.ProgressChanged += ProgressUpdated;
#if NET20 || NET35 || NET40
#if NET40
var protectionTask = Protection.RunProtectionScanOnPath(this.CurrentDrive.Name, this.Options, progress);
protectionTask.Wait();
var (protections, error) = protectionTask.Result;
@@ -1611,7 +1611,7 @@ namespace MPF.Core.UI.ViewModels
_environment.ReportStatus += ProgressUpdated;
// Run the program with the parameters
#if NET20 || NET40
#if NET40
Result result = _environment.Run(resultProgress);
#else
Result result = await _environment.Run(resultProgress);

View File

@@ -82,9 +82,7 @@ namespace MPF.Core.UI.ViewModels
public static async Task<(bool?, string?)> TestRedumpLogin(string username, string password)
#endif
{
#if NET20 || NET35
return await Task.Run(() => RedumpWebClient.ValidateCredentials(username, password));
#elif NET40
#if NET40
return Task.Factory.StartNew(() => RedumpWebClient.ValidateCredentials(username, password));
#elif NETFRAMEWORK
return await Task.Run(() => RedumpWebClient.ValidateCredentials(username, password));

View File

@@ -328,13 +328,13 @@ namespace MPF.UI.Core.Windows
/// <summary>
/// Handler for CopyProtectScanButton Click event
/// </summary>
#if NET20 || NET35 || NET40
#if NET40
public void CopyProtectScanButtonClick(object sender, RoutedEventArgs e)
#else
public async void CopyProtectScanButtonClick(object sender, RoutedEventArgs e)
#endif
{
#if NET20 || NET35 || NET40
#if NET40
var (output, error) = MainViewModel.ScanAndShowProtection();
#else
var (output, error) = await MainViewModel.ScanAndShowProtection();

View File

@@ -207,7 +207,7 @@ namespace MPF.UI.Core.Windows
/// <summary>
/// Test Redump credentials for validity
/// </summary>
#if NET20 || NET35 || NET40
#if NET40
private void OnRedumpTestClick(object sender, EventArgs e)
{
var validateTask = ValidateRedumpCredentials();