Use a dedicated attribute to mark implementation-only members#2434
Open
Sergio0694 wants to merge 6 commits into
Open
Use a dedicated attribute to mark implementation-only members#2434Sergio0694 wants to merge 6 commits into
Sergio0694 wants to merge 6 commits into
Conversation
Introduce an internal sealed attribute to mark implementation-only members for WinRT runtime. The attribute targets all members, is non-inherited, and is conditional on WINDOWS_RUNTIME_REFERENCE_ASSEMBLY so it is emitted only in reference assemblies; this makes it explicit which members are implementation-only and allows them to be stripped from the runtime DLL. Added at src/WinRT.Runtime2/Attributes/WindowsRuntimeImplementationOnlyMemberAttribute.cs.
…members Replace the combination of [EditorBrowsable(Never)] and [Obsolete(...)] with the single [WindowsRuntimeImplementationOnlyMember] attribute on implementation-only members across WinRT.Runtime. Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com>
Delete WindowsRuntimeConstants.cs which contained constants for WinRT private implementation detail messaging, the PrivateImplementationDetailObsoleteDiagnosticId (CSWINRT3001), and the CsWinRT diagnostics URL format. These constants have been removed from the project.
Delete the NoWarn entry and its comment for CSWINRT3001 from src/WinRT.Runtime2/WinRT.Runtime.csproj so warnings about '[Obsolete]' private implementation details are no longer suppressed. This change surfaces those warnings for visibility during builds.
This diagnostic is no longer applicable now that the private implementation detail [Obsolete] attributes have been removed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file was missed in the bulk conversion to the new attribute; it still referenced the now-deleted WindowsRuntimeConstants type, which would break the build. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the
[Obsolete]+[EditorBrowsable(EditorBrowsableState.Never)]pattern previously used to mark implementation-only members inWinRT.Runtimewith a new, dedicated[WindowsRuntimeImplementationOnlyMember]attribute.Motivation
Implementation-only members (constructors, methods, properties, and helper types consumed only by generated projections and interop code) were previously marked with a verbose
[Obsolete(..., DiagnosticId = "CSWINRT3001", ...)]attribute combined with[EditorBrowsable(EditorBrowsableState.Never)]. This relied on an obsolete-diagnostic message to discourage usage and required suppressingCSWINRT3001across the whole project.This PR introduces a single, purpose-built marker attribute that makes the intent explicit. Crucially, the attribute is
[Conditional("WINDOWS_RUNTIME_REFERENCE_ASSEMBLY")], so it is only emitted when building reference assemblies (where these members would not be present anyway) and is fully stripped from the shippingWinRT.Runtime.dll.This is the first PR in a series: a follow-up will use this marker to completely strip implementation-only members from the reference
.dll, so consumers compiling against the reference assembly will not see them at all.Changes
src/WinRT.Runtime2/Attributes/WindowsRuntimeImplementationOnlyMemberAttribute.cs: newinternal sealed, non-inherited marker attribute targeting all members, conditional onWINDOWS_RUNTIME_REFERENCE_ASSEMBLY.src/WinRT.Runtime2/(200+ files): replace the[Obsolete(...)]+[EditorBrowsable(...)]pattern with[WindowsRuntimeImplementationOnlyMember]across ABI types, interop services, marshallers, native object wrappers, vtables, and projection impls; remove the now-unusedusing System.ComponentModel;imports.src/WinRT.Runtime2/Properties/WindowsRuntimeConstants.cs: deleted; it held theCSWINRT3001obsolete message, diagnostic id, and diagnostics URL format that are no longer needed.src/WinRT.Runtime2/WinRT.Runtime.csproj: remove theCSWINRT3001NoWarnsuppression.docs/diagnostics/cswinrt30001.md: deleted; theCSWINRT3001diagnostic no longer applies.src/WinRT.Runtime2/InteropServices/ProjectionImpls/IActivationFactoryImpl.cs: convert the last occurrence that was missed in the bulk change (it still referenced the deletedWindowsRuntimeConstants, which would otherwise break the build).