Skip to content

Commit b812f49

Browse files
authored
Update ObsoleteAttribute remarks to account for new properties (dotnet#4984)
1 parent 44ffa45 commit b812f49

File tree

1 file changed

+103
-81
lines changed

1 file changed

+103
-81
lines changed

Diff for: xml/System/ObsoleteAttribute.xml

+103-81
Original file line numberDiff line numberDiff line change
@@ -54,43 +54,41 @@
5454
<Docs>
5555
<summary>Marks the program elements that are no longer in use. This class cannot be inherited.</summary>
5656
<remarks>
57-
<format type="text/markdown"><![CDATA[
58-
59-
## Remarks
60-
<xref:System.ObsoleteAttribute> is applicable to all program elements except assemblies, modules, parameters, and return values. Marking an element as obsolete informs users that the element will be removed in future versions of the product.
61-
62-
The <xref:System.ObsoleteAttribute> class includes two properties:
63-
64-
- <xref:System.ObsoleteAttribute.Message%2A>. The string assigned to the <xref:System.ObsoleteAttribute.Message%2A> property is emitted by the compiler when the attribute target is used in code. The string should note that the attribute target is obsolete and, if possible, provide some workaround or programmatic alternative.
65-
66-
- <xref:System.ObsoleteAttribute.IsError%2A>. This is a Boolean value that indicates to the compiler whether using the <xref:System.ObsoleteAttribute> attribute should cause it to emit an error (<xref:System.ObsoleteAttribute.IsError%2A> is `true`) or a warning (<xref:System.ObsoleteAttribute.IsError%2A> is `false`).
67-
68-
For more information about using attributes, see [Attributes](/dotnet/standard/attributes/).
69-
70-
## [!INCLUDE[win8_appname_long](~/includes/win8-appname-long-md.md)] Apps
71-
When you create a Windows Metadata library (.winmd file), the <xref:System.ObsoleteAttribute> is exported as both the <xref:System.ObsoleteAttribute> attribute and the [Windows.Foundation.Metadata.DeprecatedAttribute](https://msdn.microsoft.com/library/windows/apps/windows.foundation.metadata.deprecatedattribute.aspx) attribute if only the <xref:System.ObsoleteAttribute> is present in source code. The <xref:System.ObsoleteAttribute> is transformed to the `DeprecatedAttribute` as follows:
72-
73-
- If the `message` and `error` arguments are both present, `message` is assigned to the `DeprecatedAttribute` `message` argument. An error value of `true` maps to [DeprecationType.Remove](https://msdn.microsoft.com/library/windows/apps/windows.foundation.metadata.deprecationtype.aspx), and an `error` value of `false` maps to [DeprecationType.Deprecate](https://msdn.microsoft.com/library/windows/apps/windows.foundation.metadata.deprecationtype.aspx).
74-
75-
- If the `message` argument is not supplied in the <xref:System.ObsoleteAttribute>, its default value in the `DeprecatedAttribute` is "*element_name* is deprecated", where *element_name* is the name of the target program element to which the attribute is applied.
76-
77-
- If the `error` argument is not present in the <xref:System.ObsoleteAttribute>, its default value in the `DeprecatedAttribute` is [DeprecationType.Deprecate](https://msdn.microsoft.com/library/windows/apps/windows.foundation.metadata.deprecationtype.aspx).
78-
57+
<format type="text/markdown"><![CDATA[
58+
59+
## Remarks
60+
61+
<xref:System.ObsoleteAttribute> is applicable to all program elements except assemblies, modules, parameters, and return values. Marking an element as obsolete informs users that the element may be removed in a future version of the product.
62+
63+
The string assigned to the <xref:System.ObsoleteAttribute.Message%2A> property is emitted by the compiler when the attribute target is used in code. Ideally, the string should provide some workaround or programmatic alternative.
64+
65+
Use the <xref:System.ObsoleteAttribute.IsError%2A> property to indicate to the compiler whether using the <xref:System.ObsoleteAttribute> attribute should cause it to emit an error (<xref:System.ObsoleteAttribute.IsError%2A> is `true`) or a warning (<xref:System.ObsoleteAttribute.IsError%2A> is `false`).
66+
67+
For more information about using attributes, see [Attributes](/dotnet/standard/attributes/).
68+
69+
## Windows 8.x Store apps
70+
71+
When you create a Windows Metadata library (.winmd file), the <xref:System.ObsoleteAttribute> is exported as both the <xref:System.ObsoleteAttribute> attribute and the [Windows.Foundation.Metadata.DeprecatedAttribute](https://msdn.microsoft.com/library/windows/apps/windows.foundation.metadata.deprecatedattribute.aspx) attribute if only the <xref:System.ObsoleteAttribute> is present in source code. The <xref:System.ObsoleteAttribute> is transformed to the `DeprecatedAttribute` as follows:
72+
73+
- If the `message` and `error` arguments are both present, `message` is assigned to the `DeprecatedAttribute` `message` argument. An error value of `true` maps to [DeprecationType.Remove](https://msdn.microsoft.com/library/windows/apps/windows.foundation.metadata.deprecationtype.aspx), and an `error` value of `false` maps to [DeprecationType.Deprecate](https://msdn.microsoft.com/library/windows/apps/windows.foundation.metadata.deprecationtype.aspx).
74+
75+
- If the `message` argument is not supplied in the <xref:System.ObsoleteAttribute>, its default value in the `DeprecatedAttribute` is "*element_name* is deprecated", where *element_name* is the name of the target program element to which the attribute is applied.
76+
77+
- If the `error` argument is not present in the <xref:System.ObsoleteAttribute>, its default value in the `DeprecatedAttribute` is [DeprecationType.Deprecate](https://msdn.microsoft.com/library/windows/apps/windows.foundation.metadata.deprecationtype.aspx).
78+
7979
> [!IMPORTANT]
80-
> Directly applying the [Windows.Foundation.Metadata.DeprecatedAttribute](https://msdn.microsoft.com/library/windows/apps/windows.foundation.metadata.deprecatedattribute.aspx) attribute to managed code is not recommended, because this export occurs automatically.
81-
82-
83-
84-
## Examples
85-
The following example defines a class that contains a property and a method that are marked with the <xref:System.ObsoleteAttribute> attribute. Accessing the value of the `OldProperty` property in code generates a compiler warning, but calling the `CallOldMethod` method generates a compiler error. The example also shows the output that results when you attempt to compile the source code.
86-
80+
> Directly applying the [Windows.Foundation.Metadata.DeprecatedAttribute](/uwp/api/Windows.Foundation.Metadata.DeprecatedAttribute) attribute to managed code is not recommended, because this export occurs automatically.
81+
82+
## Examples
83+
The following example defines a class that contains a property and a method that are marked with the <xref:System.ObsoleteAttribute> attribute. Accessing the value of the `OldProperty` property in code generates a compiler warning, but calling the `CallOldMethod` method generates a compiler error. The example also shows the output that results when you attempt to compile the source code.
84+
8785
[!code-csharp[ObsoleteAttribute#1](~/samples/snippets/csharp/VS_Snippets_CLR/ObsoleteAttribute/CS/obsoleteattributeex1.cs#1)]
88-
[!code-vb[ObsoleteAttribute#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/ObsoleteAttribute/vb/obsoleteattributeex1.vb#1)]
89-
86+
[!code-vb[ObsoleteAttribute#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/ObsoleteAttribute/vb/obsoleteattributeex1.vb#1)]
87+
9088
]]></format>
9189
</remarks>
9290
<altmember cref="T:System.Attribute" />
93-
<related type="Article" href="/dotnet/standard/attributes/">Extending Metadata Using Attributes</related>
91+
<related type="Article" href="/dotnet/standard/attributes/">Extend metadata using attributes</related>
9492
</Docs>
9593
<Members>
9694
<MemberGroup MemberName=".ctor">
@@ -140,16 +138,18 @@
140138
<Docs>
141139
<summary>Initializes a new instance of the <see cref="T:System.ObsoleteAttribute" /> class with default properties.</summary>
142140
<remarks>
143-
<format type="text/markdown"><![CDATA[
144-
145-
## Remarks
146-
The following table shows the initial property values for an instance of <xref:System.ObsoleteAttribute>.
147-
148-
|Property|Value|
149-
|--------------|-----------|
150-
|<xref:System.ObsoleteAttribute.IsError%2A>|`false`|
151-
|<xref:System.ObsoleteAttribute.Message%2A>|`null`|
152-
141+
<format type="text/markdown"><![CDATA[
142+
143+
## Remarks
144+
The following table shows the initial property values for an instance of <xref:System.ObsoleteAttribute>.
145+
146+
|Property|Value|
147+
|--------------|-----------|
148+
|<xref:System.ObsoleteAttribute.IsError%2A>|`false`|
149+
|<xref:System.ObsoleteAttribute.Message%2A>|`null`|
150+
|<xref:System.ObsoleteAttribute.DiagnosticId>|`null`|
151+
|<xref:System.ObsoleteAttribute.UrlFormat>|`null`|
152+
153153
]]></format>
154154
</remarks>
155155
</Docs>
@@ -192,16 +192,18 @@
192192
<param name="message">The text string that describes alternative workarounds.</param>
193193
<summary>Initializes a new instance of the <see cref="T:System.ObsoleteAttribute" /> class with a specified workaround message.</summary>
194194
<remarks>
195-
<format type="text/markdown"><![CDATA[
196-
197-
## Remarks
198-
The following table shows the initial property values for an instance of <xref:System.ObsoleteAttribute>.
199-
200-
|Property|Value|
201-
|--------------|-----------|
202-
|<xref:System.ObsoleteAttribute.IsError%2A>|`false`.|
203-
|<xref:System.ObsoleteAttribute.Message%2A>|The workaround message.|
204-
195+
<format type="text/markdown"><![CDATA[
196+
197+
## Remarks
198+
The following table shows the initial property values for an instance of <xref:System.ObsoleteAttribute>.
199+
200+
|Property|Value|
201+
|--------------|-----------|
202+
|<xref:System.ObsoleteAttribute.IsError%2A>|`false`.|
203+
|<xref:System.ObsoleteAttribute.Message%2A>|The workaround message.|
204+
|<xref:System.ObsoleteAttribute.DiagnosticId>|`null`.|
205+
|<xref:System.ObsoleteAttribute.UrlFormat>|`null`.|
206+
205207
]]></format>
206208
</remarks>
207209
</Docs>
@@ -247,16 +249,18 @@
247249
<see langword="true" /> if the obsolete element usage generates a compiler error; <see langword="false" /> if it generates a compiler warning.</param>
248250
<summary>Initializes a new instance of the <see cref="T:System.ObsoleteAttribute" /> class with a workaround message and a Boolean value indicating whether the obsolete element usage is considered an error.</summary>
249251
<remarks>
250-
<format type="text/markdown"><![CDATA[
251-
252-
## Remarks
253-
The following table shows the initial property values for an instance of <xref:System.ObsoleteAttribute>.
254-
255-
|Property|Value|
256-
|--------------|-----------|
257-
|<xref:System.ObsoleteAttribute.IsError%2A>|The `error` value.|
258-
|<xref:System.ObsoleteAttribute.Message%2A>|The `message` value.|
259-
252+
<format type="text/markdown"><![CDATA[
253+
254+
## Remarks
255+
The following table shows the initial property values for an instance of <xref:System.ObsoleteAttribute>.
256+
257+
|Property|Value|
258+
|--------------|-----------|
259+
|<xref:System.ObsoleteAttribute.IsError%2A>|The `error` value.|
260+
|<xref:System.ObsoleteAttribute.Message%2A>|The `message` value.|
261+
|<xref:System.ObsoleteAttribute.DiagnosticId>|`null`.|
262+
|<xref:System.ObsoleteAttribute.UrlFormat>|`null`.|
263+
260264
]]></format>
261265
</remarks>
262266
</Docs>
@@ -283,9 +287,19 @@
283287
<ReturnType>System.String</ReturnType>
284288
</ReturnValue>
285289
<Docs>
286-
<summary>Gets or sets the ID the compiler will use when reporting a use of the API.</summary>
290+
<summary>Gets or sets the ID that the compiler will use when reporting a use of the API.</summary>
287291
<value>The unique diagnostic ID.</value>
288-
<remarks>To be added.</remarks>
292+
<remarks>
293+
<format type="text/markdown"><![CDATA[
294+
295+
## Remarks
296+
297+
The diagnostic ID is shown in build output for warnings and errors.
298+
299+
This property represents the unique ID that can be used to suppress the warnings or errors, if needed.
300+
301+
]]></format>
302+
</remarks>
289303
</Docs>
290304
</Member>
291305
<Member MemberName="IsError">
@@ -323,18 +337,18 @@
323337
<ReturnType>System.Boolean</ReturnType>
324338
</ReturnValue>
325339
<Docs>
326-
<summary>Gets a Boolean value indicating whether the compiler will treat usage of the obsolete program element as an error.</summary>
340+
<summary>Gets a value that indicates whether the compiler will treat usage of the obsolete program element as an error.</summary>
327341
<value>
328342
<see langword="true" /> if the obsolete element usage is considered an error; otherwise, <see langword="false" />. The default is <see langword="false" />.</value>
329343
<remarks>
330-
<format type="text/markdown"><![CDATA[
331-
332-
## Examples
333-
The following example defines a class that contains two members marked as obsolete. The first, a property named `OldProperty`, produces a compiler warning if it is called. The second, a method named `CallOldMethod`, produces a compiler error. The example uses reflection to get information about the <xref:System.ObsoleteAttribute> attributes applied to members of the type and displays the values of their <xref:System.ObsoleteAttribute.Message%2A> and <xref:System.ObsoleteAttribute.IsError%2A> properties.
334-
344+
<format type="text/markdown"><![CDATA[
345+
346+
## Examples
347+
The following example defines a class that contains two members marked as obsolete. The first, a property named `OldProperty`, produces a compiler warning if it is called. The second, a method named `CallOldMethod`, produces a compiler error. The example uses reflection to get information about the <xref:System.ObsoleteAttribute> attributes applied to members of the type and displays the values of their <xref:System.ObsoleteAttribute.Message%2A> and <xref:System.ObsoleteAttribute.IsError%2A> properties.
348+
335349
[!code-csharp[System.ObsoleteAttribute.Message#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.obsoleteattribute.message/cs/obsoleteattribute_message.cs#1)]
336-
[!code-vb[System.ObsoleteAttribute.Message#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.obsoleteattribute.message/vb/obsoleteattribute_message.vb#1)]
337-
350+
[!code-vb[System.ObsoleteAttribute.Message#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.obsoleteattribute.message/vb/obsoleteattribute_message.vb#1)]
351+
338352
]]></format>
339353
</remarks>
340354
</Docs>
@@ -374,17 +388,17 @@
374388
<ReturnType>System.String</ReturnType>
375389
</ReturnValue>
376390
<Docs>
377-
<summary>Gets the workaround message, including a description of the alternative program elements.</summary>
391+
<summary>Gets the workaround message.</summary>
378392
<value>The workaround text string.</value>
379393
<remarks>
380-
<format type="text/markdown"><![CDATA[
381-
382-
## Examples
383-
The following example defines a class that contains two members marked as obsolete. The first, a property named `OldProperty`, produces a compiler warning if it is called. The second, a method named `CallOldMethod`, produces a compiler error. The example uses reflection to get information about the <xref:System.ObsoleteAttribute> attributes applied to members of the type and displays the values of their <xref:System.ObsoleteAttribute.Message%2A> and <xref:System.ObsoleteAttribute.IsError%2A> properties.
384-
394+
<format type="text/markdown"><![CDATA[
395+
396+
## Examples
397+
The following example defines a class that contains two members marked as obsolete. The first, a property named `OldProperty`, produces a compiler warning if it is called. The second, a method named `CallOldMethod`, produces a compiler error. The example uses reflection to get information about the <xref:System.ObsoleteAttribute> attributes applied to members of the type and displays the values of their <xref:System.ObsoleteAttribute.Message%2A> and <xref:System.ObsoleteAttribute.IsError%2A> properties.
398+
385399
[!code-csharp[System.ObsoleteAttribute.Message#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.obsoleteattribute.message/cs/obsoleteattribute_message.cs#1)]
386-
[!code-vb[System.ObsoleteAttribute.Message#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.obsoleteattribute.message/vb/obsoleteattribute_message.vb#1)]
387-
400+
[!code-vb[System.ObsoleteAttribute.Message#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.obsoleteattribute.message/vb/obsoleteattribute_message.vb#1)]
401+
388402
]]></format>
389403
</remarks>
390404
</Docs>
@@ -413,7 +427,15 @@
413427
<Docs>
414428
<summary>Gets or sets the URL for corresponding documentation. The API accepts a format string instead of an actual URL, creating a generic URL that includes the diagnostic ID.</summary>
415429
<value>The format string that represents a URL to corresponding documentation.</value>
416-
<remarks>To be added.</remarks>
430+
<remarks>
431+
<format type="text/markdown"><![CDATA[
432+
433+
## Remarks
434+
435+
An example format string is `https://contoso.com/obsoletion-warnings/{0}`.
436+
437+
]]></format>
438+
</remarks>
417439
</Docs>
418440
</Member>
419441
</Members>

0 commit comments

Comments
 (0)