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

Handle reference to non-source symbols in UseConcreteTypeAnalyzer #6959

Merged
merged 1 commit into from
Sep 21, 2023

Conversation

mavasani
Copy link
Contributor

Fixes #6852

@mavasani mavasani requested a review from a team as a code owner September 21, 2023 07:33
@mavasani
Copy link
Contributor Author

@carlossanlop @jeffhandley - we may consider this for backporting to 8.0 as this fixes an analyzer exception case.

@codecov
Copy link

codecov bot commented Sep 21, 2023

Codecov Report

Merging #6959 (a6c29fa) into main (1066c7c) will decrease coverage by 0.01%.
The diff coverage is 80.00%.

@@            Coverage Diff             @@
##             main    #6959      +/-   ##
==========================================
- Coverage   96.42%   96.42%   -0.01%     
==========================================
  Files        1398     1398              
  Lines      333549   333552       +3     
  Branches    11036    11038       +2     
==========================================
  Hits       321620   321620              
- Misses       9166     9168       +2     
- Partials     2763     2764       +1     

Copy link
Contributor

@buyaa-n buyaa-n left a comment

Choose a reason for hiding this comment

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

LGTM, thank you! 💯% supportive of backporting 8.0

@mavasani mavasani merged commit 4aefee9 into dotnet:main Sep 21, 2023
@mavasani
Copy link
Contributor Author

/backport to release/8.0.1xx

@github-actions
Copy link
Contributor

Started backporting to release/8.0.1xx: /~https://github.com/dotnet/roslyn-analyzers/actions/runs/6265062342

@jeffhandley
Copy link
Member

Looks good to me too. I will advocate for the backport to be approved once the issue template is filled out on #6960.

@buyaa-n
Copy link
Contributor

buyaa-n commented Sep 21, 2023

Looks good to me too. I will advocate for the backport to be approved once the issue template is filled out on #6960.

The template is filled

@jeffhandley
Copy link
Member

As @artl93 asked on the backport PR:

is there a general pattern in this scenario here we should be considering validating more broadly?

@mavasani / @buyaa-n -- since this fix is isolated to this specific analyzer, should we scout out this category of bug across other analyzers? I don't know how often we have logic similar to this.

@buyaa-n
Copy link
Contributor

buyaa-n commented Sep 22, 2023

Just did a quick check, the API MatchesConfiguredVisibility is used in many analyzers, mostly used for analyzing symbol actions and a few operation block analysis where the symbol is guaranteed to be in source (it is the analyzing symbol or the method of the analyzing operation block), I believe they are safe

Found only one similar case that might cause this issue (CA2234):

if (!context.Options.MatchesConfiguredVisibility(Rule, method, context.ContainingSymbol, context.Compilation))
{
// only apply to methods that are exposed outside by default
return;
}

This is called for an invocation operation that could be referencing a method defined outside of the source:

It might not noticed before because this analyzer is disabled by default

@mavasani mavasani deleted the FixIssue6852 branch September 22, 2023 02:20
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.

IndexOutOfRangeException in UseConcreteTypeAnalyzer (CA1859)
4 participants