Skip to content

Commit

Permalink
Merge pull request #67
Browse files Browse the repository at this point in the history
Fix CA2000, CA2237, CA3075
  • Loading branch information
fluffynuts committed Sep 18, 2020
2 parents 0d2173d + 3941383 commit af29a3d
Show file tree
Hide file tree
Showing 8 changed files with 575 additions and 540 deletions.
2 changes: 1 addition & 1 deletion src/log4net/Appender/AdoNetAppender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ virtual protected string GetLogStatement(LoggingEvent logEvent)
}
else
{
StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
using StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
Layout.Format(writer, logEvent);
return writer.ToString();
}
Expand Down
25 changes: 24 additions & 1 deletion src/log4net/Appender/FileAppender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

using System;
using System.IO;
#if !NETCF && !NETSTANDARD1_3
using System.Runtime.Serialization;
#endif
using System.Text;
using System.Threading;
using log4net.Util;
Expand Down Expand Up @@ -138,12 +141,29 @@ public class FileAppender : TextWriterAppender
/// </summary>
private sealed class LockingStream : Stream, IDisposable
{
#if !NETCR
[Serializable]
#endif
public sealed class LockStateException : LogException
{
public LockStateException(string message)
: base(message)
{
}

public LockStateException()
{
}

public LockStateException(string message, Exception innerException) : base(message, innerException)
{
}

#if !NETCR && !NETSTANDARD1_3
private LockStateException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
#endif
}

private Stream m_realStream = null;
Expand Down Expand Up @@ -1409,7 +1429,10 @@ virtual protected void OpenFile(string fileName, bool append)
/// </remarks>
virtual protected void SetQWForFiles(Stream fileStream)
{
SetQWForFiles(new StreamWriter(fileStream, m_encoding));
#pragma warning disable CA2000 // Dispose objects before losing scope
StreamWriter writer = new StreamWriter(fileStream, m_encoding);
#pragma warning restore CA2000 // Dispose objects before losing scope
SetQWForFiles(writer);
}

/// <summary>
Expand Down
Loading

0 comments on commit af29a3d

Please sign in to comment.