Skip to content

Commit bb60359

Browse files
committed
#175 Dropping support for legacy serialization
1 parent b94b45a commit bb60359

20 files changed

+51
-23
lines changed

src/build-preview.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
dotnet build -c Release '-p:GeneratePackages=true;VersionSuffix=preview.2' ./log4net/log4net.csproj
1+
dotnet build -c Release '-p:GeneratePackages=true;VersionSuffix=preview.4' ./log4net/log4net.csproj

src/log4net/Appender/FileAppender.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public class FileAppender : TextWriterAppender
8686
/// </summary>
8787
private sealed class LockingStream : Stream, IDisposable
8888
{
89-
[Serializable]
89+
[Log4NetSerializable]
9090
public sealed class LockStateException : LogException
9191
{
9292
public LockStateException(string message)

src/log4net/Config/AliasRepositoryAttribute.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace log4net.Config
4141
/// <author>Nicko Cadell</author>
4242
/// <author>Gert Driesen</author>
4343
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
44-
[Serializable]
44+
[Log4NetSerializable]
4545
public sealed class AliasRepositoryAttribute : Attribute
4646
{
4747
/// <summary>

src/log4net/Config/PluginAttribute.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace log4net.Config
3939
/// <author>Nicko Cadell</author>
4040
/// <author>Gert Driesen</author>
4141
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
42-
[Serializable]
42+
[Log4NetSerializable]
4343
public sealed class PluginAttribute : Attribute, IPluginFactory
4444
{
4545
/// <summary>

src/log4net/Config/RepositoryAttribute.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace log4net.Config
4242
/// <author>Nicko Cadell</author>
4343
/// <author>Gert Driesen</author>
4444
[AttributeUsage(AttributeTargets.Assembly)]
45-
[Serializable]
45+
[Log4NetSerializable]
4646
public sealed class RepositoryAttribute : Attribute
4747
{
4848
/// <summary>

src/log4net/Config/SecurityContextProviderAttribute.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace log4net.Config
4242
/// </remarks>
4343
/// <author>Nicko Cadell</author>
4444
[AttributeUsage(AttributeTargets.Assembly)]
45-
[Serializable]
45+
[Log4NetSerializable]
4646
public sealed class SecurityContextProviderAttribute : ConfiguratorAttribute
4747
{
4848
/// <summary>

src/log4net/Config/XmlConfiguratorAttribute.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ namespace log4net.Config
7676
/// <author>Nicko Cadell</author>
7777
/// <author>Gert Driesen</author>
7878
[AttributeUsage(AttributeTargets.Assembly)]
79-
[Serializable]
79+
[Log4NetSerializable]
8080
public sealed class XmlConfiguratorAttribute : ConfiguratorAttribute
8181
{
8282
/// <summary>

src/log4net/Core/Level.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ namespace log4net.Core;
8282
/// </remarks>
8383
/// <author>Nicko Cadell</author>
8484
/// <author>Gert Driesen</author>
85-
[Serializable]
86-
public class Level : IComparable, ISerializable, IEquatable<Level>, IComparable<Level>
85+
[Log4NetSerializable]
86+
public class Level : IComparable, ILog4NetSerializable, IEquatable<Level>, IComparable<Level>
8787
{
8888
/// <summary>
8989
/// Constructor

src/log4net/Core/LocationInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ namespace log4net.Core
5757
/// </remarks>
5858
/// <author>Nicko Cadell</author>
5959
/// <author>Gert Driesen</author>
60-
[Serializable]
61-
public class LocationInfo : ISerializable
60+
[Log4NetSerializable]
61+
public class LocationInfo : ILog4NetSerializable
6262
{
6363
/// <summary>
6464
/// Constructor

src/log4net/Core/LogException.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace log4net.Core
3434
/// </remarks>
3535
/// <author>Nicko Cadell</author>
3636
/// <author>Gert Driesen</author>
37-
[Serializable]
37+
[Log4NetSerializable]
3838
public class LogException : ApplicationException
3939
{
4040
/// <summary>

src/log4net/Core/LoggingEvent.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ public struct LoggingEventData
164164
/// <author>Gert Driesen</author>
165165
/// <author>Douglas de la Torre</author>
166166
/// <author>Daniel Cazzulino</author>
167-
[Serializable]
168-
public class LoggingEvent : ISerializable
167+
[Log4NetSerializable]
168+
public class LoggingEvent : ILog4NetSerializable
169169
{
170170
private static readonly Type declaringType = typeof(LoggingEvent);
171171

src/log4net/Core/MethodItem.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace log4net.Core
2828
/// as that would require that the containing assembly is loaded.
2929
/// </summary>
3030
///
31-
[Serializable]
31+
[Log4NetSerializable]
3232
public class MethodItem
3333
{
3434
/// <summary>

src/log4net/Core/Serializable.cs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#if NET462_OR_GREATER
2+
global using Log4NetSerializableAttribute = System.SerializableAttribute;
3+
global using ILog4NetSerializable = System.Runtime.Serialization.ISerializable;
4+
#else
5+
global using Log4NetSerializableAttribute = log4net.Core.EmptyAttribute;
6+
global using ILog4NetSerializable = log4net.Core.IEmptyInterface;
7+
using System;
8+
#endif
9+
10+
namespace log4net.Core;
11+
#if !NET462_OR_GREATER
12+
/// <summary>
13+
/// Empty Interface (as replacement for <see cref="System.Runtime.Serialization.ISerializable"/>)
14+
/// </summary>
15+
internal interface IEmptyInterface
16+
{ }
17+
18+
/// <summary>
19+
/// Empty Attribute (as replacement for <see cref="SerializableAttribute"/>)
20+
/// </summary>
21+
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Delegate, Inherited = false)]
22+
internal sealed class EmptyAttribute : Attribute
23+
{ }
24+
#endif

src/log4net/Core/StackFrameItem.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace log4net.Core
2828
/// Provides stack frame information without actually referencing a System.Diagnostics.StackFrame
2929
/// as that would require that the containing assembly is loaded.
3030
/// </summary>
31-
[Serializable]
31+
[Log4NetSerializable]
3232
public class StackFrameItem
3333
{
3434
/// <summary>

src/log4net/Util/EmptyCollection.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace log4net.Util
3333
/// </remarks>
3434
/// <author>Nicko Cadell</author>
3535
/// <author>Gert Driesen</author>
36-
[Serializable]
36+
[Log4NetSerializable]
3737
public sealed class EmptyCollection : ICollection
3838
{
3939
/// <summary>

src/log4net/Util/EmptyDictionary.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace log4net.Util
3333
/// </remarks>
3434
/// <author>Nicko Cadell</author>
3535
/// <author>Gert Driesen</author>
36-
[Serializable]
36+
[Log4NetSerializable]
3737
public sealed class EmptyDictionary : IDictionary
3838
{
3939
/// <summary>

src/log4net/Util/PropertiesDictionary.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ namespace log4net.Util
3636
/// </remarks>
3737
/// <author>Nicko Cadell</author>
3838
/// <author>Gert Driesen</author>
39-
[Serializable]
40-
public sealed class PropertiesDictionary : ReadOnlyPropertiesDictionary, ISerializable, IDictionary
39+
[Log4NetSerializable]
40+
public sealed class PropertiesDictionary : ReadOnlyPropertiesDictionary, ILog4NetSerializable, IDictionary
4141
{
4242
/// <summary>
4343
/// Constructor

src/log4net/Util/ReadOnlyPropertiesDictionary.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ namespace log4net.Util
4040
/// </remarks>
4141
/// <author>Nicko Cadell</author>
4242
/// <author>Gert Driesen</author>
43-
[Serializable]
44-
public class ReadOnlyPropertiesDictionary : ISerializable, IDictionary, IDictionary<string, object?>
43+
[Log4NetSerializable]
44+
public class ReadOnlyPropertiesDictionary : ILog4NetSerializable, IDictionary, IDictionary<string, object?>
4545
{
4646
private const string ReadOnlyMessage = "This is a read-only dictionary and cannot be modified";
4747

src/log4net/Util/TypeConverters/ConversionNotSupportedException.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace log4net.Util.TypeConverters
3434
/// </remarks>
3535
/// <author>Nicko Cadell</author>
3636
/// <author>Gert Driesen</author>
37-
[Serializable]
37+
[Log4NetSerializable]
3838
public class ConversionNotSupportedException : ApplicationException
3939
{
4040
/// <summary>

src/site/xdoc/release/release-notes.xml

+4
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ limitations under the License.
137137
<code>log4net.Appender.NetSendAppender</code>
138138
<a href="https://github.com/apache/logging-log4net/pull/158">NetSendAdapter removed</a>
139139
</li>
140+
<li>
141+
<code>Serializable Support removed (for .netstandard)</code>
142+
<a href="https://github.com/apache/logging-log4net/discussions/175">Removing legacy serialization from log4net </a>
143+
</li>
140144
</ul>
141145
</p>
142146
<br/>

0 commit comments

Comments
 (0)