Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using FluentNHibernate.Cfg;
using FluentNHibernate.Utils;
using NUnit.Framework;

namespace FluentNHibernate.Testing.Cfg;

[TestFixture]
[Obsolete("BinaryFormatter serialization is obsolete and should not be used.")]
public class ExceptionSerializationTests
{
[Test]
Expand Down
5 changes: 3 additions & 2 deletions src/FluentNHibernate/Automapping/AutoMappingException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ public class AutoMappingException : Exception
{
public AutoMappingException(string message)
: base(message)
{}
{ }

[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
protected AutoMappingException(SerializationInfo info, StreamingContext context) : base(info, context)
{}
{ }
}
4 changes: 4 additions & 0 deletions src/FluentNHibernate/Cfg/FluentConfigurationException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public FluentConfigurationException(string message, Exception innerException)
PotentialReasons = new List<string>();
}

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

#pragma warning disable 809
[SecurityCritical]
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue("PotentialReasons", PotentialReasons, typeof(List<string>));
}
#pragma warning restore 809
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public UnmappedPropertyException(Type type, string name)
: base("Unmapped property '" + name + "' on type '" + type.Name + "'")
{}

[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
protected UnmappedPropertyException(SerializationInfo info, StreamingContext context) : base(info, context)
{}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace FluentNHibernate.Infrastructure;
/// </summary>
public static class NetStandardSerialization
{
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
public sealed class TypeSerializationSurrogate : ISurrogateProvider
{
public void GetObjectData(object obj, SerializationInfo info, StreamingContext context)
Expand Down Expand Up @@ -55,6 +56,7 @@ public object GetRealObject(StreamingContext context)
}
}

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

[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
public sealed class SurrogateSelector : ISurrogateSelector
{
private readonly ISurrogateProvider _typeSerializationProvider;
Expand Down
1 change: 1 addition & 0 deletions src/FluentNHibernate/Infrastructure/ResolveException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public ResolveException(Type type)
: base("Unable to resolve dependency: '" + type.FullName + "'")
{}

[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
protected ResolveException(SerializationInfo info, StreamingContext context) : base(info, context)
{}
}
1 change: 1 addition & 0 deletions src/FluentNHibernate/Infrastructure/Serialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public static class Serialization
/// Extend <see cref="ISerializationSurrogate"/> with a "tester" method used by <see cref="SurrogateSelector"/>.
/// Reference Via: https://github.com/CXuesong/BotBuilder.Standard/blob/netcore20%2Bnet45/CSharp/Library/Microsoft.Bot.Builder/Fibers/NetStandardSerialization.cs
/// </summary>
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
public interface ISurrogateProvider : ISerializationSurrogate
{
/// <summary>
Expand Down
5 changes: 3 additions & 2 deletions src/FluentNHibernate/Mapping/InvalidPrefixException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ namespace FluentNHibernate.Mapping;
public class InvalidPrefixException : Exception
{
public InvalidPrefixException(string message) : base(message)
{}
{ }

[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
protected InvalidPrefixException(SerializationInfo info, StreamingContext context) : base(info, context)
{}
{ }
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ namespace FluentNHibernate.MappingModel.Collections;
public class LayeredValues : Dictionary<int, object>
{
public LayeredValues()
{}
{ }

protected LayeredValues(SerializationInfo info, StreamingContext context)
: base(info, context)
{}
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
protected LayeredValues(SerializationInfo info, StreamingContext context) : base(info, context)
{ }
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ public ConventionException(string message, object conventionTarget) : base(messa
this.conventionTarget = conventionTarget;
}

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

public object ConventionTarget
{
Expand Down
5 changes: 3 additions & 2 deletions src/FluentNHibernate/MissingConstructorException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ public class MissingConstructorException : Exception
{
public MissingConstructorException(Type type)
: base("'" + type.AssemblyQualifiedName + "' is missing a parameterless constructor.")
{}
{ }

[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
protected MissingConstructorException(SerializationInfo info, StreamingContext context) : base(info, context)
{}
{ }
}
6 changes: 5 additions & 1 deletion src/FluentNHibernate/UnknownPropertyException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,21 @@ public UnknownPropertyException(Type classType, string propertyName)

public Type Type { get; private set; }

[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
protected UnknownPropertyException(SerializationInfo info, StreamingContext context) : base(info, context)
{
this.Type = Type.GetType(info.GetString("TypeFullName"));
this.Property = info.GetString("Property");
}

#pragma warning disable 809
[SecurityCritical]
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
[Obsolete("This API supports obsolete formatter-based serialization and will be removed in a future version")]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue("TypeFullName", Type.FullName);
info.AddValue("Property", Property);
}
#pragma warning restore 809
}