Skip to content

Conversation

@larus
Copy link
Member

@larus larus commented Oct 23, 2025

Purpose of this PR

add better error messages for a couple of error cases

  • When using a generic INetworkSerializable+IEquatable combo and update documentation with workaround
  • When there are no initialized elements in the network prefab list (fix null reference exception)

Example error printed with the generic IEquatable error is

Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP: (0,0): error  - TestClassNotWorking`1<System.Int32>: A generic IEquatable 'System.IEquatable`1<TestClassNotWorking`1<T>>' is not supported.

which is printed in addition to the usual error for not implementing IEquatable.

Jira ticket

MTTB-1202
MTTB-1306

Changelog

  • Fixed: Exception when the network prefab list in the network manager has uninitialized elements.
  • Changed: Better error message when using generic IEquatable in a generic INetworkSerializable class and updated documentation with workaround.

Documentation

  • Includes edits to existing public API documentation.

Testing & QA (How your changes can be verified during release Playtest)

Manually tested the codegen errors with IEquatable.

Functional Testing

Manual testing :

  • Manual testing done

Automated tests:

  • Covered by existing automated tests
  • Covered by new automated tests

Does the change require QA team to:

  • Review automated tests?
  • Execute manual tests?
  • Provide feedback about the PR?

If any boxes above are checked the QA team will be automatically added as a PR reviewer.

Backports

coming if needed

larus added 2 commits October 23, 2025 15:07
- When using a generic INetworkSerializable+IEquatable combo and update documentation with workaround
- When there are no initialized elements in the network prefab list (fix null reference exception)
@larus larus requested review from a team and jabbacakes as code owners October 23, 2025 15:46
Removing single whitespace at end of sentence.
Keeping the most recent changelog entry chronologically ordered (ordered by PR number).
Copy link
Collaborator

@NoelStephensUnity NoelStephensUnity left a comment

Choose a reason for hiding this comment

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

Just made some minor tweaks, but the rest looks good!
👍
Thank you Laurus! 🙌

@NoelStephensUnity NoelStephensUnity enabled auto-merge (squash) October 23, 2025 16:10
Copy link
Collaborator

@EmandM EmandM left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! Just some small notes.

I think there might also be an issue when the list itself has a null prefab. I'm not sure if this fix catches that?

@larus
Copy link
Member Author

larus commented Oct 23, 2025

I think there might also be an issue when the list itself has a null prefab. I'm not sure if this fix catches that?

This is already handled, this will emit an error message

@NoelStephensUnity NoelStephensUnity enabled auto-merge (squash) October 24, 2025 15:27
@NoelStephensUnity NoelStephensUnity merged commit 6eb88aa into develop-2.0.0 Oct 24, 2025
24 checks passed
@NoelStephensUnity NoelStephensUnity deleted the fix/better-errors branch October 24, 2025 17:43
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.

4 participants