Skip to content

Commit

Permalink
#175 Dropping support for legacy serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeAndNil committed Sep 9, 2024
1 parent b94b45a commit bb60359
Show file tree
Hide file tree
Showing 20 changed files with 51 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/build-preview.ps1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dotnet build -c Release '-p:GeneratePackages=true;VersionSuffix=preview.2' ./log4net/log4net.csproj
dotnet build -c Release '-p:GeneratePackages=true;VersionSuffix=preview.4' ./log4net/log4net.csproj
2 changes: 1 addition & 1 deletion src/log4net/Appender/FileAppender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class FileAppender : TextWriterAppender
/// </summary>
private sealed class LockingStream : Stream, IDisposable
{
[Serializable]
[Log4NetSerializable]
public sealed class LockStateException : LogException
{
public LockStateException(string message)
Expand Down
2 changes: 1 addition & 1 deletion src/log4net/Config/AliasRepositoryAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace log4net.Config
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
[Serializable]
[Log4NetSerializable]
public sealed class AliasRepositoryAttribute : Attribute
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/log4net/Config/PluginAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace log4net.Config
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
[Serializable]
[Log4NetSerializable]
public sealed class PluginAttribute : Attribute, IPluginFactory
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/log4net/Config/RepositoryAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace log4net.Config
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
[AttributeUsage(AttributeTargets.Assembly)]
[Serializable]
[Log4NetSerializable]
public sealed class RepositoryAttribute : Attribute
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/log4net/Config/SecurityContextProviderAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace log4net.Config
/// </remarks>
/// <author>Nicko Cadell</author>
[AttributeUsage(AttributeTargets.Assembly)]
[Serializable]
[Log4NetSerializable]
public sealed class SecurityContextProviderAttribute : ConfiguratorAttribute
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/log4net/Config/XmlConfiguratorAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace log4net.Config
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
[AttributeUsage(AttributeTargets.Assembly)]
[Serializable]
[Log4NetSerializable]
public sealed class XmlConfiguratorAttribute : ConfiguratorAttribute
{
/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/log4net/Core/Level.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ namespace log4net.Core;
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
[Serializable]
public class Level : IComparable, ISerializable, IEquatable<Level>, IComparable<Level>
[Log4NetSerializable]
public class Level : IComparable, ILog4NetSerializable, IEquatable<Level>, IComparable<Level>
{
/// <summary>
/// Constructor
Expand Down
4 changes: 2 additions & 2 deletions src/log4net/Core/LocationInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ namespace log4net.Core
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
[Serializable]
public class LocationInfo : ISerializable
[Log4NetSerializable]
public class LocationInfo : ILog4NetSerializable
{
/// <summary>
/// Constructor
Expand Down
2 changes: 1 addition & 1 deletion src/log4net/Core/LogException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace log4net.Core
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
[Serializable]
[Log4NetSerializable]
public class LogException : ApplicationException
{
/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/log4net/Core/LoggingEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ public struct LoggingEventData
/// <author>Gert Driesen</author>
/// <author>Douglas de la Torre</author>
/// <author>Daniel Cazzulino</author>
[Serializable]
public class LoggingEvent : ISerializable
[Log4NetSerializable]
public class LoggingEvent : ILog4NetSerializable
{
private static readonly Type declaringType = typeof(LoggingEvent);

Expand Down
2 changes: 1 addition & 1 deletion src/log4net/Core/MethodItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace log4net.Core
/// as that would require that the containing assembly is loaded.
/// </summary>
///
[Serializable]
[Log4NetSerializable]
public class MethodItem
{
/// <summary>
Expand Down
24 changes: 24 additions & 0 deletions src/log4net/Core/Serializable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#if NET462_OR_GREATER
global using Log4NetSerializableAttribute = System.SerializableAttribute;
global using ILog4NetSerializable = System.Runtime.Serialization.ISerializable;
#else
global using Log4NetSerializableAttribute = log4net.Core.EmptyAttribute;
global using ILog4NetSerializable = log4net.Core.IEmptyInterface;
using System;
#endif

namespace log4net.Core;
#if !NET462_OR_GREATER
/// <summary>
/// Empty Interface (as replacement for <see cref="System.Runtime.Serialization.ISerializable"/>)
/// </summary>
internal interface IEmptyInterface
{ }

/// <summary>
/// Empty Attribute (as replacement for <see cref="SerializableAttribute"/>)
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Delegate, Inherited = false)]
internal sealed class EmptyAttribute : Attribute
{ }
#endif
2 changes: 1 addition & 1 deletion src/log4net/Core/StackFrameItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace log4net.Core
/// Provides stack frame information without actually referencing a System.Diagnostics.StackFrame
/// as that would require that the containing assembly is loaded.
/// </summary>
[Serializable]
[Log4NetSerializable]
public class StackFrameItem
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/log4net/Util/EmptyCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace log4net.Util
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
[Serializable]
[Log4NetSerializable]
public sealed class EmptyCollection : ICollection
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/log4net/Util/EmptyDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace log4net.Util
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
[Serializable]
[Log4NetSerializable]
public sealed class EmptyDictionary : IDictionary
{
/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/log4net/Util/PropertiesDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ namespace log4net.Util
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
[Serializable]
public sealed class PropertiesDictionary : ReadOnlyPropertiesDictionary, ISerializable, IDictionary
[Log4NetSerializable]
public sealed class PropertiesDictionary : ReadOnlyPropertiesDictionary, ILog4NetSerializable, IDictionary
{
/// <summary>
/// Constructor
Expand Down
4 changes: 2 additions & 2 deletions src/log4net/Util/ReadOnlyPropertiesDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ namespace log4net.Util
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
[Serializable]
public class ReadOnlyPropertiesDictionary : ISerializable, IDictionary, IDictionary<string, object?>
[Log4NetSerializable]
public class ReadOnlyPropertiesDictionary : ILog4NetSerializable, IDictionary, IDictionary<string, object?>
{
private const string ReadOnlyMessage = "This is a read-only dictionary and cannot be modified";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace log4net.Util.TypeConverters
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
[Serializable]
[Log4NetSerializable]
public class ConversionNotSupportedException : ApplicationException
{
/// <summary>
Expand Down
4 changes: 4 additions & 0 deletions src/site/xdoc/release/release-notes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ limitations under the License.
<code>log4net.Appender.NetSendAppender</code>
<a href="https://github.com/apache/logging-log4net/pull/158">NetSendAdapter removed</a>
</li>
<li>
<code>Serializable Support removed (for .netstandard)</code>
<a href="https://github.com/apache/logging-log4net/discussions/175">Removing legacy serialization from log4net </a>
</li>
</ul>
</p>
<br/>
Expand Down

0 comments on commit bb60359

Please sign in to comment.