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

fix: null ref in view hierarchy #1919

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bruno-garcia
Copy link
Member

@bruno-garcia bruno-garcia commented Nov 23, 2024

Resolves: #1918

Skips possible null components before trying to get their type info.

Not sure how to test this because it depends on a Unity API GetComponents

Also: replaced the LINQ call with a foreach and allocated a new List with the known size to avoid resizes.

var extras = new List<string>(components.Count);
foreach (var component in components)
{
if (component?.GetType().Name is { } componentName)
Copy link
Member Author

Choose a reason for hiding this comment

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

The stack trace on #1918 led me to believe GetComponents is adding null to entries to the List it receives as argument.

@bruno-garcia
Copy link
Member Author

CI is showing green here but only 5 checks show. I had to cancel CI due to #1920

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

Successfully merging this pull request may close these issues.

NullReferenceException with ViewHierarchy
1 participant