JetBrains / resharper-unity

Unity support for both ReSharper and Rider
Apache License 2.0
1.21k stars 131 forks source link

:? cannot be applied to Unity objects. #2405

Open hubabenzarvt opened 1 year ago

hubabenzarvt commented 1 year ago

Language Usage Opportunities, should be able to differentiate between unity objects and pure c# objects. Currently all contexts where the following pattern exists will be flagged up by the code analyser. However if the case is that Unity objects are included this should be suppressed.

Convert the following code: if (condition) x = expr1; else x = expr2; To: x = condition ? expr1 : expr2;

vertxxyz commented 10 months ago

This is a fairly old issue, but the above code is completely fine with UnityEngine.Object types. A ternary statement is just a fancy-looking if statement. It's not related to any of the things that make UnityEngine.Object types weird, like Unity null.

Perhaps there's something else about this issue that I'm missing.