From d68bcfb96aea4c7cf7864d03f268dd097cc0e176 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 22 Nov 2023 23:38:59 -0500 Subject: [PATCH] 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. --- CHANGELIST.md | 1 + MPF.Check/MPF.Check.csproj | 2 +- MPF.Check/Program.cs | 2 +- MPF.Core/DumpEnvironment.cs | 6 +++--- MPF.Core/MPF.Core.csproj | 2 +- MPF.Core/Protection.cs | 4 ++-- MPF.Core/SubmissionInfoTool.cs | 12 ++++++------ MPF.Core/UI/ViewModels/MainViewModel.cs | 6 +++--- MPF.Core/UI/ViewModels/OptionsViewModel.cs | 4 +--- MPF.UI.Core/Windows/MainWindow.xaml.cs | 4 ++-- MPF.UI.Core/Windows/OptionsWindow.xaml.cs | 2 +- 11 files changed, 22 insertions(+), 23 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index cb398629..49b7e49a 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -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) diff --git a/MPF.Check/MPF.Check.csproj b/MPF.Check/MPF.Check.csproj index 9600995e..9ebc334d 100644 --- a/MPF.Check/MPF.Check.csproj +++ b/MPF.Check/MPF.Check.csproj @@ -2,7 +2,7 @@ - net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0 + net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0 win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64 Exe false diff --git a/MPF.Check/Program.cs b/MPF.Check/Program.cs index 2ccfa141..de8dee4c 100644 --- a/MPF.Check/Program.cs +++ b/MPF.Check/Program.cs @@ -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; diff --git a/MPF.Core/DumpEnvironment.cs b/MPF.Core/DumpEnvironment.cs index 7ec090a2..047ec1dc 100644 --- a/MPF.Core/DumpEnvironment.cs +++ b/MPF.Core/DumpEnvironment.cs @@ -219,7 +219,7 @@ namespace MPF.Core /// Execute the initial invocation of the dumping programs /// /// Optional result progress callback -#if NET20 || NET40 +#if NET40 public Result Run(IProgress? progress = null) #else public async Task Run(IProgress? 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 ExecuteInternalProgram(BaseParameters parameters) { Process childProcess; -#if NET20 || NET40 +#if NET40 string output = await Task.Factory.StartNew(() => #else string output = await Task.Run(() => diff --git a/MPF.Core/MPF.Core.csproj b/MPF.Core/MPF.Core.csproj index b2df9894..4c6190d0 100644 --- a/MPF.Core/MPF.Core.csproj +++ b/MPF.Core/MPF.Core.csproj @@ -2,7 +2,7 @@ - net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0 + net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0 win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64 false latest diff --git a/MPF.Core/Protection.cs b/MPF.Core/Protection.cs index 81d1d476..d14c4a27 100644 --- a/MPF.Core/Protection.cs +++ b/MPF.Core/Protection.cs @@ -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 diff --git a/MPF.Core/SubmissionInfoTool.cs b/MPF.Core/SubmissionInfoTool.cs index 19afaede..876d1719 100644 --- a/MPF.Core/SubmissionInfoTool.cs +++ b/MPF.Core/SubmissionInfoTool.cs @@ -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 /// Options object representing user-defined options /// Existing SubmissionInfo object to fill /// Optional result progress callback -#if NET20 || NET40 +#if NET40 public static bool FillFromRedump(Options options, SubmissionInfo info, IProgress? resultProgress = null) #else public async static Task FillFromRedump(Options options, SubmissionInfo info, IProgress? 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; diff --git a/MPF.Core/UI/ViewModels/MainViewModel.cs b/MPF.Core/UI/ViewModels/MainViewModel.cs index b7192ffb..e24448b5 100644 --- a/MPF.Core/UI/ViewModels/MainViewModel.cs +++ b/MPF.Core/UI/ViewModels/MainViewModel.cs @@ -1419,7 +1419,7 @@ namespace MPF.Core.UI.ViewModels /// /// Scan and show copy protection for the current disc /// -#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(); 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); diff --git a/MPF.Core/UI/ViewModels/OptionsViewModel.cs b/MPF.Core/UI/ViewModels/OptionsViewModel.cs index 13495e8b..6e4f71ec 100644 --- a/MPF.Core/UI/ViewModels/OptionsViewModel.cs +++ b/MPF.Core/UI/ViewModels/OptionsViewModel.cs @@ -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)); diff --git a/MPF.UI.Core/Windows/MainWindow.xaml.cs b/MPF.UI.Core/Windows/MainWindow.xaml.cs index 2a88bf7d..eadfdc37 100644 --- a/MPF.UI.Core/Windows/MainWindow.xaml.cs +++ b/MPF.UI.Core/Windows/MainWindow.xaml.cs @@ -328,13 +328,13 @@ namespace MPF.UI.Core.Windows /// /// Handler for CopyProtectScanButton Click event /// -#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(); diff --git a/MPF.UI.Core/Windows/OptionsWindow.xaml.cs b/MPF.UI.Core/Windows/OptionsWindow.xaml.cs index 32afc84c..fa4603f7 100644 --- a/MPF.UI.Core/Windows/OptionsWindow.xaml.cs +++ b/MPF.UI.Core/Windows/OptionsWindow.xaml.cs @@ -207,7 +207,7 @@ namespace MPF.UI.Core.Windows /// /// Test Redump credentials for validity /// -#if NET20 || NET35 || NET40 +#if NET40 private void OnRedumpTestClick(object sender, EventArgs e) { var validateTask = ValidateRedumpCredentials();