-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
KnownTypeAttribute.xml
318 lines (294 loc) · 19.5 KB
/
KnownTypeAttribute.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
<Type Name="KnownTypeAttribute" FullName="System.Runtime.Serialization.KnownTypeAttribute">
<TypeSignature Language="C#" Value="public sealed class KnownTypeAttribute : Attribute" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit KnownTypeAttribute extends System.Attribute" />
<TypeSignature Language="DocId" Value="T:System.Runtime.Serialization.KnownTypeAttribute" />
<TypeSignature Language="VB.NET" Value="Public NotInheritable Class KnownTypeAttribute
Inherits Attribute" />
<TypeSignature Language="F#" Value="type KnownTypeAttribute = class
 inherit Attribute" />
<TypeSignature Language="C++ CLI" Value="public ref class KnownTypeAttribute sealed : Attribute" />
<AssemblyInfo>
<AssemblyName>System.Runtime.Serialization.Primitives</AssemblyName>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime.Serialization</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<TypeForwardingChain>
<TypeForwarding From="System.Runtime.Serialization" FromVersion="4.0.0.0" To="System.Runtime.Serialization.Primitives" ToVersion="0.0.0.0" FrameworkAlternate="dotnet-uwp-10.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Runtime.Serialization.Primitives" ToVersion="5.0.0.0" FrameworkAlternate="net-5.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Runtime.Serialization.Primitives" ToVersion="6.0.0.0" FrameworkAlternate="net-6.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Runtime.Serialization.Primitives" ToVersion="7.0.0.0" FrameworkAlternate="net-7.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Runtime.Serialization.Primitives" ToVersion="8.0.0.0" FrameworkAlternate="net-8.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Runtime.Serialization.Primitives" ToVersion="9.0.0.0" FrameworkAlternate="net-9.0" />
</TypeForwardingChain>
<Base>
<BaseTypeName>System.Attribute</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Struct, AllowMultiple=true, Inherited=true)]</AttributeName>
<AttributeName Language="F#">[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Struct, AllowMultiple=true, Inherited=true)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="net-8.0;net-9.0">
<AttributeName Language="C#">[System.Runtime.CompilerServices.Nullable(0)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.Nullable(0)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="net-8.0;net-9.0">
<AttributeName Language="C#">[System.Runtime.CompilerServices.NullableContext(2)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.NullableContext(2)>]</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Specifies types that should be recognized by the <see cref="T:System.Runtime.Serialization.DataContractSerializer" /> when serializing or deserializing a given type.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Apply the <xref:System.Runtime.Serialization.KnownTypeAttribute> attribute to a type to indicate to the <xref:System.Runtime.Serialization.DataContractSerializer> types that should be recognized when serializing or deserializing an instance of the type to which the attribute is applied. This attribute could also be recognized by other serializers that understand data contracts.
> [!NOTE]
> In your code, you can use the word `KnownType` instead of the longer `KnownTypeAttribute`.
You can either apply exactly one <xref:System.Runtime.Serialization.KnownTypeAttribute> instance with the <xref:System.Runtime.Serialization.KnownTypeAttribute.MethodName%2A> property set, or one or more <xref:System.Runtime.Serialization.KnownTypeAttribute> instances with the <xref:System.Runtime.Serialization.KnownTypeAttribute.Type%2A> property set.
## Examples
The following example shows a type named `Person` and a type named `IDInformation` that should be recognized when serializing or deserializing the `Person` type.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/knowntypeattribute/cs/overview.cs" id="Snippet0":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/knowntypeattribute/vb/overview.vb" id="Snippet0":::
]]></format>
</remarks>
<altmember cref="T:System.Runtime.Serialization.DataContractAttribute" />
<altmember cref="T:System.Runtime.Serialization.DataMemberAttribute" />
<altmember cref="T:System.Runtime.Serialization.DataContractSerializer" />
<related type="Article" href="/dotnet/framework/wcf/feature-details/data-contract-known-types">Data Contract Known Types</related>
</Docs>
<Members>
<MemberGroup MemberName=".ctor">
<AssemblyInfo>
<AssemblyName>System.Runtime.Serialization.Primitives</AssemblyName>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Runtime.Serialization.KnownTypeAttribute" /> class.</summary>
</Docs>
</MemberGroup>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public KnownTypeAttribute (string methodName);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string methodName) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Runtime.Serialization.KnownTypeAttribute.#ctor(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (methodName As String)" />
<MemberSignature Language="F#" Value="new System.Runtime.Serialization.KnownTypeAttribute : string -> System.Runtime.Serialization.KnownTypeAttribute" Usage="new System.Runtime.Serialization.KnownTypeAttribute methodName" />
<MemberSignature Language="C++ CLI" Value="public:
 KnownTypeAttribute(System::String ^ methodName);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Runtime.Serialization.Primitives</AssemblyName>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime.Serialization</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="net-8.0;net-9.0">
