Skip to content

User/chriwall/deprecated#302

Open
Dreynor87 wants to merge 6 commits intomainfrom
user/chriwall/deprecated
Open

User/chriwall/deprecated#302
Dreynor87 wants to merge 6 commits intomainfrom
user/chriwall/deprecated

Conversation

@Dreynor87
Copy link
Copy Markdown

This implements the deprecated attribute as described here: https://learn.microsoft.com/en-us/uwp/api/windows.foundation.metadata.deprecatedattribute?view=winrt-26100
Along with the DeprecationType enum as described here: https://learn.microsoft.com/en-us/uwp/api/windows.foundation.metadata.deprecationtype?view=winrt-26100

Fixes: WinRT Deprecation, that right now does not do anything.

Chris Wall (WIN SDE) and others added 6 commits March 2, 2026 13:23
When -deprecatedincluded is used, emit /** @deprecated message */ JSDoc
annotations in generated .d.ts files for:
- Deprecated types (classes, interfaces, enums, delegates)
- Deprecated enum values (with parent type propagation)
- Deprecated methods and constructors
- Deprecated properties and fields
- Deprecated event listeners

Added get_deprecated_message() helper to MetadataHelpers.h to extract
the deprecation message string from DeprecatedAttribute metadata.

Note: Uses ^@ escape for @ in TextWriter format strings to avoid
TextWriter interpreting @ as a format placeholder.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- tests/TestArtifacts/verify_deprecated.ps1: Runs rnwinrt against system
  WinMD and verifies @deprecated JSDoc annotations on deprecated types,
  enums, methods, and properties (10/10 checks pass)
- docs/deprecated.md: Documents the deprecated annotation feature

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When DeprecatedAttribute has DeprecationType.Remove (arg[1]==1), the type
or member is completely hidden from the generated TypeScript declarations.
Added is_removed() helper to MetadataHelpers.h. Checks applied to delegates,
enums, enum fields, classes/interfaces, fields, properties, methods, and
event listeners in TypescriptWriter.h.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- verify_removed.ps1 validates deprecated/removed support:
  * DeprecationType enum has both deprecate(0) and remove(1)
  * is_removed(), is_deprecated(), get_deprecated_message() helpers exist
  * TypescriptWriter has is_removed() checks and WriteDeprecatedJsdoc()
  * Generated .d.ts artifacts have content

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Bug fixes in TypescriptWriter.h:
- Property deprecation: check is_removed(getter) instead of
  is_removed(prop), since MIDL places DeprecatedAttribute on the
  getter method, not the Property metadata row
- Guard all is_removed() checks with !settings.IncludeDeprecated
  so that -deprecatedincluded mode shows removed items with
  @deprecated annotations (previously still filtered them out)

verify_removed.ps1: Rewrote with WinMD-based generation tests (40 checks)
- Mode 1 (no deprecated): Verifies removed types, methods, properties,
  static properties, events, and constructors are excluded
- Mode 2 (deprecated included): Verifies all items present with
  @deprecated JSDoc annotations

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…on tests

- Settings.cpp: unconditional is_removed() in is_type_allowed()
- TypescriptWriter.h: change 9 conditional is_removed() checks to unconditional
  (removed items are always filtered, even with -deprecatedincluded)
- ReactFileGenerator.cpp: is_removed() guards in class iteration loops
- verify_removed.ps1: 47 regression tests for source guards, TS output, C++ bridge

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant