ExtendRealityLtd / ExtendRealityLtd/Malimbe
Fix null-coalescing and null-conditional operator usage with UnityEngine.Object
- Dominant language
- C#
- Stars
- 52
- Forks
- 10
- PR merge metrics
- No merged PRs in 30d
Description
https://blogs.unity3d.com/2014/05/16/custom-operator-should-we-keep-it/
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-coalescing-operator
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-conditional-operators
---
IL to match is pretty much just some form of value/field **load** followed by a `brtrue`/`brtrue.s`. The latter just needs to be replaced with a call to `[UnityEngine.CoreModule]UnityEngine.Object::op_Inequality(class [UnityEngine.CoreModule]UnityEngine.Object, class [UnityEngine.CoreModule]UnityEngine.Object)` and a `brfalse`/`brfalse.s` afterwards.
Only do this when the loaded value/field is inheriting from `UnityEngine.Object` of course.
Contributor guide
Assessment
This issue has not been assessed yet.