Skip to content

Commit 13e3eb9

Browse files
authored
Obsolete APIs related to BinaryFormatter (#648)
+semver:minor
1 parent ce48033 commit 13e3eb9

File tree

12 files changed

+32
-17
lines changed

12 files changed

+32
-17
lines changed

src/FluentNHibernate.Testing/Cfg/ExceptionSerializationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
using System.IO;
33
using System.Runtime.Serialization.Formatters.Binary;
44
using FluentNHibernate.Cfg;
5-
using FluentNHibernate.Utils;
65
using NUnit.Framework;
76

87
namespace FluentNHibernate.Testing.Cfg;
98

109
[TestFixture]
10+
[Obsolete("BinaryFormatter serialization is obsolete and should not be used.")]
1111
public class ExceptionSerializationTests
1212
{
1313
[Test]

src/FluentNHibernate/Automapping/AutoMappingException.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ public class AutoMappingException : Exception
88
{
99
public AutoMappingException(string message)
1010
: base(message)
11-
{}
11+
{ }
1212

13+
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
1314
protected AutoMappingException(SerializationInfo info, StreamingContext context) : base(info, context)
14-
{}
15+
{ }
1516
}

src/FluentNHibernate/Cfg/FluentConfigurationException.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public FluentConfigurationException(string message, Exception innerException)
1414
PotentialReasons = new List<string>();
1515
}
1616

17+
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
1718
protected FluentConfigurationException(SerializationInfo info, StreamingContext context) : base(info, context)
1819
{
1920
this.PotentialReasons = info.GetValue("PotentialReasons", typeof(List<string>)) as List<string>;
@@ -54,10 +55,13 @@ public override string ToString()
5455
return output;
5556
}
5657

58+
#pragma warning disable 809
5759
[SecurityCritical]
60+
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
5861
public override void GetObjectData(SerializationInfo info, StreamingContext context)
5962
{
6063
base.GetObjectData(info, context);
6164
info.AddValue("PotentialReasons", PotentialReasons, typeof(List<string>));
6265
}
66+
#pragma warning restore 809
6367
}

src/FluentNHibernate/Conventions/Inspections/UnmappedPropertyException.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public UnmappedPropertyException(Type type, string name)
1010
: base("Unmapped property '" + name + "' on type '" + type.Name + "'")
1111
{}
1212

13+
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
1314
protected UnmappedPropertyException(SerializationInfo info, StreamingContext context) : base(info, context)
1415
{}
1516
}

src/FluentNHibernate/Infrastructure/NetStandardSerialization.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace FluentNHibernate.Infrastructure;
1212
/// </summary>
1313
public static class NetStandardSerialization
1414
{
15+
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
1516
public sealed class TypeSerializationSurrogate : ISurrogateProvider
1617
{
1718
public void GetObjectData(object obj, SerializationInfo info, StreamingContext context)
@@ -55,6 +56,7 @@ public object GetRealObject(StreamingContext context)
5556
}
5657
}
5758

59+
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
5860
public sealed class MemberInfoSerializationSurrogate : ISurrogateProvider
5961
{
6062
public void GetObjectData(object obj, SerializationInfo info, StreamingContext context) =>
@@ -166,6 +168,7 @@ public object GetRealObject(StreamingContext context)
166168
}
167169
}
168170

171+
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
169172
public sealed class SurrogateSelector : ISurrogateSelector
170173
{
171174
private readonly ISurrogateProvider _typeSerializationProvider;

src/FluentNHibernate/Infrastructure/ResolveException.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public ResolveException(Type type)
1010
: base("Unable to resolve dependency: '" + type.FullName + "'")
1111
{}
1212

13+
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
1314
protected ResolveException(SerializationInfo info, StreamingContext context) : base(info, context)
1415
{}
1516
}

src/FluentNHibernate/Infrastructure/Serialization.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public static class Serialization
99
/// Extend <see cref="ISerializationSurrogate"/> with a "tester" method used by <see cref="SurrogateSelector"/>.
1010
/// Reference Via: https://github.com/CXuesong/BotBuilder.Standard/blob/netcore20%2Bnet45/CSharp/Library/Microsoft.Bot.Builder/Fibers/NetStandardSerialization.cs
1111
/// </summary>
12+
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
1213
public interface ISurrogateProvider : ISerializationSurrogate
1314
{
1415
/// <summary>

src/FluentNHibernate/Mapping/InvalidPrefixException.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ namespace FluentNHibernate.Mapping;
1010
public class InvalidPrefixException : Exception
1111
{
1212
public InvalidPrefixException(string message) : base(message)
13-
{}
13+
{ }
1414

15+
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
1516
protected InvalidPrefixException(SerializationInfo info, StreamingContext context) : base(info, context)
16-
{}
17+
{ }
1718
}

src/FluentNHibernate/MappingModel/Collections/LayeredValues.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ namespace FluentNHibernate.MappingModel.Collections;
88
public class LayeredValues : Dictionary<int, object>
99
{
1010
public LayeredValues()
11-
{}
11+
{ }
1212

13-
protected LayeredValues(SerializationInfo info, StreamingContext context)
14-
: base(info, context)
15-
{}
13+
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
14+
protected LayeredValues(SerializationInfo info, StreamingContext context) : base(info, context)
15+
{ }
1616
}

src/FluentNHibernate/MappingModel/Conventions/ConventionException.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ public ConventionException(string message, object conventionTarget) : base(messa
1313
this.conventionTarget = conventionTarget;
1414
}
1515

16-
protected ConventionException(
17-
SerializationInfo info,
18-
StreamingContext context) : base(info, context)
19-
{
20-
}
16+
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
17+
protected ConventionException(SerializationInfo info, StreamingContext context) : base(info, context)
18+
{ }
2119

2220
public object ConventionTarget
2321
{

0 commit comments

Comments
 (0)