Skip to content

Commit

Permalink
Code style auto-adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
LTRData committed Apr 14, 2024
1 parent 9e99700 commit 56bf0a8
Show file tree
Hide file tree
Showing 101 changed files with 303 additions and 279 deletions.
4 changes: 2 additions & 2 deletions Library/DiscUtils.BootConfig/BcdObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ public class BcdObject

static BcdObject()
{
_nameToGuid = new Dictionary<string, Guid>();
_guidToName = new Dictionary<Guid, string>();
_nameToGuid = [];
_guidToName = [];

AddMapping("{emssettings}", EmsSettingsGroupId);
AddMapping("{resumeloadersettings}", ResumeLoaderSettingsGroupId);
Expand Down
2 changes: 1 addition & 1 deletion Library/DiscUtils.Btrfs/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ internal class Context : VfsContext
{
public Context(BtrfsFileSystemOptions options)
{
FsTrees = new Dictionary<ulong, NodeHeader>();
FsTrees = [];
Options = options;
}

Expand Down
2 changes: 1 addition & 1 deletion Library/DiscUtils.Core/Archives/TarFileBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class TarFileBuilder : StreamBuilder
/// </summary>
public TarFileBuilder()
{
_files = new List<UnixBuildFileRecord>();
_files = [];
}

public bool Exists(string name)
Expand Down
8 changes: 4 additions & 4 deletions Library/DiscUtils.Core/Archives/UnixBuildFileRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ public UnixBuildFileRecord(string name, BuilderExtentSource fileSource, UnixFile

public string Name => _name;

public UnixFilePermissions FileMode => this._fileMode;
public UnixFilePermissions FileMode => _fileMode;

public int OwnerId => this._ownerId;
public int OwnerId => _ownerId;

public int GroupId => this._groupId;
public int GroupId => _groupId;

public DateTime ModificationTime => this._modificationTime;
public DateTime ModificationTime => _modificationTime;

public long Length => _source.Length;

Expand Down
2 changes: 1 addition & 1 deletion Library/DiscUtils.Core/FileSystemManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static class FileSystemManager
/// </summary>
static FileSystemManager()
{
_factories = new List<VfsFileSystemFactory>();
_factories = [];
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions Library/DiscUtils.Core/Internal/ObjectCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ internal class ObjectCache<K, V> where V : class

public ObjectCache()
{
_entries = new Dictionary<K, WeakReference<V>>();
_recent = new List<KeyValuePair<K, V>>();
_entries = [];
_recent = [];
}

public ObjectCache(IEqualityComparer<K> comparer)
{
_entries = new Dictionary<K, WeakReference<V>>(comparer);
_recent = new List<KeyValuePair<K, V>>();
_recent = [];
}

public V this[K key]
Expand Down
2 changes: 1 addition & 1 deletion Library/DiscUtils.Core/LogicalDiskManager/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Database(Stream stream)

stream.ReadExactly(buffer, 0, bufferSize);

_records = new Dictionary<ulong, DatabaseRecord>();
_records = [];
for (var i = 0; i < _vmdb.NumVBlks; ++i)
{
var rec = DatabaseRecord.ReadFrom(buffer, (int)(i * _vmdb.BlockSize));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal class DynamicDiskGroup : IDiagnosticTraceable

internal DynamicDiskGroup(VirtualDisk disk)
{
_disks = new Dictionary<Guid, DynamicDisk>();
_disks = [];

var dynDisk = new DynamicDisk(disk);
_database = dynDisk.Database;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class DynamicDiskManager : IDiagnosticTraceable
/// <param name="disks">The initial set of disks to manage.</param>
public DynamicDiskManager(params VirtualDisk[] disks)
{
_groups = new Dictionary<string, DynamicDiskGroup>();
_groups = [];

foreach (var disk in disks)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public BiosPartitionedDiskBuilder(long capacity, Geometry biosGeometry)
_bootSectors.SetLength(capacity);
PartitionTable = BiosPartitionTable.Initialize(_bootSectors, _biosGeometry);

_partitionContents = new Dictionary<int, BuilderExtent>();
_partitionContents = [];
}

/// <summary>
Expand All @@ -84,7 +84,7 @@ public BiosPartitionedDiskBuilder(long capacity, byte[] bootSectors, Geometry bi
_bootSectors.Write(bootSectors, 0, bootSectors.Length);
PartitionTable = new BiosPartitionTable(_bootSectors, biosGeometry);

_partitionContents = new Dictionary<int, BuilderExtent>();
_partitionContents = [];
}

/// <summary>
Expand Down Expand Up @@ -132,7 +132,7 @@ public BiosPartitionedDiskBuilder(VirtualDisk sourceDisk)

PartitionTable = new BiosPartitionTable(_bootSectors, _biosGeometry);

_partitionContents = new Dictionary<int, BuilderExtent>();
_partitionContents = [];
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Library/DiscUtils.Core/Setup/SetupHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class SetupHelper

static SetupHelper()
{
_alreadyLoaded = new HashSet<string>();
_alreadyLoaded = [];

// Register the core DiscUtils lib
RegisterAssembly(typeof(SetupHelper).Assembly);
Expand Down
2 changes: 1 addition & 1 deletion Library/DiscUtils.Core/VirtualDiskParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public sealed class VirtualDiskParameters
/// <summary>
/// Gets a dictionary of extended parameters, that varies by disk type.
/// </summary>
public Dictionary<string, string> ExtendedParameters { get; } = new Dictionary<string, string>();
public Dictionary<string, string> ExtendedParameters { get; } = [];

/// <summary>
/// Gets or sets the physical (aka IDE) geometry of the disk.
Expand Down
6 changes: 3 additions & 3 deletions Library/DiscUtils.Core/VolumeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public sealed class VolumeManager
/// </summary>
public VolumeManager()
{
_disks = new List<VirtualDisk>();
_physicalVolumes = new Dictionary<string, PhysicalVolumeInfo>();
_logicalVolumes = new Dictionary<string, LogicalVolumeInfo>();
_disks = [];
_physicalVolumes = [];
_logicalVolumes = [];
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Library/DiscUtils.Dmg/CompressedBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public int ReadFrom(ReadOnlySpan<byte> buffer)

CheckSum = EndianUtilities.ToStruct<UdifChecksum>(buffer.Slice(60));

Runs = new List<CompressedRun>();
Runs = [];
var numRuns = EndianUtilities.ToInt32BigEndian(buffer.Slice(200));
for (var i = 0; i < numRuns; ++i)
{
Expand Down
2 changes: 1 addition & 1 deletion Library/DiscUtils.Dmg/UdifBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public UdifBuffer(Stream stream, ResourceFork resources, long sectorCount)
_resources = resources;
_sectorCount = sectorCount;

Blocks = new List<CompressedBlock>();
Blocks = [];

foreach (var resource in _resources.GetAllResources("blkx"))
{
Expand Down
2 changes: 1 addition & 1 deletion Library/DiscUtils.Dmg/UdifPartitionTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal class UdifPartitionTable : PartitionTable
public UdifPartitionTable(Disk disk, UdifBuffer buffer)
{
_buffer = buffer;
_partitions = new Collection<PartitionInfo>();
_partitions = [];
_disk = disk;

foreach (var block in _buffer.Blocks)
Expand Down
6 changes: 3 additions & 3 deletions Library/DiscUtils.Ext/BlockGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ internal class BlockGroup64 : BlockGroup

public BlockGroup64(int descriptorSize)
{
this._descriptorSize = descriptorSize;
_descriptorSize = descriptorSize;
}

public override int Size => this._descriptorSize;
public override int Size => _descriptorSize;

public override int ReadFrom(ReadOnlySpan<byte> buffer)
{
Expand All @@ -54,7 +54,7 @@ public override int ReadFrom(ReadOnlySpan<byte> buffer)
FreeInodesCountHigh = EndianUtilities.ToUInt16LittleEndian(buffer.Slice(0x2E));
UsedDirsCountHigh = EndianUtilities.ToUInt16LittleEndian(buffer.Slice(0x30));

return this._descriptorSize;
return _descriptorSize;
}
}

Expand Down
10 changes: 1 addition & 9 deletions Library/DiscUtils.Fat/ClusterStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,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 Library/DiscUtils.Fat/Directory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,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
2 changes: 1 addition & 1 deletion Library/DiscUtils.Fat/FatBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public FatBuffer(FatType type, byte[] buffer)
{
_type = type;
_buffer = buffer;
_dirtySectors = new Dictionary<uint, uint>();
_dirtySectors = [];
}

internal int NumEntries => _type switch
Expand Down
12 changes: 6 additions & 6 deletions Library/DiscUtils.Fat/FatFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public sealed class FatFileSystem : DiscFileSystem, IDosFileSystem, IClusterBase
/// <summary>
/// The Epoch for FAT file systems (1st Jan, 1980).
/// </summary>
public static readonly DateTime Epoch = new DateTime(1980, 1, 1);
public static readonly DateTime Epoch = new(1980, 1, 1);

private readonly Dictionary<uint, Directory> _dirCache;
private readonly Ownership _ownsData;
Expand Down Expand Up @@ -87,7 +87,7 @@ static FatFileSystem()
public FatFileSystem(Stream data)
: base(new FatFileSystemOptions())
{
_dirCache = new Dictionary<uint, Directory>();
_dirCache = [];
_timeConverter = DefaultTimeConverter;
Initialize(data);
}
Expand All @@ -104,7 +104,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 @@ -118,7 +118,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 @@ -133,7 +133,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 @@ -149,7 +149,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 != null && parameters.TimeConverter != null)
{
Expand Down
4 changes: 2 additions & 2 deletions Library/DiscUtils.Iscsi/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public Connection(Session session, TargetAddress address, Authenticator[] authen
MaxInitiatorTransmitDataSegmentLength = 131072;
MaxTargetReceiveDataSegmentLength = 8192;

_negotiatedParameters = new Dictionary<string, string>();
_negotiatedParameters = [];
NegotiateSecurity();
NegotiateFeatures();
}
Expand Down Expand Up @@ -352,7 +352,7 @@ public IEnumerable<TargetInfo> EnumerateTargets()
}

currentTarget = line.Value;
currentAddresses = new List<TargetAddress>();
currentAddresses = [];
}
else if (line.Key == TargetNameParameter)
{
Expand Down
2 changes: 1 addition & 1 deletion Library/DiscUtils.Iscsi/ScsiReportLunsResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal class ScsiReportLunsResponse : ScsiResponse

public override void ReadFrom(byte[] buffer, int offset, int count)
{
Luns = new List<ulong>();
Luns = [];

if (count == 0)
{
Expand Down
2 changes: 1 addition & 1 deletion Library/DiscUtils.Iscsi/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ internal Session(SessionType type, string targetName, string userName, string pa
DataPDUInOrder = true;
DataSequenceInOrder = true;

_negotiatedParameters = new Dictionary<string, string>();
_negotiatedParameters = [];

if (string.IsNullOrEmpty(userName))
{
Expand Down
2 changes: 1 addition & 1 deletion Library/DiscUtils.Iscsi/TextBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal class TextBuffer

public TextBuffer()
{
_records = new List<KeyValuePair<string, string>>();
_records = [];
}

internal int Count => _records.Count;
Expand Down
4 changes: 2 additions & 2 deletions Library/DiscUtils.Iso9660/CDBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public sealed class CDBuilder : StreamBuilder, IFileSystemBuilder
/// </summary>
public CDBuilder()
{
_files = new List<BuildFileInfo>();
_dirs = new List<BuildDirectoryInfo>();
_files = [];
_dirs = [];
_rootDirectory = new BuildDirectoryInfo("\0", null);
_dirs.Add(_rootDirectory);

Expand Down
6 changes: 3 additions & 3 deletions Library/DiscUtils.Iso9660/Susp/SuspRecords.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ internal sealed class SuspRecords

public SuspRecords(IsoContext context, ReadOnlySpan<byte> data)
{
_records = new Dictionary<string, Dictionary<string, List<SystemUseEntry>>>();
_records = [];

var contEntry = Parse(context, data.Slice(context.SuspSkipBytes));
while (contEntry != null)
Expand Down Expand Up @@ -164,13 +164,13 @@ private void StoreEntry(SuspExtension extension, SystemUseEntry entry)

if (!_records.TryGetValue(extensionId, out var extensionEntries))
{
extensionEntries = new Dictionary<string, List<SystemUseEntry>>();
extensionEntries = [];
_records.Add(extensionId, extensionEntries);
}

if (!extensionEntries.TryGetValue(entry.Name, out var entries))
{
entries = new List<SystemUseEntry>();
entries = [];
extensionEntries.Add(entry.Name, entries);
}

Expand Down
2 changes: 1 addition & 1 deletion Library/DiscUtils.Iso9660/VfsCDReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ private static void InitializeSusp(IsoContext context, DirectoryRecord rootSelfR
var extensions = new List<SuspExtension>();
if (!SuspRecords.DetectSharingProtocol(rootSelfRecord.SystemUseData))
{
context.SuspExtensions = new List<SuspExtension>();
context.SuspExtensions = [];
context.SuspDetected = false;
return;
}
Expand Down
4 changes: 2 additions & 2 deletions Library/DiscUtils.Lvm/LogicalVolumeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public class LogicalVolumeManager
/// <param name="disks">The initial set of disks to manage.</param>
public LogicalVolumeManager(IEnumerable<VirtualDisk> disks)
{
_devices = new List<PhysicalVolume>();
_volumeGroups = new List<MetadataVolumeGroupSection>();
_devices = [];
_volumeGroups = [];
foreach (var disk in disks)
{
if (disk.IsPartitioned)
Expand Down
Loading

0 comments on commit 56bf0a8

Please sign in to comment.