Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gus33000 committed Oct 12, 2024
1 parent 2d5b0fd commit 00407d6
Show file tree
Hide file tree
Showing 27 changed files with 99 additions and 90 deletions.
4 changes: 2 additions & 2 deletions WPinternals/7zip/Common/CommandLineParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class SwitchResult
{
public bool ThereIs;
public bool WithMinus;
public ArrayList PostStrings = new();
public ArrayList PostStrings = [];
public int PostCharIndex;
public SwitchResult()
{
Expand All @@ -57,7 +57,7 @@ public SwitchResult()

public class Parser
{
public ArrayList NonSwitchStrings = new();
public ArrayList NonSwitchStrings = [];
private readonly SwitchResult[] _switches;

public Parser(int numSwitches)
Expand Down
2 changes: 1 addition & 1 deletion WPinternals/DiscUtils/DiscUtils.Core/Internal/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static U[] Map<T, U>(ICollection<T> source, Func<T, U> func)
/// <returns>The resultant array.</returns>
public static U[] Map<T, U>(IEnumerable<T> source, Func<T, U> func)
{
List<U> result = new();
List<U> result = [];

foreach (T sVal in source)
{
Expand Down
10 changes: 1 addition & 9 deletions WPinternals/DiscUtils/DiscUtils.Fat/ClusterStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,7 @@ internal ClusterStream(FatFileSystem fileSystem, FileAccess access, uint firstCl
_fat = fileSystem.Fat;
_length = length;

_knownClusters = new List<uint>();
if (firstCluster != 0)
{
_knownClusters.Add(firstCluster);
}
else
{
_knownClusters.Add(FatBuffer.EndOfChain);
}
_knownClusters = [firstCluster != 0 ? firstCluster : FatBuffer.EndOfChain];

if (_length == uint.MaxValue)
{
Expand Down
4 changes: 2 additions & 2 deletions WPinternals/DiscUtils/DiscUtils.Fat/FatBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public FatBuffer(FatType type, byte[] buffer)
{
_type = type;
_buffer = buffer;
_dirtySectors = new Dictionary<uint, uint>();
_dirtySectors = [];
}

internal int NumEntries
Expand Down Expand Up @@ -220,7 +220,7 @@ internal void FreeChain(uint head)

internal List<uint> GetChain(uint head)
{
List<uint> result = new();
List<uint> result = [];

if (head != 0)
{
Expand Down
4 changes: 2 additions & 2 deletions WPinternals/DiscUtils/DiscUtils.Fat/Modified/Directory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,8 @@ internal void UpdateEntry(long id, DirectoryEntry entry)

private void LoadEntries()
{
_entries = new Dictionary<long, DirectoryEntry>();
_freeEntries = new List<long>();
_entries = [];
_freeEntries = [];

_selfEntryLocation = -1;
_parentEntryLocation = -1;
Expand Down
14 changes: 7 additions & 7 deletions WPinternals/DiscUtils/DiscUtils.Fat/Modified/FatFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static FatFileSystem()
public FatFileSystem(Stream data)
: base(new FatFileSystemOptions())
{
_dirCache = new Dictionary<uint, Directory>();
_dirCache = [];
_timeConverter = DefaultTimeConverter;
Initialize(data);
}
Expand All @@ -111,7 +111,7 @@ public FatFileSystem(Stream data)
public FatFileSystem(Stream data, Ownership ownsData)
: base(new FatFileSystemOptions())
{
_dirCache = new Dictionary<uint, Directory>();
_dirCache = [];
_timeConverter = DefaultTimeConverter;
Initialize(data);
_ownsData = ownsData;
Expand All @@ -125,7 +125,7 @@ public FatFileSystem(Stream data, Ownership ownsData)
public FatFileSystem(Stream data, TimeConverter timeConverter)
: base(new FatFileSystemOptions())
{
_dirCache = new Dictionary<uint, Directory>();
_dirCache = [];
_timeConverter = timeConverter;
Initialize(data);
}
Expand All @@ -140,7 +140,7 @@ public FatFileSystem(Stream data, TimeConverter timeConverter)
public FatFileSystem(Stream data, Ownership ownsData, TimeConverter timeConverter)
: base(new FatFileSystemOptions())
{
_dirCache = new Dictionary<uint, Directory>();
_dirCache = [];
_timeConverter = timeConverter;
Initialize(data);
_ownsData = ownsData;
Expand All @@ -156,7 +156,7 @@ public FatFileSystem(Stream data, Ownership ownsData, TimeConverter timeConverte
public FatFileSystem(Stream data, Ownership ownsData, FileSystemParameters parameters)
: base(new FatFileSystemOptions(parameters))
{
_dirCache = new Dictionary<uint, Directory>();
_dirCache = [];

if (parameters?.TimeConverter != null)
{
Expand Down Expand Up @@ -1273,7 +1273,7 @@ public override string[] GetDirectories(string path, string searchPattern, Searc
{
Regex re = Utilities.ConvertWildcardsToRegEx(searchPattern);

List<string> dirs = new();
List<string> dirs = [];
DoSearch(dirs, path, re, searchOption == SearchOption.AllDirectories, true, false);
return [.. dirs];
}
Expand Down Expand Up @@ -1309,7 +1309,7 @@ public override string[] GetFiles(string path, string searchPattern, SearchOptio
{
Regex re = Utilities.ConvertWildcardsToRegEx(searchPattern);

List<string> results = new();
List<string> results = [];
DoSearch(results, path, re, searchOption == SearchOption.AllDirectories, false, true);
return [.. results];
}
Expand Down
8 changes: 4 additions & 4 deletions WPinternals/HelperClasses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ internal class CollapsibleSection : Section
{
public CollapsibleSection()
{
CollapsibleBlocks = new List<Block>();
CollapsibleBlocks = [];
}

protected override void OnInitialized(EventArgs e)
Expand Down Expand Up @@ -915,7 +915,7 @@ internal static class WeakEventHandlerManager
{
public static void AddWeakReferenceHandler(ref List<WeakReference> handlers, EventHandler handler, int defaultListSize)
{
(handlers ??= (defaultListSize > 0) ? new List<WeakReference>(defaultListSize) : new List<WeakReference>()).Add(new WeakReference(handler));
(handlers ??= (defaultListSize > 0) ? new List<WeakReference>(defaultListSize) : []).Add(new WeakReference(handler));
}

private static void CallHandler(object sender, EventHandler eventHandler)
Expand Down Expand Up @@ -1925,7 +1925,7 @@ internal static Version GetProductVersion(byte[] PEfile)
#if PREVIEW
internal static class Uploader
{
internal static List<Task> Uploads = new List<Task>();
internal static List<Task> Uploads = [];

internal static void Upload(string FileName, string Text)
{
Expand All @@ -1949,7 +1949,7 @@ private static void Upload(Uri Address, string InputName, string FileName, Strea
{
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);
Expand Down
4 changes: 2 additions & 2 deletions WPinternals/Models/GPT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class GPT
internal bool HasChanged = false;

[XmlElement("Partition")]
public List<Partition> Partitions = new();
public List<Partition> Partitions = [];

public GPT() // Only for serialization
{
Expand Down Expand Up @@ -334,7 +334,7 @@ internal void MergePartitions(string Xml, bool RoundToChunks, ZipArchive Archive
}
}

List<Partition> DynamicPartitions = new();
List<Partition> DynamicPartitions = [];
if (Archive != null)
{
// Partitions which are present in the archive, and which have no start-sector in the new GPT data (dynamic relocation),
Expand Down
8 changes: 4 additions & 4 deletions WPinternals/Models/LumiaDownloadModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ internal static string[] SearchEmergencyFiles(string ProductType)
ProductType = "RM-1113";
}

List<string> Result = new();
List<string> Result = [];

WebClient Client = new();
string Src;
Expand Down Expand Up @@ -488,7 +488,7 @@ public DiscoveryParameters(DiscoveryCondition Condition)
{
this.apiVersion = "1";
this.query = new DiscoveryQueryParameters();
this.condition = new List<string>();
this.condition = [];
if (Condition == DiscoveryCondition.All)
{
this.condition.Add("all");
Expand Down Expand Up @@ -517,14 +517,14 @@ public class ExtendedAttributes : ISerializable

public ExtendedAttributes()
{
this.Dictionary = new Dictionary<string, string>();
this.Dictionary = [];
}

protected ExtendedAttributes(SerializationInfo info, StreamingContext context)
{
if (info != null)
{
this.Dictionary = new Dictionary<string, string>();
this.Dictionary = [];
SerializationInfoEnumerator Enumerator = info.GetEnumerator();
while (Enumerator.MoveNext())
{
Expand Down
6 changes: 3 additions & 3 deletions WPinternals/Models/NokiaPhoneModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public NokiaPhoneModel(string DevicePath)
const string jsonrpc = "2.0";
int id = MessageId++;
string method = JsonMethod;
Dictionary<string, object> @params = new();
Dictionary<string, object> @params = [];
if (Params != null)
{
foreach (KeyValuePair<string, object> Param in Params)
Expand Down Expand Up @@ -191,7 +191,7 @@ public void ExecuteJsonMethodAsync(string JsonMethod, Dictionary<string, object>
const string jsonrpc = "2.0";
int id = MessageId++;
string method = JsonMethod;
Dictionary<string, object> @params = new();
Dictionary<string, object> @params = [];
if (Params != null)
{
foreach (KeyValuePair<string, object> Param in Params)
Expand Down Expand Up @@ -279,7 +279,7 @@ public void ExecuteJsonMethodAsTokenAsync(string JsonMethod, Dictionary<string,
const string jsonrpc = "2.0";
int id = MessageId++;
string method = JsonMethod;
Dictionary<string, object> @params = new();
Dictionary<string, object> @params = [];
if (Params != null)
{
foreach (KeyValuePair<string, object> Param in Params)
Expand Down
16 changes: 8 additions & 8 deletions WPinternals/Models/PatchEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ namespace WPinternals
{
internal class PatchEngine
{
internal List<PatchDefinition> PatchDefinitions = new();
internal readonly List<TargetRedirection> TargetRedirections = new();
internal List<PatchDefinition> PatchDefinitions = [];
internal readonly List<TargetRedirection> TargetRedirections = [];

internal PatchEngine() { }

Expand Down Expand Up @@ -115,7 +115,7 @@ internal DiscUtils.DiscFileSystem TargetImage
internal bool Patch(string PatchDefinition)
{
bool Result = false;
List<FilePatcher> LoadedFiles = new();
List<FilePatcher> LoadedFiles = [];

LogFile.Log("Attempt patch: " + PatchDefinition);

Expand Down Expand Up @@ -237,7 +237,7 @@ internal bool Patch(string PatchDefinition)

internal void Restore(string PatchDefinition)
{
List<FilePatcher> LoadedFiles = new();
List<FilePatcher> LoadedFiles = [];

try
{
Expand Down Expand Up @@ -492,15 +492,15 @@ public class PatchDefinition // Must be public to be serializable
[XmlAttribute]
public string Name;

public List<TargetVersion> TargetVersions = new();
public List<TargetVersion> TargetVersions = [];
}

public class TargetVersion // Must be public to be serializable
{
[XmlAttribute]
public string Description;

public List<TargetFile> TargetFiles = new();
public List<TargetFile> TargetFiles = [];
}

public class TargetFile // Must be public to be serializable
Expand Down Expand Up @@ -549,8 +549,8 @@ public string HashPatchedAsString
}
}

public List<Patch> Patches = new();
public List<TargetFile> Obsolete = new();
public List<Patch> Patches = [];
public List<TargetFile> Obsolete = [];
}

public class Patch // Must be public to be serializable
Expand Down
4 changes: 2 additions & 2 deletions WPinternals/Models/Privileges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ internal sealed class Privilege
{
#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

Expand Down
2 changes: 1 addition & 1 deletion WPinternals/Models/QualcommLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal static class QualcommLoaders
{
internal static List<QualcommPartition> GetPossibleLoadersForRootKeyHash(string Path, byte[] RootKeyHash)
{
List<QualcommPartition> Result = new();
List<QualcommPartition> Result = [];

try
{
Expand Down
2 changes: 1 addition & 1 deletion WPinternals/Models/QualcommSahara.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public byte[][] GetRKHs()

byte[] Response = Serial.GetResponse(null, Length: (int)RKHLength);

List<byte[]> RootKeyHashes = new();
List<byte[]> RootKeyHashes = [];
for (int i = 0; i < RKHLength / 0x20; i++)
{
RootKeyHashes.Add(Response[(i * 0x20)..((i + 1) * 0x20)]);
Expand Down
2 changes: 1 addition & 1 deletion WPinternals/Models/UEFI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal class UEFI
{
internal byte[] Binary;
private byte[] DecompressedImage;
internal List<EFI> EFIs = new();
internal List<EFI> EFIs = [];
private readonly byte PaddingByteValue = 0xFF;
private readonly UInt32 DecompressedVolumeSectionHeaderOffset;
private readonly UInt32 DecompressedVolumeHeaderOffset;
Expand Down
2 changes: 1 addition & 1 deletion WPinternals/Terminal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static TerminalResponse Parse(byte[] Buffer, int Offset)

internal class TerminalResponse
{
public Dictionary<int, byte[]> RawEntries = new();
public Dictionary<int, byte[]> RawEntries = [];
public byte[] PublicId = null;
public byte[] RootKeyHash = null;
}
Expand Down
4 changes: 2 additions & 2 deletions WPinternals/ViewModels/DownloadsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ private void ENOSWDownloaded(string[] Files, object State)
App.Config.AddSecWimToRepository(Files[0], (string)State);
}

public ObservableCollection<DownloadEntry> DownloadList { get; } = new();
public ObservableCollection<SearchResult> SearchResultList { get; } = new();
public ObservableCollection<DownloadEntry> DownloadList { get; } = [];
public ObservableCollection<SearchResult> SearchResultList { get; } = [];

private DelegateCommand _DownloadSelectedCommand = null;
public DelegateCommand DownloadSelectedCommand
Expand Down
2 changes: 1 addition & 1 deletion WPinternals/ViewModels/LumiaFlashRomViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ internal void FlashFFUTask(string FFUPath)
Phone = (LumiaFlashAppModel)PhoneNotifier.CurrentModel;
FlashPart Part;
List<FlashPart> FlashParts = new();
List<FlashPart> FlashParts = [];
Partition NvBackupPartition = GPT.GetPartition("BACKUP_BS_NV");
if (NvBackupPartition != null)
Expand Down
Loading

0 comments on commit 00407d6

Please sign in to comment.