Skip to content
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

Include experimental attribute in API definition for properties #7232

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

CollinAlpert
Copy link
Contributor

Affected analyzer: DeclarePublicApiAnalyzer
Affected diagnostic IDs: RS0016 and RS0051

This PR ensures the diagnostic ID of the ExperimentalAttribute is included in the API definition for properties.

Fixes #7195

@CollinAlpert CollinAlpert requested a review from a team as a code owner March 7, 2024 18:39
@@ -599,7 +599,13 @@ private ApiName GetApiName(ISymbol symbol)
{
for (var current = symbol; current is not null; current = current.ContainingSymbol)
{
foreach (var attribute in current.GetAttributes())
var attributes = current.GetAttributes();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 It's possible for both the property and the method to have attributes. For example:

[Experimental("A")]
public object? Value { [NotNull] get; }

Perhaps we extract the body of the foreach to a local function, and then call for both current.GetAttributes() and (if no experimental attribute was found) also call it for the containing property if the current method is an accessor.

Copy link

codecov bot commented Mar 7, 2024

Codecov Report

Attention: Patch coverage is 98.90110% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 96.47%. Comparing base (7b1f39d) to head (837b1d5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7232   +/-   ##
=======================================
  Coverage   96.46%   96.47%           
=======================================
  Files        1432     1432           
  Lines      342185   342271   +86     
  Branches    11280    11283    +3     
=======================================
+ Hits       330104   330190   +86     
+ Misses       9230     9228    -2     
- Partials     2851     2853    +2     

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PublicApiAnalyzer does not properly tag experimental property accessors
2 participants