From 6c5980a7a5f79a0ab369b8ec578ee5cca4ee837e Mon Sep 17 00:00:00 2001 From: Marc Hernandez Date: Thu, 7 Mar 2024 17:30:54 -0800 Subject: [PATCH] Fix IFormatter --- SharpLib.csproj | 2 +- net/Conn.cs | 60 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/SharpLib.csproj b/SharpLib.csproj index 82a9526..8713be8 100644 --- a/SharpLib.csproj +++ b/SharpLib.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 lib 0.0.1.0 0.0.1.0 diff --git a/net/Conn.cs b/net/Conn.cs index ad6feca..9196e74 100644 --- a/net/Conn.cs +++ b/net/Conn.cs @@ -1,15 +1,73 @@ using System; using System.Runtime.Serialization; -using System.Runtime.Serialization.Formatters.Binary; using System.Net.Sockets; using System.IO; +using System.Diagnostics.CodeAnalysis; //using Util; namespace lib { + public interface IFormatter + { + // + // Summary: + // Gets or sets the System.Runtime.Serialization.SerializationBinder that performs + // type lookups during deserialization. + // + // Returns: + // The System.Runtime.Serialization.SerializationBinder that performs type lookups + // during deserialization. + SerializationBinder? Binder { get; set; } + // + // Summary: + // Gets or sets the System.Runtime.Serialization.StreamingContext used for serialization + // and deserialization. + // + // Returns: + // The System.Runtime.Serialization.StreamingContext used for serialization and + // deserialization. + StreamingContext Context { get; set; } + // + // Summary: + // Gets or sets the System.Runtime.Serialization.SurrogateSelector used by the current + // formatter. + // + // Returns: + // The System.Runtime.Serialization.SurrogateSelector used by this formatter. + ISurrogateSelector? SurrogateSelector { get; set; } + // + // Summary: + // Deserializes the data on the provided stream and reconstitutes the graph of objects. + // + // + // Parameters: + // serializationStream: + // The stream that contains the data to deserialize. + // + // Returns: + // The top object of the deserialized graph. + [RequiresDynamicCode("BinaryFormatter serialization uses dynamic code generation, the type of objects being processed cannot be statically discovered.")] + [RequiresUnreferencedCode("BinaryFormatter serialization is not trim compatible because the type of objects being processed cannot be statically discovered.")] + object Deserialize(Stream serializationStream); + // + // Summary: + // Serializes an object, or graph of objects with the given root to the provided + // stream. + // + // Parameters: + // serializationStream: + // The stream where the formatter puts the serialized data. This stream can reference + // a variety of backing stores (such as files, network, memory, and so on). + // + // graph: + // The object, or root of the object graph, to serialize. All child objects of this + // root object are automatically serialized. + [RequiresUnreferencedCode("BinaryFormatter serialization is not trim compatible because the type of objects being processed cannot be statically discovered.")] + void Serialize(Stream serializationStream, object graph); + } public interface IProcess