Skip to content

Commit

Permalink
Use StringBuilder.Append(char) instead of (string)
Browse files Browse the repository at this point in the history
CA1834: Use StringBuilder.Append(char) for single character strings
https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1834
  • Loading branch information
decriptor committed Jul 30, 2022
1 parent 55c816c commit fa2e0ab
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/TaglibSharp/Id3v2/Frames/AttachmentFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ public override string ToString ()

if (string.IsNullOrEmpty (Description)) {
builder.Append (Description);
builder.Append (" ");
builder.Append (' ');
}

builder.AppendFormat (System.Globalization.CultureInfo.InvariantCulture, "[{0}] {1} bytes", MimeType, Data.Count);
Expand Down
4 changes: 2 additions & 2 deletions src/TaglibSharp/Id3v2/Frames/TextIdentificationFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ protected override ByteVector RenderFields (byte version)
StringBuilder data = new StringBuilder ();
foreach (string s in text) {
if (!prev_value_indexed) {
data.Append (";").Append (s);
data.Append (';').Append (s);
continue;
}

Expand Down Expand Up @@ -1192,7 +1192,7 @@ public override string[] Text {
/// </returns>
public override string ToString ()
{
return new StringBuilder ().Append ("[")
return new StringBuilder ().Append ('[')
.Append (Description)
.Append ("] ")
.Append (base.ToString ()).ToString ();
Expand Down
2 changes: 1 addition & 1 deletion src/TaglibSharp/Id3v2/Frames/UrlLinkFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ public override string[] Text {
/// </returns>
public override string ToString ()
{
return new StringBuilder ().Append ("[")
return new StringBuilder ().Append ('[')
.Append (Description)
.Append ("] ")
.Append (base.ToString ()).ToString ();
Expand Down
4 changes: 2 additions & 2 deletions src/TaglibSharp/Id3v2/Tag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -979,14 +979,14 @@ protected void Parse (ByteVector data, File file, long position, ReadStyle style
if (tdat != null) {
string tdat_text = tdat.ToString ();
if (tdat_text.Length == 4) {
tdrc_text.Append ("-").Append (tdat_text, 0, 2).Append ("-").Append (tdat_text, 2, 2);
tdrc_text.Append ('-').Append (tdat_text, 0, 2).Append ('-').Append (tdat_text, 2, 2);

// Add the time
if (time != null) {
string time_text = time.ToString ();

if (time_text.Length == 4)
tdrc_text.Append ("T").Append (time_text, 0, 2).Append (":").Append (time_text, 2, 2);
tdrc_text.Append ('T').Append (time_text, 0, 2).Append (':').Append (time_text, 2, 2);

RemoveFrames (FrameType.TIME);
}
Expand Down
4 changes: 2 additions & 2 deletions src/TaglibSharp/Mpeg/AudioHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,10 @@ public string Description {
builder.Append ("MPEG Version ");
switch (Version) {
case Version.Version1:
builder.Append ("1");
builder.Append ('1');
break;
case Version.Version2:
builder.Append ("2");
builder.Append ('2');
break;
case Version.Version25:
builder.Append ("2.5");
Expand Down

0 comments on commit fa2e0ab

Please sign in to comment.