winforms
winforms copied to clipboard
Add a new feature switch for WinForms trimming
Trimming WinForms will require a set of feature switches to be used similar to other feature switches when trimming WinForms applications.
Exploring the trim warnings from the TrimTest project shows the following areas where having a feature switch(es) could help:
- Not to use WPF assemblies (assume UseWPF
propertyis set to false). - Separate design time (where trimming is not required) and runtime experiences. Design time experience should be able to leverage trim incompatible capabilities like reflection and the publishing experience for trimmed applications should not generate trim warnings for the code that is only leveraged only at design time.
- System.ComponentModel.Design.IDesignerHost.IsSupported
-
System.Drawing.Design.UITypeEditor.IsSupported -
System.Windows.Forms.Control.AreDesignTimeFeaturesSupported -
System.ComponentModel.DefaultValueAttribute.IsSupported
- No support for Binding
- Use
ComponentModelin a trim safe way. See the new API proposal-
System.Windows.Forms.Primitives.TypeConverterHelper.UseComponentModelRegisteredTypes- Used in
System.Windows.Forms.Primitivesassembly
- Used in
-
System.Windows.Forms.Control.UseComponentModelRegisteredTypes
-
- No support for advanced control usage
- ActiveX:
System.Windows.Forms.ActiveXImpl.IsSupported - MdiWindowDialog:
System.Windows.Forms.MdiWindowDialog.IsSupported - ImageIndexConverter:
System.Windows.Forms.ImageIndexConverter.IsSupported
- ActiveX:
- The vast majority of the trim warnings are actually not hit by simple WinForms applications like the TrimTest project. However, the following areas are unlikely to be supported in trimming
- Resource usage that require
BinaryFormatter- System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization
- Its very likely the type extension mechanism offered by WinForms need to be curtailed with a feature switch for trimming. For example, ICustomTypeDescriptor likely need to be restricted and code paths that use this interface will need to be removed via the feature switch.
Default_Trimmed_Warnings_wpf_attributes_excluded_ComponentModel_ICustomTypeDescriptor.txt
-
System.ComponentModel.TypeDescriptor.SupportsInstanceBasedDescriptors -
System.ComponentModel.TypeDescriptor.IsComObjectDescriptorSupported
-
- Using Nullable Converter
-
System.ComponentModel.NullableConverter.IsSupported
-
- Resource usage that require
- Remove the current WinForms trimming prevention block when this feature switch is set.