diff --git a/ATL/AudioData/IO/FLAC.cs b/ATL/AudioData/IO/FLAC.cs
index 11a88715..263cbe32 100644
--- a/ATL/AudioData/IO/FLAC.cs
+++ b/ATL/AudioData/IO/FLAC.cs
@@ -32,7 +32,7 @@ partial class FLAC : VorbisTagHolder, IMetaDataIO, IAudioDataIO
private const byte FLAG_LAST_METADATA_BLOCK = 0x80;
- private FlacHeader header = null;
+ private FlacHeader header;
private AudioDataManager.SizeInfo sizeInfo;
@@ -467,7 +467,7 @@ private int writePictureBlock(BinaryWriter w, PictureInfo picture, bool isLastMe
w.Write(new byte[] { 0, 0, 0 }); // Placeholder for 24-bit integer that will be rewritten at the end of the method
var dataPos = w.BaseStream.Position;
- vorbisTag.WritePicture(w, picture.PictureData, picture.MimeType, picture.PicType.Equals(PictureInfo.PIC_TYPE.Unsupported) ? picture.NativePicCode : ID3v2.EncodeID3v2PictureType(picture.PicType), picture.Description);
+ VorbisTag.WritePicture(w, picture.PictureData, picture.MimeType, picture.PicType.Equals(PictureInfo.PIC_TYPE.Unsupported) ? picture.NativePicCode : ID3v2.EncodeID3v2PictureType(picture.PicType), picture.Description);
var finalPos = w.BaseStream.Position;
w.BaseStream.Seek(sizePos, SeekOrigin.Begin);
diff --git a/ATL/AudioData/IO/GYM.cs b/ATL/AudioData/IO/GYM.cs
index 465c0fc6..b65e7e80 100644
--- a/ATL/AudioData/IO/GYM.cs
+++ b/ATL/AudioData/IO/GYM.cs
@@ -163,7 +163,7 @@ private bool readHeader(BufferedBinaryReader source, ReadTagParams readTagParams
}
}
- private uint calculateDuration(BufferedBinaryReader source, uint loopStart, uint nbLoops)
+ private static uint calculateDuration(BufferedBinaryReader source, uint loopStart, uint nbLoops)
{
long streamSize = source.Length;
uint frameIndex = 0;
diff --git a/ATL/AudioData/IO/Helpers/BextTag.cs b/ATL/AudioData/IO/Helpers/BextTag.cs
index 16fbe5d0..c3d00363 100644
--- a/ATL/AudioData/IO/Helpers/BextTag.cs
+++ b/ATL/AudioData/IO/Helpers/BextTag.cs
@@ -18,7 +18,7 @@ internal static class BextTag
///
public const string CHUNK_BEXT = "bext";
- private static readonly byte[] CR_LF = new byte[2] { 13, 10 };
+ private static readonly byte[] CR_LF = { 13, 10 };
///
/// Read a bext chunk from the given source into the given Metadata I/O, using the given read parameters
@@ -28,12 +28,11 @@ internal static class BextTag
/// Read parameters to use
public static void FromStream(Stream source, MetaDataIO meta, ReadTagParams readTagParams)
{
- string str;
byte[] data = new byte[256];
// Description
source.Read(data, 0, 256);
- str = Utils.StripEndingZeroChars(Encoding.UTF8.GetString(data).Trim());
+ var str = Utils.StripEndingZeroChars(Encoding.UTF8.GetString(data).Trim());
if (str.Length > 0) meta.SetMetaField("bext.description", str, readTagParams.ReadAllMetaFrames);
// Originator
@@ -147,7 +146,7 @@ public static int ToStream(BinaryWriter w, bool isLittleEndian, MetaDataIO meta)
// Text values
string description = Utils.ProtectValue(meta.GeneralDescription);
- if (0 == description.Length && additionalFields.Keys.Contains("bext.description")) description = additionalFields["bext.description"];
+ if (0 == description.Length && additionalFields.TryGetValue("bext.description", out var field)) description = field;
WavHelper.writeFixedTextValue(description, 256, w);
WavHelper.writeFixedFieldTextValue("bext.originator", additionalFields, 32, w);
@@ -160,7 +159,7 @@ public static int ToStream(BinaryWriter w, bool isLittleEndian, MetaDataIO meta)
WavHelper.writeFieldIntValue("bext.version", additionalFields, w, (ushort)0);
// UMID
- if (additionalFields.Keys.Contains("bext.UMID"))
+ if (additionalFields.ContainsKey("bext.UMID"))
{
if (Utils.IsHex(additionalFields["bext.UMID"]))
{
@@ -196,9 +195,9 @@ public static int ToStream(BinaryWriter w, bool isLittleEndian, MetaDataIO meta)
// CodingHistory
byte[] textData = Array.Empty();
- if (additionalFields.Keys.Contains("bext.codingHistory"))
+ if (additionalFields.TryGetValue("bext.codingHistory", out var additionalField))
{
- textData = Utils.Latin1Encoding.GetBytes(additionalFields["bext.codingHistory"]);
+ textData = Utils.Latin1Encoding.GetBytes(additionalField);
w.Write(textData);
}
w.Write(new byte[] { 13, 10 } /* CR LF */);
diff --git a/ATL/AudioData/IO/Helpers/WavHelper.cs b/ATL/AudioData/IO/Helpers/WavHelper.cs
index 4e0dd8d0..4d0210c6 100644
--- a/ATL/AudioData/IO/Helpers/WavHelper.cs
+++ b/ATL/AudioData/IO/Helpers/WavHelper.cs
@@ -86,9 +86,9 @@ public static void readInt16(Stream source, MetaDataIO meta, string fieldName, b
/// Padding value to use (default : 0x00)
public static void writeFixedFieldTextValue(string field, IDictionary additionalFields, int length, BinaryWriter w, byte paddingByte = 0)
{
- if (additionalFields.Keys.Contains(field))
+ if (additionalFields.TryGetValue(field, out var additionalField))
{
- writeFixedTextValue(additionalFields[field], length, w, paddingByte);
+ writeFixedTextValue(additionalField, length, w, paddingByte);
}
else
{
@@ -186,7 +186,7 @@ public static void writeFieldIntValue(string field, IDictionary
/// Default value to use in case no value is found in the given Map; type determines the type of the written value
public static void writeField100DecimalValue(string field, IDictionary additionalFields, BinaryWriter w, object defaultValue)
{
- if (additionalFields.Keys.Contains(field))
+ if (additionalFields.ContainsKey(field))
{
if (Utils.IsNumeric(additionalFields[field]))
{
diff --git a/ATL/AudioData/IO/Helpers/XmpTag.cs b/ATL/AudioData/IO/Helpers/XmpTag.cs
index 64cd9133..d44a4bdf 100644
--- a/ATL/AudioData/IO/Helpers/XmpTag.cs
+++ b/ATL/AudioData/IO/Helpers/XmpTag.cs
@@ -33,7 +33,7 @@ private static XmlArray createXmlArray()
|| e.Equals("RDF:SEQ", StringComparison.OrdinalIgnoreCase)
|| e.Equals("RDF:ALT", StringComparison.OrdinalIgnoreCase)
),
- e => false
+ _ => false
);
result.setStructuralAttributes(ATTRIBUTES);
return result;
diff --git a/ATL/AudioData/IO/MIDI.cs b/ATL/AudioData/IO/MIDI.cs
index b0945471..1e80e837 100644
--- a/ATL/AudioData/IO/MIDI.cs
+++ b/ATL/AudioData/IO/MIDI.cs
@@ -443,11 +443,10 @@ protected override bool read(Stream source, ReadTagParams readTagParams)
// Ready to read header data...
source.Read(buffer, 0, buffer.Length);
- if ((buffer[0] != 0) ||
- (buffer[1] != 0) ||
- (buffer[2] != 0) ||
- (buffer[3] != 6)
- )
+ if (buffer[0] != 0 ||
+ buffer[1] != 0 ||
+ buffer[2] != 0 ||
+ buffer[3] != 6)
{
LogDelegator.GetLogDelegate()(Log.LV_ERROR, "Wrong MIDI header");
return false;
@@ -469,7 +468,6 @@ protected override bool read(Stream source, ReadTagParams readTagParams)
tempo = 0; // maybe (hopefully!) overwritten by parseTrack
- int trackSize;
int nbTrack = 0;
comment = new StringBuilder("");
@@ -491,7 +489,7 @@ protected override bool read(Stream source, ReadTagParams readTagParams)
// trackSize is stored in big endian -> needs inverting
source.Read(buffer, 0, 4);
- trackSize = StreamUtils.DecodeBEInt32(buffer);
+ var trackSize = StreamUtils.DecodeBEInt32(buffer);
byte[] trackData = new byte[trackSize];
source.Read(trackData, 0, trackSize);
@@ -954,15 +952,13 @@ private MidiTrack parseTrack(byte[] data, int trackNumber)
// variable length string to int (+repositioning)
//---------------------------------------------------------------
//# TO LOOK AFTER CAREFULLY <.<
- private int readVarLen(ref byte[] data, ref int pos)
+ private static int readVarLen(ref byte[] data, ref int pos)
{
- int value;
- int c;
-
- value = data[pos++];
+ int value = data[pos++];
if ((value & 0x80) != 0)
{
value &= 0x7F;
+ int c;
do
{
c = data[pos++];
diff --git a/ATL/AudioData/IO/MP4.cs b/ATL/AudioData/IO/MP4.cs
index ef6e7139..3954c8d3 100644
--- a/ATL/AudioData/IO/MP4.cs
+++ b/ATL/AudioData/IO/MP4.cs
@@ -8,8 +8,6 @@
using static ATL.AudioData.FileStructureHelper;
using System.Linq;
using System.Collections.Concurrent;
-using System.Runtime.CompilerServices;
-using System.Xml;
using static ATL.TagData;
namespace ATL.AudioData.IO
@@ -1423,7 +1421,7 @@ private void readTag(BinaryReader source, ReadTagParams readTagParams)
{
var picturePosition = takePicturePosition(picType);
- int dataSize = (int)Math.Max(0, pictureSize - 16);
+ int dataSize = Math.Max(0, (int)pictureSize - 16);
if (readTagParams.ReadPictures)
{
PictureInfo picInfo = PictureInfo.fromBinaryData(source.BaseStream, dataSize, picType, getImplementedTagType(), dataClass, picturePosition);
@@ -1522,11 +1520,13 @@ private void setXtraField(string ID, string data, bool readAllMetaFrames)
}
}
- private Uuid readUuid(Stream source)
+ private static Uuid readUuid(Stream source)
{
- Uuid result = new Uuid();
- result.size = navigateToAtom(source, "uuid");
- result.position = source.Position - 8;
+ Uuid result = new Uuid
+ {
+ size = navigateToAtom(source, "uuid"),
+ position = source.Position - 8
+ };
if (result.size >= 16 + 8)
{
Span key = new byte[16];
diff --git a/ATL/AudioData/IO/MPEGaudio.cs b/ATL/AudioData/IO/MPEGaudio.cs
index 9075d49b..6491ccd6 100644
--- a/ATL/AudioData/IO/MPEGaudio.cs
+++ b/ATL/AudioData/IO/MPEGaudio.cs
@@ -471,7 +471,7 @@ private double getDuration()
return 0;
}
- private ChannelsArrangement getChannelsArrangement(FrameHeader frame)
+ private static ChannelsArrangement getChannelsArrangement(FrameHeader frame)
{
switch (frame.ModeID)
{
diff --git a/ATL/AudioData/IO/Ogg.cs b/ATL/AudioData/IO/Ogg.cs
index e1b43f0d..70611c51 100644
--- a/ATL/AudioData/IO/Ogg.cs
+++ b/ATL/AudioData/IO/Ogg.cs
@@ -216,7 +216,7 @@ private sealed class VorbisHeader
public void Reset()
{
- ID = new byte[0];
+ ID = Array.Empty();
Array.Clear(BitstreamVersion, 0, BitstreamVersion.Length);
ChannelMode = 0;
SampleRate = 0;
@@ -245,7 +245,7 @@ private sealed class OpusHeader
public void Reset()
{
- ID = new byte[0];
+ ID = Array.Empty();
Version = 0;
OutputChannelCount = 0;
PreSkip = 0;
@@ -364,7 +364,7 @@ public override IList MetadataFormats
// ---------------------------------------------------------------------------
// Read total samples of OGG file, which are located on the very last page of the file
- private ulong getSamples(BufferedBinaryReader source)
+ private static ulong getSamples(BufferedBinaryReader source)
{
byte typeFlag;
byte[] lacingValues = new byte[255];
@@ -912,7 +912,7 @@ private byte[] buildSegmentsTable(long newTagSize, int commentsHeader_nbSegments
}
// Resize the whole in-memory stream once and for all to avoid multiple reallocations while repaging
- private void resizeMemStream(Stream memStream, int commentsHeader_nbSegments, int setupHeader_nbSegments)
+ private static void resizeMemStream(Stream memStream, int commentsHeader_nbSegments, int setupHeader_nbSegments)
{
int nbPageHeaders = (int)Math.Ceiling((commentsHeader_nbSegments + setupHeader_nbSegments) / 255.0);
int totalPageHeadersSize = (nbPageHeaders * 27) + commentsHeader_nbSegments + setupHeader_nbSegments;
@@ -976,7 +976,7 @@ private int repageMemStream(
}
// Generate CRC32 of created pages
- private void generatePageCrc32(Stream s, IList> pageHeaderOffsets)
+ private static void generatePageCrc32(Stream s, IEnumerable> pageHeaderOffsets)
{
byte[] data = Array.Empty();
foreach (KeyValuePair kv in pageHeaderOffsets)
@@ -991,7 +991,7 @@ private void generatePageCrc32(Stream s, IList> pageHead
}
}
- private bool renumberRemainingPages(Stream s, long nextPageOffset, int writtenPages)
+ private static bool renumberRemainingPages(Stream s, long nextPageOffset, int writtenPages)
{
OggPageHeader header = new OggPageHeader();
byte[] data = Array.Empty();
diff --git a/ATL/AudioData/IO/PSF.cs b/ATL/AudioData/IO/PSF.cs
index fa5f1093..25dd58a5 100644
--- a/ATL/AudioData/IO/PSF.cs
+++ b/ATL/AudioData/IO/PSF.cs
@@ -188,7 +188,7 @@ public static bool IsValidHeader(byte[] data)
return StreamUtils.ArrBeginsWith(data, PSF_FORMAT_TAG);
}
- private bool readHeader(Stream source, ref PSFHeader header)
+ private static bool readHeader(Stream source, ref PSFHeader header)
{
byte[] buffer = new byte[4];
source.Read(header.FormatTag, 0, 3);
@@ -208,7 +208,7 @@ private bool readHeader(Stream source, ref PSFHeader header)
}
}
- private string readPSFLine(Stream source, Encoding encoding)
+ private static string readPSFLine(Stream source, Encoding encoding)
{
long lineStart = source.Position;
long lineEnd;
@@ -301,7 +301,7 @@ private bool readTag(Stream source, ref PSFTag tag, ReadTagParams readTagParams)
}
}
- private double parsePSFDuration(string durationStr)
+ private static double parsePSFDuration(string durationStr)
{
string hStr = "";
string mStr = "";
@@ -310,49 +310,49 @@ private double parsePSFDuration(string durationStr)
double result = 0;
// decimal
- var sepIndex = durationStr.LastIndexOf(".");
- if (-1 == sepIndex) sepIndex = durationStr.LastIndexOf(",");
+ var sepIndex = durationStr.LastIndexOf('.');
+ if (-1 == sepIndex) sepIndex = durationStr.LastIndexOf(',');
if (-1 != sepIndex)
{
sepIndex++;
dStr = durationStr.Substring(sepIndex, durationStr.Length - sepIndex);
- durationStr = durationStr.Substring(0, Math.Max(0, sepIndex - 1));
+ durationStr = durationStr[..Math.Max(0, sepIndex - 1)];
}
// seconds
- sepIndex = durationStr.LastIndexOf(":");
+ sepIndex = durationStr.LastIndexOf(':');
sepIndex++;
sStr = durationStr.Substring(sepIndex, durationStr.Length - sepIndex);
- durationStr = durationStr.Substring(0, Math.Max(0, sepIndex - 1));
+ durationStr = durationStr[..Math.Max(0, sepIndex - 1)];
// minutes
if (durationStr.Length > 0)
{
- sepIndex = durationStr.LastIndexOf(":");
+ sepIndex = durationStr.LastIndexOf(':');
sepIndex++;
mStr = durationStr.Substring(sepIndex, durationStr.Length - sepIndex);
- durationStr = durationStr.Substring(0, Math.Max(0, sepIndex - 1));
+ durationStr = durationStr[..Math.Max(0, sepIndex - 1)];
}
// hours
if (durationStr.Length > 0)
{
- sepIndex = durationStr.LastIndexOf(":");
+ sepIndex = durationStr.LastIndexOf(':');
sepIndex++;
hStr = durationStr.Substring(sepIndex, durationStr.Length - sepIndex);
}
- if (dStr != "") result = result + (Int32.Parse(dStr) * 100);
- if (sStr != "") result = result + (Int32.Parse(sStr) * 1000);
- if (mStr != "") result = result + (Int32.Parse(mStr) * 60000);
- if (hStr != "") result = result + (Int32.Parse(hStr) * 3600000);
+ if (dStr != "") result += (int.Parse(dStr) * 100);
+ if (sStr != "") result += (int.Parse(sStr) * 1000);
+ if (mStr != "") result += (int.Parse(mStr) * 60000);
+ if (hStr != "") result += (int.Parse(hStr) * 3600000);
return result;
}
@@ -368,7 +368,6 @@ public bool Read(Stream source, SizeInfo sizeInfo, ReadTagParams readTagParams)
protected override bool read(Stream source, ReadTagParams readTagParams)
{
- bool result = true;
PSFHeader header = new PSFHeader();
PSFTag tag = new PSFTag();
@@ -394,7 +393,7 @@ protected override bool read(Stream source, ReadTagParams readTagParams)
version = header.VersionByte;
BitRate = AudioDataSize * 8 / Duration;
- return result;
+ return true;
}
protected override int write(TagData tag, Stream s, string zone)
@@ -447,7 +446,7 @@ private int write(TagData tag, BinaryWriter w)
return result;
}
- private void writeTextFrame(BinaryWriter writer, string frameCode, string text)
+ private static void writeTextFrame(BinaryWriter writer, string frameCode, string text)
{
string[] textLines;
if (text.Contains(Environment.NewLine))
@@ -457,7 +456,7 @@ private void writeTextFrame(BinaryWriter writer, string frameCode, string text)
}
else
{
- textLines = new string[1] { text };
+ textLines = new[] { text };
}
foreach (string s in textLines)
@@ -492,7 +491,7 @@ private TagData prepareRemove()
foreach (MetaFieldInfo fieldInfo in GetAdditionalFields())
{
var fieldCode = fieldInfo.NativeFieldCode.ToLower();
- if (!fieldCode.StartsWith("_") && !playbackFrames.Contains(fieldCode))
+ if (!fieldCode.StartsWith('_') && !playbackFrames.Contains(fieldCode))
{
MetaFieldInfo emptyFieldInfo = new MetaFieldInfo(fieldInfo);
emptyFieldInfo.MarkedForDeletion = true;
diff --git a/ATL/AudioData/IO/S3M.cs b/ATL/AudioData/IO/S3M.cs
index a07163bc..f0601153 100644
--- a/ATL/AudioData/IO/S3M.cs
+++ b/ATL/AudioData/IO/S3M.cs
@@ -23,7 +23,7 @@ class S3M : MetaDataIO, IAudioDataIO
{
private const string ZONE_TITLE = "title";
- private const String S3M_SIGNATURE = "SCRM";
+ private const string S3M_SIGNATURE = "SCRM";
private const byte MAX_ROWS = 64;
// Effects
@@ -274,7 +274,7 @@ private double calculateDuration()
return result;
}
- private string getTrackerName(ushort trackerVersion)
+ private static string getTrackerName(ushort trackerVersion)
{
string result = "";
@@ -433,7 +433,7 @@ protected override bool read(Stream source, ReadTagParams readTagParams)
for (int i = 0; i < 32; i++)
{
FChannelTable.Add(bSource.ReadByte());
- if (FChannelTable[FChannelTable.Count - 1] < 30) nbChannels++;
+ if (FChannelTable[^1] < 30) nbChannels++;
}
// Pattern table
@@ -482,7 +482,7 @@ protected override int write(TagData tag, Stream s, string zone)
if (ZONE_TITLE.Equals(zone))
{
string title = tag[Field.TITLE];
- if (title.Length > 28) title = title.Substring(0, 28);
+ if (title.Length > 28) title = title[..28];
else if (title.Length < 28) title = Utils.BuildStrictLengthString(title, 28, '\0');
StreamUtils.WriteBytes(s, Utils.Latin1Encoding.GetBytes(title));
result = 1;
diff --git a/ATL/AudioData/IO/SPC.cs b/ATL/AudioData/IO/SPC.cs
index bf7f4ddc..630638e7 100644
--- a/ATL/AudioData/IO/SPC.cs
+++ b/ATL/AudioData/IO/SPC.cs
@@ -244,7 +244,7 @@ public static bool IsValidHeader(byte[] data)
return StreamUtils.ArrBeginsWith(data, SPC_FORMAT_TAG);
}
- private bool readHeader(Stream source, ref SpcHeader header)
+ private static bool readHeader(Stream source, ref SpcHeader header)
{
source.Seek(0, SeekOrigin.Begin);
@@ -361,7 +361,7 @@ private void readHeaderTags(Stream source, ref SpcHeader header, ReadTagParams r
}
}
- private int isText(byte[] data)
+ private static int isText(byte[] data)
{
int c = 0;
@@ -569,16 +569,16 @@ protected override int write(TagData tag, Stream s, string zone)
return result;
}
- private bool canBeWrittenInExtendedMetadata(Field frameType, string value)
+ private static bool canBeWrittenInExtendedMetadata(Field frameType, string value)
{
if (frameType == Field.TITLE || frameType == Field.ALBUM || frameType == Field.COMMENT || frameType == Field.ARTIST)
{
- return (value.Length > 32);
+ return value.Length > 32;
}
- else return true;
+ return true;
}
- private void writeSubChunk(Stream stream, byte frameCode, string text, Span buffer)
+ private static void writeSubChunk(Stream stream, byte frameCode, string text, Span buffer)
{
stream.WriteByte(frameCode);
diff --git a/ATL/AudioData/IO/TwinVQ.cs b/ATL/AudioData/IO/TwinVQ.cs
index a0772eb0..8e96d02d 100644
--- a/ATL/AudioData/IO/TwinVQ.cs
+++ b/ATL/AudioData/IO/TwinVQ.cs
@@ -58,7 +58,7 @@ protected override Field getFrameMapping(string zone, string ID, byte tagVersion
private sealed class ChunkHeader
{
public string ID;
- public uint Size = 0; // Chunk size
+ public uint Size; // Chunk size
}
#pragma warning disable S4487 // Unread "private" fields should be removed
@@ -179,7 +179,7 @@ private static uint getBitRate(HeaderInfo Header)
return Header.BitRate;
}
- private int GetSampleRate(HeaderInfo Header)
+ private static int GetSampleRate(HeaderInfo Header)
{
int result = (int)Header.SampleRate;
result = result switch
@@ -195,7 +195,7 @@ private int GetSampleRate(HeaderInfo Header)
// Get duration from header
private double getDuration(HeaderInfo Header)
{
- return Math.Abs(sizeInfo.FileSize - Header.Size - 20) * 1000.0 / 125.0 / (double)Header.BitRate;
+ return Math.Abs(sizeInfo.FileSize - Header.Size - 20) * 1000.0 / 125.0 / Header.BitRate;
}
private static bool headerEndReached(ChunkHeader Chunk)
@@ -312,7 +312,7 @@ protected override int write(TagData tag, Stream s, string zone)
if (recordingYear.Length > 0)
{
string recordingDate = Utils.ProtectValue(tag[Field.RECORDING_DATE]);
- if (0 == recordingDate.Length || !recordingDate.StartsWith(recordingYear)) map[TagData.Field.RECORDING_DATE] = recordingYear;
+ if (0 == recordingDate.Length || !recordingDate.StartsWith(recordingYear)) map[Field.RECORDING_DATE] = recordingYear;
}
// Supported textual fields
@@ -346,7 +346,7 @@ protected override int write(TagData tag, Stream s, string zone)
return result;
}
- private void writeTextFrame(Stream s, string frameCode, string text)
+ private static void writeTextFrame(Stream s, string frameCode, string text)
{
StreamUtils.WriteBytes(s, Utils.Latin1Encoding.GetBytes(frameCode));
byte[] textBytes = Encoding.UTF8.GetBytes(text);
@@ -373,7 +373,7 @@ private TagData prepareRemove()
foreach (MetaFieldInfo fieldInfo in GetAdditionalFields())
{
var fieldCode = fieldInfo.NativeFieldCode.ToLower();
- if (!fieldCode.StartsWith("_") && !fieldCode.Equals("DSIZ") && !fieldCode.Equals("COMM"))
+ if (!fieldCode.StartsWith('_') && !fieldCode.Equals("DSIZ") && !fieldCode.Equals("COMM"))
{
MetaFieldInfo emptyFieldInfo = new MetaFieldInfo(fieldInfo);
emptyFieldInfo.MarkedForDeletion = true;
diff --git a/ATL/AudioData/IO/VGM.cs b/ATL/AudioData/IO/VGM.cs
index f961a812..3860e806 100644
--- a/ATL/AudioData/IO/VGM.cs
+++ b/ATL/AudioData/IO/VGM.cs
@@ -29,9 +29,9 @@ class VGM : MetaDataIO, IAudioDataIO
private const int VGM_HEADER_SIZE = 256;
- private static readonly int LOOP_COUNT_DEFAULT = 1; // Default loop count
- private static readonly int FADEOUT_DURATION_DEFAULT = 10000; // Default fadeout duration, in milliseconds (10s)
- private static readonly int RECORDING_RATE_DEFAULT = 60; // Default playback rate for v1.00 files
+ private const int LOOP_COUNT_DEFAULT = 1; // Default loop count
+ private const int FADEOUT_DURATION_DEFAULT = 10000; // Default fadeout duration, in milliseconds (10s)
+ private const int RECORDING_RATE_DEFAULT = 60; // Default playback rate for v1.00 files
// Standard fields
@@ -128,7 +128,6 @@ public static bool IsValidHeader(byte[] data)
private bool readHeader(BufferedBinaryReader source, ReadTagParams readTagParams)
{
- int nbSamples, loopNbSamples;
int nbLoops = LOOP_COUNT_DEFAULT;
int recordingRate = RECORDING_RATE_DEFAULT;
@@ -164,11 +163,11 @@ private bool readHeader(BufferedBinaryReader source, ReadTagParams readTagParams
}
}
- nbSamples = source.ReadInt32();
+ var nbSamples = source.ReadInt32();
source.Seek(4, SeekOrigin.Current); // Loop offset
- loopNbSamples = source.ReadInt32();
+ var loopNbSamples = source.ReadInt32();
if (version >= 0x00000101)
{
recordingRate = source.ReadInt32();
@@ -248,9 +247,9 @@ private void readGd3Tag(BufferedBinaryReader source, int offset)
// === PUBLIC METHODS ===
- public bool Read(Stream source, SizeInfo sizeNfo, ReadTagParams readTagParams)
+ public bool Read(Stream source, SizeInfo sizeInfo, ReadTagParams readTagParams)
{
- this.sizeInfo = sizeNfo;
+ this.sizeInfo = sizeInfo;
return read(source, readTagParams);
}
@@ -298,7 +297,7 @@ protected override int write(TagData tag, Stream s, string zone)
private int write(TagData tag, BinaryWriter w)
{
- byte[] endString = new byte[2] { 0, 0 };
+ byte[] endString = new byte[] { 0, 0 };
int result = 11; // 11 field to write
Encoding unicodeEncoder = Encoding.Unicode;
diff --git a/ATL/AudioData/IO/VorbisTag.cs b/ATL/AudioData/IO/VorbisTag.cs
index f7b94e63..43e640b7 100644
--- a/ATL/AudioData/IO/VorbisTag.cs
+++ b/ATL/AudioData/IO/VorbisTag.cs
@@ -570,7 +570,7 @@ private void writeChapters(BinaryWriter writer, IList chapters)
}
}
- private void writeTextFrame(BinaryWriter writer, string frameCode, string text)
+ private static void writeTextFrame(BinaryWriter writer, string frameCode, string text)
{
var frameSizePos = writer.BaseStream.Position;
writer.Write((uint)0); // Frame size placeholder to be rewritten in a few lines
@@ -607,7 +607,7 @@ private void writePictureFrame(BinaryWriter writer, byte[] pictureData, string m
writer.BaseStream.Seek(finalFramePos, SeekOrigin.Begin);
}
- public void WritePicture(BinaryWriter picW, byte[] pictureData, string mimeType, int pictureTypeCode, string picDescription)
+ public static void WritePicture(BinaryWriter picW, byte[] pictureData, string mimeType, int pictureTypeCode, string picDescription)
{
picW.Write(StreamUtils.EncodeBEInt32(pictureTypeCode));
picW.Write(StreamUtils.EncodeBEInt32(mimeType.Length));
diff --git a/ATL/AudioData/IO/WAV.cs b/ATL/AudioData/IO/WAV.cs
index 4b2e5f71..af6292b4 100644
--- a/ATL/AudioData/IO/WAV.cs
+++ b/ATL/AudioData/IO/WAV.cs
@@ -480,7 +480,7 @@ private bool readWAV(Stream source, ReadTagParams readTagParams)
return true;
}
- private object getFormattedRiffChunkSize(long input, bool isRf64)
+ private static object getFormattedRiffChunkSize(long input, bool isRf64)
{
if (isRf64) return input;
return (uint)input;
diff --git a/ATL/AudioData/IO/WMA.cs b/ATL/AudioData/IO/WMA.cs
index 295f9d47..0d7046b2 100644
--- a/ATL/AudioData/IO/WMA.cs
+++ b/ATL/AudioData/IO/WMA.cs
@@ -644,7 +644,7 @@ private bool readData(Stream source, ReadTagParams readTagParams)
return result;
}
- private bool isValid(FileData Data)
+ private static bool isValid(FileData Data)
{
return Data.Channels > 0 && Data.SampleRate >= 8000 && Data.SampleRate <= 96000;
}
@@ -699,7 +699,7 @@ private int write(TagData tag, BinaryWriter w, string zone)
};
}
- private int writeContentDescription(TagData tag, BinaryWriter w)
+ private static int writeContentDescription(TagData tag, BinaryWriter w)
{
var beginPos = w.BaseStream.Position;
w.Write(WMA_CONTENT_DESCRIPTION_ID);
@@ -903,7 +903,7 @@ private ushort writeExtendedMeta(TagData tag, BinaryWriter w, bool isExtendedMet
return counter;
}
- private void writeTextFrame(BinaryWriter writer, string frameCode, string text, bool isExtendedHeader = false, ushort languageIndex = 0, ushort streamNumber = 0)
+ private static void writeTextFrame(BinaryWriter writer, string frameCode, string text, bool isExtendedHeader = false, ushort languageIndex = 0, ushort streamNumber = 0)
{
byte[] nameBytes = Encoding.Unicode.GetBytes(frameCode + '\0');
ushort nameSize = (ushort)nameBytes.Length;
@@ -979,7 +979,7 @@ private void writeTextFrame(BinaryWriter writer, string frameCode, string text,
writer.BaseStream.Seek(finalFramePos, SeekOrigin.Begin);
}
- private void writePictureFrame(BinaryWriter writer, byte[] pictureData, string mimeType, byte pictureTypeCode, string description, bool isExtendedHeader = false, ushort languageIndex = 0, ushort streamNumber = 0)
+ private static void writePictureFrame(BinaryWriter writer, byte[] pictureData, string mimeType, byte pictureTypeCode, string description, bool isExtendedHeader = false, ushort languageIndex = 0, ushort streamNumber = 0)
{
byte[] nameBytes = Encoding.Unicode.GetBytes("WM/Picture" + '\0');
ushort nameSize = (ushort)nameBytes.Length;
diff --git a/ATL/AudioData/Utils/FileSurgeon.cs b/ATL/AudioData/Utils/FileSurgeon.cs
index 9b0a654a..18b9bec2 100644
--- a/ATL/AudioData/Utils/FileSurgeon.cs
+++ b/ATL/AudioData/Utils/FileSurgeon.cs
@@ -169,15 +169,10 @@ private async Task RewriteZonesAsync(
bool tagExists,
bool useBuffer)
{
- long oldTagSize;
- long newTagSize;
- long globalOffsetCorrection;
long globalCumulativeDelta = 0;
bool result = true;
- bool isBuffered;
IList zoneRegions = computeZoneRegions(zones, fullScopeWriter.Length);
- Stream writer;
displayRegions(zoneRegions);
@@ -192,6 +187,9 @@ private async Task RewriteZonesAsync(
MemoryStream buffer = null;
try
{
+ Stream writer;
+ bool isBuffered;
+ long globalOffsetCorrection;
if (useBuffer && region.IsBufferable)
{
isBuffered = true;
@@ -221,9 +219,7 @@ private async Task RewriteZonesAsync(
foreach (Zone zone in region.Zones)
{
- bool isNothing;
- oldTagSize = zone.Size;
- WriteResult writeResult;
+ var oldTagSize = zone.Size;
Logging.LogDelegator.GetLogDelegate()(Logging.Log.LV_DEBUG, "------ ZONE " + zone.Name + (zone.IsReadonly ? " (read-only) " : "") + "@" + zone.Offset);
Logging.LogDelegator.GetLogDelegate()(Logging.Log.LV_DEBUG, "Allocating " + Utils.GetBytesReadable(zone.Size));
@@ -231,6 +227,8 @@ private async Task RewriteZonesAsync(
// Write new tag to a MemoryStream
using (var memStream = new MemoryStream((int)Math.Min(zone.Size, int.MaxValue)))
{
+ WriteResult writeResult;
+ long newTagSize;
if (!zone.IsReadonly)
{
// DataSizeDelta needs to be incremented to be used by classes that don't use FileStructureHelper (e.g. FLAC)
@@ -275,7 +273,7 @@ private async Task RewriteZonesAsync(
newTagSize = oldTagSize;
}
long delta = newTagSize - oldTagSize;
- isNothing = 0 == oldTagSize && 0 == delta; // Avoids unnecessary operations to optimize processing time
+ var isNothing = 0 == oldTagSize && 0 == delta;
Logging.LogDelegator.GetLogDelegate()(Logging.Log.LV_DEBUG, "newTagSize : " + Utils.GetBytesReadable(newTagSize));
@@ -381,7 +379,7 @@ private async Task RewriteZonesAsync(
return result;
}
- private void displayRegions(IList zoneRegions)
+ private static void displayRegions(IList zoneRegions)
{
Logging.LogDelegator.GetLogDelegate()(Logging.Log.LV_DEBUG, "========================================");
Logging.LogDelegator.GetLogDelegate()(Logging.Log.LV_DEBUG, "Found " + zoneRegions.Count + " regions");
diff --git a/ATL/AudioData/Utils/TrackUtils.cs b/ATL/AudioData/Utils/TrackUtils.cs
index 9a950d89..4b547c8b 100644
--- a/ATL/AudioData/Utils/TrackUtils.cs
+++ b/ATL/AudioData/Utils/TrackUtils.cs
@@ -70,7 +70,7 @@ public static ushort ExtractTrackTotal(string str)
if (null == str) return 0;
str = str.Trim();
if (str.Length < 1) return 0;
- if (!str.Contains("/")) return 0;
+ if (!str.Contains('/')) return 0;
int delimiterOffset = str.IndexOf('/');
if (delimiterOffset == str.Length - 1) return 0;
@@ -331,7 +331,7 @@ public static string ExtractStrYear(string str)
/// Given track or disc number(s) formatted according to the given paramaters
public static string FormatWithLeadingZeroes(string value, bool overrideExistingFormat, int existingDigits, bool useLeadingZeroes, string total)
{
- if (value.Contains("/"))
+ if (value.Contains('/'))
{
string[] parts = value.Split('/');
return formatWithLeadingZeroesInternal(parts[0], overrideExistingFormat, existingDigits, useLeadingZeroes, parts[1]) + "/" + formatWithLeadingZeroesInternal(parts[1], overrideExistingFormat, existingDigits, useLeadingZeroes, parts[1]);
@@ -428,11 +428,11 @@ public static string FormatISOTimestamp(string year, string day, string month, s
StringBuilder result = new StringBuilder();
if (4 == year.Length && Utils.IsNumeric(year)) result.Append(year);
- if (2 == month.Length && Utils.IsNumeric(month)) result.Append("-").Append(month);
- if (2 == day.Length && Utils.IsNumeric(day)) result.Append("-").Append(day);
- if (2 == hour.Length && Utils.IsNumeric(hour)) result.Append("T").Append(hour);
- if (2 == minutes.Length && Utils.IsNumeric(minutes)) result.Append(":").Append(minutes);
- if (2 == seconds.Length && Utils.IsNumeric(seconds)) result.Append(":").Append(seconds);
+ if (2 == month.Length && Utils.IsNumeric(month)) result.Append('-').Append(month);
+ if (2 == day.Length && Utils.IsNumeric(day)) result.Append('-').Append(day);
+ if (2 == hour.Length && Utils.IsNumeric(hour)) result.Append('T').Append(hour);
+ if (2 == minutes.Length && Utils.IsNumeric(minutes)) result.Append(':').Append(minutes);
+ if (2 == seconds.Length && Utils.IsNumeric(seconds)) result.Append(':').Append(seconds);
return result.ToString();
}
diff --git a/ATL/AudioData/Utils/XmlArray.cs b/ATL/AudioData/Utils/XmlArray.cs
index 40d93765..7eb918a7 100644
--- a/ATL/AudioData/Utils/XmlArray.cs
+++ b/ATL/AudioData/Utils/XmlArray.cs
@@ -4,7 +4,6 @@
using System.Linq;
using System.Text;
using System.Xml;
-using System.Xml.Linq;
using ATL.AudioData.IO;
using ATL.Logging;
using Commons;
@@ -139,6 +138,7 @@ public int ToStream(BinaryWriter w, bool isLittleEndian, MetaDataIO meta)
Encoding = Encoding.UTF8
};
+ // Isolate all namespaces
var nsKeys = meta.AdditionalFields.Keys.Where(k => k.Contains("xmlns:")).ToHashSet();
var namespaces = new Dictionary();
foreach (var nsKey in nsKeys)
@@ -239,11 +239,7 @@ public int ToStream(BinaryWriter w, bool isLittleEndian, MetaDataIO meta)
}
// Close all terminated paths
- if (previousPathNodes != null)
- for (int i = previousPathNodes.Count - 2; i >= 0; i--)
- {
- writer.WriteEndElement();
- }
+ for (int i = previousPathNodes.Count - 2; i >= 0; i--) writer.WriteEndElement();
return 14;
}
diff --git a/ATL/CatalogDataReaders/BinaryLogic/Cue.cs b/ATL/CatalogDataReaders/BinaryLogic/Cue.cs
index b07688c1..d6198097 100644
--- a/ATL/CatalogDataReaders/BinaryLogic/Cue.cs
+++ b/ATL/CatalogDataReaders/BinaryLogic/Cue.cs
@@ -12,26 +12,22 @@ namespace ATL.CatalogDataReaders.BinaryLogic
///
public class Cue : ICatalogDataReader
{
- private string title = "";
- private string artist = "";
private readonly StringBuilder comments = new StringBuilder();
- readonly IList