Skip to content

Commit c58ed1b

Browse files
ViktorHofermairaw
authored andcommitted
Adding .NET Core binary serialization doc (dotnet#2841)
* Adding .NET Core binary serialization doc * updates * addressed feedback * removed link * reestructured
1 parent c5e20c8 commit c58ed1b

File tree

1 file changed

+117
-8
lines changed

1 file changed

+117
-8
lines changed

docs/standard/serialization/binary-serialization.md

Lines changed: 117 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,139 @@
11
---
22
title: "Binary serialization"
3-
ms.date: "08/07/2017"
3+
ms.date: "08/11/2017"
44
ms.prod: ".net"
55
ms.topic: "article"
66
helpviewer_keywords:
77
- "binary serialization"
88
- "serialization, about serialization"
99
- "deserialization"
1010
- "binary serialization, about serialization"
11+
- "binary serialization, .net core serialization"
12+
- "serialization, cross-framework"
1113
ms.assetid: 2b1ea3be-1152-4032-b2b3-07794054c405
1214
caps.latest.revision: 5
13-
author: "Erikre"
14-
ms.author: "erikre"
15-
manager: "erikre"
15+
author: "ViktorHofer"
16+
ms.author: "mairaw"
1617
---
1718
# Binary serialization
19+
1820
Serialization can be defined as the process of storing the state of an object to a storage medium. During this process, the public and private fields of the object and the name of the class, including the assembly containing the class, are converted to a stream of bytes, which is then written to a data stream. When the object is subsequently deserialized, an exact clone of the original object is created.
1921

2022
When implementing a serialization mechanism in an object-oriented environment, you have to make a number of tradeoffs between ease of use and flexibility. The process can be automated to a large extent, provided you are given sufficient control over the process. For example, situations may arise where simple binary serialization is not sufficient, or there might be a specific reason to decide which fields in a class need to be serialized. The following sections examine the robust serialization mechanism provided with .NET and highlight a number of important features that allow you to customize the process to meet your needs.
21-
23+
2224
> [!NOTE]
23-
> The state of a UTF-8 or UTF-7 encoded object is not preserved if the object is serialized and deserialized using different .NET Framework versions.
25+
> The state of a UTF-8 or UTF-7 encoded object is not preserved if the object is serialized and deserialized using different .NET Framework versions.
2426
2527
[!INCLUDE [binary-serialization-warning](../../../includes/binary-serialization-warning.md)]
26-
27-
## In this section
28+
29+
As the nature of binary serialization allows the modification of private members inside an object and therefore changing the state of it, other serialization frameworks like JSON.NET which operate on the public API surface are recommended.
30+
31+
## Binary serialization in .NET Core
32+
33+
.NET Core supports binary serialization with a subset of types. You can see the list of supported types in the [Serializable types section](#serializable-types). The defined set of types are guaranteed to be serializable between .NET Framework 4.5.1 and later versions and .NET Core 2.0 and later versions. Other .NET implementations, such as Mono, aren't officially supported but should also be working.
34+
35+
### Serializable types
36+
37+
- <xref:System.AggregateException?displayProperty=fullName>
38+
- <xref:System.Array?displayProperty=fullName>
39+
- <xref:System.ArraySegment%601?displayProperty=fullName>
40+
- <xref:System.Attribute?displayProperty=fullName>
41+
- <xref:System.Boolean?displayProperty=fullName>
42+
- <xref:System.Byte?displayProperty=fullName>
43+
- <xref:System.Char?displayProperty=fullName>
44+
- <xref:System.Collections.ArrayList?displayProperty=fullName>
45+
- <xref:System.Collections.BitArray?displayProperty=fullName>
46+
- <xref:System.Collections.Comparer?displayProperty=fullName>
47+
- <xref:System.Collections.DictionaryEntry?displayProperty=fullName>
48+
- <xref:System.Collections.Generic.Comparer%601?displayProperty=fullName>
49+
- <xref:System.Collections.Generic.Dictionary%602?displayProperty=fullName>
50+
- <xref:System.Collections.Generic.EqualityComparer%601?displayProperty=fullName>
51+
- <xref:System.Collections.Generic.HashSet%601?displayProperty=fullName>
52+
- <xref:System.Collections.Generic.KeyValuePair%602?displayProperty=fullName>
53+
- <xref:System.Collections.Generic.LinkedList%601?displayProperty=fullName>
54+
- <xref:System.Collections.Generic.List%601?displayProperty=fullName>
55+
- <xref:System.Collections.Generic.Queue%601?displayProperty=fullName>
56+
- <xref:System.Collections.Generic.SortedDictionary%602?displayProperty=fullName>
57+
- <xref:System.Collections.Generic.SortedList%602?displayProperty=fullName>
58+
- <xref:System.Collections.Generic.SortedSet%601?displayProperty=fullName>
59+
- <xref:System.Collections.Generic.Stack%601?displayProperty=fullName>
60+
- <xref:System.Collections.Hashtable?displayProperty=fullName>
61+
- <xref:System.Collections.ObjectModel.Collection%601?displayProperty=fullName>
62+
- <xref:System.Collections.ObjectModel.KeyedCollection%602?displayProperty=fullName>
63+
- <xref:System.Collections.ObjectModel.ObservableCollection%601?displayProperty=fullName>
64+
- <xref:System.Collections.ObjectModel.ReadOnlyCollection%601?displayProperty=fullName>
65+
- <xref:System.Collections.ObjectModel.ReadOnlyDictionary%602?displayProperty=fullName>
66+
- <xref:System.Collections.ObjectModel.ReadOnlyObservableCollection%601?displayProperty=fullName>
67+
- <xref:System.Collections.Queue?displayProperty=fullName>
68+
- <xref:System.Collections.SortedList?displayProperty=fullName>
69+
- <xref:System.Collections.Specialized.HybridDictionary?displayProperty=fullName>
70+
- <xref:System.Collections.Specialized.ListDictionary?displayProperty=fullName>
71+
- <xref:System.Collections.Specialized.OrderedDictionary?displayProperty=fullName>
72+
- <xref:System.Collections.Specialized.StringCollection?displayProperty=fullName>
73+
- <xref:System.Collections.Specialized.StringDictionary?displayProperty=fullName>
74+
- <xref:System.Collections.Stack?displayProperty=fullName>
75+
- <xref:System.ComponentModel.BindingList%601?displayProperty=fullName>
76+
- <xref:System.Data.DataSet?displayProperty=fullName>
77+
- <xref:System.Data.DataTable?displayProperty=fullName>
78+
- <xref:System.Data.PropertyCollection?displayProperty=fullName>
79+
- <xref:System.Data.SqlTypes.SqlBoolean?displayProperty=fullName>
80+
- <xref:System.Data.SqlTypes.SqlByte?displayProperty=fullName>
81+
- <xref:System.Data.SqlTypes.SqlDateTime?displayProperty=fullName>
82+
- <xref:System.Data.SqlTypes.SqlDouble?displayProperty=fullName>
83+
- <xref:System.Data.SqlTypes.SqlGuid?displayProperty=fullName>
84+
- <xref:System.Data.SqlTypes.SqlInt16?displayProperty=fullName>
85+
- <xref:System.Data.SqlTypes.SqlInt32?displayProperty=fullName>
86+
- <xref:System.Data.SqlTypes.SqlInt64?displayProperty=fullName>
87+
- <xref:System.Data.SqlTypes.SqlString?displayProperty=fullName>
88+
- <xref:System.DateTime?displayProperty=fullName>
89+
- <xref:System.DateTimeOffset?displayProperty=fullName>
90+
- <xref:System.Decimal?displayProperty=fullName>
91+
- <xref:System.Double?displayProperty=fullName>
92+
- <xref:System.Drawing.Color?displayProperty=fullName>
93+
- <xref:System.Drawing.Point?displayProperty=fullName>
94+
- <xref:System.Drawing.PointF?displayProperty=fullName>
95+
- <xref:System.Drawing.Rectangle?displayProperty=fullName>
96+
- <xref:System.Drawing.RectangleF?displayProperty=fullName>
97+
- <xref:System.Drawing.Size?displayProperty=fullName>
98+
- <xref:System.Drawing.SizeF?displayProperty=fullName>
99+
- <xref:System.Enum?displayProperty=fullName>
100+
- <xref:System.Exception?displayProperty=fullName>
101+
- <xref:System.Globalization.CompareInfo?displayProperty=fullName>
102+
- <xref:System.Globalization.SortVersion?displayProperty=fullName>
103+
- <xref:System.Guid?displayProperty=fullName>
104+
- <xref:System.Int16?displayProperty=fullName>
105+
- <xref:System.Int32?displayProperty=fullName>
106+
- <xref:System.Int64?displayProperty=fullName>
107+
- <xref:System.IntPtr?displayProperty=fullName>
108+
- <xref:System.Net.Cookie?displayProperty=fullName>
109+
- <xref:System.Net.CookieCollection?displayProperty=fullName>
110+
- <xref:System.Net.CookieContainer?displayProperty=fullName>
111+
- <xref:System.Nullable%601?displayProperty=fullName>
112+
- <xref:System.Numerics.BigInteger?displayProperty=fullName>
113+
- <xref:System.Numerics.Complex?displayProperty=fullName>
114+
- <xref:System.Object?displayProperty=fullName>
115+
- <xref:System.SByte?displayProperty=fullName>
116+
- <xref:System.Single?displayProperty=fullName>
117+
- <xref:System.String?displayProperty=fullName>
118+
- <xref:System.StringComparer?displayProperty=fullName>
119+
- <xref:System.Text.StringBuilder?displayProperty=fullName>
120+
- <xref:System.TimeSpan?displayProperty=fullName>
121+
- <xref:System.TimeZoneInfo?displayProperty=fullName>
122+
- <xref:System.TimeZoneInfo.AdjustmentRule?displayProperty=fullName>
123+
- <xref:System.Tuple?displayProperty=fullName>
124+
- <xref:System.UInt16?displayProperty=fullName>
125+
- <xref:System.UInt32?displayProperty=fullName>
126+
- <xref:System.UInt64?displayProperty=fullName>
127+
- <xref:System.UIntPtr?displayProperty=fullName>
128+
- <xref:System.Uri?displayProperty=fullName>
129+
- <xref:System.ValueTuple?displayProperty=fullName>
130+
- <xref:System.ValueType?displayProperty=fullName>
131+
- <xref:System.Version?displayProperty=fullName>
132+
- <xref:System.WeakReference?displayProperty=fullName>
133+
- <xref:System.WeakReference%601?displayProperty=fullName>
134+
135+
## In this section
136+
28137
[Serialization Concepts](../../../docs/standard/serialization/serialization-concepts.md)
29138
Discusses two scenarios where serialization is useful: when persisting data to storage and when passing objects across application domains.
30139

0 commit comments

Comments
 (0)