fix: replace null-coalescencing and null-conditional operators [MTT-7125]#867
Merged
LPLafontaineB merged 10 commits intodevelopfrom Sep 6, 2023
Merged
Conversation
Packages/com.unity.multiplayer.samples.coop/Utilities/Net/SessionManager.cs
Show resolved
Hide resolved
Packages/com.unity.multiplayer.samples.coop/Utilities/Net/SessionManager.cs
Show resolved
Hide resolved
Packages/com.unity.multiplayer.samples.coop/Utilities/Net/SessionManager.cs
Show resolved
Hide resolved
noellie-velez
previously approved these changes
Sep 5, 2023
noellie-velez
approved these changes
Sep 6, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR replaces occurrences of the null-coalesing (
??=) and null-conditional (?.) operators in the project. These operators can cause issues when used with types inheritingUnityEngine.Objectbecause that type redefines the==operator to define when an object is null. This redefinition applies to regular null checks (if foo == null) but not to those operators, thus this could lead to unexpected behaviour.While those operators were safely used within Boss Room, only with types that were not inheriting
UnityEngine.Object, we decided to remove most usages for consistency. This will also help avoid accidental mistakes, such as a user reusing a part of this code, but modifying it so that one of those operators are used with aUnityEngine.Object.The only cases where we kept the null-conditional operator were with events/delegates/actions, for which there is no risk of confusion.
Issue Number(s)
MTT-7125
Contribution checklist