From 00407d6f241dc8d734454b918be5e6b66fb1ab2d Mon Sep 17 00:00:00 2001 From: Gustave Monce Date: Sat, 12 Oct 2024 13:40:24 +0200 Subject: [PATCH] Cleanup --- WPinternals/7zip/Common/CommandLineParser.cs | 4 ++-- .../DiscUtils.Core/Internal/Utilities.cs | 2 +- .../DiscUtils/DiscUtils.Fat/ClusterStream.cs | 10 +------- .../DiscUtils/DiscUtils.Fat/FatBuffer.cs | 4 ++-- .../DiscUtils.Fat/Modified/Directory.cs | 4 ++-- .../DiscUtils.Fat/Modified/FatFileSystem.cs | 14 +++++------ WPinternals/HelperClasses.cs | 8 +++---- WPinternals/Models/GPT.cs | 4 ++-- WPinternals/Models/LumiaDownloadModel.cs | 8 +++---- WPinternals/Models/NokiaPhoneModel.cs | 6 ++--- WPinternals/Models/PatchEngine.cs | 16 ++++++------- WPinternals/Models/Privileges.cs | 4 ++-- WPinternals/Models/QualcommLoader.cs | 2 +- WPinternals/Models/QualcommSahara.cs | 2 +- WPinternals/Models/UEFI.cs | 2 +- WPinternals/Terminal.cs | 2 +- WPinternals/ViewModels/DownloadsViewModel.cs | 4 ++-- .../ViewModels/LumiaFlashRomViewModel.cs | 2 +- .../LumiaUnlockBootloaderViewModel.cs | 14 +++++------ .../ViewModels/LumiaV2UnlockBootViewModel.cs | 24 +++++++++---------- WPinternals/ViewModels/NokiaLabelViewModel.cs | 19 +++++++++++---- WPinternals/ViewModels/SwitchModeViewModel.cs | 18 ++++++++++---- WPinternals/WPinternalsConfig.cs | 8 +++---- WPinternals/WinUSBNet/API/DeviceManagement.cs | 2 +- WPinternals/WinUSBNet/API/WinUSBDevice.cs | 2 +- WPinternals/WinUSBNet/USBDevice.cs | 2 +- .../WinUSBNet/USBInterfaceCollection.cs | 2 +- 27 files changed, 99 insertions(+), 90 deletions(-) diff --git a/WPinternals/7zip/Common/CommandLineParser.cs b/WPinternals/7zip/Common/CommandLineParser.cs index 6facd78..43d7524 100644 --- a/WPinternals/7zip/Common/CommandLineParser.cs +++ b/WPinternals/7zip/Common/CommandLineParser.cs @@ -47,7 +47,7 @@ namespace SevenZip.CommandLineParser { public bool ThereIs; public bool WithMinus; - public ArrayList PostStrings = new(); + public ArrayList PostStrings = []; public int PostCharIndex; public SwitchResult() { @@ -57,7 +57,7 @@ namespace SevenZip.CommandLineParser public class Parser { - public ArrayList NonSwitchStrings = new(); + public ArrayList NonSwitchStrings = []; private readonly SwitchResult[] _switches; public Parser(int numSwitches) diff --git a/WPinternals/DiscUtils/DiscUtils.Core/Internal/Utilities.cs b/WPinternals/DiscUtils/DiscUtils.Core/Internal/Utilities.cs index c02593a..0c4e20b 100644 --- a/WPinternals/DiscUtils/DiscUtils.Core/Internal/Utilities.cs +++ b/WPinternals/DiscUtils/DiscUtils.Core/Internal/Utilities.cs @@ -61,7 +61,7 @@ namespace DiscUtils.Internal /// The resultant array. public static U[] Map(IEnumerable source, Func func) { - List result = new(); + List result = []; foreach (T sVal in source) { diff --git a/WPinternals/DiscUtils/DiscUtils.Fat/ClusterStream.cs b/WPinternals/DiscUtils/DiscUtils.Fat/ClusterStream.cs index 67f050f..85d2cc0 100644 --- a/WPinternals/DiscUtils/DiscUtils.Fat/ClusterStream.cs +++ b/WPinternals/DiscUtils/DiscUtils.Fat/ClusterStream.cs @@ -48,15 +48,7 @@ namespace DiscUtils.Fat _fat = fileSystem.Fat; _length = length; - _knownClusters = new List(); - if (firstCluster != 0) - { - _knownClusters.Add(firstCluster); - } - else - { - _knownClusters.Add(FatBuffer.EndOfChain); - } + _knownClusters = [firstCluster != 0 ? firstCluster : FatBuffer.EndOfChain]; if (_length == uint.MaxValue) { diff --git a/WPinternals/DiscUtils/DiscUtils.Fat/FatBuffer.cs b/WPinternals/DiscUtils/DiscUtils.Fat/FatBuffer.cs index a18d3c2..f10425b 100644 --- a/WPinternals/DiscUtils/DiscUtils.Fat/FatBuffer.cs +++ b/WPinternals/DiscUtils/DiscUtils.Fat/FatBuffer.cs @@ -64,7 +64,7 @@ namespace DiscUtils.Fat { _type = type; _buffer = buffer; - _dirtySectors = new Dictionary(); + _dirtySectors = []; } internal int NumEntries @@ -220,7 +220,7 @@ namespace DiscUtils.Fat internal List GetChain(uint head) { - List result = new(); + List result = []; if (head != 0) { diff --git a/WPinternals/DiscUtils/DiscUtils.Fat/Modified/Directory.cs b/WPinternals/DiscUtils/DiscUtils.Fat/Modified/Directory.cs index b790669..a1b3126 100644 --- a/WPinternals/DiscUtils/DiscUtils.Fat/Modified/Directory.cs +++ b/WPinternals/DiscUtils/DiscUtils.Fat/Modified/Directory.cs @@ -452,8 +452,8 @@ namespace DiscUtils.Fat private void LoadEntries() { - _entries = new Dictionary(); - _freeEntries = new List(); + _entries = []; + _freeEntries = []; _selfEntryLocation = -1; _parentEntryLocation = -1; diff --git a/WPinternals/DiscUtils/DiscUtils.Fat/Modified/FatFileSystem.cs b/WPinternals/DiscUtils/DiscUtils.Fat/Modified/FatFileSystem.cs index 6e82bcf..6a8030c 100644 --- a/WPinternals/DiscUtils/DiscUtils.Fat/Modified/FatFileSystem.cs +++ b/WPinternals/DiscUtils/DiscUtils.Fat/Modified/FatFileSystem.cs @@ -94,7 +94,7 @@ namespace DiscUtils.Fat public FatFileSystem(Stream data) : base(new FatFileSystemOptions()) { - _dirCache = new Dictionary(); + _dirCache = []; _timeConverter = DefaultTimeConverter; Initialize(data); } @@ -111,7 +111,7 @@ namespace DiscUtils.Fat public FatFileSystem(Stream data, Ownership ownsData) : base(new FatFileSystemOptions()) { - _dirCache = new Dictionary(); + _dirCache = []; _timeConverter = DefaultTimeConverter; Initialize(data); _ownsData = ownsData; @@ -125,7 +125,7 @@ namespace DiscUtils.Fat public FatFileSystem(Stream data, TimeConverter timeConverter) : base(new FatFileSystemOptions()) { - _dirCache = new Dictionary(); + _dirCache = []; _timeConverter = timeConverter; Initialize(data); } @@ -140,7 +140,7 @@ namespace DiscUtils.Fat public FatFileSystem(Stream data, Ownership ownsData, TimeConverter timeConverter) : base(new FatFileSystemOptions()) { - _dirCache = new Dictionary(); + _dirCache = []; _timeConverter = timeConverter; Initialize(data); _ownsData = ownsData; @@ -156,7 +156,7 @@ namespace DiscUtils.Fat public FatFileSystem(Stream data, Ownership ownsData, FileSystemParameters parameters) : base(new FatFileSystemOptions(parameters)) { - _dirCache = new Dictionary(); + _dirCache = []; if (parameters?.TimeConverter != null) { @@ -1273,7 +1273,7 @@ namespace DiscUtils.Fat { Regex re = Utilities.ConvertWildcardsToRegEx(searchPattern); - List dirs = new(); + List dirs = []; DoSearch(dirs, path, re, searchOption == SearchOption.AllDirectories, true, false); return [.. dirs]; } @@ -1309,7 +1309,7 @@ namespace DiscUtils.Fat { Regex re = Utilities.ConvertWildcardsToRegEx(searchPattern); - List results = new(); + List results = []; DoSearch(results, path, re, searchOption == SearchOption.AllDirectories, false, true); return [.. results]; } diff --git a/WPinternals/HelperClasses.cs b/WPinternals/HelperClasses.cs index 54b98b2..ba11ded 100644 --- a/WPinternals/HelperClasses.cs +++ b/WPinternals/HelperClasses.cs @@ -279,7 +279,7 @@ namespace WPinternals { public CollapsibleSection() { - CollapsibleBlocks = new List(); + CollapsibleBlocks = []; } protected override void OnInitialized(EventArgs e) @@ -915,7 +915,7 @@ namespace WPinternals { public static void AddWeakReferenceHandler(ref List handlers, EventHandler handler, int defaultListSize) { - (handlers ??= (defaultListSize > 0) ? new List(defaultListSize) : new List()).Add(new WeakReference(handler)); + (handlers ??= (defaultListSize > 0) ? new List(defaultListSize) : []).Add(new WeakReference(handler)); } private static void CallHandler(object sender, EventHandler eventHandler) @@ -1925,7 +1925,7 @@ namespace WPinternals #if PREVIEW internal static class Uploader { - internal static List Uploads = new List(); + internal static List Uploads = []; internal static void Upload(string FileName, string Text) { @@ -1949,7 +1949,7 @@ namespace WPinternals { System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; System.Net.Http.HttpClient httpClient = new System.Net.Http.HttpClient(); - System.Net.Http.MultipartFormDataContent form = new System.Net.Http.MultipartFormDataContent(); + System.Net.Http.MultipartFormDataContent form = []; System.Net.Http.StreamContent Content = new System.Net.Http.StreamContent(FileStream); Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("text/plain"); form.Add(Content, InputName, FileName); diff --git a/WPinternals/Models/GPT.cs b/WPinternals/Models/GPT.cs index 287fb9e..9ece00d 100644 --- a/WPinternals/Models/GPT.cs +++ b/WPinternals/Models/GPT.cs @@ -42,7 +42,7 @@ namespace WPinternals internal bool HasChanged = false; [XmlElement("Partition")] - public List Partitions = new(); + public List Partitions = []; public GPT() // Only for serialization { @@ -334,7 +334,7 @@ namespace WPinternals } } - List DynamicPartitions = new(); + List DynamicPartitions = []; if (Archive != null) { // Partitions which are present in the archive, and which have no start-sector in the new GPT data (dynamic relocation), diff --git a/WPinternals/Models/LumiaDownloadModel.cs b/WPinternals/Models/LumiaDownloadModel.cs index 8764076..e9c6377 100644 --- a/WPinternals/Models/LumiaDownloadModel.cs +++ b/WPinternals/Models/LumiaDownloadModel.cs @@ -327,7 +327,7 @@ namespace WPinternals ProductType = "RM-1113"; } - List Result = new(); + List Result = []; WebClient Client = new(); string Src; @@ -488,7 +488,7 @@ namespace WPinternals { this.apiVersion = "1"; this.query = new DiscoveryQueryParameters(); - this.condition = new List(); + this.condition = []; if (Condition == DiscoveryCondition.All) { this.condition.Add("all"); @@ -517,14 +517,14 @@ namespace WPinternals public ExtendedAttributes() { - this.Dictionary = new Dictionary(); + this.Dictionary = []; } protected ExtendedAttributes(SerializationInfo info, StreamingContext context) { if (info != null) { - this.Dictionary = new Dictionary(); + this.Dictionary = []; SerializationInfoEnumerator Enumerator = info.GetEnumerator(); while (Enumerator.MoveNext()) { diff --git a/WPinternals/Models/NokiaPhoneModel.cs b/WPinternals/Models/NokiaPhoneModel.cs index 2fab9e6..35af4b5 100644 --- a/WPinternals/Models/NokiaPhoneModel.cs +++ b/WPinternals/Models/NokiaPhoneModel.cs @@ -56,7 +56,7 @@ namespace WPinternals const string jsonrpc = "2.0"; int id = MessageId++; string method = JsonMethod; - Dictionary @params = new(); + Dictionary @params = []; if (Params != null) { foreach (KeyValuePair Param in Params) @@ -191,7 +191,7 @@ namespace WPinternals const string jsonrpc = "2.0"; int id = MessageId++; string method = JsonMethod; - Dictionary @params = new(); + Dictionary @params = []; if (Params != null) { foreach (KeyValuePair Param in Params) @@ -279,7 +279,7 @@ namespace WPinternals const string jsonrpc = "2.0"; int id = MessageId++; string method = JsonMethod; - Dictionary @params = new(); + Dictionary @params = []; if (Params != null) { foreach (KeyValuePair Param in Params) diff --git a/WPinternals/Models/PatchEngine.cs b/WPinternals/Models/PatchEngine.cs index 440b8a8..bb2d892 100644 --- a/WPinternals/Models/PatchEngine.cs +++ b/WPinternals/Models/PatchEngine.cs @@ -33,8 +33,8 @@ namespace WPinternals { internal class PatchEngine { - internal List PatchDefinitions = new(); - internal readonly List TargetRedirections = new(); + internal List PatchDefinitions = []; + internal readonly List TargetRedirections = []; internal PatchEngine() { } @@ -115,7 +115,7 @@ namespace WPinternals internal bool Patch(string PatchDefinition) { bool Result = false; - List LoadedFiles = new(); + List LoadedFiles = []; LogFile.Log("Attempt patch: " + PatchDefinition); @@ -237,7 +237,7 @@ namespace WPinternals internal void Restore(string PatchDefinition) { - List LoadedFiles = new(); + List LoadedFiles = []; try { @@ -492,7 +492,7 @@ namespace WPinternals [XmlAttribute] public string Name; - public List TargetVersions = new(); + public List TargetVersions = []; } public class TargetVersion // Must be public to be serializable @@ -500,7 +500,7 @@ namespace WPinternals [XmlAttribute] public string Description; - public List TargetFiles = new(); + public List TargetFiles = []; } public class TargetFile // Must be public to be serializable @@ -549,8 +549,8 @@ namespace WPinternals } } - public List Patches = new(); - public List Obsolete = new(); + public List Patches = []; + public List Obsolete = []; } public class Patch // Must be public to be serializable diff --git a/WPinternals/Models/Privileges.cs b/WPinternals/Models/Privileges.cs index 11f420f..5017b33 100644 --- a/WPinternals/Models/Privileges.cs +++ b/WPinternals/Models/Privileges.cs @@ -35,8 +35,8 @@ namespace WPinternals { #region Private static members private static readonly LocalDataStoreSlot tlsSlot = Thread.AllocateDataSlot(); - private static readonly HybridDictionary privileges = new(); - private static readonly HybridDictionary luids = new(); + private static readonly HybridDictionary privileges = []; + private static readonly HybridDictionary luids = []; private static readonly ReaderWriterLock privilegeLock = new(); #endregion diff --git a/WPinternals/Models/QualcommLoader.cs b/WPinternals/Models/QualcommLoader.cs index c5ac384..a935ba1 100644 --- a/WPinternals/Models/QualcommLoader.cs +++ b/WPinternals/Models/QualcommLoader.cs @@ -29,7 +29,7 @@ namespace WPinternals { internal static List GetPossibleLoadersForRootKeyHash(string Path, byte[] RootKeyHash) { - List Result = new(); + List Result = []; try { diff --git a/WPinternals/Models/QualcommSahara.cs b/WPinternals/Models/QualcommSahara.cs index f23c18c..309f8ce 100644 --- a/WPinternals/Models/QualcommSahara.cs +++ b/WPinternals/Models/QualcommSahara.cs @@ -117,7 +117,7 @@ namespace WPinternals byte[] Response = Serial.GetResponse(null, Length: (int)RKHLength); - List RootKeyHashes = new(); + List RootKeyHashes = []; for (int i = 0; i < RKHLength / 0x20; i++) { RootKeyHashes.Add(Response[(i * 0x20)..((i + 1) * 0x20)]); diff --git a/WPinternals/Models/UEFI.cs b/WPinternals/Models/UEFI.cs index 0140200..0d17280 100644 --- a/WPinternals/Models/UEFI.cs +++ b/WPinternals/Models/UEFI.cs @@ -39,7 +39,7 @@ namespace WPinternals { internal byte[] Binary; private byte[] DecompressedImage; - internal List EFIs = new(); + internal List EFIs = []; private readonly byte PaddingByteValue = 0xFF; private readonly UInt32 DecompressedVolumeSectionHeaderOffset; private readonly UInt32 DecompressedVolumeHeaderOffset; diff --git a/WPinternals/Terminal.cs b/WPinternals/Terminal.cs index df55734..c58cf54 100644 --- a/WPinternals/Terminal.cs +++ b/WPinternals/Terminal.cs @@ -61,7 +61,7 @@ namespace WPinternals internal class TerminalResponse { - public Dictionary RawEntries = new(); + public Dictionary RawEntries = []; public byte[] PublicId = null; public byte[] RootKeyHash = null; } diff --git a/WPinternals/ViewModels/DownloadsViewModel.cs b/WPinternals/ViewModels/DownloadsViewModel.cs index c1a165e..f6e1eba 100644 --- a/WPinternals/ViewModels/DownloadsViewModel.cs +++ b/WPinternals/ViewModels/DownloadsViewModel.cs @@ -382,8 +382,8 @@ namespace WPinternals App.Config.AddSecWimToRepository(Files[0], (string)State); } - public ObservableCollection DownloadList { get; } = new(); - public ObservableCollection SearchResultList { get; } = new(); + public ObservableCollection DownloadList { get; } = []; + public ObservableCollection SearchResultList { get; } = []; private DelegateCommand _DownloadSelectedCommand = null; public DelegateCommand DownloadSelectedCommand diff --git a/WPinternals/ViewModels/LumiaFlashRomViewModel.cs b/WPinternals/ViewModels/LumiaFlashRomViewModel.cs index d5ca718..0b8d53c 100644 --- a/WPinternals/ViewModels/LumiaFlashRomViewModel.cs +++ b/WPinternals/ViewModels/LumiaFlashRomViewModel.cs @@ -549,7 +549,7 @@ namespace WPinternals Phone = (LumiaFlashAppModel)PhoneNotifier.CurrentModel; FlashPart Part; - List FlashParts = new(); + List FlashParts = []; Partition NvBackupPartition = GPT.GetPartition("BACKUP_BS_NV"); if (NvBackupPartition != null) diff --git a/WPinternals/ViewModels/LumiaUnlockBootloaderViewModel.cs b/WPinternals/ViewModels/LumiaUnlockBootloaderViewModel.cs index 4c37e86..adbc23a 100644 --- a/WPinternals/ViewModels/LumiaUnlockBootloaderViewModel.cs +++ b/WPinternals/ViewModels/LumiaUnlockBootloaderViewModel.cs @@ -1683,7 +1683,7 @@ namespace WPinternals ((LumiaBootManagerAppModel)Notifier.CurrentModel).SwitchToFlashAppContext(); - List FlashParts = new(); + List FlashParts = []; if (UndoEFIESPPadding) { @@ -1928,7 +1928,7 @@ namespace WPinternals LogFile.Log("Enabling Test Signing", LogType.FileAndConsole); SetWorkingStatus("Enabling Test Signing", null, null); - List Parts = new(); + List Parts = []; FlashPart Part; // Now add NV partition @@ -2020,7 +2020,7 @@ namespace WPinternals ShouldApplyOldEFIESPMethod = false; } - Parts = ShouldApplyOldEFIESPMethod ? new List() : LumiaGenerateEFIESPFlashPayload(UnlockedEFIESP, GPT, ProfileFFU, IsSpecB); + Parts = ShouldApplyOldEFIESPMethod ? [] : LumiaGenerateEFIESPFlashPayload(UnlockedEFIESP, GPT, ProfileFFU, IsSpecB); Part = null; UInt32 OriginalEfiespSizeInSectors = (UInt32)GPT.GetPartition("EFIESP").SizeInSectors; @@ -2214,7 +2214,7 @@ namespace WPinternals SetWorkingStatus("Problem detected, rolling back...", ErrorMessage); await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash); - Parts = new List(); + Parts = []; // Restore original GPT, which will also reference the original NV. Part = new FlashPart @@ -2390,7 +2390,7 @@ namespace WPinternals GPT.Partitions.Add(IsUnlockedFlag); } - Parts = new List(); + Parts = []; GPT.Rebuild(); Part = new FlashPart { @@ -2528,7 +2528,7 @@ namespace WPinternals byte[] SecondEFIESP = NewEFIESP.Skip((int)SectorSize * ReservedOGSectors).Take((int)(NewEFIESP.Length - (ReservedSectors * SectorSize))).ToArray(); - List Parts = new(); + List Parts = []; FlashPart Part = new(); Part.StartSector = (uint)EFIESP.FirstSector; @@ -2559,7 +2559,7 @@ namespace WPinternals byte[] FirstSector = DeviceFFU.GetPartition("EFIESP").Take(EFIESPFirstPartSize).ToArray(); - List Parts = new(); + List Parts = []; FlashPart Part = new(); Part.StartSector = (uint)EFIESP.FirstSector; diff --git a/WPinternals/ViewModels/LumiaV2UnlockBootViewModel.cs b/WPinternals/ViewModels/LumiaV2UnlockBootViewModel.cs index 76912d1..3af7249 100644 --- a/WPinternals/ViewModels/LumiaV2UnlockBootViewModel.cs +++ b/WPinternals/ViewModels/LumiaV2UnlockBootViewModel.cs @@ -127,7 +127,7 @@ namespace WPinternals UIContext.Send(s => Notifier.Start(), null); LumiaFlashAppModel FlashModel = (LumiaFlashAppModel)await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash); - List Parts = new(); + List Parts = []; FlashPart Part; // Use GetGptChunk() here instead of ReadGPT(), because ReadGPT() skips the first sector. @@ -261,7 +261,7 @@ namespace WPinternals PhoneNotifierViewModel Notifier = new(); UIContext.Send(s => Notifier.Start(), null); LumiaFlashAppModel FlashModel = (LumiaFlashAppModel)await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash); - List Parts = new(); + List Parts = []; // Use GetGptChunk() here instead of ReadGPT(), because ReadGPT() skips the first sector. // We need the fist sector if we want to write back the GPT. @@ -355,7 +355,7 @@ namespace WPinternals bool IsUnlocked = false; bool GPTChanged = false; - List Parts = new(); + List Parts = []; FlashPart Part; if (string.Equals(PartitionName, "EFIESP", StringComparison.CurrentCultureIgnoreCase)) { @@ -468,16 +468,14 @@ namespace WPinternals { using MemoryStream Stream = new(Data); FlashPart Part = new() { StartSector = StartSector, Stream = Stream }; - List Parts = new(); - Parts.Add(Part); + List Parts = [Part]; await LumiaV2CustomFlash(Notifier, FFUPath, PerformFullFlashFirst, SkipWrite, Parts, DoResetFirst, ClearFlashingStatusAtEnd, CheckSectorAlignment, ShowProgress, Experimental); } internal async static Task LumiaV2CustomFlash(PhoneNotifierViewModel Notifier, string FFUPath, bool PerformFullFlashFirst, bool SkipWrite, UInt32 StartSector, Stream Data, bool DoResetFirst = true, bool ClearFlashingStatusAtEnd = true, bool CheckSectorAlignment = true, bool ShowProgress = true, bool Experimental = false) //, string LoaderPath = null) { FlashPart Part = new() { StartSector = StartSector, Stream = Data }; - List Parts = new(); - Parts.Add(Part); + List Parts = [Part]; await LumiaV2CustomFlash(Notifier, FFUPath, PerformFullFlashFirst, SkipWrite, Parts, DoResetFirst, ClearFlashingStatusAtEnd, CheckSectorAlignment, ShowProgress, Experimental); } @@ -1880,7 +1878,7 @@ namespace WPinternals SetWorkingStatus("Hashing resources...", "Initializing flash...", (UInt64)TotalProcess1, Status: WPinternalsStatus.Initializing); var crypto = System.Security.Cryptography.SHA256.Create(); - List flashingPayloads = new(); + List flashingPayloads = []; if (flashParts == null) { return [.. flashingPayloads]; @@ -1911,7 +1909,7 @@ namespace WPinternals // internal static FlashingPayload[] GetOptimizedPayloads(List flashParts, Int32 chunkSize, UInt32 MaximumChunkCount, SetWorkingStatus SetWorkingStatus = null, UpdateWorkingStatus UpdateWorkingStatus = null) { - List flashingPayloads = new(); + List flashingPayloads = []; if (flashParts == null) { return [.. flashingPayloads]; @@ -2013,7 +2011,7 @@ namespace WPinternals Partition Target; FlashPart Part; - List Parts = new(); + List Parts = []; ulong MainOSOldSectorCount = 0; ulong MainOSNewSectorCount = 0; ulong DataOldSectorCount = 0; @@ -2406,7 +2404,7 @@ namespace WPinternals Partition Target; FlashPart Part; - List Parts = new(); + List Parts = []; ulong MainOSOldSectorCount = 0; ulong MainOSNewSectorCount = 0; ulong DataOldSectorCount = 0; @@ -2712,8 +2710,8 @@ namespace WPinternals private static UInt32 CurrentBufferSize = 0; public static byte[] Buffer; - private static readonly List Allocations = new(); - private static readonly List FreeMemRanges = new(); + private static readonly List Allocations = []; + private static readonly List FreeMemRanges = []; public static UInt32 RoundUpToPages(UInt32 Size) { diff --git a/WPinternals/ViewModels/NokiaLabelViewModel.cs b/WPinternals/ViewModels/NokiaLabelViewModel.cs index da833c1..b8e9166 100644 --- a/WPinternals/ViewModels/NokiaLabelViewModel.cs +++ b/WPinternals/ViewModels/NokiaLabelViewModel.cs @@ -74,10 +74,21 @@ namespace WPinternals byte[] AsskMask = [1, 0, 16, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64]; byte[] Challenge = new byte[0x88]; - Dictionary Params = new(); - Params.Add("AsskMask", AsskMask); - Params.Add("Challenge", Challenge); - Params.Add("AsicIndex", 0); + Dictionary Params = new() + { + { + "AsskMask", + AsskMask + }, + { + "Challenge", + Challenge + }, + { + "AsicIndex", + 0 + } + }; byte[] TerminalResponseBytes = CurrentModel.ExecuteJsonMethodAsBytes("TerminalChallenge", Params, "TerminalResponse"); if (TerminalResponseBytes != null) { diff --git a/WPinternals/ViewModels/SwitchModeViewModel.cs b/WPinternals/ViewModels/SwitchModeViewModel.cs index 3799d16..4740d4f 100644 --- a/WPinternals/ViewModels/SwitchModeViewModel.cs +++ b/WPinternals/ViewModels/SwitchModeViewModel.cs @@ -289,9 +289,17 @@ namespace WPinternals return; } - Dictionary Params = new(); - Params.Add("DeviceMode", DeviceMode); - Params.Add("ResetMethod", "HwReset"); + Dictionary Params = new() + { + { + "DeviceMode", + DeviceMode + }, + { + "ResetMethod", + "HwReset" + } + }; try { ((NokiaPhoneModel)PhoneNotifier.CurrentModel).ExecuteJsonMethodAsync("SetDeviceMode", Params); @@ -1077,7 +1085,7 @@ namespace WPinternals // We've been reading the GPT, so we let the phone reset once more to be sure that memory maps are the same WPinternalsStatus LastStatus = WPinternalsStatus.Undefined; - List Parts = new(); + List Parts = []; FlashPart Part = new(); Part.StartSector = (uint)Target.FirstSector; Part.Stream = SB; @@ -1286,7 +1294,7 @@ namespace WPinternals // We've been reading the GPT, so we let the phone reset once more to be sure that memory maps are the same WPinternalsStatus LastStatus = WPinternalsStatus.Undefined; - List Parts = new(); + List Parts = []; FlashPart Part = new(); Part.StartSector = (uint)Target.FirstSector; Part.Stream = SB; diff --git a/WPinternals/WPinternalsConfig.cs b/WPinternals/WPinternalsConfig.cs index bc71d5d..4181fac 100644 --- a/WPinternals/WPinternalsConfig.cs +++ b/WPinternals/WPinternalsConfig.cs @@ -151,7 +151,7 @@ namespace WPinternals return FlashProfiles.Find(p => string.Equals(p.PlatformID, PlatformID, StringComparison.CurrentCultureIgnoreCase) && string.Equals(p.PhoneFirmware, PhoneFirmware, StringComparison.CurrentCultureIgnoreCase) && ((FfuFirmware == null) || string.Equals(p.FfuFirmware, FfuFirmware, StringComparison.CurrentCultureIgnoreCase))); } - public List FlashProfiles = new(); + public List FlashProfiles = []; internal void AddFfuToRepository(string FFUPath) { @@ -218,7 +218,7 @@ namespace WPinternals } } - public List FFURepository = new(); + public List FFURepository = []; internal void AddSecWimToRepository(string SecWimPath, string FirmwareVersion) { @@ -264,9 +264,9 @@ namespace WPinternals } } - public List SecWimRepository = new(); + public List SecWimRepository = []; - public List EmergencyRepository = new(); + public List EmergencyRepository = []; internal void AddEmergencyToRepository(string Type, string ProgrammerPath, string PayloadPath) { diff --git a/WPinternals/WinUSBNet/API/DeviceManagement.cs b/WPinternals/WinUSBNet/API/DeviceManagement.cs index 7a7c2c4..ba66565 100644 --- a/WPinternals/WinUSBNet/API/DeviceManagement.cs +++ b/WPinternals/WinUSBNet/API/DeviceManagement.cs @@ -206,7 +206,7 @@ namespace MadWizard.WinUSBNet.API public static DeviceDetails[] FindDevicesFromGuid(Guid guid) { IntPtr deviceInfoSet = IntPtr.Zero; - List deviceList = new(); + List deviceList = []; try { deviceInfoSet = SetupDiGetClassDevs(ref guid, IntPtr.Zero, IntPtr.Zero, diff --git a/WPinternals/WinUSBNet/API/WinUSBDevice.cs b/WPinternals/WinUSBNet/API/WinUSBDevice.cs index e85abd9..3820c1c 100644 --- a/WPinternals/WinUSBNet/API/WinUSBDevice.cs +++ b/WPinternals/WinUSBNet/API/WinUSBDevice.cs @@ -260,7 +260,7 @@ namespace MadWizard.WinUSBNet.API throw APIException.Win32("Failed to initialize WinUSB handle. Device might not be connected."); } - List interfaces = new(); + List interfaces = []; byte numAddInterfaces = 0; byte idx = 0; diff --git a/WPinternals/WinUSBNet/USBDevice.cs b/WPinternals/WinUSBNet/USBDevice.cs index 29a4906..2427c5a 100644 --- a/WPinternals/WinUSBNet/USBDevice.cs +++ b/WPinternals/WinUSBNet/USBDevice.cs @@ -147,7 +147,7 @@ namespace MadWizard.WinUSBNet { int numInterfaces = InternalDevice.InterfaceCount; - List allPipes = new(); + List allPipes = []; InputPipe = null; OutputPipe = null; diff --git a/WPinternals/WinUSBNet/USBInterfaceCollection.cs b/WPinternals/WinUSBNet/USBInterfaceCollection.cs index fd1cc9d..9a0125b 100644 --- a/WPinternals/WinUSBNet/USBInterfaceCollection.cs +++ b/WPinternals/WinUSBNet/USBInterfaceCollection.cs @@ -107,7 +107,7 @@ namespace MadWizard.WinUSBNet /// array if no interface matches. public USBInterface[] FindAll(USBBaseClass interfaceClass) { - List matchingInterfaces = new(); + List matchingInterfaces = []; for (int i = 0; i < _interfaces.Length; i++) { USBInterface iface = _interfaces[i];