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

DebuggerTypeProxy types are empty after linking #37307

Closed
eerhardt opened this issue Jun 2, 2020 · 5 comments · Fixed by #39126
Closed

DebuggerTypeProxy types are empty after linking #37307

eerhardt opened this issue Jun 2, 2020 · 5 comments · Fixed by #39126
Assignees
Labels
area-System.Diagnostics linkable-framework Issues associated with delivering a linker friendly framework
Milestone

Comments

@eerhardt
Copy link
Member

eerhardt commented Jun 2, 2020

After linking an application, any type that is used by a DebuggerTypeProxyAttribute still exists, but is empty. This is because there are no callers of any of the members on these types - they exist so the debugger can call them to show in the Watch window. So the linker is removing all of the members from the type. But the type remains because it is being referenced by the DebuggerTypeProxyAttribute. This will limit the ability to debug a linked application, because any type that uses a DebuggerTypeProxy will be empty in the Watch window.

We should fix this by annotating the DebuggerTypeProxyAttribute class to tell the linker to preserve its members that are required by the debugger. My initial thinking is that includes PublicConstructors and PublicProperties, as I don't think the debugger will call any methods on the proxy type.

cc @vitek-karas @joperezr @layomia

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Jun 2, 2020
@Dotnet-GitSync-Bot
Copy link
Collaborator

I couldn't figure out the best area label to add to this issue. Please help me learn by adding exactly one area label.

@eerhardt eerhardt added area-System.Diagnostics linkable-framework Issues associated with delivering a linker friendly framework labels Jun 2, 2020
@ghost
Copy link

ghost commented Jun 2, 2020

Tagging subscribers to this area: @tommcdon, @krwq
Notify danmosemsft if you want to be subscribed.

@stephentoub
Copy link
Member

My initial thinking is that includes PublicConstructors and PublicProperties, as I don't think the debugger will call any methods on the proxy type.

That sounds reasonable; while technically the debugger can show things beyond public properties, every type proxy I've looked at has only public constructors and properties (beyond the private fields that serve those properties). That said, the same argument could be used to say "just keep everything", because there's unlikely to be anything more in the debugger type proxy than public ctors and properties, and if there is, it's likely there for a good debugging reason.

@MichalStrehovsky
Copy link
Member

After linking an application, any type that is used by a DebuggerTypeProxyAttribute still exists, but is empty

That's odd because linker has bunch of code that is attempting to do stuff with that attribute.

I'll be happy to replace this with the public dataflow annotations and delete the linker special casing with prejudice.

Unless we get a statement from VS debugging folks on what they can actually use, I would go with .All.

@eerhardt
Copy link
Member Author

eerhardt commented Jun 2, 2020

That's odd because linker has bunch of code that is attempting to do stuff with that attribute.

It looks like in order to get that code activated, you need to pass -v to the linker command line, which I wasn't.

We should probably come up with a coherent strategy for trimming "debug only" code out.

I think we should have a single "feature switch" that can be turned on/off as necessary.

See

@tommcdon tommcdon added this to the 5.0 milestone Jun 9, 2020
@tommcdon tommcdon removed the untriaged New issue has not been triaged by the area owner label Jun 9, 2020
@eerhardt eerhardt self-assigned this Jul 9, 2020
eerhardt added a commit to eerhardt/runtime that referenced this issue Jul 10, 2020
Also, ensure the test app assembly is linked, and not copied during trimming tests, which was a bug in our test infrastructure.

Fix dotnet#37307
eerhardt added a commit that referenced this issue Jul 14, 2020
* Preserve DebuggerTypeProxyAttribute classes

Also, ensure the test app assembly is linked, and not copied during trimming tests, which was a bug in our test infrastructure.

Fix #37307

* Add test for DebuggerTypeProxy string overload.

* Update ref to match impl.
@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Diagnostics linkable-framework Issues associated with delivering a linker friendly framework
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants