ExtendRealityLtd / ExtendRealityLtd/Malimbe

Fix null-coalescing and null-conditional operator usage with UnityEngine.Object

Open
#13 0 comments 1 reaction 0 assignees View on GitHub
feature
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.