Skip to content

Commit efe234c

Browse files
committed
Make exception types serializable only for the .NET Framework
1 parent 88539ad commit efe234c

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/Castle.Core/Core/Logging/LoggerException.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ namespace Castle.Core.Logging
1717
using System;
1818
using System.Runtime.Serialization;
1919

20+
#if FEATURE_SERIALIZATION
2021
[Serializable]
22+
#endif
2123
public class LoggerException : Exception
2224
{
2325
public LoggerException()
@@ -32,8 +34,10 @@ public LoggerException(string message, Exception innerException) : base(message,
3234
{
3335
}
3436

37+
#if FEATURE_SERIALIZATION
3538
protected LoggerException(SerializationInfo info, StreamingContext context) : base(info, context)
3639
{
3740
}
41+
#endif
3842
}
3943
}

src/Castle.Core/Core/Resource/ResourceException.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ namespace Castle.Core.Resource
1717
using System;
1818
using System.Runtime.Serialization;
1919

20+
#if FEATURE_SERIALIZATION
2021
[Serializable]
22+
#endif
2123
public class ResourceException : Exception
2224
{
2325
public ResourceException()
@@ -32,8 +34,10 @@ public ResourceException(string message, Exception innerException) : base(messag
3234
{
3335
}
3436

37+
#if FEATURE_SERIALIZATION
3538
protected ResourceException(SerializationInfo info, StreamingContext context) : base(info, context)
3639
{
3740
}
41+
#endif
3842
}
3943
}

src/Castle.Core/DynamicProxy/DynamicProxyException.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ namespace Castle.DynamicProxy
2323
// Prefer throwing Base Class Library exception types wherever appropriate.
2424
// This exception type is to be used mostly when something inside DynamicProxy goes wrong.
2525
// Think of it as a "failed assertion" / "bug" exception.
26+
#if FEATURE_SERIALIZATION
2627
[Serializable]
28+
#endif
2729
public sealed class DynamicProxyException : Exception
2830
{
2931
internal DynamicProxyException(string message) : base(message)
@@ -34,8 +36,10 @@ internal DynamicProxyException(string message, Exception innerException) : base(
3436
{
3537
}
3638

39+
#if FEATURE_SERIALIZATION
3740
internal DynamicProxyException(SerializationInfo info, StreamingContext context) : base(info, context)
3841
{
3942
}
43+
#endif
4044
}
4145
}

0 commit comments

Comments
 (0)