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

IDE0270 should be suppressed by the UnityObjectNullHandlingAnalyzer #323

Closed
JorisCleVR opened this issue Apr 18, 2024 · 2 comments · Fixed by #324
Closed

IDE0270 should be suppressed by the UnityObjectNullHandlingAnalyzer #323

JorisCleVR opened this issue Apr 18, 2024 · 2 comments · Fixed by #324
Labels
approved rule Indicates if the new proposed rule has been approved to move to implementation phase

Comments

@JorisCleVR
Copy link
Contributor

Problem statement

UnityObjectNullHandlingAnalyzer now supresses IDE0029 but not IDE0270. This causes IDE0270 to suggest null coalesce on Unity objects.
The following code example raises IDE0270

using UnityEngine;

class Camera : MonoBehaviour
{
	public void M()
	{
		Camera item = FindItem() as Camera;
		if (item == null)
			throw new System.InvalidOperationException();
	}

	MonoBehaviour FindItem() => null;
}

Proposed solution

Add IDE0270 as a supressor to the UnityObjectNullHandlingAnalyzer

@JorisCleVR
Copy link
Contributor Author

I know that the issue is not yet approved, but I am confident about this fixing issues. Therefore I already created a pull request to hopefully be merged once this issue is approved: #324

@sailro
Copy link
Member

sailro commented Apr 18, 2024

Indeed, thank you for this contribution !

@sailro sailro added the approved rule Indicates if the new proposed rule has been approved to move to implementation phase label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved rule Indicates if the new proposed rule has been approved to move to implementation phase
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants