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

False positive for CA2225 when a base class already has the method defined #6640

Open
matt-edmondson opened this issue May 19, 2023 · 1 comment
Labels
Area-Microsoft.CodeAnalysis.NetAnalyzers Bug The product is not behaving according to its current intended design Category-Usage False_Positive A diagnostic is reported for non-problematic case help wanted The issue is up-for-grabs, and can be claimed by commenting
Milestone

Comments

@matt-edmondson
Copy link

Analyzer

Diagnostic ID: CA2225: Operator overloads have named alternates

Analyzer source

SDK: Built-in CA analyzers in .NET 7 SDK or later

Version: SDK 7.0.302

Describe the bug

CA2225 is triggered even though the requested method is defined and publicly available on the base class.

Steps To Reproduce

namespace ktsu.io
{
	public class A
	{
		public bool ToBoolean() => this is not null;
	}

	public class B : A
	{
		public static implicit operator bool(B value) => value?.ToBoolean() ?? false;
	}
}

Expected behavior

A.ToBoolean() should be found by the analyzer as a candidate method.

Actual behavior

A.ToBoolean() is not considered when checking if B has an implementation for the requested methods

@NewellClark
Copy link
Contributor

I would like to be assigned to this issue. Should be an easy fix.

NewellClark added a commit to NewellClark/roslyn-analyzers that referenced this issue Jun 6, 2023
@mavasani mavasani added Bug The product is not behaving according to its current intended design Area-Microsoft.CodeQuality.Analyzers False_Positive A diagnostic is reported for non-problematic case Category-Usage labels Jun 22, 2023
@mavasani mavasani added this to the Unknown milestone Jun 22, 2023
@mavasani mavasani added the help wanted The issue is up-for-grabs, and can be claimed by commenting label Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Microsoft.CodeAnalysis.NetAnalyzers Bug The product is not behaving according to its current intended design Category-Usage False_Positive A diagnostic is reported for non-problematic case help wanted The issue is up-for-grabs, and can be claimed by commenting
Projects
None yet
Development

No branches or pull requests

3 participants