<AttributeName Language="C#">[System.Runtime.CompilerServices.NullableContext(1)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.NullableContext(1)>]</AttributeName>
</Attribute>
</Attributes>
<Parameters>
<Parameter Name="methodName" Type="System.String" />
</Parameters>
<Docs>
<param name="methodName">The name of the method that returns an <see cref="T:System.Collections.IEnumerable" /> of types used when serializing or deserializing data.</param>
<summary>Initializes a new instance of the <see cref="T:System.Runtime.Serialization.KnownTypeAttribute" /> class with the name of a method that returns an <see cref="T:System.Collections.IEnumerable" /> of known types.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This constructor uses a method name that matches a method of the class. The method returns a <xref:System.Collections.Generic.IEnumerable%601> of <xref:System.Type> objects. During serialization or deserialization, the types found in the collection can be used within the root type to which the attribute is applied.
## Examples
The following example uses the `methodName` parameter to identify a method in the type that contains an array of <xref:System.Type> objects.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/knowntypeattribute_ctor_string/cs/knowntype_ctor1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/knowntypeattribute_ctor_string/vb/knowntypeattribute_ctor1.vb" id="Snippet1":::
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public KnownTypeAttribute (Type type);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(class System.Type type) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Runtime.Serialization.KnownTypeAttribute.#ctor(System.Type)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (type As Type)" />
<MemberSignature Language="F#" Value="new System.Runtime.Serialization.KnownTypeAttribute : Type -> System.Runtime.Serialization.KnownTypeAttribute" Usage="new System.Runtime.Serialization.KnownTypeAttribute type" />
<MemberSignature Language="C++ CLI" Value="public:
 KnownTypeAttribute(Type ^ type);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Runtime.Serialization.Primitives</AssemblyName>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime.Serialization</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="net-8.0;net-9.0">
<AttributeName Language="C#">[System.Runtime.CompilerServices.NullableContext(1)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.NullableContext(1)>]</AttributeName>
</Attribute>
</Attributes>
<Parameters>
<Parameter Name="type" Type="System.Type" />
</Parameters>
<Docs>
<param name="type">The <see cref="T:System.Type" /> that is included as a known type when serializing or deserializing data.</param>
<summary>Initializes a new instance of the <see cref="T:System.Runtime.Serialization.KnownTypeAttribute" /> class with the specified type.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following example shows a type named `Person` and a type named `IDInformation` that should be included when or deserializing.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/knowntypeattribute/cs/overview.cs" id="Snippet0":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/knowntypeattribute/vb/overview.vb" id="Snippet0":::
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="MethodName">
<MemberSignature Language="C#" Value="public string MethodName { get; }" FrameworkAlternate="dotnet-uwp-10.0;netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-2.0;netstandard-2.1" />
<MemberSignature Language="ILAsm" Value=".property instance string MethodName" />
<MemberSignature Language="DocId" Value="P:System.Runtime.Serialization.KnownTypeAttribute.MethodName" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property MethodName As String" />
<MemberSignature Language="F#" Value="member this.MethodName : string" Usage="System.Runtime.Serialization.KnownTypeAttribute.MethodName" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ MethodName { System::String ^ get(); };" />
<MemberSignature Language="C#" Value="public string? MethodName { get; }" FrameworkAlternate="net-5.0;net-6.0;net-7.0;net-8.0;net-9.0" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Runtime.Serialization.Primitives</AssemblyName>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime.Serialization</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the name of a method that will return a list of types that should be recognized during serialization or deserialization.</summary>
<value>A <see cref="T:System.String" /> that contains the name of the method on the type defined by the <see cref="T:System.Runtime.Serialization.KnownTypeAttribute" /> class.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The method must exist on the class or structure that the <xref:System.Runtime.Serialization.KnownTypeAttribute> is applied to, must be static, must accept no parameters, and must return an instance of any type that implements the generic <xref:System.Collections.Generic.IEnumerable%601> interface, such as the <xref:System.Collections.ObjectModel.Collection%601> class, or an array of <xref:System.Type> objects.
The method is called once per application domain when the data contract is loaded for the type.
## Examples
The following example uses the `methodName` parameter to identify a method in the type that contains an array of <xref:System.Type> objects.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/knowntypeattribute_ctor_string/cs/knowntype_ctor1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/knowntypeattribute_ctor_string/vb/knowntypeattribute_ctor1.vb" id="Snippet1":::
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Type">
<MemberSignature Language="C#" Value="public Type Type { get; }" FrameworkAlternate="dotnet-uwp-10.0;netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-2.0;netstandard-2.1" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Type Type" />
<MemberSignature Language="DocId" Value="P:System.Runtime.Serialization.KnownTypeAttribute.Type" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property Type As Type" />
<MemberSignature Language="F#" Value="member this.Type : Type" Usage="System.Runtime.Serialization.KnownTypeAttribute.Type" />
<MemberSignature Language="C++ CLI" Value="public:
 property Type ^ Type { Type ^ get(); };" />
<MemberSignature Language="C#" Value="public Type? Type { get; }" FrameworkAlternate="net-5.0;net-6.0;net-7.0;net-8.0;net-9.0" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Runtime.Serialization.Primitives</AssemblyName>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime.Serialization</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Type</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the type that should be recognized during serialization or deserialization by the <see cref="T:System.Runtime.Serialization.DataContractSerializer" />.</summary>
<value>The <see cref="T:System.Type" /> that is used during serialization or deserialization.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
</Members>
</Type>