Skip to content

Commit af29a3d

Browse files
authored
Merge pull request #67
Fix CA2000, CA2237, CA3075
2 parents 0d2173d + 3941383 commit af29a3d

File tree

8 files changed

+575
-540
lines changed

8 files changed

+575
-540
lines changed

src/log4net/Appender/AdoNetAppender.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ virtual protected string GetLogStatement(LoggingEvent logEvent)
617617
}
618618
else
619619
{
620-
StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
620+
using StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
621621
Layout.Format(writer, logEvent);
622622
return writer.ToString();
623623
}

src/log4net/Appender/FileAppender.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
using System;
2121
using System.IO;
22+
#if !NETCF && !NETSTANDARD1_3
23+
using System.Runtime.Serialization;
24+
#endif
2225
using System.Text;
2326
using System.Threading;
2427
using log4net.Util;
@@ -138,12 +141,29 @@ public class FileAppender : TextWriterAppender
138141
/// </summary>
139142
private sealed class LockingStream : Stream, IDisposable
140143
{
144+
#if !NETCR
145+
[Serializable]
146+
#endif
141147
public sealed class LockStateException : LogException
142148
{
143149
public LockStateException(string message)
144150
: base(message)
145151
{
146152
}
153+
154+
public LockStateException()
155+
{
156+
}
157+
158+
public LockStateException(string message, Exception innerException) : base(message, innerException)
159+
{
160+
}
161+
162+
#if !NETCR && !NETSTANDARD1_3
163+
private LockStateException(SerializationInfo info, StreamingContext context) : base(info, context)
164+
{
165+
}
166+
#endif
147167
}
148168

149169
private Stream m_realStream = null;
@@ -1409,7 +1429,10 @@ virtual protected void OpenFile(string fileName, bool append)
14091429
/// </remarks>
14101430
virtual protected void SetQWForFiles(Stream fileStream)
14111431
{
1412-
SetQWForFiles(new StreamWriter(fileStream, m_encoding));
1432+
#pragma warning disable CA2000 // Dispose objects before losing scope
1433+
StreamWriter writer = new StreamWriter(fileStream, m_encoding);
1434+
#pragma warning restore CA2000 // Dispose objects before losing scope
1435+
SetQWForFiles(writer);
14131436
}
14141437

14151438
/// <summary>

0 commit comments

Comments
 (0)