-
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
Do not trim private methods used by the designer #102244
Comments
FYI: @LakshanF @steveharter |
Tagging subscribers to this area: @roji, @ajcvickers |
System.Data has the most problems, but all assemblies should be examined for this pattern. |
@steveharter @ericstj can we have this triaged soon? This is super important for WinForms customers. |
Tagging subscribers to this area: @dotnet/area-system-componentmodel |
Marking this one as ComponentModel - the caller of private reflection here is ComponentModel. |
The fix is likely to use In addition to
|
@steveharter did you also look for the Reset pattern? I see that might be on a couple additional types. Cool that we can do this with attributes - that's much better than the XML config. Another possible fix here would be to just make these public so that it's clear that they're externally called. I don't have much preference so long as we can ensure we preserve the members in the framework assemblies we ship, as well as preserve them in a self-contained trimmed application that might depend on them. |
Yes the regex I used is |
Draft PR is opened, but I'd like feedback on how deep we should go. There are two trimming issue categories:
Should we only focus on (1) for now? Note that the PR currently includes all of (1) and only part of (2) - in particular there are additional classes including |
Is the title of this issue "Do not trim private methods used by the designer" correct ? If it is correct, the trimming done by the user (2) does not impact designers. The trimming in of inbox assemblies should be fixed by |
The second case might impact winforms applications that expose IDE-like functionality. The simplest scenario I can think of is an application with property grid, and the user trying to reset property value to the default. However, if such an application is trimmed, developer has to "register" types that are displayed in the property grid using the new feature Steve introduced to get TypeDescriptor infrastructure working. Will such types from System.Data.Odbc preserve the Reset/ShouldSerialize methods? |
Applications that expose IDE-like functionality are typically incompatible with trimming for many different reasons. (If we hear about applications like that and the TypeDescriptor being one of the last things preventing them from being trimmable, we can always fix this for them by adding a feature switch.) |
Description
Copied from dotnet/winforms#11314
Private methods whose names follow the pattern
ShouldSerialize<PropertyName>
orReset<ProppertyName>
should not be trimmed by the linker because they are used by the TypeDescriptor via reflection. Additional conditions: Winforms designer is interested in types derived fromIComponent
. Property should not be hidden from serializers via SerializerVisibility attribute. Property should be public.TypeDescriptor accesses these methods here
Suggested fix from @ericstj
Searches yeld some false positives if the class is not designable, not an
IComponent
, or class does not have the public, serializable property, or method is actually called directly. For each property we need to examine metadata in the trimmed assembly to see if the methods were removed.Reproduction Steps
This works on 4.8.1 but doesn't on net6
Expected behavior
ShouldSerialize, Reset methods are present in the assembly
Actual behavior
ShouldSerialize, Reset methods are trimmed
Regression?
The end scenario regressed between the InProc and OOP designers.
Known Workarounds
none
Configuration
WIndows
Other information
Trimmed ShouldSerialize causes serialization using BinaryFormatter. The fix should be serviced.
The text was updated successfully, but these errors were encountered: