dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.44k stars 10.02k forks source link

Support simpler syntax for Enum values in Blazor Component attributes #19139

Closed fitdev closed 3 years ago

fitdev commented 4 years ago

Is your feature request related to a problem? Please describe.

It would be nice if a few keystrokes be saved when entering enum value for an Enum-valued Blazor Component parameter by not having to specify the Enum's name (similar to how it is currently possible to do with Tag Helpers).

public enum MyEnum {
  Value1,
  Value2,
  Value3
}

Right now (AspNetCore 3.1) you have to use this syntax, explicitly prefixing Value2 with its containing type MyEnum:

<MyComponent MyEnumTypedParameter="MyEnum.Value2" />

Describe the solution you'd like

It would be nice if the Value2 is automatically inferred to be of MyEnum since that is the type of the MyEnumTypedParameter in this example.

<MyComponent MyEnumTypedParameter="Value2" />
javiercn commented 4 years ago

@fitdev thanks for contacting us.

This is not something that we could do as it could conflict with static usings in your razor component.

I would suggest that you look into using a static using instead to achieve this.

fitdev commented 4 years ago

@javiercn I see. Thank you for the tip. But how is this possible with tag helpers then?

mkArtakMSFT commented 4 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to happen for the coming release. We will reassess the backlog following the current release and consider this item at that time. However, keep in mind that there are many other high priority features with which it will be competing for resources.

TanayParikh commented 3 years ago

This is not something that we could do as it could conflict with static usings in your razor component.

I would suggest that you look into using a static using instead to achieve this.

Thanks for contacting us. We believe that the question you've raised have been answered. If you still feel a need to continue the discussion, feel free to reopen it and add your comments.