diff --git a/CHANGELIST.md b/CHANGELIST.md index 678d0209..526e00b2 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -25,6 +25,7 @@ - Get Check building with Framework 4.0 - Use TryGetValue on dictionaries - Support proper async in .NET Framework 4.0 +- Temporarily remove .NET Framework 4.0 ### 3.0.0 (2023-11-14) diff --git a/MPF.Check/MPF.Check.csproj b/MPF.Check/MPF.Check.csproj index c17e3a76..25623fa2 100644 --- a/MPF.Check/MPF.Check.csproj +++ b/MPF.Check/MPF.Check.csproj @@ -2,7 +2,7 @@ - net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0 + 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 6fb549e2..6f766399 100644 --- a/MPF.Check/Program.cs +++ b/MPF.Check/Program.cs @@ -74,7 +74,11 @@ namespace MPF.Check var env = new DumpEnvironment(options, filepath, drive, knownSystem, mediaType, internalProgram: null, parameters: null); // Finally, attempt to do the output dance +#if NET40 + var result = env.VerifyAndSaveDumpOutput(resultProgress, protectionProgress); +#else var result = env.VerifyAndSaveDumpOutput(resultProgress, protectionProgress).ConfigureAwait(false).GetAwaiter().GetResult(); +#endif Console.WriteLine(result.Message); } } diff --git a/MPF.Core/MPF.Core.csproj b/MPF.Core/MPF.Core.csproj index c13ee408..93243be0 100644 --- a/MPF.Core/MPF.Core.csproj +++ b/MPF.Core/MPF.Core.csproj @@ -2,7 +2,7 @@ - net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0 + 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 @@ -24,6 +24,30 @@ + + + + + + + + + + + + + + + + + + + + + runtime; compile; build; native; analyzers; buildtransitive @@ -35,31 +59,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/MPF.Core/SubmissionInfoTool.cs b/MPF.Core/SubmissionInfoTool.cs index 10b2f487..61fb6dca 100644 --- a/MPF.Core/SubmissionInfoTool.cs +++ b/MPF.Core/SubmissionInfoTool.cs @@ -442,7 +442,11 @@ namespace MPF.Core /// Existing SubmissionInfo object to fill /// Optional result progress callback /// TODO: All instances of Task.Factory.StartNew should be propigated down to RedumpLib +#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) +#endif { // If no username is provided if (string.IsNullOrWhiteSpace(options.RedumpUsername) || string.IsNullOrWhiteSpace(options.RedumpPassword)) @@ -504,7 +508,9 @@ namespace MPF.Core } #if NET40 - (bool singleFound, var foundIds, string? result) = await Task.Factory.StartNew(() => Validator.ValidateSingleTrack(wc, info, hashData)); + var validateTask = Task.Factory.StartNew(() => Validator.ValidateSingleTrack(wc, info, hashData)); + validateTask.Wait(); + (bool singleFound, var foundIds, string? result) = validateTask.Result; #else (bool singleFound, var foundIds, string? result) = await Validator.ValidateSingleTrack(wc, info, hashData); #endif @@ -535,7 +541,9 @@ namespace MPF.Core if (!info.PartiallyMatchedIDs.Any() && info.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.UniversalHash) == true) { #if NET40 - (bool singleFound, var foundIds, string? result) = await Task.Factory.StartNew(() => Validator.ValidateUniversalHash(wc, info)); + var validateTask = Task.Factory.StartNew(() => Validator.ValidateUniversalHash(wc, info)); + validateTask.Wait(); + (bool singleFound, var foundIds, string? result) = validateTask.Result; #else (bool singleFound, var foundIds, string? result) = await Validator.ValidateUniversalHash(wc, info); #endif @@ -576,7 +584,9 @@ namespace MPF.Core { // Skip if the track count doesn't match #if NET40 - if (!await Task.Factory.StartNew(() => Validator.ValidateTrackCount(wc, fullyMatchedIDs[i], trackCount))) + var validateTask = Task.Factory.StartNew(() => Validator.ValidateTrackCount(wc, fullyMatchedIDs[i], trackCount)); + validateTask.Wait(); + if (!validateTask.Result) #else if (!await Validator.ValidateTrackCount(wc, fullyMatchedIDs[i], trackCount)) #endif @@ -585,7 +595,9 @@ namespace MPF.Core // Fill in the fields from the existing ID resultProgress?.Report(Result.Success($"Filling fields from existing ID {fullyMatchedIDs[i]}...")); #if NET40 - _ = await Task.Factory.StartNew(() => Builder.FillFromId(wc, info, fullyMatchedIDs[i], options.PullAllInformation)); + var fillTask = Task.Factory.StartNew(() => Builder.FillFromId(wc, info, fullyMatchedIDs[i], options.PullAllInformation)); + fillTask.Wait(); + _ = fillTask.Result; #else _ = await Builder.FillFromId(wc, info, fullyMatchedIDs[i], options.PullAllInformation); #endif diff --git a/MPF.Core/UI/ViewModels/MainViewModel.cs b/MPF.Core/UI/ViewModels/MainViewModel.cs index 822167fb..8b77ab39 100644 --- a/MPF.Core/UI/ViewModels/MainViewModel.cs +++ b/MPF.Core/UI/ViewModels/MainViewModel.cs @@ -1411,7 +1411,11 @@ namespace MPF.Core.UI.ViewModels /// /// Scan and show copy protection for the current disc /// +#if NET40 + public (string?, string?) ScanAndShowProtection() +#else public async Task<(string?, string?)> ScanAndShowProtection() +#endif { // Determine current environment, just in case _environment ??= DetermineEnvironment(); @@ -1431,7 +1435,13 @@ namespace MPF.Core.UI.ViewModels var progress = new Progress(); progress.ProgressChanged += ProgressUpdated; +#if NET40 + var protectionTask = Protection.RunProtectionScanOnPath(this.CurrentDrive.Name, this.Options, progress); + protectionTask.Wait(); + var (protections, error) = protectionTask.Result; +#else var (protections, error) = await Protection.RunProtectionScanOnPath(this.CurrentDrive.Name, this.Options, progress); +#endif var output = Protection.FormatProtections(protections); // If SmartE is detected on the current disc, remove `/sf` from the flags for DIC only -- Disabled until further notice diff --git a/MPF.Core/UI/ViewModels/OptionsViewModel.cs b/MPF.Core/UI/ViewModels/OptionsViewModel.cs index 76e204ca..6e4f71ec 100644 --- a/MPF.Core/UI/ViewModels/OptionsViewModel.cs +++ b/MPF.Core/UI/ViewModels/OptionsViewModel.cs @@ -76,10 +76,14 @@ namespace MPF.Core.UI.ViewModels /// /// Test Redump login credentials /// +#if NET40 + public static Task<(bool?, string?)> TestRedumpLogin(string username, string password) +#else public static async Task<(bool?, string?)> TestRedumpLogin(string username, string password) +#endif { #if NET40 - return await Task.Factory.StartNew(() => RedumpWebClient.ValidateCredentials(username, password)); + return Task.Factory.StartNew(() => RedumpWebClient.ValidateCredentials(username, password)); #elif NETFRAMEWORK return await Task.Run(() => RedumpWebClient.ValidateCredentials(username, password)); #else diff --git a/MPF.Core/Utilities/Logging.cs b/MPF.Core/Utilities/Logging.cs index 1d976db0..89429ae1 100644 --- a/MPF.Core/Utilities/Logging.cs +++ b/MPF.Core/Utilities/Logging.cs @@ -15,7 +15,7 @@ namespace MPF.Core.Utilities /// Invoking class, passed on to the event handler /// Event handler to be invoked to write to log #if NET40 - public static async Task OutputToLog(TextReader reader, object baseClass, EventHandler? handler) + public static void OutputToLog(TextReader reader, object baseClass, EventHandler? handler) #else public static async Task OutputToLog(TextReader reader, object baseClass, EventHandler? handler) #endif @@ -31,7 +31,9 @@ namespace MPF.Core.Utilities { // Try to read the next chunk of characters #if NET40 - read = await Task.Factory.StartNew(() => reader.Read(buffer, 0, buffer.Length)); + var readTask = Task.Factory.StartNew(() => reader.Read(buffer, 0, buffer.Length)); + readTask.Wait(); + read = readTask.Result; #else read = await reader.ReadAsync(buffer, 0, buffer.Length); #endif diff --git a/MPF.UI.Core/MPF.UI.Core.csproj b/MPF.UI.Core/MPF.UI.Core.csproj index 7e22f14a..a99f4222 100644 --- a/MPF.UI.Core/MPF.UI.Core.csproj +++ b/MPF.UI.Core/MPF.UI.Core.csproj @@ -2,7 +2,7 @@ - net40;net452;net462;net472;net48;netcoreapp3.1;net5.0-windows;net6.0-windows;net7.0-windows;net8.0-windows + net452;net462;net472;net48;netcoreapp3.1;net5.0-windows;net6.0-windows;net7.0-windows;net8.0-windows win-x86;win-x64 false latest @@ -31,9 +31,10 @@ - - - + +