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

Add CA 2021 into CodeAnalysis config #82649

Merged
merged 1 commit into from
Feb 25, 2023
Merged

Add CA 2021 into CodeAnalysis config #82649

merged 1 commit into from
Feb 25, 2023

Conversation

buyaa-n
Copy link
Contributor

@buyaa-n buyaa-n commented Feb 24, 2023

CA2021: Do not call Enumerable.Cast<T> or Enumerable.OfType<T> with incompatible types is a new analyzer that added in January.

Because it is Warns by default it caused build failure on automation PR that updates analyzer feed which caused by some edge case scenario bug.

Because the bug could cause a failure in other repos we lowered the severity of the analyzer until those bugs get fixed. Now the fix is ready for merge which also upgrades the severity into Warning back, we need to turn off the analyzer on test projects before merge because it would cause a warning for valid scenarios like:

Assert.Throws<InvalidCastException>(() => { foreach (var t in rst) ; });
and
int[] source = { 99, 45, 81 };
Assert.Empty(source.OfType<long>());

@buyaa-n buyaa-n requested a review from stephentoub February 24, 2023 22:48
@ghost ghost assigned buyaa-n Feb 24, 2023
@ghost
Copy link

ghost commented Feb 24, 2023

Tagging subscribers to this area: @dotnet/area-meta
See info in area-owners.md if you want to be subscribed.

Issue Details

CA2021: Do not call Enumerable.Cast<T> or Enumerable.OfType<T> with incompatible types is a new analyzer that added in January.

Because it is Warns by default it caused build failure on automation PR that updates analyzer feed which caused by some edge case scenario bug.

Because the bug could cause a failure in other repos we lowered the severity of the analyzer until those bugs get fixed. Now the fix is ready for merge which also upgrades the severity into Warning back, we need to turn off the analyzer on test projects before merge because it would cause a warning for valid scenarios like:

Assert.Throws<InvalidCastException>(() => { foreach (var t in rst) ; });
and
int[] source = { 99, 45, 81 };
Assert.Empty(source.OfType<long>());

Author: buyaa-n
Assignees: -
Labels:

area-Meta

Milestone: -

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

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

LGTM if CI is green

@buyaa-n
Copy link
Contributor Author

buyaa-n commented Feb 25, 2023

The only failure is unrelated and known

@buyaa-n buyaa-n merged commit e26e33f into dotnet:main Feb 25, 2023
@buyaa-n buyaa-n deleted the ca2021 branch February 25, 2023 01:25
@ghost ghost locked as resolved and limited conversation to collaborators Mar 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants