Note
Even if this flag is enabled, non-serializable types will not be serialized automatically. Use the RecursiveSerializationAsFallback to
enable serialization of such types.
[FlagsAttribute]
public enum BinarySerializationOptions<FlagsAttribute>
Public Enumeration BinarySerializationOptions[FlagsAttribute]
public enum class BinarySerializationOptions[<FlagsAttribute>]
type BinarySerializationOptions| None | 0x0000 | All options are disabled. |
| ForceRecursiveSerializationOfSupportedTypes | 0x0001 | Apart from primitive types, strings and arrays forces to serialize every type recursively. If SurrogateSelector is set, then the surrogate selectors will be tried to be used even for the supported types (as if TryUseSurrogateSelectorForAnyType was also enabled). This flag is considered on serialization. Default state at serialization methods in BinarySerializer: Disabled |
| ForcedSerializationValueTypesAsFallback | 0x0002 | This option makes possible to serialize ValueTypes (struct) that are not marked by SerializableAttribute. This flag is considered on serialization. Default state at serialization methods in BinarySerializer: Disabled |
| RecursiveSerializationAsFallback | 0x0004 | Makes possible to serialize any non-natively supported types if they are not marked by SerializableAttribute. This flag is considered on serialization. Default state at serialization methods in BinarySerializer: Disabled |
| IgnoreSerializationMethods | 0x0008 | If a type has methods decorated by OnSerializingAttribute, OnSerializedAttribute, OnDeserializingAttribute or OnDeserializedAttribute, or the type implements IDeserializationCallback, then these methods are called during the process. By setting this flag these methods can be ignored. This flag is considered both on serialization and deserialization. Default state at serialization methods in BinarySerializer: Disabled |
| IgnoreIBinarySerializable | 0x0010 | This flag ignores IBinarySerializable implementations. This flag is considered on serialization. Default state at serialization methods in BinarySerializer: Disabled |
| OmitAssemblyQualifiedNames | 0x0020 | If enabled, type references will be stored without assembly identification. This can make possible to restore a type even if the version of the assembly has been modified since last serialization while makes serialized data more compact; however, it cannot be guaranteed that the correct type will be even found on deserialization without specifying the expected types. This flag is considered on serialization. Default state at serialization methods in BinarySerializer: Disabled |
| IgnoreObjectChanges | 0x0040 | This option makes possible to deserialize an object, which has been changed since last serialization. When this option is enabled, names of the base classes, and fields that have been serialized but have been since then removed, will be ignored. This flag is considered on deserialization. Default state at serialization methods in BinarySerializer: Disabled |
| IgnoreTypeForwardedFromAttribute | 0x0080 | When this flag is enabled, every type will be serialized with its actual assembly identity rather than considering the value of an existing TypeForwardedFromAttribute. This flag is ignored if OmitAssemblyQualifiedNames is enabled. This flag is considered on serialization. Default state at serialization methods in BinarySerializer: Disabled |
| IgnoreISerializable | 0x0100 | This flag ignores ISerializable implementations for natively not supported types, forcing to serialize a default object graph (unless an applicable surrogate selector is defined). This flag is considered both on serialization and deserialization. Default state at serialization methods in BinarySerializer: Disabled |
| IgnoreIObjectReference | 0x0200 | This flag ignores IObjectReference implementations. This flag is considered on deserialization. Default state at serialization methods in BinarySerializer: Disabled |
| CompactSerializationOfStructures | 0x0400 | If a ValueType (struct) contains no references, then by enabling this option the instance will be serialized in a compact way form if possible. This flag is considered on serialization. Default state at serialization methods in BinarySerializer: Disabled |
| TryUseSurrogateSelectorForAnyType | 0x0800 | If this flag is enabled while SurrogateSelector is set, then the selector is tried to be used even for natively supported types. This flag is considered on serialization. Default state at serialization methods in BinarySerializer: Disabled |
| SafeMode | 0x1000 | When this flag is enabled, the natively not supported types, whose assembly qualified names are stored in the serialization stream must be explicitly declared as expected types in the deserialization methods, including enums. Additionally, safe mode ensures that during the deserialization natively supported collections are allocated with limited capacity to prevent possible attacks that can cause OutOfMemoryException. Deserializing an invalid stream still may cause to throw a SerializationException. It also disallows deserializing the natively not supported non-serializable types, though this can be relaxed by enabling the AllowNonSerializableExpectedCustomTypes flag. This flag is considered on deserialization. Default state at serialization methods in BinarySerializer: Enabled |
| AllowNonSerializableExpectedCustomTypes | 0x2000 | Indicates that recursively serialized types that are indicated as expected types at the deserialization methods should be able to be deserialized in SafeMode even if they are not marked by the SerializableAttribute. This flag is considered on deserialization. Default state at serialization methods in BinarySerializer: Disabled |
| PreferInvokingDefaultConstructor | 0x4000 | Indicates that the default constructor should be called when it exists and no other constructor would be called on deserialization otherwise. This flag is considered on deserialization. This flag does not affect IBinarySerializable types, as their default constructor is called anyway if the special constructor does not exist. Default state at serialization methods in BinarySerializer: Disabled |
| LegacySafeMode | 0x8000 | The SafeMode option became more and more strict lately, tempting users to turn it off rather than to address the stricter security requirements if deserialization broke after a version upgrade. This flag exists only to be able to use at least the earlier security settings instead of going completely unsafe, but it is not recommended to prefer this option in a new project. Using this flag instead of SafeMode allows setting the SurrogateSelector and Binder properties to any custom instance. In legacy safe mode it is not required to specify the expected types for deserialization (though when they are specified, they are respected). With no specified expected types, this option only prevents loading assemblies during deserialization, so all the assemblies that are referred by the serialization stream must be preloaded before starting the deserialization (though this restriction can be worked around by setting a custom binder that still can load assemblies, for example). All the other restrictions of SafeMode are effective in LegacySafeMode as well. When both flags are set, the stricter SafeMode will be used. Default state at serialization methods in BinarySerializer: Disabled |
| AllFlagsDefined |
Gets whether every single bit value in flags are defined in the enum type of flags,
or when flags is zero, it is checked whether zero is defined in the enum type of flags.
(Defined by EnumExtensions) |
| IsSingleFlag |
Gets whether only a single bit is set in value.
(Defined by EnumExtensions) |