-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use generic attributes on a struct in Blazor WASM #78255
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsIs there an existing issue for this?
Describe the bugBlazor WASM applications fail when a generic attribute is applied to a struct. It fails to load and shows the following stack trace in dev tools:
Expected BehaviorFor it to accept the generic attribute on the Steps To ReproduceCreate a new .NET 7 Blazor WASM project. Change using BlazorApp1;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
await builder.Build().RunAsync();
public class MyAttribute<T> : Attribute
{
}
[MyAttribute<string>]
public struct Foo
{
} Exceptions (if any)No exceptions, but there is a stack trace from mono in the dev tools (as described above) .NET Version7.0.100 Anything else?Blazor version: 7
|
@mkArtakMSFT - Hi - I thought the source of this bug was mono, hence why I raised it in aspnet. I'm genuinely curious as to why you think it belongs here; I'd be keen on trying to fix this myself but I'd need a fair amount of guidance as a I literally haven't got a clue where to start nor what the workflow would look like! |
Duplicate of #77047 |
Is there an existing issue for this?
Describe the bug
Blazor WASM applications fail when a generic attribute is applied to a struct.
It fails to load and shows the following stack trace in dev tools:
Expected Behavior
For it to accept the generic attribute on the
struct
. If I change the struct to aclass
, it works.Steps To Reproduce
Create a new .NET 7 Blazor WASM project.
Change
Program.cs
to be:Exceptions (if any)
No exceptions, but there is a stack trace from mono in the dev tools (as described above)
.NET Version
7.0.100
Anything else?
Blazor version: 7
IDE: VS2022 17.5.0 Preview 1.0
dotnet --info
:The text was updated successfully, but these errors were encountered: