-
Notifications
You must be signed in to change notification settings - Fork 522
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: replace null-coalescencing and null-conditional operators [MTT-7125] #867
Merged
LPLafontaineB
merged 10 commits into
develop
from
fix/replace-null-coalescence-operators
Sep 6, 2023
Merged
fix: replace null-coalescencing and null-conditional operators [MTT-7125] #867
LPLafontaineB
merged 10 commits into
develop
from
fix/replace-null-coalescence-operators
Sep 6, 2023
Conversation
This file contains 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
LPLafontaineB
added
2-Easy
This PR is trivial and can be reviewed quickly
1-Needs Review
PR needs attention from the assignee and reviewers
labels
Aug 29, 2023
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
MissCaligari
previously approved these changes
Sep 5, 2023
MissCaligari
approved these changes
Sep 6, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
1-Needs Review
PR needs attention from the assignee and reviewers
2-Easy
This PR is trivial and can be reviewed quickly
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.Object
because 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