Skip to content

StaticExtension throws build error for enums with underlying types that are not int or long #32056

@selaskar

Description

@selaskar

Description

The build fails with "Specified cast is not valid." error. I encountered this error while passing an enum value as command parameter. In order to simplify the example, I didn't use Community Toolkit or ICommand.

Steps to Reproduce

Re-produce:

  1. Try to build.
  2. See the build error.

Mitigate:

  1. Change the underlying type of Enum1 (in MainPage.xaml.cs) to int or long.
  2. Successfully builds and runs

Kind of a workaround

  1. Set the underlying type of Enum1 to any of byte, sbyte, short, ushort, uint, ulong.
  2. Comment-out the first label in MainPage.xaml (which uses the Static extension)
  3. Run the application
  4. Comment-in the label and hot reload.
  5. Observe the successfully running code.

Link to public reproduction project repository

https://github.com/selaskar/MauiApp1

Version with bug

9.0.82 SR8.2

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android, Windows

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-xamlXAML, CSS, Triggers, Behaviorsplatform/androidplatform/windowss/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions