Make APIs that take object as a parameter trim safe
- Dominant language
- C#
- Stars
- 4.9k
- Forks
- 1.1k
- Avg merge
- 20h 23m
- Merged PRs (30d)
- 103
Description
The [TrimTest ](https://github.com/dotnet/winforms/blob/main/src/System.Windows.Forms/tests/IntegrationTests/TrimTest/TrimTest.csproj)project generates trim warnings from WinForms code that pass object. These APIs need to be made trim safe. Some examples are below:
- At [CheckBinding](https://github.com/dotnet/winforms/blob/8ffa229122e82ff1f09d6e038784b556c4488194/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/Binding.cs#L471),
- [TypeDescriptor.GetAttributes(Object)](https://github.com/dotnet/winforms/blob/8ffa229122e82ff1f09d6e038784b556c4488194/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/Binding.cs#L493): BindableComponent instance is IBindableComponent
- [TypeDescriptor.GetProperties(Type)](https://github.com/dotnet/winforms/blob/8ffa229122e82ff1f09d6e038784b556c4488194/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/Binding.cs#L496C29-L496C57): controlClass type is from BindableComponent.GetType()
- [TypeDescriptor.GetProperties(Object)](https://github.com/dotnet/winforms/blob/8ffa229122e82ff1f09d6e038784b556c4488194/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/Binding.cs#L500)
- [TypeDescriptor.GetEvents(Object)](https://github.com/dotnet/winforms/blob/8ffa229122e82ff1f09d6e038784b556c4488194/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/Binding.cs#L545)
- [TypeDescriptor.GetConverter(Type)](https://github.com/dotnet/winforms/blob/8ffa229122e82ff1f09d6e038784b556c4488194/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/Binding.cs#L793): type is object.GetType(), also [here](https://github.com/dotnet/winforms/blob/8ffa229122e82ff1f09d6e038784b556c4488194/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/Binding.cs#L719).
- Control's [IArrangedElement.SetBounds](https://github.com/dotnet/winforms/blob/904487a9da4bb66f2149edeaab1cc92b67bcc5b2/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs#L13352C10-L13352C36)
- [TypeDescriptor.GetProperties(Object)](https://github.com/dotnet/winforms/blob/904487a9da4bb66f2149edeaab1cc92b67bcc5b2/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs#L13363-L13364)
More details can be seen in this file,
[Default_Trimmed_Warnings_wpf_attributes_excluded_ComponentModel.txt](https://github.com/dotnet/winforms/files/14144256/Default_Trimmed_Warnings_wpf_attributes_excluded_ComponentModel.txt)
Contributor guide
Assessment
This issue has not been assessed yet.