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

IDE0016 should be ignored for types inheriting from UnityEngine.Object #204

Closed
KuraiAndras opened this issue Feb 28, 2022 · 2 comments · Fixed by #209
Closed

IDE0016 should be ignored for types inheriting from UnityEngine.Object #204

KuraiAndras opened this issue Feb 28, 2022 · 2 comments · Fixed by #209
Assignees
Labels
approved rule Indicates if the new proposed rule has been approved to move to implementation phase

Comments

@KuraiAndras
Copy link

Bug description

IDE0016 is reported for types inheriting from the UnityEngine.Object class

  • Version of analyzers assembly: 1.12.0

To Reproduce

Insert the following code snippet

    public class Billboard : MonoBehaviour
    {
        [SerializeField] private Camera _camera = default!;

        private void Update() => transform.rotation = _camera.transform.rotation;

        public void SetCamera(Camera nextCamera)
        {
            // IDE0016 is reported here for the throw
            if (nextCamera == null) throw new ArgumentNullException(nameof(nextCamera));
            _camera = nextCamera;
        }
    }

Expected behavior

IDE0016 is not reported

Screenshots

image

Additional context

This might be applicable for other analyzers where null checking can be simplified

@sailro
Copy link
Member

sailro commented Feb 28, 2022

Yes I agree, we should create a new Suppressor for this case.

^@jbevain, what do you think?

@sailro sailro added the approved rule Indicates if the new proposed rule has been approved to move to implementation phase label Feb 28, 2022
@jbevain
Copy link
Member

jbevain commented Feb 28, 2022

Yep, approved!

@sailro sailro self-assigned this Mar 2, 2022
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.

3 participants