Skip to content
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

Blazor Wasm: debugging broken by attribute with type parameter #86765

Closed
1 task done
zbecknell opened this issue May 25, 2023 · 7 comments · Fixed by #86789
Closed
1 task done

Blazor Wasm: debugging broken by attribute with type parameter #86765

zbecknell opened this issue May 25, 2023 · 7 comments · Fixed by #86789
Assignees
Milestone

Comments

@zbecknell
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When a generic attribute is applied in a hosted Blazor Web Assembly project, debugging is broken.

Reproduction is here: https://github.com/zbecknell/UndebuggableV2

Notice Index.razor is applying @attribute [Bad<App>]. Remove that line and debugging now works.

Clues as to how to fix this would hopefully be found in this old previous issue dotnet/aspnetcore#25380 where the same thing would happen when an attribute had an enum parameter.

Expected Behavior

Debugging the client web assembly application hits breakpoints as expected.

Steps To Reproduce

Run and attempt to debug the client side of this hosted web assembly app: https://github.com/zbecknell/UndebuggableV2

Exceptions (if any)

The console outputs this when failure occurs:

[13:14:55] fail: DevToolsProxy[0]
      Failed to load https://localhost:7129/_framework/DebugTest.Client.dll (Specified cast is not valid.)

.NET Version

7.0.302

Anything else?

System info (though this is reproduced across OSs):

.NET SDK:
 Version:   7.0.302
 Commit:    990cf98a27

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  13.3
 OS Platform: Darwin
 RID:         osx.13-arm64
 Base Path:   /usr/local/share/dotnet/sdk/7.0.302/

Host:
  Version:      7.0.5
  Architecture: arm64
  Commit:       8042d61b17

.NET SDKs installed:
  7.0.100 [/usr/local/share/dotnet/sdk]
  7.0.200 [/usr/local/share/dotnet/sdk]
  7.0.203 [/usr/local/share/dotnet/sdk]
  7.0.302 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 7.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 7.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found
@javiercn javiercn transferred this issue from dotnet/aspnetcore May 25, 2023
@msftbot msftbot bot added the untriaged New issue has not been triaged by the area owner label May 25, 2023
@msftbot
Copy link
Contributor

msftbot bot commented May 25, 2023

Tagging subscribers to this area: @thaystg
See info in area-owners.md if you want to be subscribed.

Issue Details

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When a generic attribute is applied in a hosted Blazor Web Assembly project, debugging is broken.

Reproduction is here: https://github.com/zbecknell/UndebuggableV2

Notice Index.razor is applying @attribute [Bad<App>]. Remove that line and debugging now works.

Clues as to how to fix this would hopefully be found in this old previous issue dotnet/aspnetcore#25380 where the same thing would happen when an attribute had an enum parameter.

Expected Behavior

Debugging the client web assembly application hits breakpoints as expected.

Steps To Reproduce

Run and attempt to debug the client side of this hosted web assembly app: https://github.com/zbecknell/UndebuggableV2

Exceptions (if any)

The console outputs this when failure occurs:

[13:14:55] fail: DevToolsProxy[0]
      Failed to load https://localhost:7129/_framework/DebugTest.Client.dll (Specified cast is not valid.)

.NET Version

7.0.302

Anything else?

System info (though this is reproduced across OSs):

.NET SDK:
 Version:   7.0.302
 Commit:    990cf98a27

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  13.3
 OS Platform: Darwin
 RID:         osx.13-arm64
 Base Path:   /usr/local/share/dotnet/sdk/7.0.302/

Host:
  Version:      7.0.5
  Architecture: arm64
  Commit:       8042d61b17

.NET SDKs installed:
  7.0.100 [/usr/local/share/dotnet/sdk]
  7.0.200 [/usr/local/share/dotnet/sdk]
  7.0.203 [/usr/local/share/dotnet/sdk]
  7.0.302 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 7.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 7.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found
Author: zbecknell
Assignees: -
Labels:

area-Debugger-mono

Milestone: -

@lewing lewing added this to the 8.0.0 milestone May 25, 2023
@msftbot msftbot bot removed the untriaged New issue has not been triaged by the area owner label May 25, 2023
@lewing
Copy link
Member

lewing commented May 25, 2023

@lambdageek are there any known mono issues lurking here?

@lambdageek
Copy link
Member

@lewing yea we had some issue with generic custom attributes. Don't recall if it was resolved. The debugger is an interesting twist - I didn't know it looks at custom attributes.

@lewing
Copy link
Member

lewing commented May 25, 2023

@lewing yea we had some issue with generic custom attributes. Don't recall if it was resolved. The debugger is an interesting twist - I didn't know it looks at custom attributes.

It walks them for debugger hints. @ilonatommy it looks like there is at least one places in DebugStore where it makes assumptions about the attribute metadata and casts without a guard, can you take a look.

@lambdageek
Copy link
Member

@lewing @ilonatommy The runtime issue that I was thinking of was resolved already. This works with both Mono and CoreCLR:

using System;
using System.Reflection;

[AttributeUsage(AttributeTargets.Method, AllowMultiple=true)]
public class BadAttribute<T> : Attribute
{
        public BadAttribute() {}
                
}

public class P
{
        [Bad<int>]
        [Bad<double>]
        public static void Main() {
                var mi = typeof(P).GetMethod("Main", BindingFlags.Static | BindingFlags.Public);
                var cattrs = mi.GetCustomAttributes (typeof(BadAttribute<>));
                foreach (var ca in cattrs)
                        Console.WriteLine ($"generic: {ca}");

                var cattr = mi.GetCustomAttribute(typeof(BadAttribute<int>));
                Console.WriteLine ($"instance<int>: {cattr}");

                cattr = mi.GetCustomAttribute(typeof(BadAttribute<double>));
                Console.WriteLine ($"instance<double>: {cattr}");

                cattr = mi.GetCustomAttribute(typeof(BadAttribute<string>));
                Console.WriteLine ($"instance<string>: {cattr}");
                
        }
}

Output:

generic: BadAttribute`1[System.Int32]
generic: BadAttribute`1[System.Double]
instance<int>: BadAttribute`1[System.Int32]
instance<double>: BadAttribute`1[System.Double]
instance<string>:

@ilonatommy
Copy link
Member

ilonatommy commented May 26, 2023

@lewing @ilonatommy The runtime issue that I was thinking of was resolved already. This works with both Mono and CoreCLR:

Could you, please give the link to the issue? I cannot find it and I just checked the above code pasted into hosted WASM to the Client and result is as described:

[09:49:50] fail: DevToolsProxy[0]
      Failed to load https://localhost:5001/_framework/HostedBlazorWebassemblyApp.Client.wasm (Specified cast is not valid.)
[09:49:52] fail: DevToolsProxy[0]
      Failed to load assembly: (Stream does not contain a valid Webcil file)

edit: actually not that important, found the problem.

@msftbot msftbot bot added the in-pr There is an active PR which will close this issue when it is merged label May 26, 2023
@zbecknell
Copy link
Author

Thank you everyone for fixing this so quickly!

@msftbot msftbot bot removed the in-pr There is an active PR which will close this issue when it is merged label May 26, 2023
@msftbot msftbot bot added the in-pr There is an active PR which will close this issue when it is merged label May 29, 2023
@msftbot msftbot bot removed the in-pr There is an active PR which will close this issue when it is merged label Jun 6, 2023
@msftbot msftbot bot locked as resolved and limited conversation to collaborators Jul 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants