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

GCop405 false alarm #262

Open
sungam3r opened this issue Jan 17, 2019 · 0 comments
Open

GCop405 false alarm #262

sungam3r opened this issue Jan 17, 2019 · 0 comments

Comments

@sungam3r
Copy link
Contributor

 internal class Inspector
        {
            public static IEnumerable<string> Inspect(Type type)
            {
                if (type != null)
                {
                    foreach (var property in type.GetProperties())
                        yield return property.Name;
                }
            }
        }

declares

GCop405	You should use 
foreach (var property in type?.GetProperties())
                    yield return property.Name;

but in runtime it gives

System.NullReferenceException: 'Object reference not set to an instance of an object.'

if I call

Inspector.Inspect(null);
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

No branches or pull requests

1 participant