-
Notifications
You must be signed in to change notification settings - Fork 2
[Logging] Check for null agents using MonoBehaviour #205
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
base: master
Are you sure you want to change the base?
Conversation
|
🧱 Stack PR · Base of stack Stack Structure:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly addresses an issue with logging telemetry for destroyed agents by using a cast to AgentBase to handle Unity's 'fake-null' objects. The changes also improve efficiency by combining filters into a single LINQ Where clause and removing an unnecessary .ToList() call. I've added one suggestion to use OfType<T>() which can make the code more idiomatic and readable. Overall, this is a good improvement.
📝 WalkthroughWalkthroughThe RecordTelemetry method in SimMonitor.cs was refactored to filter agents in a single pass using OfType() with a combined predicate (non-null, not terminated, and activeInHierarchy). The telemetry writer null check is performed before retrieving time. The loop now iterates directly over the filtered agents, removing the prior inner activeInHierarchy check and the intermediate list creation. Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Resolves #203. During the simulation destruction, agents might already be destroyed, but the
SimMonitorstill wants to log one last telemetry data point for them.IAgentis an interface independent ofMonoBehaviour, so the null check does not return correctly for fake-null objects. Instead, the agent has to be cast toAgentBase, which will then invoke the fake-null-compatible comparison withnull.