Skip to content

Fix CA2000, CA2237, CA3075 #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should refactor this somehow.

StreamWriter writer = new StreamWriter(fileStream, m_encoding);
#pragma warning restore CA2000 // Dispose objects before losing scope
SetQWForFiles(writer);
}

/// <summary>
Expand Down
Loading