From c19f9ea173dd8e12cbb3eb676192b37c4dca7f8e Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 11 Oct 2023 12:29:06 -0400 Subject: [PATCH] Var-ify many instances --- CHANGELIST.md | 1 + MPF.Test/Core/Data/XgdInfoTests.cs | 10 +++++----- MPF.Test/Library/InfoToolTests.cs | 8 ++++---- MPF.Test/Modules/DiscImageCreatorTests.cs | 12 ++++++------ .../External/WPFCustomMessageBox/CustomMessageBox.cs | 6 +++--- MPF.UI.Core/UserControls/LogOutput.xaml.cs | 4 ++-- 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index 531fa18f..3bddef76 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -14,6 +14,7 @@ - Enable nullability in MPF.UI.Core - Enable nullability in MPF.Test - Handle some suggested changes +- Var-ify many instances ### 2.7.0 (2023-10-11) diff --git a/MPF.Test/Core/Data/XgdInfoTests.cs b/MPF.Test/Core/Data/XgdInfoTests.cs index 1d5e6d9a..b6512012 100644 --- a/MPF.Test/Core/Data/XgdInfoTests.cs +++ b/MPF.Test/Core/Data/XgdInfoTests.cs @@ -13,7 +13,7 @@ namespace MPF.Test.Core.Data [InlineData("123456789")] public void UnmatchedStringTests(string invalidString) { - XgdInfo xgdInfo = new XgdInfo(invalidString); + var xgdInfo = new XgdInfo(invalidString); Assert.False(xgdInfo.Initialized); } @@ -22,7 +22,7 @@ namespace MPF.Test.Core.Data [InlineData("AV00100W\0", "AV", "001", "00", 'W')] public void XGD1ValidTests(string validString, string publisher, string gameId, string version, char regionIdentifier) { - XgdInfo xgdInfo = new XgdInfo(validString); + var xgdInfo = new XgdInfo(validString); Assert.True(xgdInfo.Initialized); Assert.NotNull(xgdInfo.XMID); @@ -41,7 +41,7 @@ namespace MPF.Test.Core.Data [InlineData("AV00000Z\0")] public void XGD1InvalidTests(string invalidString) { - XgdInfo xgdInfo = new XgdInfo(invalidString); + var xgdInfo = new XgdInfo(invalidString); Assert.False(xgdInfo.Initialized); } @@ -56,7 +56,7 @@ namespace MPF.Test.Core.Data [InlineData("AV200100W01F11DEADBEEF\0", "AV", "001", "00", 'W', "01", 'F', "11", "DEADBEEF")] public void XGD23ValidTests(string validString, string publisher, string gameId, string sku, char regionIdentifier, string baseVersion, char mediaSubtype, string discNumber, string cert) { - XgdInfo xgdInfo = new XgdInfo(validString); + var xgdInfo = new XgdInfo(validString); Assert.True(xgdInfo.Initialized); Assert.NotNull(xgdInfo.XeMID); @@ -110,7 +110,7 @@ namespace MPF.Test.Core.Data [InlineData("AV200000W00A0000000000\0")] public void XGD23InvalidTests(string invalidString) { - XgdInfo xgdInfo = new XgdInfo(invalidString); + var xgdInfo = new XgdInfo(invalidString); Assert.False(xgdInfo.Initialized); } } diff --git a/MPF.Test/Library/InfoToolTests.cs b/MPF.Test/Library/InfoToolTests.cs index af1b589d..9179cd35 100644 --- a/MPF.Test/Library/InfoToolTests.cs +++ b/MPF.Test/Library/InfoToolTests.cs @@ -79,7 +79,7 @@ namespace MPF.Test.Library public void ProcessSpecialFieldsCompleteTest() { // Create a new SubmissionInfo object - SubmissionInfo info = new SubmissionInfo() + var info = new SubmissionInfo() { CommonDiscInfo = new CommonDiscInfoSection() { @@ -127,7 +127,7 @@ namespace MPF.Test.Library public void ProcessSpecialFieldsNullObjectTest() { // Create a new SubmissionInfo object - SubmissionInfo info = new SubmissionInfo() + var info = new SubmissionInfo() { CommonDiscInfo = null, }; @@ -143,7 +143,7 @@ namespace MPF.Test.Library public void ProcessSpecialFieldsNullCommentsContentsTest() { // Create a new SubmissionInfo object - SubmissionInfo info = new SubmissionInfo() + var info = new SubmissionInfo() { CommonDiscInfo = new CommonDiscInfoSection() { @@ -191,7 +191,7 @@ namespace MPF.Test.Library public void ProcessSpecialFieldsNullDictionariesTest() { // Create a new SubmissionInfo object - SubmissionInfo info = new SubmissionInfo() + var info = new SubmissionInfo() { CommonDiscInfo = new CommonDiscInfoSection() { diff --git a/MPF.Test/Modules/DiscImageCreatorTests.cs b/MPF.Test/Modules/DiscImageCreatorTests.cs index 510f44a4..3f70b01d 100644 --- a/MPF.Test/Modules/DiscImageCreatorTests.cs +++ b/MPF.Test/Modules/DiscImageCreatorTests.cs @@ -34,7 +34,7 @@ namespace MPF.Test.Modules var options = new Options(); var actual = new Parameters(knownSystem, mediaType, 'D', "disc.bin", 16, options); - HashSet expectedSet = new HashSet(expected ?? Array.Empty()); + var expectedSet = new HashSet(expected ?? Array.Empty()); HashSet actualSet = GenerateUsedKeys(actual); Assert.Equal(expectedSet, actualSet); } @@ -47,7 +47,7 @@ namespace MPF.Test.Modules var options = new Options { DICRereadCount = rereadC2 }; var actual = new Parameters(knownSystem, mediaType, 'D', "disc.bin", 16, options); - HashSet expectedSet = new HashSet(expected ?? Array.Empty()); + var expectedSet = new HashSet(expected ?? Array.Empty()); HashSet actualSet = GenerateUsedKeys(actual); Assert.Equal(expectedSet, actualSet); @@ -67,7 +67,7 @@ namespace MPF.Test.Modules var options = new Options { DICDVDRereadCount = rereadDVDBD }; var actual = new Parameters(knownSystem, mediaType, 'D', "disc.bin", 16, options); - HashSet expectedSet = new HashSet(expected ?? Array.Empty()); + var expectedSet = new HashSet(expected ?? Array.Empty()); HashSet actualSet = GenerateUsedKeys(actual); Assert.Equal(expectedSet, actualSet); @@ -91,7 +91,7 @@ namespace MPF.Test.Modules var options = new Options { DICMultiSectorRead = multiSectorRead }; var actual = new Parameters(knownSystem, mediaType, 'D', "disc.bin", 16, options); - HashSet expectedSet = new HashSet(expected ?? Array.Empty()); + var expectedSet = new HashSet(expected ?? Array.Empty()); HashSet actualSet = GenerateUsedKeys(actual); Assert.Equal(expectedSet, actualSet); if (expectedSet.Count != 1 && multiSectorRead) @@ -112,7 +112,7 @@ namespace MPF.Test.Modules var options = new Options { DICParanoidMode = paranoidMode }; var actual = new Parameters(knownSystem, mediaType, 'D', "disc.bin", 16, options); - HashSet expectedSet = new HashSet(expected ?? Array.Empty()); + var expectedSet = new HashSet(expected ?? Array.Empty()); HashSet actualSet = GenerateUsedKeys(actual); Assert.Equal(expectedSet, actualSet); if (paranoidMode) @@ -258,7 +258,7 @@ namespace MPF.Test.Modules /// HashSet representing the strings private static HashSet GenerateUsedKeys(Parameters parameters) { - HashSet usedKeys = new HashSet(); + var usedKeys = new HashSet(); if (parameters?.Keys == null) return usedKeys; diff --git a/MPF.UI.Core/External/WPFCustomMessageBox/CustomMessageBox.cs b/MPF.UI.Core/External/WPFCustomMessageBox/CustomMessageBox.cs index 49c9f1e4..67f6754f 100644 --- a/MPF.UI.Core/External/WPFCustomMessageBox/CustomMessageBox.cs +++ b/MPF.UI.Core/External/WPFCustomMessageBox/CustomMessageBox.cs @@ -527,7 +527,7 @@ namespace WPFCustomMessageBox { MessageBoxButton buttonLayout = string.IsNullOrEmpty(cancelButtonText) ? MessageBoxButton.OK : MessageBoxButton.OKCancel; - CustomMessageBoxWindow msg = new CustomMessageBoxWindow(owner, messageBoxText, caption, buttonLayout, icon, RemoveTitleBarIcon); + var msg = new CustomMessageBoxWindow(owner, messageBoxText, caption, buttonLayout, icon, RemoveTitleBarIcon); if (!string.IsNullOrEmpty(okButtonText)) msg.OkButtonText = okButtonText; if (!string.IsNullOrEmpty(cancelButtonText)) @@ -561,7 +561,7 @@ namespace WPFCustomMessageBox { MessageBoxButton buttonLayout = string.IsNullOrEmpty(cancelButtonText) ? MessageBoxButton.YesNo : MessageBoxButton.YesNoCancel; - CustomMessageBoxWindow msg = new CustomMessageBoxWindow(owner, messageBoxText, caption, buttonLayout, icon, RemoveTitleBarIcon); + var msg = new CustomMessageBoxWindow(owner, messageBoxText, caption, buttonLayout, icon, RemoveTitleBarIcon); if (!string.IsNullOrEmpty(yesButtonText)) msg.YesButtonText = yesButtonText; if (!string.IsNullOrEmpty(noButtonText)) @@ -585,7 +585,7 @@ namespace WPFCustomMessageBox { //System.Threading.Timer timer = null; //timer = new System.Threading.Timer(s => { msg.Close(); timer.Dispose(); }, null, timeout.Value, System.Threading.Timeout.Infinite); - System.Timers.Timer timer = new System.Timers.Timer(timeout.Value) { AutoReset = false }; + var timer = new System.Timers.Timer(timeout.Value) { AutoReset = false }; timer.Elapsed += delegate { Application.Current.Dispatcher.Invoke(new Action(() => { diff --git a/MPF.UI.Core/UserControls/LogOutput.xaml.cs b/MPF.UI.Core/UserControls/LogOutput.xaml.cs index 22ed8190..85186586 100644 --- a/MPF.UI.Core/UserControls/LogOutput.xaml.cs +++ b/MPF.UI.Core/UserControls/LogOutput.xaml.cs @@ -188,12 +188,12 @@ namespace MPF.UI.Core.UserControls /// private void SaveInlines() { - using (StreamWriter tw = new StreamWriter(File.OpenWrite("console.log"))) + using (var sw = new StreamWriter(File.OpenWrite("console.log"))) { foreach (var inline in _paragraph.Inlines) { if (inline is Run run) - tw.Write(run.Text); + sw.Write(run.Text); } } }