Skip to content

Repo sync for protected CLA branch #3647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions docs/cppcx/deprecating-types-and-members-c-cx.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
---
description: "Learn more about: Deprecating types and members (C++/CX)"
title: "Deprecating types and members (C++/CX)"
ms.date: "12/30/2016"
ms.assetid: b20b01c1-a439-4ff0-8cf3-d7280c492813
ms.date: 01/07/2022
no-loc: [ "class", "delegate", "enum", "field", "interface", "method", "property", "struct" ]
---
# Deprecating types and members (C++/CX)

In C++/CX, deprecation of Windows Runtime types and members for producers and consumers by using the [Deprecated](/uwp/api/windows.foundation.metadata.deprecatedattribute) attribute is supported. If you consume an API to which this attribute has been applied, you get a compile-time warning message that 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.
C++/CX supports deprecation of Windows Runtime types and members for producers and consumers by using the [`Deprecated`](/uwp/api/windows.foundation.metadata.deprecatedattribute) 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`](/uwp/api/windows.foundation.metadata.deprecatedattribute) attribute is for use only with Windows Runtime types. For standard C++ classes and members, use
[`[[deprecated]]`](../cpp/deprecated-cpp.md) (C++14 and later) or [`__declspec(deprecated)`](../cpp/deprecated-cpp.md).
> The [`Deprecated`](/uwp/api/windows.foundation.metadata.deprecatedattribute) attribute is for use only with Windows Runtime types. For standard C++ classes and members, use [`[[deprecated]]`](../cpp/deprecated-cpp.md) (C++14 and later) or [`__declspec(deprecated)`](../cpp/deprecated-cpp.md).

### Example
## 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](/uwp/api/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](/uwp/api/windows.foundation.metadata.platformattribute) to which the attribute applies.

```
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`](/uwp/api/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`](/uwp/api/windows.foundation.metadata.platformattribute) to which the attribute applies.

```cpp
namespace wfm = Windows::Foundation::Metadata;

public ref class Bicycle sealed
Expand All @@ -33,29 +31,29 @@ public:

## Supported targets

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

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

## See also

[Type System](../cppcx/type-system-c-cx.md)<br/>
[C++/CX Language Reference](../cppcx/visual-c-language-reference-c-cx.md)<br/>
[Namespaces Reference](../cppcx/namespaces-reference-c-cx.md)
[Type system (C++/CX)](../cppcx/type-system-c-cx.md)\
[C++/CX language reference](../cppcx/visual-c-language-reference-c-cx.md)\
[Namespaces reference](../cppcx/namespaces-reference-c-cx.md)
Loading