DeprecatedAttribute vs. ObsoleteAttribute,

Source: Internet
Author: User

DeprecatedAttribute vs. ObsoleteAttribute,
Definition comparison ObsoleteAttribute

[SerializableAttribute][AttributeUsageAttribute(AttributeTargets.Class 
| AttributeTargets.Struct 
| AttributeTargets.Enum 
| AttributeTargets.Constructor 
| AttributeTargets.Method 
| AttributeTargets.Property 
| AttributeTargets.Field 
| AttributeTargets.Event 
| AttributeTargets.Interface 
| AttributeTargets.Delegate,     Inherited = false)][ComVisibleAttribute(true)]public sealed class ObsoleteAttribute : Attribute

 

ObsoleteAttribute is applicable to all program elements attributes t 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.

The ObsoleteAttribute class except des two properties:

  • Message. the string assigned to the Message property is emitted by the compiler when the attribute target is used in code. the string shocould note that the attribute target is obsolete and, if possible, provide some workaround or programmatic alternative.

  • IsError. This is a Boolean value that indicates to the compiler whether using the ObsoleteAttribute attribute shocould cause it to emit an error (IsError isTrue) Or a warning (IsError isFalse).

For more information about using attributes, see Extending Metadata Using Attributes.

 

DeprecatedAttribute

 

public sealed class DeprecatedAttribute : Attribute
Literal comparison

Deprecated: Express disapproval.

Obsolete: No longer produced or used; out of date.

 

Some people have explained the two analogy in HTML.

  

It is recommended that you don't use deprecated elements, because they will likely not be supported in the future, whereas obsolete elements have already been discontinued from use.

 

MSDN explanation
  

Directly applying the Windows.Foundation.Metadata.DeprecatedAttribute attribute to managed code is not recommended, because this export occurs automatically.

When you create a Windows Metadata library (. winmd file), the ObsoleteAttribute is exported as both the ObsoleteAttribute and theWindows. foundation. metadata. deprecatedAttribute attribute if only the ObsoleteAttribute is present in source code. the ObsoleteAttribute is transformed toDeprecatedAttributeAs follows:

  • IfMessageAndErrorArguments are both present,MessageIs assigned toDeprecatedAttributeMessageArgument. An error valueTrueMaps to DeprecationType. Remove, andErrorValueFalseMaps to DeprecationType. Deprecate.

  • IfMessageArgument is not supplied in the ObsoleteAttribute, its default value inDeprecatedAttributeIs"Element_nameIs deprecated ", whereElement_nameIs the name of the target program element to which the attribute is applied.

  • IfErrorArgument is not present in the ObsoleteAttribute, its default value inDeprecatedAttributeIs DeprecationType. Deprecate.

 

Personal Understanding

Differences:

They belong to different frameworks :(The deprecatedattri namespace is Windows. Foundation. Metadata and

The namespace of ObsoleteAttribute isSystem)

 

DeprecatedAttribute is supported only after window8.x.

ObsoleteAttribute is introduced in. netfraemwork 1.1

 

 

Reference

DeprecatedAttribute

ObsoleteAttribute

Obsolete vs. Deprecated HTML

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.