Yellow-Dog-Man / Resonite-Issues

Issue repository for Resonite.
https://resonite.com
102 stars 0 forks source link

Nullable enums require "System.Nullable<T>", unlike generic types such as "int?" #1945

Open Raidriar796 opened 2 weeks ago

Raidriar796 commented 2 weeks ago

Describe the bug?

Nullable enum types require that you enter System.Nullable<T>, which is inconsistent with more generic nullable types like int?. This is exemplified by the recent change to the Filter Mode setting on StaticTexture2D, where all components using TextureFilterMode as the type have drives/references broken, and can only be fixed by using the Pack Nullable Protoflux node or by replacing components with equivalents using System.Nullable<TextureFilterMode>.

To Reproduce

  1. Create any component that can take TextureFilterMode, such as ValueField<TextureFilterMode>
  2. Try to create another of the same component but with type TextureFilterMode? (It will say invalid type)
  3. Try to drive the filter mode setting with a component, such as ValueMultiDriver<TextureFilterMode> (it doesn't work)

Expected behavior

You should be able to get nullable enums by appending "?" to the type name like more generic types, and potentially migrate existing components of type TextureFilterMode to instead use TextureFilterMode? to keep content from breaking.

Screenshots

This is showing that TextureFilterMode? isn't valid ValueField TextureFilterMode ValueField TextureFilterMode? This is showing that it is valid for other types such as int? ValueField int? This is what happens when you drive the Filter Mode on a StaticTexture2D component Nullable TextureFilterMode This is showing that is can still be worked with by using Pack Nullable PackNullableTextureFilterMode

Resonite Version Number

Beta 2024.5.3.1229

What Platforms does this occur on?

Windows, Linux

What headset if any do you use?

No response

Log Files

2024.5.3.1229 - 2024-05-03 15_23_21.log

Additional Context

I recently made an update to a world that included a lower quality mode that changed the textures to use Trilinear instead of Anisotropic with level 16, and this recent update every drive of type TextureFilterMode related to this feature was broken. I have since removed it because I actually prefer the texture filtering of said world to be controlled by user settings instead of in world settings.

Reporters

@Raidriar796 / raidriar796

stiefeljackal commented 2 weeks ago

It should be System.Nullable<TextureFilterMode> to get the nullable form. However, TextureFilterMode? should have been accepted as well.

image
Raidriar796 commented 2 weeks ago

Ah, I didn't know it was specifically System.Nullable. I tried different variations and got close to System.Nullable but never thought to try it that specifically, but in hindsight it was pretty obvious given stuff like System.Single for Floats. Thanks.

Banane9 commented 2 weeks ago

For anyone wondering, int? is just syntactic sugar for System.Nullable<int> - but the behavior is certainly inconsistent

shadowpanther commented 2 weeks ago

I feel that #427 should've covered easier typing for Nullable types too.

Banane9 commented 2 weeks ago

I feel that #427 should've covered easier typing for Nullable types too.

Seems to be inconsistent at the moment, int? at the top works, but the enum here doesn't.

stiefeljackal commented 2 weeks ago

All enum types are currently exhibiting this behavior.


Non-syntactic Sugar System.Nullable<ExceptionAction>

image

Syntatic Sugar ExceptionAction?

image

@Raidriar796 It might be worth updating this issue since this is impacting enum types in general and not specifically the TextureFilterMode one.

Raidriar796 commented 2 weeks ago

Updated the title and original comment to focus more on enums in general, but still focused on TextureFilterMode as the lead example due to potential content breakage.