Skip to content

Latest commit

 

History

History
59 lines (46 loc) · 2.51 KB

deprecating-types-and-members-c-cx.md

File metadata and controls

59 lines (46 loc) · 2.51 KB
title description ms.date no-loc
Deprecating types and members (C++/CX)
Learn more about: Deprecating types and members (C++/CX)
01/07/2022
class
delegate
enum
field
interface
method
property
struct

Deprecating types and members (C++/CX)

C++/CX supports deprecation of Windows Runtime types and members for producers and consumers by using the Deprecated attribute. If you consume an API that has this attribute, you get a compile-time warning message. It indicates that the API is deprecated and also recommends an alternative API to use. In your own public types and methods, you can apply this attribute and supply your own custom message.

Caution

The Deprecated attribute is for use only with Windows Runtime types. For standard C++ classes and members, use [[deprecated]] (C++14 and later) or __declspec(deprecated).

Example

The following example shows how to deprecate your own public APIs—for example, in a Windows Runtime component. The second parameter, of type Windows::Foundation::Metadata::DeprecationType specifies whether the API is being deprecated or removed. Currently only the DeprecationType::Deprecated value is supported. The third parameter in the attribute specifies the Windows::Foundation::Metadata::Platform to which the attribute applies.

namespace wfm = Windows::Foundation::Metadata;

public ref class Bicycle sealed
{

public:
    property double Speed;

    [wfm::Deprecated("Use the Speed property to compute the angular speed of the wheel", wfm::DeprecationType::Deprecate, 0x0)]
    double ComputeAngularVelocity();
};

Supported targets

The following table lists the constructs to which the Deprecated attribute may be applied:

:::row::: :::column span=""::: class
enum
event
method
property
struct field :::column-end::: :::column span=""::: delegate
enum field
interface
parameterized constructor
struct
XAML control :::column-end::: :::row-end:::

See also

Type system (C++/CX)
C++/CX language reference
Namespaces reference