[CodeGen] Fix compiler warnings related to [Sync] when using nullable
#9922
+28
−20
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.
Summary
Fixes two distinct issues of nullable compiler warnings in the code generator by adding null-forgiving operators (!) in several places.
Issue 1
If you had a sbox project with
nullablesenabled then whenever you use a[Sync]attribute you'd get warnings in console.Issue 2
If you are using a nullable type
Type?and[Sync]you will get warnings. This issue describes the initial problem #215Motivation & Context
For awhile now if you used a nullable type
Type?with[Sync]you'd get a warning.Since 26.01.28 update's network optimization warnings appear with
nullablesenabled in project settings if you use[Sync].Nullablesis an option in Project Settings, i personally prefer having them enabled and I think you should be able to use them without being penalized by having compiler warnings.Fixes: #215
Implementation Details
There were two ways this could be solved, I used the less invasive approach of essentially doing
value!which will silence any null warnings.The alternative way would be to properly type things as nullable
type? myVariable = etcThis alternative though require us to wrap all generated code with
#nullable enable/disableand would require more invasive changes.Tests
Some tests were updated as a result of the changes.
Checklist