diff --git a/src/Coherence.SessionStore/Coherence.SessionStore.csproj b/src/Coherence.SessionStore/Coherence.SessionStore.csproj index 644236a..ffd4dc4 100644 --- a/src/Coherence.SessionStore/Coherence.SessionStore.csproj +++ b/src/Coherence.SessionStore/Coherence.SessionStore.csproj @@ -1,7 +1,7 @@ - net6.0 + net6.0;net8.0 enable disable Tangosol @@ -13,6 +13,7 @@ Oracle Coherence SessionStore 14.1.2.0 14.1.2.0 + true diff --git a/src/Coherence/Coherence.csproj b/src/Coherence/Coherence.csproj index de95030..9de6f39 100644 --- a/src/Coherence/Coherence.csproj +++ b/src/Coherence/Coherence.csproj @@ -1,13 +1,14 @@ - net6.0 + net6.0;net8.0 Tangosol true prompt 4 true 162, 618, 675 + true @@ -42,10 +43,10 @@ https://raw.githubusercontent.com/oracle/coherence-dotnet-extend-client/main/assets/coherence-logo.png coherence-logo.png - This is a .NET 6 implementation of Oracle Coherence .NET Extend Client. + Implementation of Oracle Coherence .NET Extend Client. - For release notes, please visit https://github.com/oracle/coherence-dotnet-extend-client/releases/tag/$(Version)-core/. + For release notes, please visit https://github.com/oracle/coherence-dotnet-extend-client/releases/tag/$(Version)/. IMDG;Scalable;Distributed;DB;Cache;Microservices Oracle @@ -56,14 +57,14 @@ snupkg - + DEBUG;TRACE true true bin\Debug - + true bin\Release @@ -71,10 +72,18 @@ - + + + + + + + + + diff --git a/src/Coherence/IO/BinarySerializer.cs b/src/Coherence/IO/BinarySerializer.cs deleted file mode 100644 index 378c42c..0000000 --- a/src/Coherence/IO/BinarySerializer.cs +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. - * - * Licensed under the Universal Permissive License v 1.0 as shown at - * http://oss.oracle.com/licenses/upl. - */ - -using System; -using System.IO; -using System.Runtime.Serialization.Formatters.Binary; - -namespace Tangosol.IO -{ - /// - /// implementation that uses .NET binary - /// serializer. - /// - /// - /// As of 14.1.2.0, this class is deprecated as it relies on - /// , which is scheduled for removal - /// in .NET 9. - /// - /// Aleksandar Seovic 2009.06.22 - /// Coherence 3.5 - [Obsolete("since Coherence 14.1.2.0")] - public class BinarySerializer : ISerializer - { - #region Implementation of ISerializer - - /// - /// Serialize an object to a stream by writing its state using the - /// specified object. - /// - /// - /// The DataWriter with which to write the object's state. - /// - /// - /// The object to serialize. - /// - /// - /// If an I/O error occurs. - /// - public void Serialize(DataWriter writer, object o) - { - BinaryFormatter formatter = new BinaryFormatter(); - formatter.Serialize(writer.BaseStream, o); - } - - /// - /// Deserialize an object from a stream by reading its state using - /// the specified object. - /// - /// - /// The DataReader with which to read the object's state. - /// - /// - /// The deserialized user type instance. - /// - /// - /// If an I/O error occurs. - /// - public object Deserialize(DataReader reader) - { - BinaryFormatter formatter = new BinaryFormatter(); - return formatter.Deserialize(reader.BaseStream); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Coherence/IO/OptimizedBinarySerializer.cs b/src/Coherence/IO/OptimizedBinarySerializer.cs deleted file mode 100644 index 665d894..0000000 --- a/src/Coherence/IO/OptimizedBinarySerializer.cs +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. - * - * Licensed under the Universal Permissive License v 1.0 as shown at - * http://oss.oracle.com/licenses/upl. - */ -using System; -using System.IO; -using System.Runtime.Serialization.Formatters.Binary; - -namespace Tangosol.IO -{ - /// - /// implementation that optimizes serialization - /// of primitive types and falls back to .NET BinaryFormatter for - /// custom types. - /// - /// - /// - /// As of 14.1.2.0, this class is deprecated as it relies on a - /// deprecated - /// - /// - /// Aleksandar Seovic 2010.03.17 - /// Coherence 3.6 - [Obsolete("since Coherence 14.1.2.0")] - public class OptimizedBinarySerializer : ISerializer - { - #region Implementation of ISerializer - - /// - /// Serialize an object to a stream by writing its state using the - /// specified object. - /// - /// - /// The DataWriter with which to write the object's state. - /// - /// - /// The object to serialize. - /// - /// - /// If an I/O error occurs. - /// - public void Serialize(DataWriter writer, Object o) - { - TypeId typeId = GetTypeId(o); - writer.Write((Byte) typeId); - - switch (typeId) - { - case TypeId.NULL: - break; - - case TypeId.BYTE: - writer.Write((Byte) o); - break; - - case TypeId.CHAR: - writer.Write((Char) o); - break; - - case TypeId.STRING: - writer.Write((String) o); - break; - - case TypeId.BOOL: - writer.Write((Boolean) o); - break; - - case TypeId.INT16: - writer.Write((Int16) o); - break; - - case TypeId.INT32: - writer.WritePackedInt32((Int32) o); - break; - - case TypeId.INT64: - writer.WritePackedInt64((Int64) o); - break; - - case TypeId.SINGLE: - writer.Write((Single) o); - break; - - case TypeId.DOUBLE: - writer.Write((Double) o); - break; - - case TypeId.DECIMAL: - int[] bits = Decimal.GetBits((Decimal) o); - for (int i = 0; i < 4; i++) - { - writer.WritePackedInt32(bits[i]); - } - break; - - case TypeId.DATETIME: - DateTime dt = (DateTime) o; - writer.WritePackedInt64(dt.Ticks); - break; - - case TypeId.TIMESPAN: - TimeSpan ts = (TimeSpan) o; - writer.WritePackedInt64(ts.Ticks); - break; - - case TypeId.GUID: - byte[] bytes = ((Guid) o).ToByteArray(); - writer.Write(bytes); - break; - - case TypeId.BYTE_ARRAY: - byte[] arrBytes = (Byte[]) o; - writer.WritePackedInt32(arrBytes.Length); - writer.Write(arrBytes); - break; - - default: - BinaryFormatter formatter = new BinaryFormatter(); - formatter.Serialize(writer.BaseStream, o); - break; - } - } - - /// - /// Deserialize an object from a stream by reading its state using - /// the specified object. - /// - /// - /// The DataReader with which to read the object's state. - /// - /// - /// The deserialized user type instance. - /// - /// - /// If an I/O error occurs. - /// - public object Deserialize(DataReader reader) - { - TypeId typeId = (TypeId) Enum.ToObject(typeof(TypeId), reader.ReadByte()); - - switch (typeId) - { - case TypeId.NULL: - return null; - - case TypeId.BYTE: - return reader.ReadByte(); - - case TypeId.CHAR: - return reader.ReadChar(); - - case TypeId.STRING: - return reader.ReadString(); - - case TypeId.BOOL: - return reader.ReadBoolean(); - - case TypeId.INT16: - return reader.ReadInt16(); - - case TypeId.INT32: - return reader.ReadPackedInt32(); - - case TypeId.INT64: - return reader.ReadPackedInt64(); - - case TypeId.SINGLE: - return reader.ReadSingle(); - - case TypeId.DOUBLE: - return reader.ReadDouble(); - - case TypeId.DECIMAL: - int[] bits = new int[4]; - for (int i = 0; i < 4; i++) - { - bits[i] = reader.ReadPackedInt32(); - } - return new Decimal(bits); - - case TypeId.DATETIME: - return new DateTime(reader.ReadPackedInt64()); - - case TypeId.TIMESPAN: - return new TimeSpan(reader.ReadPackedInt64()); - - case TypeId.GUID: - return new Guid(reader.ReadBytes(0x10)); - - case TypeId.BYTE_ARRAY: - int cb = reader.ReadPackedInt32(); - return reader.ReadBytes(cb); - - default: - BinaryFormatter formatter = new BinaryFormatter(); - return formatter.Deserialize(reader.BaseStream); - } - } - - #endregion - - #region Helper methods - - private static TypeId GetTypeId(object o) - { - return o == null ? TypeId.NULL - : o is byte ? TypeId.BYTE - : o is char ? TypeId.CHAR - : o is string ? TypeId.STRING - : o is bool ? TypeId.BOOL - : o is Int16 ? TypeId.INT16 - : o is Int32 ? TypeId.INT32 - : o is Int64 ? TypeId.INT64 - : o is Single ? TypeId.SINGLE - : o is Double ? TypeId.DOUBLE - : o is Decimal ? TypeId.DECIMAL - : o is DateTime ? TypeId.DATETIME - : o is TimeSpan ? TypeId.TIMESPAN - : o is Guid ? TypeId.GUID - : o is Byte[] ? TypeId.BYTE_ARRAY - : TypeId.USER_TYPE; - } - - #endregion - - #region TypeId enumeration - - private enum TypeId : byte - { - NULL, - BYTE, - CHAR, - STRING, - BOOL, - INT16, - INT32, - INT64, - SINGLE, - DOUBLE, - DECIMAL, - DATETIME, - TIMESPAN, - GUID, - BYTE_ARRAY, - USER_TYPE - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Coherence/IO/Pof/BinaryPofSerializer.cs b/src/Coherence/IO/Pof/BinaryPofSerializer.cs deleted file mode 100644 index 61101d7..0000000 --- a/src/Coherence/IO/Pof/BinaryPofSerializer.cs +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. - * - * Licensed under the Universal Permissive License v 1.0 as shown at - * http://oss.oracle.com/licenses/upl. - */ -using System; -using System.Diagnostics; -using System.IO; -using System.Runtime.Serialization; -using System.Runtime.Serialization.Formatters.Binary; - -namespace Tangosol.IO.Pof -{ - /// implementation that supports - /// the serialization and deserialization of any serializable .NET type. - /// - /// - /// - /// As of 14.1.2.0, this class is deprecated as it relies on a - /// deprecated - /// - /// - /// Goran Milosavljevic 2007.08.23 - /// Coherence 3.4 - [Obsolete("since Coherence 14.1.2.0")] - public class BinaryPofSerializer : IPofSerializer - { - #region Constructors - - /// - /// Create a new BinaryPofSerializer for the user type with - /// the given type identifier. - /// - /// - /// The user type identifier. - /// - public BinaryPofSerializer(int typeId) - { - Debug.Assert(typeId >= 0, "user type identifier cannot be negative"); - m_typeId = typeId; - } - - #endregion - - #region IPofSerializer Members - - /// - /// Serialize a user type instance to a POF stream by writing its - /// state using the specified object. - /// - /// - /// An implementation of IPofSerializer is required to follow - /// the following steps in sequence for writing out an object of a - /// user type: - /// - /// - /// - /// The implementation may write any combination of the properties of - /// the user type by using the "write" methods of the - /// IPofWriter, but it must do so in the order of the property - /// indexes. - /// - /// - /// - /// - /// After all desired properties of the user type have been written, - /// the implementation must terminate the writing of the user type by - /// calling . - /// - /// - /// - /// - /// - /// The IPofWriter with which to write the object's state. - /// - /// - /// The object to serialize. - /// - /// - /// If an I/O error occurs. - /// - public void Serialize(IPofWriter writer, object o) - { - MemoryStream stream = new MemoryStream(); - try - { - new BinaryFormatter().Serialize(stream, o); - - stream.Position = 0; - writer.WriteObject(0, stream.GetBuffer()); - writer.WriteRemainder(null); - } - catch (SerializationException e) - { - string typeName = null; - try - { - typeName = writer.PofContext.GetTypeName(m_typeId); - } - catch (Exception) - { } - - string actual = o.GetType().FullName; - throw new IOException( - "An exception occurred writing an object" - + " user type to a POF stream: type-id=" + m_typeId - + (typeName == null ? "" : ", class-name=" + typeName) - + (actual == null ? "" : ", actual class-name=" + actual) - + ", exception=\n" + e); - } - finally - { - stream.Close(); - } - } - - /// - /// Deserialize a user type instance from a POF stream by reading its - /// state using the specified object. - /// - /// - /// An implementation of IPofSerializer is required to follow - /// the following steps in sequence for reading in an object of a - /// user type: - /// - /// - /// - /// The implementation may read any combination of the - /// properties of the user type by using "read" methods of the - /// IPofReader, but it must do so in the order of the property - /// indexes. - /// - /// - /// - /// - /// After all desired properties of the user type have been read, - /// the implementation must terminate the reading of the user type by - /// calling . - /// - /// - /// - /// - /// - /// The IPofReader with which to read the object's state. - /// - /// - /// The deserialized user type instance. - /// - /// - /// If an I/O error occurs. - /// - public object Deserialize(IPofReader reader) - { - MemoryStream stream = new MemoryStream((byte[]) reader.ReadObject(0)); - try - { - reader.ReadRemainder(); - return new BinaryFormatter().Deserialize(stream); - } - catch (Exception e) - { - string typeName = null; - try - { - typeName = reader.PofContext.GetTypeName(m_typeId); - } - catch (Exception) - { } - - throw new IOException( - "An exception occurred instantiating an object" - + " user type from a POF stream: type-id=" + m_typeId - + (typeName == null ? "" : ", class-name=" + typeName) - + ", exception=\n" + e); - } - finally - { - stream.Close(); - } - } - - #endregion - - #region Data members - - /// - /// The type identifier of the user type to serialize and - /// deserialize. - /// - protected internal int m_typeId; - - #endregion - } -} \ No newline at end of file diff --git a/src/Coherence/IO/Pof/PortableException.cs b/src/Coherence/IO/Pof/PortableException.cs index 892d5ae..79e225d 100644 --- a/src/Coherence/IO/Pof/PortableException.cs +++ b/src/Coherence/IO/Pof/PortableException.cs @@ -174,6 +174,9 @@ public PortableException(string message, Exception e) : base(message, e) /// The StreamingContext that contains contextual information /// about the source or destination. /// +#if NET8_0_OR_GREATER + [Obsolete("Obsolete as of Coherence 14.1.2.0. This API uses obsolete formatter-based serialization. It should not be called or extended by application code. (https://aka.ms/dotnet-warnings/SYSLIB0051)")] +#endif public PortableException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -242,6 +245,9 @@ public override string StackTrace /// The StreamingContext that contains contextual information /// about the source or destination. /// +#if NET8_0_OR_GREATER + [Obsolete("Obsolete as of Coherence 14.1.2.0. This API uses obsolete formatter-based serialization. It should not be called or extended by application code. (https://aka.ms/dotnet-warnings/SYSLIB0051)")] +#endif public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/Coherence/IO/Pof/SafeConfigurablePofContext.cs b/src/Coherence/IO/Pof/SafeConfigurablePofContext.cs deleted file mode 100644 index 82be699..0000000 --- a/src/Coherence/IO/Pof/SafeConfigurablePofContext.cs +++ /dev/null @@ -1,783 +0,0 @@ -/* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. - * - * Licensed under the Universal Permissive License v 1.0 as shown at - * http://oss.oracle.com/licenses/upl. - */ -using System; -using System.Collections; -using System.IO; -using System.Runtime.Serialization; - -using Tangosol.Net; -using Tangosol.Run.Xml; -using Tangosol.Util; -using Tangosol.Util.Collections; - -namespace Tangosol.IO.Pof -{ - /// - /// SafeConfigurablePofContext is an extension of ConfigurablePofContext - /// that can serialize and deserialize any valid POF user type, even those - /// that have not been explicitly configured, as well as any .NET - /// serializable types. - /// - /// - /// Important note: this class is meant to be used only during - /// application design time and replaced with the ConfigurablePofContext - /// for production deployments as it has the following limitations: - /// - /// - /// SafeConfigurablePofContext is supported only for .NET clients; - /// - /// - /// Its performance is less optimal than of the ConfigurablePofContext; - /// - /// - /// The serialized form produced by the SafeConfigurablePofContext will - /// not be recognized by POF aware ValueExtractors. - /// - /// - /// - /// For user types that have been explicitly configured, this IPofContext - /// behaves identically to the ConfigurablePofContext. - /// - /// - /// As of 14.1.2.0, this class is deprecated as it relies on a - /// deprecated - /// - /// - /// Jason Howes 2007.05.03 - /// Aleksandar Seovic (.NET) 2009.09.25 - /// Coherence 3.6 - [Obsolete("since Coherence 14.1.2.0")] - public class SafeConfigurablePofContext : ConfigurablePofContext - { - #region Constructors - - /// - /// Default constructor. - /// - /// - /// Create a default ConfigurablePofContext that will load - /// definitions from the default POF config file. - /// - public SafeConfigurablePofContext() - { - } - - /// - /// Create a ConfigurablePofContext that will use the passed - /// configuration information. - /// - /// - /// An Stream containing information in the format of a - /// configuration file used by ConfigurablePofContext. - /// - public SafeConfigurablePofContext(Stream stream) : base(stream) - { - } - - /// - /// Create a ConfigurablePofContext that will load - /// configuration information from the specified locator. - /// - /// - /// The locator that specifies the location of the - /// configuration file; the locator is - /// either a valid path or a URL. - /// - public SafeConfigurablePofContext(string locator) : base(locator) - { - } - - /// - /// Create a ConfigurablePofContext that will use the passed - /// configuration information. - /// - /// - /// An IXmlElement containing information in the format of a - /// configuration file used by ConfigurablePofContext. - /// - public SafeConfigurablePofContext(IXmlElement xml) : base(xml) - { - } - - #endregion - - #region IPofContext implementation - - /// - /// Return an that can be used to - /// serialize and deserialize an object of the specified user type to - /// and from a POF stream. - /// - /// - /// The type identifier of the user type that can be serialized and - /// deserialized using the returned IPofSerializer; must be - /// non-negative. - /// - /// - /// An IPofSerializer for the specified user type. - /// - /// - /// If the specified user type is negative or unknown to this - /// IPofContext. - /// - public override IPofSerializer GetPofSerializer(int typeId) - { - EnsureInitialized(); - - switch (typeId) - { - case TYPE_PORTABLE: - return m_serializerPof; - - case TYPE_SERIALIZABLE: - return m_serializerDotNet; - - default: - return base.GetPofSerializer(typeId); - } - } - - /// - /// Determine the type associated with the given user type - /// identifier. - /// - /// - /// The user type identifier; must be non-negative. - /// - /// - /// The type associated with the specified user type identifier. - /// - /// - /// If the specified user type is negative or unknown to this - /// IPofContext. - /// - public override Type GetType(int typeId) - { - switch (typeId) - { - case TYPE_PORTABLE: - // should never get here - return typeof (IPortableObject); - - case TYPE_SERIALIZABLE: - // should never get here - return typeof (Object); - - default: - return base.GetType(typeId); - } - } - - /// - /// Determine the user type identifier associated with the given - /// type. - /// - /// - /// A user type; must not be null. - /// - /// - /// The type identifier of the user type associated with the given - /// type. - /// - /// - /// If the user type associated with the given type is unknown to - /// this IPofContext. - /// - public override int GetUserTypeIdentifier(Type type) - { - EnsureInitialized(); - - int nTypeId = GetUserTypeIdentifierInternal(type); - if (nTypeId < 0) - { - if (IsUserType(type)) - { - nTypeId = GetGenericTypeId(type); - using (BlockingLock l = BlockingLock.Lock(this)) - { - IDictionary mapTypeIdByType = - GetPofConfig().m_mapTypeIdByType; - mapTypeIdByType = new Hashtable(mapTypeIdByType); - mapTypeIdByType[type] = nTypeId; - GetPofConfig().m_mapTypeIdByType = mapTypeIdByType; - } - } - else - { - throw new ArgumentException("Unknown user type: " + type); - } - } - - return nTypeId; - } - - /// - /// Determine the user type identifier associated with the given type - /// name. - /// - /// - /// The assembly-qualified name of a user type; must not be null. - /// - /// - /// The type identifier of the user type associated with the given - /// type name. - /// - /// - /// If the user type associated with the given type name is unknown - /// to this IPofContext. - /// - public override int GetUserTypeIdentifier(String typeName) - { - EnsureInitialized(); - - int nTypeId = GetUserTypeIdentifierInternal(typeName); - if (nTypeId < 0) - { - if (IsUserType(typeName)) - { - nTypeId = GetGenericTypeId(TypeResolver.Resolve(typeName)); - using (BlockingLock l = BlockingLock.Lock(this)) - { - IDictionary mapTypeIdByTypeName = - GetPofConfig().m_mapTypeIdByTypeName; - mapTypeIdByTypeName = new Hashtable(mapTypeIdByTypeName); - mapTypeIdByTypeName[typeName] = nTypeId; - GetPofConfig().m_mapTypeIdByTypeName = mapTypeIdByTypeName; - } - } - else - { - throw new ArgumentException("Unknown user type: " + typeName); - } - } - - return nTypeId; - } - - /// - /// Determine if the given type is a user type known to this - /// IPofContext. - /// - /// - /// The type to test; must not be null. - /// - /// - /// true iff the specified type is a valid user type. - /// - public override bool IsUserType(Type type) - { - bool fUserType = base.IsUserType(type); - if (!fUserType) - { - if (!PofHelper.IsIntrinsicPofType(type)) - { - fUserType = typeof(IPortableObject).IsAssignableFrom(type) || - typeof(ISerializable).IsAssignableFrom(type) || - type.IsDefined(typeof(SerializableAttribute), false); - } - } - - return fUserType; - } - - /// - /// Determine if the type with the given name is a user type known to - /// this IPofContext. - /// - /// - /// The assembly-qualified name of the type to test; must not be - /// null or empty. - /// - /// - /// true iff the type with the specified name is a valid user - /// type. - /// - public override bool IsUserType(String typeName) - { - bool fUserType = base.IsUserType(typeName); - if (!fUserType) - { - try - { - var type = TypeResolver.Resolve(typeName); - if (!PofHelper.IsIntrinsicPofType(type)) - { - fUserType = typeof(IPortableObject).IsAssignableFrom(type) || - typeof(ISerializable).IsAssignableFrom(type) || - type.IsDefined(typeof(SerializableAttribute), false); - } - } - catch (Exception) - { - } - } - - return fUserType; - } - - #endregion - - #region Internal methods - - /// - /// Fully initialize the SafeConfigurablePofContext if it has - /// not already been initialized. - /// - protected internal override void EnsureInitialized() - { - base.EnsureInitialized(); - if (m_serializerDotNet == null) - { - m_serializerDotNet = new DotNetPofSerializer(); - m_serializerPof = new SafePofSerializer(this); - } - } - - /// - /// For user types that are not registered in the POF configuration - /// used by this PofContext, determine if the user type can be - /// serialized using POF, otherwise determine if the user type can be - /// serialized using standard .NET BinaryFormatter. - /// - /// - /// A user type that is not configured in this IPofContext. - /// - /// - /// A special user type id that indicates that the user type is - /// supported by "generic" POF serialization or traditional .NET - /// serialization embedded in a POF stream. - /// - protected virtual int GetGenericTypeId(Type type) - { - if (typeof(IPortableObject).IsAssignableFrom(type)) - { - return TYPE_PORTABLE; - } - - if (typeof(ISerializable).IsAssignableFrom(type) - || type.IsDefined(typeof(SerializableAttribute), false)) - { - return TYPE_SERIALIZABLE; - } - - throw new ArgumentException("The \"" + type.FullName - + "\" type is not supported by " - + GetType().Name); - } - - #endregion - - #region Inner class: DotNetPofSerializer - - /// - /// Serializer used for Serializable objects. - /// - public class DotNetPofSerializer : SerializationHelper, IPofSerializer - { - #region IPofSerializer implementation - - /// - /// Serialize a user type instance to a POF stream by writing its - /// state using the specified object. - /// - /// - /// An implementation of IPofSerializer is required to follow - /// the following steps in sequence for writing out an object of a - /// user type: - /// - /// - /// - /// If the object is evolvable, the implementation must set the - /// version by calling . - /// - /// - /// - /// - /// The implementation may write any combination of the properties of - /// the user type by using the "write" methods of the - /// IPofWriter, but it must do so in the order of the property - /// indexes. - /// - /// - /// - /// - /// After all desired properties of the user type have been written, - /// the implementation must terminate the writing of the user type by - /// calling . - /// - /// - /// - /// - /// - /// The IPofWriter with which to write the object's state. - /// - /// - /// The object to serialize. - /// - /// - /// If an I/O error occurs. - /// - public void Serialize(IPofWriter writer, Object o) - { - writer.WriteBinary(0, ToBinary(o, m_serializer)); - writer.WriteRemainder(null); - Register(o); - } - - /// - /// Deserialize a user type instance from a POF stream by reading its - /// state using the specified object. - /// - /// - /// An implementation of IPofSerializer is required to follow - /// the following steps in sequence for reading in an object of a - /// user type: - /// - /// - /// - /// If the object is evolvable, the implementation must get the - /// version by calling . - /// - /// - /// - /// - /// The implementation may read any combination of the - /// properties of the user type by using "read" methods of the - /// IPofReader, but it must do so in the order of the property - /// indexes. - /// - /// - /// - /// - /// After all desired properties of the user type have been read, - /// the implementation must terminate the reading of the user type by - /// calling . - /// - /// - /// - /// - /// - /// The IPofReader with which to read the object's state. - /// - /// - /// The deserialized user type instance. - /// - /// - /// If an I/O error occurs. - /// - public Object Deserialize(IPofReader reader) - { - Object o = FromBinary(reader.ReadBinary(0), m_serializer); - reader.RegisterIdentity(o); - reader.ReadRemainder(); - Register(o); - return o; - } - - #endregion - - #region Internal methods - - /// - /// Register a class as having been encountered by the serializer. - /// - /// - /// An object that is being serialized or has been deserialized. - /// - protected void Register(Object o) - { - if (o != null) - { - m_mapRegisteredClasses.AcquireWriteLock(); - try - { - String typeName = o.GetType().FullName; - if (!m_mapRegisteredClasses.Contains(typeName)) - { - m_mapRegisteredClasses.Add(typeName, null); - CacheFactory.Log("TODO: Add POF support for \"" + typeName + "\".", 0); - } - } - finally - { - m_mapRegisteredClasses.ReleaseWriteLock(); - } - } - } - - #endregion - - #region Data members - - /// - /// Serializer used by this IPofSerializer. - /// - private readonly ISerializer m_serializer = new BinarySerializer(); - - /// - /// All classes that have been registered. - /// - private readonly SynchronizedDictionary m_mapRegisteredClasses = - new SynchronizedDictionary(); - - #endregion - } - - #endregion - - #region Inner class: SafePofSerializer - - /// - /// Serializer used for objects implementing the IPortableObject - /// interface. - /// - public class SafePofSerializer : SerializationHelper, IPofSerializer - { - #region Constructors - - /// - /// Construct a new instance of SafePofSerializer. - /// - /// - /// The ConfigurablePofContext to use. - /// - public SafePofSerializer(ConfigurablePofContext ctx) - { - m_pofContext = ctx; - } - - #endregion - - #region IPofSerializer implementation - - /// - /// Serialize a user type instance to a POF stream by writing its - /// state using the specified object. - /// - /// - /// An implementation of IPofSerializer is required to follow - /// the following steps in sequence for writing out an object of a - /// user type: - /// - /// - /// - /// If the object is evolvable, the implementation must set the - /// version by calling . - /// - /// - /// - /// - /// The implementation may write any combination of the properties of - /// the user type by using the "write" methods of the - /// IPofWriter, but it must do so in the order of the property - /// indexes. - /// - /// - /// - /// - /// After all desired properties of the user type have been written, - /// the implementation must terminate the writing of the user type by - /// calling . - /// - /// - /// - /// - /// - /// The IPofWriter with which to write the object's state. - /// - /// - /// The object to serialize. - /// - /// - /// If an I/O error occurs. - /// - public void Serialize(IPofWriter writer, Object o) - { - var buffer = new BinaryMemoryStream(1024*8); - PofStreamWriter userTypeWriter = new PofStreamWriter.UserTypeWriter( - new DataWriter(buffer), m_pofContext, TYPE_PORTABLE, -1); - - // COH-5065: due to the complexity of maintaining references - // in future data, we won't support them for IEvolvable objects - if (m_pofContext.IsReferenceEnabled && !(o is IEvolvable)) - { - userTypeWriter.EnableReference(); - } - - m_serializer.Serialize(userTypeWriter, o); - - String typeName = o.GetType().AssemblyQualifiedName; - writer.WriteString(0, typeName); - writer.WriteBinary(1, buffer.ToBinary()); - writer.WriteRemainder(null); - - Register(typeName); - } - - /// - /// Deserialize a user type instance from a POF stream by reading its - /// state using the specified object. - /// - /// - /// An implementation of IPofSerializer is required to follow - /// the following steps in sequence for reading in an object of a - /// user type: - /// - /// - /// - /// If the object is evolvable, the implementation must get the - /// version by calling . - /// - /// - /// - /// - /// The implementation may read any combination of the - /// properties of the user type by using "read" methods of the - /// IPofReader, but it must do so in the order of the property - /// indexes. - /// - /// - /// - /// - /// After all desired properties of the user type have been read, - /// the implementation must terminate the reading of the user type by - /// calling . - /// - /// - /// - /// - /// - /// The IPofReader with which to read the object's state. - /// - /// - /// The deserialized user type instance. - /// - /// - /// If an I/O error occurs. - /// - public Object Deserialize(IPofReader reader) - { - String typeName = reader.ReadString(0); - Binary bin = reader.ReadBinary(1); - reader.ReadRemainder(); - - ConfigurablePofContext ctx = m_pofContext; - IPortableObject po; - try - { - po = (IPortableObject) ObjectUtils.CreateInstance(TypeResolver.Resolve(typeName)); - } - catch (Exception e) - { - throw new Exception("Unable to instantiate PortableObject class: " + typeName, e); - } - - DataReader dataReader = bin.GetReader(); - int nType = dataReader.ReadPackedInt32(); - if (nType != TYPE_PORTABLE) - { - throw new IOException("Invalid POF type: " + nType - + " (" + TYPE_PORTABLE + " expected)"); - } - - int iVersion = dataReader.ReadPackedInt32(); - - IPofReader pofReader = new PofStreamReader.UserTypeReader( - dataReader, ctx, TYPE_PORTABLE, iVersion); - - m_serializer.Initialize(po, pofReader); - - Register(typeName); - - return po; - } - - #endregion - - #region Internal methods - - /// - /// Register a class as having been encountered by the serializer. - /// - /// - /// The name of a class that is being serialized or deserialized. - /// - protected void Register(String typeName) - { - m_mapRegisteredClasses.AcquireWriteLock(); - try - { - if (!m_mapRegisteredClasses.Contains(typeName)) - { - m_mapRegisteredClasses.Add(typeName, null); - CacheFactory.Log("TODO: Add the class \"" + typeName - + "\" to the POF configuration file.", 0); - } - } - finally - { - m_mapRegisteredClasses.ReleaseWriteLock(); - } - } - - #endregion - - #region Data members - - /// - /// Reference to outer SafeConfigurablePofContext. - /// - private readonly ConfigurablePofContext m_pofContext; - - /// - /// Serializer used by this IPofSerializer. - /// - private readonly PortableObjectSerializer m_serializer = - new PortableObjectSerializer(TYPE_PORTABLE); - - /// - /// All classes that have been registered. - /// - private readonly SynchronizedDictionary m_mapRegisteredClasses = - new SynchronizedDictionary(); - - #endregion - } - - #endregion - - #region Constants - - /// - /// The type identifier for objects that implement the PortableObject - /// interface. - /// - public const int TYPE_PORTABLE = Int32.MaxValue - 1; - - /// - /// The type identifier for .NET Serializable objects. - /// - public const int TYPE_SERIALIZABLE = Int32.MaxValue; - - #endregion - - #region Data members - - /// - /// Serializer used for Serializable objects. - /// - private IPofSerializer m_serializerDotNet; - - /// - /// Serializer used for [not registered] objects implementing - /// IPortableObject interface. - /// - private IPofSerializer m_serializerPof; - - #endregion - } -} \ No newline at end of file diff --git a/src/Coherence/Net/RequestIncompleteException.cs b/src/Coherence/Net/RequestIncompleteException.cs index 4b4a15d..03d6095 100644 --- a/src/Coherence/Net/RequestIncompleteException.cs +++ b/src/Coherence/Net/RequestIncompleteException.cs @@ -119,6 +119,9 @@ public RequestIncompleteException(SerializationInfo info, StreamingContext conte /// The StreamingContext that contains contextual information /// about the source or destination. /// +#if NET8_0_OR_GREATER + [Obsolete("Obsolete as of Coherence 14.1.2.0. This API uses obsolete formatter-based serialization. It should not be called or extended by application code. (https://aka.ms/dotnet-warnings/SYSLIB0051)")] +#endif public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/src/Coherence/Util/Collections/HashDictionary.cs b/src/Coherence/Util/Collections/HashDictionary.cs index 7b2d56d..9415aa6 100644 --- a/src/Coherence/Util/Collections/HashDictionary.cs +++ b/src/Coherence/Util/Collections/HashDictionary.cs @@ -312,6 +312,9 @@ public HashDictionary(IDictionary d, float loadFactor, /// /// is null. /// +#if NET8_0_OR_GREATER + [Obsolete("Obsolete as of Coherence 14.1.2.0. This API uses obsolete formatter-based serialization. It should not be called or extended by application code. (https://aka.ms/dotnet-warnings/SYSLIB0051)")] +#endif protected HashDictionary(SerializationInfo info, StreamingContext context) : base(info, context) @@ -683,6 +686,9 @@ public override object Clone() /// /// Serialization info. /// Serialization context. +#if NET8_0_OR_GREATER + [Obsolete("Obsolete as of Coherence 14.1.2.0. This API uses obsolete formatter-based serialization. It should not be called or extended by application code. (https://aka.ms/dotnet-warnings/SYSLIB0051)")] +#endif public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/tests/Coherence.Pof.Tests/Coherence.Pof.Tests.csproj b/tests/Coherence.Pof.Tests/Coherence.Pof.Tests.csproj index 40f0c5c..acc5d7c 100644 --- a/tests/Coherence.Pof.Tests/Coherence.Pof.Tests.csproj +++ b/tests/Coherence.Pof.Tests/Coherence.Pof.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net6.0;net8.0 Tangosol.Data false prompt diff --git a/tests/Coherence.Tests/Coherence.Tests.csproj b/tests/Coherence.Tests/Coherence.Tests.csproj index c03cc10..5eff47d 100644 --- a/tests/Coherence.Tests/Coherence.Tests.csproj +++ b/tests/Coherence.Tests/Coherence.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net6.0;net8.0 Tangosol false prompt @@ -10,7 +10,7 @@ 162, 618, 675 false - Library + Library @@ -18,7 +18,7 @@ - + diff --git a/tests/Coherence.Tests/IO/Pof/BinaryPofSerializerTests.cs b/tests/Coherence.Tests/IO/Pof/BinaryPofSerializerTests.cs deleted file mode 100644 index d25ac67..0000000 --- a/tests/Coherence.Tests/IO/Pof/BinaryPofSerializerTests.cs +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. - * - * Licensed under the Universal Permissive License v 1.0 as shown at - * http://oss.oracle.com/licenses/upl. - */ -using System; -using System.Data; -using System.IO; - -using NUnit.Framework; - -using Tangosol.Util.Collections; -using Tangosol.Util.Filter; - -namespace Tangosol.IO.Pof -{ - [TestFixture] - public class BinaryPofSerializerTests - { - [Test] - public void TestSynchronizedDictionarySerialization() - { - SynchronizedDictionary ht = new SynchronizedDictionary(); - - SimplePofContext ctx = new SimplePofContext(); - BinaryPofSerializer serializer = new BinaryPofSerializer(1); - - ctx.RegisterUserType(1, ht.GetType(), serializer); - - Assert.AreEqual(1, ctx.GetUserTypeIdentifier(ht)); - Assert.AreEqual(1, ctx.GetUserTypeIdentifier(ht.GetType())); - - Assert.AreEqual(ht.GetType(), ctx.GetType(1)); - Assert.AreEqual(ht.GetType().FullName, ctx.GetTypeName(1)); - Assert.AreEqual(serializer, ctx.GetPofSerializer(1)); - - ht.Add(1, 1); - ht.Add(2, 2); - ht.Add(3, 3); - ht.Add(4, 4); - ht.Add(5, 5); - ht.Add(6, 6); - ht.Add(7, 7); - - Stream stream = new MemoryStream(); - ctx.Serialize(new DataWriter(stream), ht); - - stream.Position = 0; - SynchronizedDictionary ht2 = (SynchronizedDictionary)ctx.Deserialize(new DataReader(stream)); - - Assert.AreEqual(ht[1], ht2[1]); - Assert.AreEqual(ht[2], ht2[2]); - Assert.AreEqual(ht[3], ht2[3]); - Assert.AreEqual(ht[4], ht2[4]); - Assert.AreEqual(ht[5], ht2[5]); - Assert.AreEqual(ht[6], ht2[6]); - Assert.AreEqual(ht[7], ht2[7]); - } - - [Test] - public void TestDataSetSerialization() - { - DataSet dataSet1 = new DataSet(); - - SimplePofContext ctx = new SimplePofContext(); - BinaryPofSerializer serializer = new BinaryPofSerializer(1); - - ctx.RegisterUserType(1, dataSet1.GetType(), serializer); - - Assert.AreEqual(1, ctx.GetUserTypeIdentifier(dataSet1)); - Assert.AreEqual(1, ctx.GetUserTypeIdentifier(dataSet1.GetType())); - - Assert.AreEqual(dataSet1.GetType(), ctx.GetType(1)); - Assert.AreEqual(dataSet1.GetType().FullName, ctx.GetTypeName(1)); - Assert.AreEqual(serializer, ctx.GetPofSerializer(1)); - - dataSet1.Tables.Add("Order"); - dataSet1.Tables["Order"].Columns.Add("Id" , typeof(String)); - dataSet1.Tables["Order"].Columns.Add("Name", typeof(String)); - - dataSet1.Tables.Add("OrderDetail"); - dataSet1.Tables["OrderDetail"].Columns.Add("Id", typeof(String)); - dataSet1.Tables["OrderDetail"].Columns.Add("Sum", typeof(Double)); - dataSet1.Tables["OrderDetail"].Columns.Add("OrderId", typeof(String)); - - DataRelation relation = new DataRelation("Order_OrderDetail", dataSet1.Tables["Order"].Columns["Id"], dataSet1.Tables["OrderDetail"].Columns["OrderId"]); - - dataSet1.Relations.Add(relation); - - dataSet1.Tables["Order"].Rows.Add(new object[] { "01/2007", "Comedy books" }); - dataSet1.Tables["Order"].Rows.Add(new object[] { "02/2007", "Suite" }); - - dataSet1.Tables["OrderDetail"].Rows.Add(new object[] { "01/2007-01", 1500, "01/2007" }); - dataSet1.Tables["OrderDetail"].Rows.Add(new object[] { "01/2007-02", 1350, "01/2007" }); - dataSet1.Tables["OrderDetail"].Rows.Add(new object[] { "02/2007-01", 5500.50, "02/2007" }); - - Stream stream = new MemoryStream(); - ctx.Serialize(new DataWriter(stream), dataSet1); - - stream.Position = 0; - DataSet dataSet2 = (DataSet)ctx.Deserialize(new DataReader(stream)); - - Assert.AreEqual(dataSet1.Tables["Order"].Columns.Count, dataSet2.Tables["Order"].Columns.Count); - Assert.AreEqual(dataSet1.Tables["Order"].Columns["Id"].DataType , dataSet2.Tables["Order"].Columns["Id"].DataType); - Assert.AreEqual(dataSet1.Tables["Order"].Columns["Name"].DataType, dataSet2.Tables["Order"].Columns["Name"].DataType); - - Assert.AreEqual(dataSet1.Tables["OrderDetail"].Columns.Count, dataSet2.Tables["OrderDetail"].Columns.Count); - Assert.AreEqual(dataSet1.Tables["OrderDetail"].Columns["Id"].DataType , dataSet2.Tables["OrderDetail"].Columns["Id"].DataType); - Assert.AreEqual(dataSet1.Tables["OrderDetail"].Columns["Sum"].DataType , dataSet2.Tables["OrderDetail"].Columns["Sum"].DataType); - Assert.AreEqual(dataSet1.Tables["OrderDetail"].Columns["OrderId"].DataType, dataSet2.Tables["OrderDetail"].Columns["OrderId"].DataType); - - Assert.AreEqual(dataSet1.Tables["Order"].Rows.Count, dataSet2.Tables["Order"].Rows.Count); - Assert.AreEqual(dataSet1.Tables["Order"].Rows[0]["Id"] , dataSet2.Tables["Order"].Rows[0]["Id"]); - Assert.AreEqual(dataSet1.Tables["Order"].Rows[0]["Name"], dataSet2.Tables["Order"].Rows[0]["Name"]); - Assert.AreEqual(dataSet1.Tables["Order"].Rows[1]["Id"] , dataSet2.Tables["Order"].Rows[1]["Id"]); - Assert.AreEqual(dataSet1.Tables["Order"].Rows[1]["Name"], dataSet2.Tables["Order"].Rows[1]["Name"]); - - Assert.AreEqual(dataSet1.Tables["OrderDetail"].Rows.Count, dataSet2.Tables["OrderDetail"].Rows.Count); - Assert.AreEqual(dataSet1.Tables["OrderDetail"].Rows[0]["Id"] , dataSet2.Tables["OrderDetail"].Rows[0]["Id"]); - Assert.AreEqual(dataSet1.Tables["OrderDetail"].Rows[0]["Sum"] , dataSet2.Tables["OrderDetail"].Rows[0]["Sum"]); - Assert.AreEqual(dataSet1.Tables["OrderDetail"].Rows[0]["OrderId"], dataSet2.Tables["OrderDetail"].Rows[0]["OrderId"]); - - Assert.AreEqual(dataSet1.Tables["OrderDetail"].Rows[1]["Id"] , dataSet2.Tables["OrderDetail"].Rows[1]["Id"]); - Assert.AreEqual(dataSet1.Tables["OrderDetail"].Rows[1]["Sum"] , dataSet2.Tables["OrderDetail"].Rows[1]["Sum"]); - Assert.AreEqual(dataSet1.Tables["OrderDetail"].Rows[1]["OrderId"], dataSet2.Tables["OrderDetail"].Rows[1]["OrderId"]); - - Assert.AreEqual(dataSet1.Tables["OrderDetail"].Rows[2]["Id"] , dataSet2.Tables["OrderDetail"].Rows[2]["Id"]); - Assert.AreEqual(dataSet1.Tables["OrderDetail"].Rows[2]["Sum"] , dataSet2.Tables["OrderDetail"].Rows[2]["Sum"]); - Assert.AreEqual(dataSet1.Tables["OrderDetail"].Rows[2]["OrderId"], dataSet2.Tables["OrderDetail"].Rows[2]["OrderId"]); - - ctx.UnregisterUserType(1); - } - - [Test] - public void TestConfigPofContextException() - { - LikeFilter filter = new LikeFilter("field", "goran", '\\', false); - - SimplePofContext ctx = new SimplePofContext(); - BinaryPofSerializer serializer = new BinaryPofSerializer(1); - - ctx.RegisterUserType(1, filter.GetType(), serializer); - - Stream stream = new MemoryStream(); - Assert.That(() => ctx.Serialize(new DataWriter(stream), filter), Throws.TypeOf()); - } - } -} \ No newline at end of file diff --git a/tests/Coherence.Tests/IO/Pof/Coh25103Tests.cs b/tests/Coherence.Tests/IO/Pof/Coh25103Tests.cs index 4cd4fd1..a81db97 100644 --- a/tests/Coherence.Tests/IO/Pof/Coh25103Tests.cs +++ b/tests/Coherence.Tests/IO/Pof/Coh25103Tests.cs @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. * * Licensed under the Universal Permissive License v 1.0 as shown at * https://oss.oracle.com/licenses/upl. @@ -18,7 +18,7 @@ public class Coh25103Tests [SetUp] public void Setup() { - m_pofContext = new SafeConfigurablePofContext("config/include-pof-config.xml"); + m_pofContext = new ConfigurablePofContext("config/include-pof-config.xml"); } [Test] diff --git a/tests/Coherence.Tests/IO/Pof/ConfigurablePofConfigTests.cs b/tests/Coherence.Tests/IO/Pof/ConfigurablePofConfigTests.cs index 0becbd6..819596c 100644 --- a/tests/Coherence.Tests/IO/Pof/ConfigurablePofConfigTests.cs +++ b/tests/Coherence.Tests/IO/Pof/ConfigurablePofConfigTests.cs @@ -1,8 +1,8 @@ /* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. * * Licensed under the Universal Permissive License v 1.0 as shown at - * http://oss.oracle.com/licenses/upl. + * https://oss.oracle.com/licenses/upl. */ using System; using System.IO; @@ -304,7 +304,7 @@ public void TestConfigWithDefaultSerializer() type = ctx.GetType(typeId); Assert.AreEqual(type, portablePersonType); serializer = ctx.GetPofSerializer(typeId); - Assert.IsInstanceOf(typeof(BinaryPofSerializer), serializer); + Assert.IsInstanceOf(typeof(PortableObjectSerializer), serializer); Assert.IsTrue(ctx.IsUserType(portablePerson)); // does not have serializer defined and default is not specified diff --git a/tests/Coherence.Tests/IO/Pof/PortableExceptionTests.cs b/tests/Coherence.Tests/IO/Pof/PortableExceptionTests.cs index 81dd069..7b578eb 100644 --- a/tests/Coherence.Tests/IO/Pof/PortableExceptionTests.cs +++ b/tests/Coherence.Tests/IO/Pof/PortableExceptionTests.cs @@ -1,12 +1,10 @@ /* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. * * Licensed under the Universal Permissive License v 1.0 as shown at - * http://oss.oracle.com/licenses/upl. + * https://oss.oracle.com/licenses/upl. */ using System.IO; -using System.Runtime.Serialization; -using System.Runtime.Serialization.Formatters.Binary; using NUnit.Framework; @@ -123,14 +121,16 @@ public void PortableExceptionSerializationTest() } catch (PortableException pe) { - IFormatter formatter = new BinaryFormatter(); + IPofContext ctx = (IPofContext) cacheServiceChannel.Serializer; byte[] buffer = new byte[1024 * 16]; Stream stream = new MemoryStream(buffer); - formatter.Serialize(stream, pe); + DataWriter writer = new DataWriter(stream); + ctx.Serialize(writer, pe); stream.Close(); stream = new MemoryStream(buffer); - PortableException desPE = (PortableException) formatter.Deserialize(stream); + DataReader reader = new DataReader(stream); + PortableException desPE = (PortableException)ctx.Deserialize(reader); Assert.IsNotNull(desPE); stream.Close(); diff --git a/tests/Coherence.Tests/IO/Pof/SafeConfigurablePofContextTests.cs b/tests/Coherence.Tests/IO/Pof/SafeConfigurablePofContextTests.cs deleted file mode 100644 index 345ebe8..0000000 --- a/tests/Coherence.Tests/IO/Pof/SafeConfigurablePofContextTests.cs +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. - * - * Licensed under the Universal Permissive License v 1.0 as shown at - * http://oss.oracle.com/licenses/upl. - */ -using System; -using System.IO; - -using NUnit.Framework; - -using Tangosol.Net.Messaging; -using Tangosol.Util; -using Tangosol.Util.Collections; - -namespace Tangosol.IO.Pof -{ - [TestFixture] - public class SafeConfigurablePofContextTests - { - [Test] - public void testGetPofSerializerWithNegativeTypeId() - { - var ctx = new SafeConfigurablePofContext(); - Assert.That(() => ctx.GetPofSerializer(-1), Throws.ArgumentException); - } - - [Test] - public void testGetPofSerializerWithKnownTypeId() - { - var ctx = new SafeConfigurablePofContext(); - Assert.IsTrue(ctx.GetPofSerializer(1) is PortableObjectSerializer); - } - - [Test] - public void testGetPofSerializerWithUnknownTypeId() - { - var ctx = new SafeConfigurablePofContext(); - Assert.That(() => ctx.GetPofSerializer(12358), Throws.ArgumentException); - } - - [Test] - public void testGetTypeWithNegativeTypeId() - { - var ctx = new SafeConfigurablePofContext(); - Assert.That(() => ctx.GetType(-1), Throws.ArgumentException); - } - - [Test] - public void testGetTypeWithKnownTypeId() - { - var ctx = new SafeConfigurablePofContext(); - Assert.IsTrue(typeof(Exception).Equals(ctx.GetType(0))); - } - - [Test] - public void testGetTypeWithUnknownTypeId() - { - var ctx = new SafeConfigurablePofContext(); - Assert.That(() => ctx.GetType(12358), Throws.ArgumentException); - } - - [Test] - public void testGetUserTypeIdentifierWithNullObject() - { - var ctx = new SafeConfigurablePofContext(); - Assert.That(() => ctx.GetUserTypeIdentifier((object) null), Throws.ArgumentNullException); - } - - [Test] - public void testGetUserTypeIdentifierWithUnknownObject() - { - var ctx = new SafeConfigurablePofContext(); - Assert.IsTrue(ctx.GetUserTypeIdentifier(new NestedType()) - == SafeConfigurablePofContext.TYPE_PORTABLE); - } - - [Test] - public void testGetUserTypeIdentifierWithPofObject() - { - var ctx = new SafeConfigurablePofContext(); - Assert.That(() => ctx.GetUserTypeIdentifier(new HashDictionary()), Throws.ArgumentException); - } - - [Test] - public void testGetUserTypeIdentifierWithNullType() - { - var ctx = new SafeConfigurablePofContext(); - Assert.That(() => ctx.GetUserTypeIdentifier((Type) null), Throws.ArgumentNullException); - } - - [Test] - public void testGetUserTypeIdentifierWithUnknownType() - { - var ctx = new SafeConfigurablePofContext(); - Assert.IsTrue(ctx.GetUserTypeIdentifier(typeof(NestedType)) - == SafeConfigurablePofContext.TYPE_PORTABLE); - - // COH-5584: repeat the test to verify that NestedType is now - // cached in ConfigurablePofContext. - Assert.IsTrue(ctx.GetUserTypeIdentifier(typeof(NestedType)) - == SafeConfigurablePofContext.TYPE_PORTABLE); - } - - [Test] - public void testGetUserTypeIdentifierWithPofType() - { - var ctx = new SafeConfigurablePofContext(); - Assert.That(() => ctx.GetUserTypeIdentifier(typeof(HashDictionary)), Throws.ArgumentException); - } - - [Test] - public void testGetUserTypeIdentifierWithKnownType() - { - var ctx = new SafeConfigurablePofContext(); - Assert.IsTrue(ctx.GetUserTypeIdentifier(typeof(Exception)) == 0); - } - - [Test] - public void testGetUserTypeIdentifierWithNullTypeName() - { - var ctx = new SafeConfigurablePofContext(); - Assert.That(() => ctx.GetUserTypeIdentifier((String) null), Throws.ArgumentException); - } - - [Test] - public void testGetUserTypeIdentifierWithUnknownTypeName() - { - var ctx = new SafeConfigurablePofContext(); - Assert.IsTrue(ctx.GetUserTypeIdentifier(typeof(NestedType).AssemblyQualifiedName) - == SafeConfigurablePofContext.TYPE_PORTABLE); - } - - [Test] - public void testGetUserTypeIdentifierWithPofTypeName() - { - var ctx = new SafeConfigurablePofContext(); - Assert.That(() => ctx.GetUserTypeIdentifier(ctx.GetUserTypeIdentifier(typeof(HashDictionary).AssemblyQualifiedName)), Throws.ArgumentException); - } - - [Test] - public void testGetUserTypeIdentifierWithKnownTypeName() - { - var ctx = new SafeConfigurablePofContext(); - Assert.IsTrue(ctx.GetUserTypeIdentifier(typeof(Exception).AssemblyQualifiedName) == 0); - } - - [Test] - public void testIsUserTypeWithNullObject() - { - var ctx = new SafeConfigurablePofContext(); - Assert.That(() => ctx.IsUserType((Object)null), Throws.ArgumentNullException); - } - - [Test] - public void testIsUserTypeWithUnknownObject() - { - var ctx = new SafeConfigurablePofContext(); - Assert.IsFalse(ctx.IsUserType(this)); - } - - [Test] - public void testIsUserTypeWithPofObject() - { - var ctx = new SafeConfigurablePofContext(); - Assert.IsFalse(ctx.IsUserType(new HashDictionary())); - } - - [Test] - public void testIsUserTypeWithKnownObject() - { - var ctx = new SafeConfigurablePofContext(); - Assert.IsTrue(ctx.IsUserType(new Exception())); - } - - [Test] - public void testIsUserTypeWithNullType() - { - var ctx = new SafeConfigurablePofContext(); - Assert.That(() => ctx.IsUserType((Type) null), Throws.ArgumentNullException); - } - - [Test] - public void testIsUserTypeWithUnknownType() - { - var ctx = new SafeConfigurablePofContext(); - Assert.IsFalse(ctx.IsUserType(typeof(SafeConfigurablePofContextTests))); - } - - [Test] - public void testIsUserTypeWithPofType() - { - var ctx = new SafeConfigurablePofContext(); - Assert.IsFalse(ctx.IsUserType(typeof(HashDictionary))); - } - - [Test] - public void testIsUserTypeWithKnownType() - { - var ctx = new SafeConfigurablePofContext(); - Assert.IsTrue(ctx.IsUserType(typeof(Exception))); - } - - [Test] - public void testIsUserTypeWithNullTypeName() - { - var ctx = new SafeConfigurablePofContext(); - Assert.That(() => ctx.IsUserType((String) null), Throws.ArgumentException); - } - - [Test] - public void testIsUserTypeWithUnknownTypeName() - { - var ctx = new SafeConfigurablePofContext(); - Assert.IsFalse(ctx.IsUserType(typeof(SafeConfigurablePofContextTests).AssemblyQualifiedName)); - } - - [Test] - public void testIsUserTypeWithPofTypeName() - { - var ctx = new SafeConfigurablePofContext(); - Assert.IsFalse(ctx.IsUserType(typeof(HashDictionary).AssemblyQualifiedName)); - } - - [Test] - public void testIsUserTypeWithKnownTypeName() - { - var ctx = new SafeConfigurablePofContext(); - Assert.IsTrue(ctx.IsUserType(typeof(Exception).AssemblyQualifiedName)); - } - - [Test] - public void testSerialization() - { - var ctx = new SafeConfigurablePofContext(); - var uuid = new UUID(); - var buffer = new MemoryStream(1024); - ctx.Serialize(new DataWriter(buffer), uuid); - - buffer.Position = 0; - Object o = ctx.Deserialize(new DataReader(buffer)); - Assert.AreEqual(o, uuid); - - var person = new PortablePerson("Aleksandar Seovic", - new DateTime(74, 7, 24)); - person.Address = new Address("208 Myrtle Ridge Rd", "Lutz", "FL", "33549"); - person.Children = new Person[] - { - new PortablePerson("Aleksandar Seovic JR.", new DateTime(174, 1, 1)) - }; - - buffer.Position = 0; - ctx.Serialize(new DataWriter(buffer), person); - - buffer.Position = 0; - o = ctx.Deserialize(new DataReader(buffer)); - Assert.AreEqual(o, person); - } - - [Test] - public void testEvolvableSerialization() - { - var ctx = new SafeConfigurablePofContext(); - var person = new EvolvablePortablePerson("Aleksandar Seovic", - new DateTime(74, 7, 24)); - person.Address = new Address("208 Myrtle Ridge Rd", "Lutz", "FL", "33549"); - person.DataVersion = 2; - - var buffer = new MemoryStream(1024); - ctx.Serialize(new DataWriter(buffer), person); - - buffer.Position = 0; - Object o = ctx.Deserialize(new DataReader(buffer)); - Assert.IsTrue((((EvolvablePortablePerson) o).DataVersion == 2)); - Assert.AreEqual(o, person); - } - - [Test] - public void testSetSerializer() - { - IPofContext ctx = new ConfigurablePofContext("assembly://Coherence.Tests/Tangosol.Resources/s4hc-test-config.xml"); - var set = new HashSet(); - Assert.IsTrue(ctx.IsUserType(set)); - Assert.IsTrue(ctx.IsUserType(typeof(HashSet))); - Assert.IsTrue(ctx.IsUserType(typeof(HashSet).AssemblyQualifiedName)); - - var buffer = new MemoryStream(1024); - var writer = new DataWriter(buffer); - ctx.Serialize(writer, new HashSet()); - - var reader = new DataReader(buffer); - buffer.Position = 0; - object o = ctx.Deserialize(reader); - Assert.IsTrue(o is HashSet); - buffer.Close(); - - ctx = new SafeConfigurablePofContext("assembly://Coherence.Tests/Tangosol.Resources/s4hc-test-config.xml"); - Assert.IsTrue(ctx.IsUserType(set)); - Assert.IsTrue(ctx.IsUserType(typeof(HashSet))); - Assert.IsTrue(ctx.IsUserType(typeof(HashSet).AssemblyQualifiedName)); - - buffer = new MemoryStream(1024); - writer = new DataWriter(buffer); - ctx.Serialize(writer, new HashSet()); - - reader = new DataReader(buffer); - buffer.Position = 0; - o = ctx.Deserialize(reader); - Assert.IsTrue(o is HashSet); - buffer.Close(); - } - - } -} \ No newline at end of file diff --git a/tests/Coherence.Tests/IO/Pof/SerializationPerformanceComparisonTests.cs b/tests/Coherence.Tests/IO/Pof/SerializationPerformanceComparisonTests.cs index fa26f9f..7fe1f9b 100644 --- a/tests/Coherence.Tests/IO/Pof/SerializationPerformanceComparisonTests.cs +++ b/tests/Coherence.Tests/IO/Pof/SerializationPerformanceComparisonTests.cs @@ -1,15 +1,14 @@ /* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. * * Licensed under the Universal Permissive License v 1.0 as shown at - * http://oss.oracle.com/licenses/upl. + * https://oss.oracle.com/licenses/upl. */ #pragma warning disable 618,612 using System; using System.IO; using System.Runtime.Serialization; -using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Serialization.Json; using System.Text.Json; using System.Xml.Serialization; @@ -23,7 +22,6 @@ namespace Tangosol.IO.Pof public class SerializationPerformanceComparisonTests { private readonly SimplePofContext pofSerializer; - private readonly BinaryFormatter binarySerializer; private readonly XmlSerializer xmlSerializer; private readonly DataContractSerializer dcSerializer; private readonly DataContractJsonSerializer dcJsonSerializer; @@ -43,7 +41,6 @@ public SerializationPerformanceComparisonTests() populatedObject = CreatePopulatedObjectInstance(); typeName = emptyObject.GetType().FullName; - binarySerializer = new BinaryFormatter(); xmlSerializer = new XmlSerializer(emptyObject.GetType()); dcSerializer = new DataContractSerializer(emptyObject.GetType()); dcJsonSerializer = new DataContractJsonSerializer(emptyObject.GetType()); @@ -107,7 +104,6 @@ public void TestSerializationSize() Console.Out.WriteLine("Empty " + typeName + " Size:"); Console.Out.WriteLine("----------------------------------------------------------------"); Console.Out.WriteLine("POF".PadRight(25) + SerializePof(emptyObject).Length.ToString("N0") + " bytes"); - Console.Out.WriteLine("Binary".PadRight(25) + SerializeBinary(emptyObject).Length.ToString("N0") + " bytes"); Console.Out.WriteLine("JSON".PadRight(25) + SerializeJson(emptyObject).Length.ToString("N0") + " bytes\n" + SerializeJson(emptyObject)); //Console.Out.WriteLine("XML".PadRight(25) + SerializeXml(emptyObject).Length.ToString("N0") + " bytes"); Console.Out.WriteLine("DataContract".PadRight(25) + SerializeDataContract(emptyObject).Length.ToString("N0") + " bytes"); @@ -117,7 +113,6 @@ public void TestSerializationSize() Console.Out.WriteLine("Populated " + typeName + " Size:"); Console.Out.WriteLine("----------------------------------------------------------------"); Console.Out.WriteLine("POF".PadRight(25) + SerializePof(populatedObject).Length.ToString("N0") + " bytes"); - Console.Out.WriteLine("Binary".PadRight(25) + SerializeBinary(populatedObject).Length.ToString("N0") + " bytes"); Console.Out.WriteLine("JSON".PadRight(25) + SerializeJson(populatedObject).Length.ToString("N0") + " bytes\n" + SerializeJson(populatedObject)); //Console.Out.WriteLine("XML".PadRight(25) + SerializeXml(populatedObject).Length.ToString("N0") + " bytes"); Console.Out.WriteLine("DataContract".PadRight(25) + SerializeDataContract(populatedObject).Length.ToString("N0") + " bytes"); @@ -128,7 +123,6 @@ public void TestSerializationSize() public void TestSerializationSpeed() { long pof = TimePofSerialization(emptyObject); - long binary = TimeBinarySerialization(emptyObject); long json = TimeJsonSerialization(emptyObject); //long xml = TimeXmlSerialization(emptyObject); long dc = TimeDataContractSerialization(emptyObject); @@ -138,14 +132,12 @@ public void TestSerializationSpeed() Console.Out.WriteLine("Empty " + typeName + " Speed (" + ITERATION_COUNT.ToString("N0") + " iterations):"); Console.Out.WriteLine("----------------------------------------------------------------"); Console.Out.WriteLine("POF".PadRight(25) + pof.ToString("N0") + " ms"); - Console.Out.WriteLine("Binary".PadRight(25) + binary.ToString("N0") + " ms"); Console.Out.WriteLine("JSON".PadRight(25) + json.ToString("N0") + " ms"); //Console.Out.WriteLine("XML".PadRight(25) + xml.ToString("N0") + " ms"); Console.Out.WriteLine("DataContract".PadRight(25) + dc.ToString("N0") + " ms"); Console.Out.WriteLine("DataContract JSON".PadRight(25) + dcJson.ToString("N0") + " ms"); pof = TimePofSerialization(populatedObject); - binary = TimeBinarySerialization(populatedObject); json = TimeJsonSerialization(populatedObject); //xml = TimeXmlSerialization(populatedObject); dc = TimeDataContractSerialization(populatedObject); @@ -155,7 +147,6 @@ public void TestSerializationSpeed() Console.Out.WriteLine("Populated " + typeName + " Speed (" + ITERATION_COUNT.ToString("N0") + " iterations):"); Console.Out.WriteLine("----------------------------------------------------------------"); Console.Out.WriteLine("POF".PadRight(25) + pof.ToString("N0") + " ms"); - Console.Out.WriteLine("Binary".PadRight(25) + binary.ToString("N0") + " ms"); Console.Out.WriteLine("JSON".PadRight(25) + json.ToString("N0") + " ms"); //Console.Out.WriteLine("XML".PadRight(25) + xml.ToString("N0") + " ms"); Console.Out.WriteLine("DataContract".PadRight(25) + dc.ToString("N0") + " ms"); @@ -164,16 +155,6 @@ public void TestSerializationSpeed() #region Timer helpers - private long TimeBinarySerialization(object o) - { - long start = DateTimeUtils.GetSafeTimeMillis(); - for (int i = 0; i < ITERATION_COUNT; i++) - { - DeserializeBinary(SerializeBinary(o)); - } - return DateTimeUtils.GetSafeTimeMillis() - start; - } - private long TimePofSerialization(object o) { long start = DateTimeUtils.GetSafeTimeMillis(); @@ -228,19 +209,6 @@ private long TimeDataContractJsonSerialization(object o) #region Serialization helpers - private byte[] SerializeBinary(object o) - { - MemoryStream buffer = new MemoryStream(); - binarySerializer.Serialize(buffer, o); - return buffer.ToArray(); - } - - private object DeserializeBinary(byte[] data) - { - MemoryStream buffer = new MemoryStream(data); - return binarySerializer.Deserialize(buffer); - } - private byte[] SerializePof(object o) { MemoryStream buffer = new MemoryStream(); diff --git a/tests/Coherence.Tests/Net/Messaging/ConnectionExceptionTests.cs b/tests/Coherence.Tests/Net/Messaging/ConnectionExceptionTests.cs index e99f204..e1c3468 100644 --- a/tests/Coherence.Tests/Net/Messaging/ConnectionExceptionTests.cs +++ b/tests/Coherence.Tests/Net/Messaging/ConnectionExceptionTests.cs @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. * * Licensed under the Universal Permissive License v 1.0 as shown at - * http://oss.oracle.com/licenses/upl. + * https://oss.oracle.com/licenses/upl. */ using System; using System.IO; -using System.Runtime.Serialization; -using System.Runtime.Serialization.Formatters.Binary; - +using System.Text.RegularExpressions; using NUnit.Framework; +using Tangosol.IO; +using Tangosol.IO.Pof; namespace Tangosol.Net.Messaging { @@ -62,24 +62,27 @@ public void ConnectionExceptionSerializationTest() new ArgumentException("inner_exception", "dummy_param")); Assert.IsNotNull(ce); - IFormatter formatter = new BinaryFormatter(); + ConfigurablePofContext ctx = new ConfigurablePofContext( + "assembly://Coherence/Tangosol.Config/coherence-pof-config.xml"); byte[] buffer = new byte[1024*16]; Stream stream = new MemoryStream(buffer); - formatter.Serialize(stream, ce); + DataWriter writer = new DataWriter(stream); + ctx.Serialize(writer, ce); stream.Close(); stream = new MemoryStream(buffer); - ConnectionException deserCE = (ConnectionException) formatter.Deserialize(stream); + DataReader reader = new DataReader(stream); + PortableException deserCE = (PortableException)ctx.Deserialize(reader); stream.Close(); Assert.IsNotNull(deserCE); Assert.AreEqual(ce.Message, deserCE.Message); - Assert.AreEqual(ce.StackTrace, deserCE.StackTrace); + Assert.AreEqual("\tat \n" + + Regex.Replace(ce.StackTrace, "System.ArgumentException", "Portable($&)"), deserCE.StackTrace); Assert.IsNotNull(deserCE.InnerException); - Assert.AreEqual(deserCE.InnerException.GetType(), ce.InnerException.GetType()); - Assert.AreEqual(((ArgumentException) deserCE.InnerException).ParamName, - ((ArgumentException) ce.InnerException).ParamName); + Assert.AreEqual(typeof(PortableException), deserCE.InnerException.GetType()); + Assert.IsTrue(deserCE.InnerException.Message.Contains(((ArgumentException)ce.InnerException).ParamName)); } } } diff --git a/tests/Coherence.Tests/Resources/s4hc-test-config-defaultserializer-included.xml b/tests/Coherence.Tests/Resources/s4hc-test-config-defaultserializer-included.xml index a2be30c..f134359 100644 --- a/tests/Coherence.Tests/Resources/s4hc-test-config-defaultserializer-included.xml +++ b/tests/Coherence.Tests/Resources/s4hc-test-config-defaultserializer-included.xml @@ -25,6 +25,6 @@ - Tangosol.IO.Pof.BinaryPofSerializer, Coherence + Tangosol.IO.Pof.PortableObjectSerializer, Coherence \ No newline at end of file diff --git a/tests/Coherence.Tests/Util/Collections/AbstractBaseDictionaryTests.cs b/tests/Coherence.Tests/Util/Collections/AbstractBaseDictionaryTests.cs index 3cdd682..a962013 100644 --- a/tests/Coherence.Tests/Util/Collections/AbstractBaseDictionaryTests.cs +++ b/tests/Coherence.Tests/Util/Collections/AbstractBaseDictionaryTests.cs @@ -1,8 +1,8 @@ /* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. * * Licensed under the Universal Permissive License v 1.0 as shown at - * http://oss.oracle.com/licenses/upl. + * https://oss.oracle.com/licenses/upl. */ using System; using System.Collections; @@ -184,30 +184,6 @@ public void TestEnumerator() Assert.AreEqual(4, n); } - [Test] - public void TestBinarySerialization() - { - ISerializer serializer = new BinarySerializer(); - - IDictionary original = InstantiateDictionary(); - original.Add("A", "A"); - original.Add("B", "B"); - original.Add("C", "C"); - - Binary bin = SerializationHelper.ToBinary(original, serializer); - Object copy = SerializationHelper.FromBinary(bin, serializer); - - Assert.AreEqual(original, copy); - Assert.AreEqual(original.GetHashCode(), copy.GetHashCode()); - - original.Add(null, null); - bin = SerializationHelper.ToBinary(original, serializer); - copy = SerializationHelper.FromBinary(bin, serializer); - - Assert.AreEqual(original, copy); - Assert.AreEqual(original.GetHashCode(), copy.GetHashCode()); - } - [Test] public void TestPofSerialization() { diff --git a/tests/Coherence.Tests/Util/Collections/SortedDictionaryTests.cs b/tests/Coherence.Tests/Util/Collections/SortedDictionaryTests.cs index 1561ae4..f7b6961 100644 --- a/tests/Coherence.Tests/Util/Collections/SortedDictionaryTests.cs +++ b/tests/Coherence.Tests/Util/Collections/SortedDictionaryTests.cs @@ -1,17 +1,13 @@ /* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. * * Licensed under the Universal Permissive License v 1.0 as shown at - * http://oss.oracle.com/licenses/upl. + * https://oss.oracle.com/licenses/upl. */ using System; using System.Collections; -using System.IO; using System.Reflection; -using System.Runtime.Serialization; -using System.Runtime.Serialization.Formatters.Binary; using NUnit.Framework; -using Tangosol.IO.Pof.Reflection.Internal; namespace Tangosol.Util.Collections { @@ -156,30 +152,6 @@ public void TestSortedHashSetConstruction() AssertInstanceOf(typeof(SortedHashSet), "m_dict", setSorted, typeof(SortedDictionary)); } - [Test] - public void TesSortedHashSetSerialization() - { - var setSorted = new SortedHashSet(); - - setSorted.Add("C"); - setSorted.Add("A"); - setSorted.Add("B"); - - // assert we have ascending characters - EnsureAlphabetic(setSorted); - - // serialize -> deserialize - var formatter = new BinaryFormatter(); - var binOut = new MemoryStream(); - formatter.Serialize(binOut, setSorted); - binOut.Flush(); - binOut.Position = 0; - - var setSortedCloned = formatter.Deserialize(binOut) as SortedHashSet; - EnsureAlphabetic(setSortedCloned); - AssertInstanceOf(typeof(SortedHashSet), "m_dict", setSortedCloned, typeof(SortedDictionary)); - } - private static void EnsureAlphabetic(ICollection colSorted) { // assert we have ascending characters diff --git a/tests/Coherence.Tests/Util/SerializationHelperTests.cs b/tests/Coherence.Tests/Util/SerializationHelperTests.cs index caed274..83c10f4 100644 --- a/tests/Coherence.Tests/Util/SerializationHelperTests.cs +++ b/tests/Coherence.Tests/Util/SerializationHelperTests.cs @@ -1,16 +1,15 @@ /* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. * * Licensed under the Universal Permissive License v 1.0 as shown at - * http://oss.oracle.com/licenses/upl. + * https://oss.oracle.com/licenses/upl. */ -using System; using System.IO; using Tangosol.IO; -using Tangosol.Util; using NUnit.Framework; +using Tangosol.IO.Pof; namespace Tangosol.Util { @@ -20,7 +19,7 @@ public class SerializationHelperTests [Test] public void TestToAndFromBinary() { - ISerializer serializer = new BinarySerializer(); + ISerializer serializer = new ConfigurablePofContext("config/include-pof-config.xml"); string original = "hello"; Binary bin = SerializationHelper.ToBinary(original, serializer); string copy = (string) SerializationHelper.FromBinary(bin, serializer); @@ -42,7 +41,7 @@ public void TestToAndFromBinary() [Test] public void TestDecoration() { - ISerializer serializer = new BinarySerializer(); + ISerializer serializer = new ConfigurablePofContext("config/include-pof-config.xml"); string original = "hello"; Binary bin = SerializationHelper.ToBinary(original, serializer);