diff --git a/src/System.Windows.Forms/src/System.Windows.Forms.csproj b/src/System.Windows.Forms/src/System.Windows.Forms.csproj index deb84b1c471..146eb6dfc4f 100644 --- a/src/System.Windows.Forms/src/System.Windows.Forms.csproj +++ b/src/System.Windows.Forms/src/System.Windows.Forms.csproj @@ -11,13 +11,24 @@ IL Trim warnings which should be removed in order to make WinForms trimmable See https://github.com/dotnet/winforms/issues/4649 --> - $(NoWarn);IL2026;IL2050;IL2057;IL2062;IL2067;IL2070;IL2072;IL2075;IL2077;IL2080;IL2092;IL2093;IL2094;IL2096;IL2111 + $(NoWarn);IL2050;IL2057;IL2062;IL2067;IL2070;IL2072;IL2075;IL2077;IL2080;IL2092;IL2093;IL2094;IL2096;IL2111 Resources\System\Windows\Forms\XPThemes.manifest true true true + true + + + + + + + + + diff --git a/src/System.Windows.Forms/src/System/Resources/AssemblyNamesTypeResolutionService.cs b/src/System.Windows.Forms/src/System/Resources/AssemblyNamesTypeResolutionService.cs index 4bca6be8ef7..5eb7f171cb1 100644 --- a/src/System.Windows.Forms/src/System/Resources/AssemblyNamesTypeResolutionService.cs +++ b/src/System.Windows.Forms/src/System/Resources/AssemblyNamesTypeResolutionService.cs @@ -18,9 +18,11 @@ internal class AssemblyNamesTypeResolutionService : ITypeResolutionService internal AssemblyNamesTypeResolutionService(AssemblyName[]? names) => _names = names; + [RequiresUnreferencedCode("Calls System.Resources.AssemblyNamesTypeResolutionService.GetAssembly(AssemblyName, Boolean)")] public Assembly? GetAssembly(AssemblyName name) => GetAssembly(name, true); [UnconditionalSuppressMessage("SingleFile", "IL3002", Justification = "Handles single file case")] + [RequiresUnreferencedCode("Calls System.Reflection.Assembly.LoadFrom(String)")] public Assembly? GetAssembly(AssemblyName name, bool throwOnError) { _cachedAssemblies ??= new(); @@ -69,8 +71,10 @@ public string GetPathOfAssembly(AssemblyName name) public Type? GetType(string name) => GetType(name, true); + [RequiresUnreferencedCode("Calls System.Resources.AssemblyNamesTypeResolutionService.GetType(String, Boolean, Boolean)")] public Type? GetType(string name, bool throwOnError) => GetType(name, throwOnError, false); + [RequiresUnreferencedCode("Calls System.Reflection.Assembly.GetType(String, Boolean, Boolean)")] public Type? GetType(string name, bool throwOnError, bool ignoreCase) { // Check type cache first diff --git a/src/System.Windows.Forms/src/System/Resources/ResXDataNode.cs b/src/System.Windows.Forms/src/System/Resources/ResXDataNode.cs index a95e2061fb5..becd557b891 100644 --- a/src/System.Windows.Forms/src/System/Resources/ResXDataNode.cs +++ b/src/System.Windows.Forms/src/System/Resources/ResXDataNode.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel; @@ -217,6 +217,7 @@ private static string ToBase64WrappedString(byte[] data) return raw; } + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetConverter(Type)")] private void FillDataNodeInfoFromObject(DataNodeInfo nodeInfo, object? value) { if (value is CultureInfo cultureInfo) @@ -287,6 +288,7 @@ private void FillDataNodeInfoFromObject(DataNodeInfo nodeInfo, object? value) #pragma warning restore SYSLIB0051 #pragma warning disable SYSLIB0011 // Type or member is obsolete + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] static void SerializeWithBinaryFormatter( IFormatter? binaryFormatter, DataNodeInfo nodeInfo, @@ -325,6 +327,7 @@ static void SerializeWithBinaryFormatter( #pragma warning restore SYSLIB0011 } + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetConverter(Type)")] private object? GenerateObjectFromDataNodeInfo(DataNodeInfo dataNodeInfo, ITypeResolutionService? typeResolver) { string? mimeTypeName = dataNodeInfo.MimeType; @@ -398,6 +401,7 @@ Type ResolveTypeName(string typeName) return type; } + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetConverter(Type)")] object? ResolveMimeType(string mimeTypeName) { if (string.Equals(mimeTypeName, ResXResourceWriter.ByteArraySerializedObjectMimeType) @@ -414,6 +418,7 @@ Type ResolveTypeName(string typeName) } [Obsolete(DiagnosticId = "SYSLIB0051")] + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] private object? GenerateObjectFromBinaryDataNodeInfo(DataNodeInfo dataNodeInfo, ITypeResolutionService? typeResolver) { if (!string.Equals(dataNodeInfo.MimeType, ResXResourceWriter.BinSerializedObjectMimeType)) @@ -459,6 +464,7 @@ Type ResolveTypeName(string typeName) return result; } + [RequiresUnreferencedCode("Calls System.Resources.ResXDataNode.FillDataNodeInfoFromObject(DataNodeInfo, Object)")] internal DataNodeInfo GetDataNodeInfo() { bool shouldSerialize = true; @@ -512,6 +518,7 @@ internal DataNodeInfo GetDataNodeInfo() /// /// Retrieves the type name for the value by using the specified type resolution service /// + [RequiresUnreferencedCode("")] public string? GetValueTypeName(ITypeResolutionService? typeResolver) { // The type name here is always a fully qualified name. @@ -595,6 +602,7 @@ internal DataNodeInfo GetDataNodeInfo() /// /// Retrieves the object that is stored by this node by using the specified type resolution service. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] public object? GetValue(ITypeResolutionService? typeResolver) { if (_value is not null) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.AxContainer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.AxContainer.cs index f5ca62c8518..598b4be318d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.AxContainer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.AxContainer.cs @@ -460,6 +460,7 @@ internal void OnInPlaceDeactivate(AxHost site) } } + [RequiresUnreferencedCode("Calls System.Windows.Forms.AxHost.SetSelectionStyle(Int32)")] internal void OnUIDeactivate(AxHost site) { Debug.Assert(_siteUIActive is null || _siteUIActive == site, "Deactivating when not active"); @@ -634,6 +635,7 @@ internal void OnExitEditMode(AxHost ctl) _controlInEditMode = null; } + [RequiresUnreferencedCode("Calls System.Windows.Forms.AxHost.SetSelectionStyle(Int32)")] HRESULT IOleInPlaceFrame.Interface.SetActiveObject(IOleInPlaceActiveObject* pActiveObject, PCWSTR pszObjName) { if (_siteUIActive is { } activeHost) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.AxEnumConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.AxEnumConverter.cs index 5545fa92371..9e4ff5c0d1d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.AxEnumConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.AxEnumConverter.cs @@ -22,6 +22,7 @@ public AxEnumConverter(AxPropertyDescriptor target, Com2Enum com2Enum) _target = target; } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] public override StandardValuesCollection? GetStandardValues(ITypeDescriptorContext? context) { // Make sure the converter has been properly refreshed by calling the Converter property. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.AxPropertyDescriptor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.AxPropertyDescriptor.cs index c60f12b55a9..f9c15dda52a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.AxPropertyDescriptor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.AxPropertyDescriptor.cs @@ -72,6 +72,7 @@ public override Type ComponentType } } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] public override TypeConverter Converter { [RequiresUnreferencedCode(TrimmingConstants.PropertyDescriptorPropertyTypeMessage)] diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.OleInterfaces.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.OleInterfaces.cs index c8877145f1d..de5613b400c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.OleInterfaces.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.OleInterfaces.cs @@ -466,6 +466,7 @@ HRESULT IOleInPlaceSite.Interface.OnPosRectChange(RECT* lprcPosRect) // IPropertyNotifySink methods + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] HRESULT IPropertyNotifySink.Interface.OnChanged(int dispid) { // Some controls fire OnChanged() notifications when getting values of some properties. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.PropertyBagStream.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.PropertyBagStream.cs index ade948fdaf9..7c73000d787 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.PropertyBagStream.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.PropertyBagStream.cs @@ -18,6 +18,7 @@ internal class PropertyBagStream : IPropertyBag.Interface internal PropertyBagStream() => _bag = new(); + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] internal PropertyBagStream(Stream stream) { long position = stream.Position; @@ -93,6 +94,7 @@ HRESULT IPropertyBag.Interface.Write(PCWSTR pszPropName, VARIANT* pVar) return HRESULT.S_OK; } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] internal void Save(Stream stream) { long position = stream.Position; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.cs index 79ac2fb96e2..2ae4b43ede3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Specialized; @@ -980,6 +980,7 @@ protected override void OnLostFocus(EventArgs e) } } + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetProperties(Object)")] private void OnNewSelection(object? sender, EventArgs e) { if (IsUserMode() || !Site.TryGetService(out ISelectionService? selectionService)) @@ -2398,6 +2399,7 @@ private void CreateInstance() return null; } + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetProperties(Object)")] private void SetSelectionStyle(int selectionStyle) { if (IsUserMode()) @@ -2420,6 +2422,7 @@ private void SetSelectionStyle(int selectionStyle) } [EditorBrowsable(EditorBrowsableState.Advanced)] + [RequiresUnreferencedCode("")] public void InvokeEditMode() { Debug.Assert((_flags & AxFlags.PreventEditMode) == 0, "edit mode should have been disabled"); @@ -2446,6 +2449,7 @@ public void InvokeEditMode() // [EditorBrowsable(EditorBrowsableState.Advanced)] + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "ICustomTypeDescriptor")] AttributeCollection ICustomTypeDescriptor.GetAttributes() { if (!_axState[s_editorRefresh] && HasPropertyPages()) @@ -2527,6 +2531,7 @@ AttributeCollection ICustomTypeDescriptor.GetAttributes() } [EditorBrowsable(EditorBrowsableState.Advanced)] + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "ICustomTypeDescriptor")] EventDescriptorCollection ICustomTypeDescriptor.GetEvents() => TypeDescriptor.GetEvents(this, noCustomTypeDesc: true); @@ -2565,6 +2570,7 @@ private bool RefreshAllProperties } } + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetProperties(Object, Attribute[], Boolean)")] private PropertyDescriptorCollection FillProperties(Attribute[]? attributes) { if (RefreshAllProperties) @@ -2735,6 +2741,7 @@ PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[]? at return this; } + [RequiresUnreferencedCode("Calls System.Windows.Forms.AxHost.FillProperties(Attribute[])")] private AxPropertyDescriptor? GetPropertyDescriptorFromDispid(int dispid) { Debug.Assert(dispid != PInvokeCore.DISPID_UNKNOWN, "Wrong dispid sent to GetPropertyDescriptorFromDispid"); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/Control.ActiveXImpl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/Control.ActiveXImpl.cs index 0329b4c08d9..553e12f2c5d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/Control.ActiveXImpl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/Control.ActiveXImpl.cs @@ -970,6 +970,7 @@ internal HRESULT InPlaceDeactivate() /// /// Looks at the property to see if it should be loaded / saved as a resource or through a type converter. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] private bool IsResourceProperty(PropertyDescriptor property) { TypeConverter converter = property.Converter; @@ -1022,6 +1023,7 @@ internal HRESULT Load(IStorage* stg) } /// + [RequiresUnreferencedCode("Calls System.Windows.Forms.Control.ActiveXImpl.Load(IPropertyBag*, IErrorLog*)")] internal void Load(IStream* stream) { // We do everything through property bags because we support full fidelity @@ -1033,6 +1035,7 @@ internal void Load(IStream* stream) } /// + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetProperties(Object, Attribute[])")] internal unsafe void Load(IPropertyBag* propertyBag, IErrorLog* errorLog) { PropertyDescriptorCollection props = TypeDescriptor.GetProperties( @@ -1105,6 +1108,7 @@ internal unsafe void Load(IPropertyBag* propertyBag, IErrorLog* errorLog) } } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] bool SetValue(PropertyDescriptor currentProperty, object data) { string? value = data as string ?? Convert.ToString(data, CultureInfo.InvariantCulture); @@ -1336,6 +1340,7 @@ internal void OnFocus(bool focus) }; /// + [RequiresUnreferencedCode("Calls GetDefaultEventsInterface(Type)")] internal unsafe HRESULT QuickActivate(QACONTAINER* pQaContainer, QACONTROL* pQaControl) { if (pQaControl is null) @@ -1416,6 +1421,7 @@ internal unsafe HRESULT QuickActivate(QACONTAINER* pQaContainer, QACONTROL* pQaC return HRESULT.S_OK; // Get the default COM events interface declared on a .NET class. + [RequiresUnreferencedCode("Calls System.Reflection.Assembly.GetType(String, Boolean)")] static Type? GetDefaultEventsInterface(Type controlType) { Type? eventInterface = null; @@ -1467,6 +1473,7 @@ internal void Save(IStream* stream, BOOL fClearDirty) } /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] internal void Save(IPropertyBag* propertyBag, BOOL clearDirty, BOOL saveAllProperties) { PropertyDescriptorCollection props = TypeDescriptor.GetProperties( diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/Control_ActiveXControlInterfaces.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/Control_ActiveXControlInterfaces.cs index 7487db545f9..9eafb9aab09 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/Control_ActiveXControlInterfaces.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/Control_ActiveXControlInterfaces.cs @@ -377,6 +377,7 @@ HRESULT IPersistPropertyBag.Interface.GetClassID(Guid* pClassID) } /// + [RequiresUnreferencedCode("Calls System.Windows.Forms.Control.ActiveXImpl.Load(IPropertyBag*, IErrorLog*)")] HRESULT IPersistPropertyBag.Interface.Load(IPropertyBag* pPropBag, IErrorLog* pErrorLog) { ActiveXInstance.Load(pPropBag, pErrorLog); @@ -452,6 +453,7 @@ HRESULT IPersistStreamInit.Interface.GetClassID(Guid* pClassID) HRESULT IPersistStreamInit.Interface.IsDirty() => ActiveXInstance.IsDirty(); /// + [RequiresUnreferencedCode("Calls System.Windows.Forms.Control.ActiveXImpl.Load(IStream*)")] HRESULT IPersistStreamInit.Interface.Load(IStream* pStm) { if (pStm is null) @@ -482,6 +484,7 @@ HRESULT IPersistStreamInit.Interface.Save(IStream* pStm, BOOL fClearDirty) HRESULT IPersistStreamInit.Interface.InitNew() => HRESULT.S_OK; /// + [RequiresUnreferencedCode("Calls System.Windows.Forms.Control.ActiveXImpl.QuickActivate(QACONTAINER*, QACONTROL*)")] HRESULT IQuickActivate.Interface.QuickActivate(QACONTAINER* pQaContainer, QACONTROL* pQaControl) => ActiveXInstance.QuickActivate(pQaContainer, pQaControl); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ExtendedTypeConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ExtendedTypeConverter.cs index d596910e94a..54b2ec16a68 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ExtendedTypeConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ExtendedTypeConverter.cs @@ -19,6 +19,7 @@ public Com2ExtendedTypeConverter(TypeConverter? innerConverter) _innerConverter = innerConverter; } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] public Com2ExtendedTypeConverter([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type baseType) { _innerConverter = TypeDescriptor.GetConverter(baseType); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ExtendedUITypeEditor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ExtendedUITypeEditor.cs index be45b142198..75bec4912a9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ExtendedUITypeEditor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ExtendedUITypeEditor.cs @@ -17,6 +17,7 @@ public Com2ExtendedUITypeEditor(UITypeEditor? baseTypeEditor) _innerEditor = baseTypeEditor; } + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetEditor(Type, Type)")] public Com2ExtendedUITypeEditor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type baseType) { _innerEditor = (UITypeEditor?)TypeDescriptor.GetEditor(baseType, typeof(UITypeEditor)); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IManagedPerPropertyBrowsingHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IManagedPerPropertyBrowsingHandler.cs index 5e8dff5945d..03496577bd3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IManagedPerPropertyBrowsingHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IManagedPerPropertyBrowsingHandler.cs @@ -30,6 +30,7 @@ public override void RegisterEvents(Com2PropertyDescriptor[]? properties) /// Here is where we handle IVsPerPropertyBrowsing.GetLocalizedPropertyInfo and IVsPerPropertyBrowsing. /// Hide properties such as IPerPropertyBrowsing, IProvidePropertyBuilder, etc. /// + [RequiresUnreferencedCode("Calls System.Windows.Forms.ComponentModel.Com2Interop.Com2IManagedPerPropertyBrowsingHandler.GetComponentAttributes(IVSMDPerPropertyBrowsing*, Int32)")] private void OnGetAttributes(Com2PropertyDescriptor sender, GetAttributesEvent e) { using var propertyBrowsing = TryGetComScope(sender.TargetObject, out HRESULT hr); @@ -43,6 +44,7 @@ private void OnGetAttributes(Com2PropertyDescriptor sender, GetAttributesEvent e } } + [RequiresUnreferencedCode("Calls System.Reflection.Assembly.GetType(String)")] internal static Attribute[] GetComponentAttributes(IVSMDPerPropertyBrowsing* propertyBrowsing, int dispid) { uint attributeCount = 0; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IPerPropertyBrowsingHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IPerPropertyBrowsingHandler.cs index 466feaa9c28..3a9ab47b35a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IPerPropertyBrowsingHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IPerPropertyBrowsingHandler.cs @@ -71,6 +71,7 @@ private void OnGetBaseAttributes(Com2PropertyDescriptor sender, GetAttributesEve } } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] private void OnGetDisplayValue(Com2PropertyDescriptor sender, GetNameItemEvent e) { using var propertyBrowsing = TryGetComScope(sender.TargetObject, out HRESULT hr); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PropertyDescriptor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PropertyDescriptor.cs index 2f845147586..287a11bc9d5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PropertyDescriptor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PropertyDescriptor.cs @@ -469,6 +469,7 @@ public object Clone() protected sealed override AttributeCollection CreateAttributeCollection() => new(AttributeArray); + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] private TypeConverter GetBaseTypeConverter() { if (PropertyType is null) @@ -509,6 +510,7 @@ private TypeConverter GetBaseTypeConverter() return localConverter ?? new TypeConverter(); } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] private object? GetBaseTypeEditor(Type editorBaseType) { if (PropertyType is null) @@ -673,6 +675,7 @@ internal unsafe VARIANT GetNativeValue(object? component) /// the parameter will be passed in. /// /// + [RequiresUnreferencedCode("Calls System.Windows.Forms.ComponentModel.Com2Interop.ComNativeDescriptor.ResolveVariantTypeConverterAndTypeEditor(Object, ref TypeConverter, Type, ref Object)")] public void GetTypeConverterAndTypeEditor([NotNull] ref TypeConverter? typeConverter, Type editorBaseType, ref object? typeEditor) { // Get the base editor and converter, attributes first. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ComNativeDescriptor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ComNativeDescriptor.cs index e20f44030af..1aaab4b050d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ComNativeDescriptor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ComNativeDescriptor.cs @@ -94,8 +94,10 @@ internal static string GetClassName(object component) return typeInfoName.AsSpan().TrimStart('_').ToString(); } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] internal static TypeConverter GetIComponentConverter() => TypeDescriptor.GetConverter(typeof(IComponent)); + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetEditor(Type, Type)")] internal static object? GetEditor(object component, Type baseEditorType) => TypeDescriptor.GetEditor(component.GetType(), baseEditorType); @@ -233,6 +235,7 @@ private void CheckClear() return properties; } + [RequiresUnreferencedCode("Calls System.Windows.Forms.ComponentModel.Com2Interop.Com2IManagedPerPropertyBrowsingHandler.GetComponentAttributes(IVSMDPerPropertyBrowsing*, Int32)")] internal static AttributeCollection GetAttributes(object component) { List attributes = []; @@ -325,6 +328,7 @@ private void OnPropsInfoDisposed(object? sender, EventArgs e) /// Looks at value's type and creates an editor based on that. We use this to decide which editor to use /// for a generic variant. /// + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetConverter(Type)")] internal static void ResolveVariantTypeConverterAndTypeEditor( object? propertyValue, ref TypeConverter currentConverter, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.States.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.States.cs index f23ab2dfa83..7a35161dbce 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.States.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.States.cs @@ -8,36 +8,36 @@ public partial class Control [Flags] private protected enum States { - Created = 0x00000001, - Visible = 0x00000002, - Enabled = 0x00000004, - TabStop = 0x00000008, - Recreate = 0x00000010, - Modal = 0x00000020, - AllowDrop = 0x00000040, - DropTarget = 0x00000080, - NoZOrder = 0x00000100, - LayoutDeferred = 0x00000200, - UseWaitCursor = 0x00000400, - Disposed = 0x00000800, - Disposing = 0x00001000, - MouseEnterPending = 0x00002000, - TrackingMouseEvent = 0x00004000, - ThreadMarshalPending = 0x00008000, - SizeLockedByOS = 0x00010000, - CausesValidation = 0x00020000, - CreatingHandle = 0x00040000, - TopLevel = 0x00080000, - IsAccessible = 0x00100000, - OwnCtlBrush = 0x00200000, - ExceptionWhilePainting = 0x00400000, - LayoutIsDirty = 0x00800000, - CheckedHost = 0x01000000, - HostedInDialog = 0x02000000, - DoubleClickFired = 0x04000000, - MousePressed = 0x08000000, - ValidationCancelled = 0x10000000, - ParentRecreating = 0x20000000, - Mirrored = 0x40000000, + Created = 0x00000001, + Visible = 0x00000002, + Enabled = 0x00000004, + TabStop = 0x00000008, + Recreate = 0x00000010, + Modal = 0x00000020, + AllowDrop = 0x00000040, + DropTarget = 0x00000080, + NoZOrder = 0x00000100, + LayoutDeferred = 0x00000200, + UseWaitCursor = 0x00000400, + Disposed = 0x00000800, + Disposing = 0x00001000, + MouseEnterPending = 0x00002000, + TrackingMouseEvent = 0x00004000, + ThreadMarshalPending = 0x00008000, + SizeLockedByOS = 0x00010000, + CausesValidation = 0x00020000, + CreatingHandle = 0x00040000, + TopLevel = 0x00080000, + IsAccessible = 0x00100000, + OwnCtlBrush = 0x00200000, + ExceptionWhilePainting = 0x00400000, + LayoutIsDirty = 0x00800000, + CheckedHost = 0x01000000, + HostedInDialog = 0x02000000, + DoubleClickFired = 0x04000000, + MousePressed = 0x08000000, + ValidationCancelled = 0x10000000, + ParentRecreating = 0x20000000, + Mirrored = 0x40000000, } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs index 01c2a2554a1..89a9f2ad68a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs @@ -769,6 +769,7 @@ public event EventHandler? AutoSizeChanged /// Controls the location of where this control is scrolled to in ScrollableControl.ScrollControlIntoView. /// Default is the upper left hand corner of the control. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Advanced)] [DefaultValue(typeof(Point), "0, 0")] @@ -2780,6 +2781,7 @@ public event EventHandler? MarginChanged [Localizable(true)] [SRDescription(nameof(SR.ControlMaximumSizeDescr))] [AmbientValue(typeof(Size), "0, 0")] + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] public virtual Size MaximumSize { get { return CommonProperties.GetMaximumSize(this, DefaultMaximumSize); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/Buttons/ButtonBase.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/Buttons/ButtonBase.cs index c5642fe1f79..6b0e7e5ff7f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/Buttons/ButtonBase.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/Buttons/ButtonBase.cs @@ -149,6 +149,7 @@ public override bool AutoSize public override Color BackColor { get => base.BackColor; + [RequiresUnreferencedCode("")] set { if (DesignMode) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/Buttons/FlatButtonAppearance.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/Buttons/FlatButtonAppearance.cs index a787a881f3f..50db373ea57 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/Buttons/FlatButtonAppearance.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/Buttons/FlatButtonAppearance.cs @@ -57,6 +57,7 @@ public int BorderSize /// /// For buttons whose FlatStyle is FlatStyle.Flat, this property specifies the color of the border around the button. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [Browsable(true)] [ApplicableToButton] [NotifyParentProperty(true)] @@ -86,6 +87,7 @@ public Color BorderColor /// For buttons whose FlatStyle is FlatStyle.Flat, this property specifies the color of the client area /// of the button when the button state is checked and the mouse cursor is NOT within the bounds of the control. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [Browsable(true)] [NotifyParentProperty(true)] [SRCategory(nameof(SR.CatAppearance))] @@ -109,6 +111,7 @@ public Color CheckedBackColor /// For buttons whose FlatStyle is FlatStyle.Flat, this property specifies the color of the client area /// of the button when the mouse cursor is within the bounds of the control and the left button is pressed. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [Browsable(true)] [ApplicableToButton] [NotifyParentProperty(true)] @@ -133,6 +136,7 @@ public Color MouseDownBackColor /// For buttons whose FlatStyle is FlatStyle.Flat, this property specifies the color of the client /// area of the button when the mouse cursor is within the bounds of the control. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [Browsable(true)] [ApplicableToButton] [NotifyParentProperty(true)] diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ComboBox/ComboBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ComboBox/ComboBox.cs index 47c4b708544..7a042f6ffe9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ComboBox/ComboBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ComboBox/ComboBox.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections; @@ -1191,6 +1191,7 @@ public ComboBoxStyle DropDownStyle [AllowNull] public override string Text { + [RequiresUnreferencedCode("")] get { if (SelectedItem is not null && !BindingFieldEmpty) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridView.DataConnection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridView.DataConnection.cs index a790ef2ead7..4ca8bec6498 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridView.DataConnection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridView.DataConnection.cs @@ -268,6 +268,7 @@ public void ApplySortingInformationFromBackEnd() } } + [RequiresUnreferencedCode("Calls System.ComponentModel.PropertyDescriptor.Converter")] public TypeConverter BoundColumnConverter(int boundColumnIndex) { Debug.Assert(_props is not null); @@ -905,6 +906,7 @@ public void Dispose() CurrencyManager = null; } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] private static DataGridViewColumn GetDataGridViewColumnFromType(Type type) { DataGridViewColumn dataGridViewColumn; @@ -925,6 +927,7 @@ private static DataGridViewColumn GetDataGridViewColumnFromType(Type type) return dataGridViewColumn; } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] public List? GetCollectionOfBoundDataGridViewColumns() { if (_props is null) @@ -1458,6 +1461,7 @@ public void ProcessException(Exception exception, DataGridViewCellCancelEventArg } } + [RequiresUnreferencedCode("Calls System.Windows.Forms.DataGridView.DataGridViewDataConnection.BoundColumnConverter(Int32)")] public bool PushValue(int boundColumnIndex, int columnIndex, int rowIndex, object? value) { try diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridView.Methods.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridView.Methods.cs index cce1b6d07d0..854336bab76 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridView.Methods.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridView.Methods.cs @@ -6977,6 +6977,7 @@ private void FlushSelectionChanged() return AccessibilityObject.GetChild(objectId - 1); } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] internal TypeConverter GetCachedTypeConverter(Type type) { if (_converters.TryGetValue(type, out TypeConverter? converter)) @@ -10864,6 +10865,7 @@ private void MoveColumnHeadersOrRowResize(MouseEventArgs e) Invalidate(CalcRowResizeFeedbackRect(_currentRowSplitBar)); } + [RequiresUnreferencedCode("Calls System.Windows.Forms.DataGridView.DataGridViewDataConnection.BoundColumnConverter(Int32)")] private void MapDataGridViewColumnToDataBoundField(DataGridViewColumn dataGridViewColumn) { Debug.Assert(DataSource is not null, "this method should only be called when we have a data connection"); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridViewCell.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridViewCell.cs index 6a182f879b7..e2cc9e3cd79 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridViewCell.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridViewCell.cs @@ -242,6 +242,7 @@ public object? FormattedValue [Browsable(false)] public virtual Type? FormattedValueType => ValueType; + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] private TypeConverter? FormattedValueTypeConverter { get @@ -755,6 +756,7 @@ public virtual Type? ValueType } } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] private TypeConverter? ValueTypeConverter { get diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridViewComboBoxCell.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridViewComboBoxCell.cs index f68d3de28eb..1355c2c9bc0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridViewComboBoxCell.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridViewComboBoxCell.cs @@ -361,6 +361,7 @@ private Type DisplayType } } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] private TypeConverter DisplayTypeConverter => DataGridView is not null ? DataGridView.GetCachedTypeConverter(DisplayType) : TypeDescriptor.GetConverter(DisplayType); @@ -997,6 +998,7 @@ OwningColumn is null || return errorIconBounds; } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] protected override object? GetFormattedValue( object? value, int rowIndex, @@ -1138,6 +1140,7 @@ OwningColumn is null || } } + [RequiresUnreferencedCode("Calls System.Windows.Forms.DataGridViewComboBoxCell.GetItemDisplayValue(Object)")] internal string? GetItemDisplayText(object item) { object? displayValue = GetItemDisplayValue(item); @@ -1146,6 +1149,7 @@ OwningColumn is null || : string.Empty; } + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetProperties(Object)")] internal object? GetItemDisplayValue(object item) { Debug.Assert(item is not null); @@ -1222,6 +1226,7 @@ internal ObjectCollection GetItems(DataGridView? dataGridView) return items; } + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetProperties(Object)")] internal object? GetItemValue(object item) { bool valueSet = false; @@ -1549,6 +1554,7 @@ private void InitializeValueMemberPropertyDescriptor(string? valueMember) return item; } + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetProperties(Object)")] private object? ItemFromComboBoxItems(int rowIndex, string field, object key) { Debug.Assert(!string.IsNullOrEmpty(field)); @@ -1638,6 +1644,7 @@ public override bool KeyEntersEditMode(KeyEventArgs e) /// ComboBox datasource. We then use DisplayMember to get the /// text to display. /// + [RequiresUnreferencedCode("Calls System.Windows.Forms.DataGridViewComboBoxCell.ItemFromComboBoxItems(Int32, String, Object)")] private bool LookupDisplayValue(int rowIndex, object value, out object? displayValue) { Debug.Assert(value is not null); @@ -1676,6 +1683,7 @@ private bool LookupDisplayValue(int rowIndex, object value, out object? displayV /// We use the display value and DisplayMember to look up the item in the /// ComboBox datasource. We then use ValueMember to get the value. /// + [RequiresUnreferencedCode("Calls System.Windows.Forms.DataGridViewComboBoxCell.ItemFromComboBoxItems(Int32, String, Object)")] private bool LookupValue(object? formattedValue, out object? value) { if (formattedValue is null) @@ -2478,6 +2486,7 @@ private Rectangle PaintPrivate( return resultBounds; } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] public override object? ParseFormattedValue( object? formattedValue, DataGridViewCellStyle cellStyle, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DateTimePicker/DateTimePicker.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DateTimePicker/DateTimePicker.cs index 86d0a3ee306..0801848ac1d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DateTimePicker/DateTimePicker.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DateTimePicker/DateTimePicker.cs @@ -5,8 +5,8 @@ using System.Drawing; using System.Globalization; using System.Windows.Forms.Layout; -using Microsoft.Win32; using SourceGenerated; +using Microsoft.Win32; using Windows.Win32.System.Variant; using Windows.Win32.UI.Accessibility; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/Labels/LinkArea.LinkAreaConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/Labels/LinkArea.LinkAreaConverter.cs index 916c7011c62..caf34e63a1b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/Labels/LinkArea.LinkAreaConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/Labels/LinkArea.LinkAreaConverter.cs @@ -83,6 +83,7 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destina /// type is string. If this cannot convert to the destination type, this will /// throw a NotSupportedException. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType) { if (value is LinkArea pt) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/Labels/LinkConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/Labels/LinkConverter.cs index 83a003d0b61..1dd534ac21a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/Labels/LinkConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/Labels/LinkConverter.cs @@ -79,6 +79,7 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destina /// type is string. If this cannot convert to the destination type, this will /// throw a NotSupportedException. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType) { if (value is LinkLabel.Link link) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ListBoxes/ListBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ListBoxes/ListBox.cs index 9b242b22892..be610046391 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ListBoxes/ListBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ListBoxes/ListBox.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections; @@ -1054,6 +1054,7 @@ public bool Sorted [AllowNull] public override string Text { + [RequiresUnreferencedCode("")] get { if (SelectionMode != SelectionMode.None && SelectedItem is not null) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ListControl/ListControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ListControl/ListControl.cs index ad962062dd3..0f04e569cc9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ListControl/ListControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ListControl/ListControl.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections; @@ -131,6 +131,7 @@ public event EventHandler? DisplayMemberChanged /// /// Cached type converter of the property associated with the display member /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] private TypeConverter? DisplayMemberConverter { get @@ -344,6 +345,7 @@ public event EventHandler? ValueMemberChanged [DisallowNull] public object? SelectedValue { + [RequiresUnreferencedCode("")] get { if (SelectedIndex != -1 && _dataManager is not null) @@ -413,11 +415,13 @@ private void DataManager_ItemChanged(object? sender, ItemChangedEventArgs e) } } + [RequiresUnreferencedCode("")] protected object? FilterItemOnProperty(object? item) { return FilterItemOnProperty(item, _displayMember.BindingField); } + [RequiresUnreferencedCode("")] protected object? FilterItemOnProperty(object? item, string? field) { if (item is not null && !string.IsNullOrEmpty(field)) @@ -497,6 +501,7 @@ private protected int FindStringInternal(string? str, IList? items, int startInd return -1; } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] public string? GetItemText(object? item) { if (!_formattingEnabled) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ListView/ColumnHeaderConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ListView/ColumnHeaderConverter.cs index 58b0434d3f9..92f24a5bbae 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ListView/ColumnHeaderConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ListView/ColumnHeaderConverter.cs @@ -31,6 +31,7 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destina /// type is string. If this cannot convert to the destination type, this will /// throw a NotSupportedException. /// + [RequiresUnreferencedCode("")] public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType) { ArgumentNullException.ThrowIfNull(destinationType); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ListView/ListViewItemStateImageIndexConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ListView/ListViewItemStateImageIndexConverter.cs index 5b697793e10..9c3d4de6650 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ListView/ListViewItemStateImageIndexConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ListView/ListViewItemStateImageIndexConverter.cs @@ -39,6 +39,7 @@ protected override bool IncludeNoneAsStandardValue /// this collection contains a single object with a value of -1. This method returns /// if the data type doesn't support a standard set of values. /// + [RequiresUnreferencedCode("")] public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context) { if (context is not null && context.Instance is not null) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/MonthCalendar/SelectionRangeConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/MonthCalendar/SelectionRangeConverter.cs index cb3ef29db8d..88daad0e627 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/MonthCalendar/SelectionRangeConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/MonthCalendar/SelectionRangeConverter.cs @@ -89,6 +89,7 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destina /// type is string. If this cannot convert to the destination type, this will /// throw a NotSupportedException. /// + [RequiresUnreferencedCode("")] public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType) { ArgumentNullException.ThrowIfNull(destinationType); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGrid.Flags.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGrid.Flags.cs index 3bbbe5c773c..676cad026e1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGrid.Flags.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGrid.Flags.cs @@ -8,15 +8,15 @@ public partial class PropertyGrid [Flags] private enum Flags : ushort { - PropertiesChanged = 0x0001, - GotDesignerEventService = 0x0002, - InternalChange = 0x0004, - TabsChanging = 0x0008, - BatchMode = 0x0010, - ReInitTab = 0x0020, - SysColorChangeRefresh = 0x0040, - FullRefreshAfterBatch = 0x0080, - BatchModeChange = 0x0100, - RefreshingProperties = 0x0200 + PropertiesChanged = 0x0001, + GotDesignerEventService = 0x0002, + InternalChange = 0x0004, + TabsChanging = 0x0008, + BatchMode = 0x0010, + ReInitTab = 0x0020, + SysColorChangeRefresh = 0x0040, + FullRefreshAfterBatch = 0x0080, + BatchModeChange = 0x0100, + RefreshingProperties = 0x0200 } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGrid.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGrid.cs index 19de619a6ff..e089336bbbb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGrid.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGrid.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel; @@ -406,6 +406,7 @@ public AttributeCollection BrowsableAttributes /// /// The text used color for category headings. The background color is determined by the LineColor property. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [SRCategory(nameof(SR.CatAppearance))] [SRDescription(nameof(SR.PropertyGridCategoryForeColorDesc))] [DefaultValue(typeof(Color), "ControlText")] @@ -488,6 +489,7 @@ public Color CommandsDisabledLinkColor /// /// The border color for the hot commands region /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [SRCategory(nameof(SR.CatAppearance))] [SRDescription(nameof(SR.PropertyGridCommandsBorderColorDesc))] [DefaultValue(typeof(Color), "ControlDark")] @@ -627,6 +629,7 @@ private bool FreezePainting /// /// The background color for the help region. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [SRCategory(nameof(SR.CatAppearance))] [SRDescription(nameof(SR.PropertyGridHelpBackColorDesc))] [DefaultValue(typeof(Color), "Control")] @@ -639,6 +642,7 @@ public Color HelpBackColor /// /// The foreground color for the help region. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [SRCategory(nameof(SR.CatAppearance))] [SRDescription(nameof(SR.PropertyGridHelpForeColorDesc))] [DefaultValue(typeof(Color), "ControlText")] @@ -651,6 +655,7 @@ public Color HelpForeColor /// /// The border color for the help region. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [SRCategory(nameof(SR.CatAppearance))] [SRDescription(nameof(SR.PropertyGridHelpBorderColorDesc))] [DefaultValue(typeof(Color), "ControlDark")] @@ -699,6 +704,7 @@ public virtual bool HelpVisible /// /// Background color for Highlighted text. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [SRCategory(nameof(SR.CatAppearance))] [SRDescription(nameof(SR.PropertyGridSelectedItemWithFocusBackColorDesc))] [DefaultValue(typeof(Color), "Highlight")] @@ -718,6 +724,7 @@ public Color SelectedItemWithFocusBackColor /// /// Foreground color for Highlighted (selected) text. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [SRCategory(nameof(SR.CatAppearance))] [SRDescription(nameof(SR.PropertyGridSelectedItemWithFocusForeColorDesc))] [DefaultValue(typeof(Color), "HighlightText")] @@ -737,6 +744,7 @@ public Color SelectedItemWithFocusForeColor /// /// Foreground color for disabled text in the Grid View /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [SRCategory(nameof(SR.CatAppearance))] [SRDescription(nameof(SR.PropertyGridDisabledItemForeColorDesc))] [DefaultValue(typeof(Color), "GrayText")] @@ -753,6 +761,7 @@ public Color DisabledItemForeColor /// /// Color for the horizontal splitter line separating property categories. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [SRCategory(nameof(SR.CatAppearance))] [SRDescription(nameof(SR.PropertyGridCategorySplitterColorDesc))] [DefaultValue(typeof(Color), "Control")] @@ -773,6 +782,7 @@ public Color CategorySplitterColor /// Gets or sets a value that indicates whether OS-specific visual style glyphs are used for the expansion /// nodes in the grid area. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [SRCategory(nameof(SR.CatAppearance))] [SRDescription(nameof(SR.PropertyGridCanShowVisualStyleGlyphsDesc))] [DefaultValue(true)] @@ -789,6 +799,7 @@ public bool CanShowVisualStyleGlyphs } } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [SRCategory(nameof(SR.CatAppearance))] [SRDescription(nameof(SR.PropertyGridLineColorDesc))] [DefaultValue(typeof(Color), "InactiveBorder")] @@ -902,6 +913,7 @@ public object? SelectedObject public object[] SelectedObjects { get => _selectedObjects is null ? Array.Empty() : (object[])_selectedObjects.Clone(); + [RequiresUnreferencedCode("")] set { using FreezePaintScope _ = new(this); @@ -1271,6 +1283,7 @@ protected ToolStripRenderer? ToolStripRenderer } } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [SRCategory(nameof(SR.CatAppearance))] [SRDescription(nameof(SR.PropertyGridViewBackColorDesc))] [DefaultValue(typeof(Color), "Window")] @@ -1284,6 +1297,7 @@ public Color ViewBackColor } } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [SRCategory(nameof(SR.CatAppearance))] [SRDescription(nameof(SR.PropertyGridViewForeColorDesc))] [DefaultValue(typeof(Color), "WindowText")] @@ -1300,6 +1314,7 @@ public Color ViewForeColor /// /// Border color for the property grid view. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [SRCategory(nameof(SR.CatAppearance))] [SRDescription(nameof(SR.PropertyGridViewBorderColorDesc))] [DefaultValue(typeof(Color), "ControlDark")] @@ -1988,6 +2003,7 @@ private static void DrawXorBar(Control targetControl, Rectangle rcFrame) } } + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetEditor(Object, Type)")] private bool EnablePropPageButton(object? obj) { if (_viewPropertyPagesButton is null) @@ -2360,6 +2376,7 @@ private void OnActiveDesignerChanged(object? sender, ActiveDesignerEventArgs e) /// /// Called when a property on an Ole32 Object changes. /// + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetClassName(Object)")] HRESULT IPropertyNotifySink.Interface.OnChanged(int dispID) { // We don't want the grid's own property sets doing this, but if we're getting @@ -2937,6 +2954,7 @@ protected virtual void OnPropertyValueChanged(PropertyValueChangedEventArgs e) ((PropertyValueChangedEventHandler?)Events[s_propertyValueChangedEvent])?.Invoke(this, e); } + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetEditor(Type, Type)")] internal void OnPropertyValueSet(GridItem changedItem, object? oldValue) { OnPropertyValueChanged(new PropertyValueChangedEventArgs(changedItem, oldValue)); @@ -3115,6 +3133,7 @@ private void OnViewTabButtonClick(object? sender, EventArgs e) OnButtonClick(sender, e); } + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetEditor(Object, Type)")] private void OnViewPropertyPagesButtonClick(object? sender, EventArgs e) { if (_viewPropertyPagesButton!.Enabled && @@ -3828,6 +3847,7 @@ private void SetToolStripRenderer() private void SetupToolbar() => SetupToolbar(fullRebuild: false); + [RequiresUnreferencedCode("Calls System.Windows.Forms.PropertyGrid.OnViewPropertyPagesButtonClick(Object, EventArgs)")] private void SetupToolbar(bool fullRebuild) { // If the tab array hasn't changed, don't bother to do all this work. @@ -4261,6 +4281,7 @@ private void RescaleConstants() _toolStripButtonPaddingY = LogicalToDeviceUnits(ToolStripButtonPaddingY); } + [RequiresUnreferencedCode("")] protected override unsafe void WndProc(ref Message m) { switch (m.MsgInternal) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/GridEntry.Flags.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/GridEntry.Flags.cs index fa32947acfd..6377200b75f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/GridEntry.Flags.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/GridEntry.Flags.cs @@ -11,7 +11,7 @@ internal abstract partial class GridEntry [Flags] public enum Flags { - TextEditable = 0x00000001, + TextEditable = 0x00000001, /// /// The supports standard values. @@ -21,60 +21,60 @@ public enum Flags /// /// The current returned true for . /// - CustomPaint = 0x00000004, + CustomPaint = 0x00000004, /// /// The current is . /// - ModalEditable = 0x00000010, + ModalEditable = 0x00000010, /// /// The current is . /// - DropDownEditable = 0x00000020, + DropDownEditable = 0x00000020, /// /// True if the label should be rendered in bold text. Used by . /// - LabelBold = 0x00000040, + LabelBold = 0x00000040, /// /// True when the value cannot be edited via the text box, but has a modal editor (`...` button). /// - ReadOnlyEditable = 0x00000080, + ReadOnlyEditable = 0x00000080, - RenderReadOnly = 0x00000100, + RenderReadOnly = 0x00000100, /// /// True when the value is attributed with or the /// indicates that it is immutable. /// - Immutable = 0x00000200, + Immutable = 0x00000200, /// /// Used to distribute read-only behavior to child properties when the root is /// read-only or one of the objects in the root (with multiple select) is read-only. /// - ForceReadOnly = 0x00000400, + ForceReadOnly = 0x00000400, /// /// True when is set. /// - RenderPassword = 0x00001000, + RenderPassword = 0x00001000, - Disposed = 0x00002000, - Expand = 0x00010000, - Expandable = 0x00020000, - ExpandableFailed = 0x00080000, + Disposed = 0x00002000, + Expand = 0x00010000, + Expandable = 0x00020000, + ExpandableFailed = 0x00080000, /// /// Inverse of that is only used when full flags have not been checked. /// - NoCustomPaint = 0x00100000, + NoCustomPaint = 0x00100000, /// /// Set when all the flags have been checked. /// - Checked = unchecked((int)0x80000000) + Checked = unchecked((int)0x80000000) } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/GridEntry.PaintValueFlags.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/GridEntry.PaintValueFlags.cs index 5b3a392ba1c..b3565123619 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/GridEntry.PaintValueFlags.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/GridEntry.PaintValueFlags.cs @@ -8,9 +8,9 @@ internal abstract partial class GridEntry [Flags] internal enum PaintValueFlags { - None = 0x0, - DrawSelected = 0x1, - CheckShouldSerialize = 0x4, - PaintInPlace = 0x8 + None = 0x0, + DrawSelected = 0x1, + CheckShouldSerialize = 0x4, + PaintInPlace = 0x8 } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/GridEntry.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/GridEntry.cs index dc29485bea0..ce35d8b59a5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/GridEntry.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/GridEntry.cs @@ -744,6 +744,7 @@ public virtual bool ShouldRenderReadOnly /// /// Returns the type converter for this entry. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] internal virtual TypeConverter TypeConverter => _typeConverter ??= TypeDescriptor.GetConverter(PropertyValue ?? PropertyType); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/ImmutablePropertyDescriptorGridEntry.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/ImmutablePropertyDescriptorGridEntry.cs index 353fa847fb5..8e2a76d5d2d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/ImmutablePropertyDescriptorGridEntry.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/ImmutablePropertyDescriptorGridEntry.cs @@ -33,6 +33,7 @@ internal ImmutablePropertyDescriptorGridEntry( public override object? PropertyValue { get => base.PropertyValue; + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeConverter.GetProperties(ITypeDescriptorContext, Object)")] set { // Create a new instance of the value and set it into the parent grid entry. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/MergePropertyDescriptor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/MergePropertyDescriptor.cs index 553d9032a7d..1570726e942 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/MergePropertyDescriptor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/MergePropertyDescriptor.cs @@ -27,6 +27,7 @@ public MergePropertyDescriptor(PropertyDescriptor[] descriptors) public override Type ComponentType => _descriptors[0].ComponentType; + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] public override TypeConverter Converter { [RequiresUnreferencedCode(PropertyDescriptorPropertyTypeMessage)] @@ -105,6 +106,7 @@ public override bool CanResetValue(object component) /// This method attempts to copy the given value so unique values are always passed to each object. /// If the value cannot be copied the original value will be returned. /// + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetConverter(Object)")] private static object? CopyValue(object? value) { // Null is always OK. @@ -308,6 +310,7 @@ private void SetCollectionValues(Array a, IList listValue) } } + [RequiresUnreferencedCode("Calls System.Windows.Forms.PropertyGridInternal.MergePropertyDescriptor.CopyValue(Object)")] public override void SetValue(object? component, object? value) { Debug.Assert(component is Array, "MergePropertyDescriptor::SetValue called with non-array value"); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/MultiPropertyDescriptorGridEntry.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/MultiPropertyDescriptorGridEntry.cs index 90af02da813..b1c55561aea 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/MultiPropertyDescriptorGridEntry.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/MultiPropertyDescriptorGridEntry.cs @@ -196,6 +196,7 @@ internal override bool SendNotification(GridEntry entry, Notify notification) } } + [RequiresUnreferencedCode("Calls System.ComponentModel.AttributeCollection.Contains(Attribute)")] protected override void NotifyParentsOfChanges(GridEntry entry) { // Now see if we need to notify the parent(s) up the chain. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/MultiSelectRootGridEntry.PropertyMerger.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/MultiSelectRootGridEntry.PropertyMerger.cs index 7aea823cb7d..c9f2ac4ff34 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/MultiSelectRootGridEntry.PropertyMerger.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/MultiSelectRootGridEntry.PropertyMerger.cs @@ -287,7 +287,7 @@ private static List UnsortedMerge( int result = string.Compare(entryName, sortString, ignoreCase: false, CultureInfo.InvariantCulture); if (result == 0) { - mergedEntries.Add([basePropertyDescriptor, ..propertyDescriptors]); + mergedEntries.Add([basePropertyDescriptor, .. propertyDescriptors]); break; } else if (result < 0) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/MultiSelectRootGridEntry.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/MultiSelectRootGridEntry.cs index 251b4ba756e..c4dbd82f154 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/MultiSelectRootGridEntry.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/MultiSelectRootGridEntry.cs @@ -15,6 +15,7 @@ internal sealed partial class MultiSelectRootGridEntry : SingleSelectRootGridEnt { private static readonly PropertyDescriptorComparer s_propertyComparer = new(); + [RequiresUnreferencedCode("Calls System.Windows.Forms.PropertyGridInternal.SingleSelectRootGridEntry.SingleSelectRootGridEntry(PropertyGridView, Object, IServiceProvider, IDesignerHost, PropertyTab, PropertySort)")] internal MultiSelectRootGridEntry( PropertyGridView view, object[] target, @@ -28,6 +29,7 @@ internal MultiSelectRootGridEntry( internal override bool ForceReadOnly { + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetAttributes(Object)")] get { if (!_forceReadOnlyChecked) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertiesTab.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertiesTab.cs index 2859609182d..af174e6525d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertiesTab.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertiesTab.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel; @@ -13,6 +13,7 @@ public class PropertiesTab : PropertyTab public override string HelpKeyword => "vs.properties"; // do not localize. #pragma warning disable CA1725 // Parameter names should match base declaration - publicly shipped API + [RequiresUnreferencedCode("")] public override PropertyDescriptor? GetDefaultProperty(object obj) #pragma warning restore CA1725 { @@ -40,6 +41,7 @@ public class PropertiesTab : PropertyTab public override PropertyDescriptorCollection? GetProperties(object component, Attribute[]? attributes) => GetProperties(context: null, component, attributes); + [RequiresUnreferencedCode("")] public override PropertyDescriptorCollection? GetProperties(ITypeDescriptorContext? context, object component, Attribute[]? attributes) { attributes ??= new Attribute[] { BrowsableAttribute.Yes }; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyDescriptorGridEntry.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyDescriptorGridEntry.cs index ea9172f8ddf..348449c7ccc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyDescriptorGridEntry.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyDescriptorGridEntry.cs @@ -265,6 +265,7 @@ public override bool ShouldRenderReadOnly } } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] internal override TypeConverter TypeConverter { get @@ -280,6 +281,7 @@ internal override TypeConverter TypeConverter } } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] internal override UITypeEditor UITypeEditor { get diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.DropDownHolder.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.DropDownHolder.cs index bcf9207e3e5..505c2648db8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.DropDownHolder.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.DropDownHolder.cs @@ -175,6 +175,7 @@ public unsafe void DoModalLoop() public Control? Component => _currentControl; + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] private static InstanceCreationEditor? GetInstanceCreationEditor(PropertyDescriptorGridEntry? entry) { // First we look on the property type, and if we don't find that we'll go up to the editor type diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.Flags.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.Flags.cs index a02f11f883f..537dd58d22f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.Flags.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.Flags.cs @@ -8,20 +8,20 @@ internal sealed partial class PropertyGridView [Flags] private enum Flags : ushort { - NeedsRefresh = 0x0001, - IsNewSelection = 0x0002, - IsSplitterMove = 0x0004, - IsSpecialKey = 0x0008, - InPropertySet = 0x0010, - DropDownClosing = 0x0020, - DropDownCommit = 0x0040, + NeedsRefresh = 0x0001, + IsNewSelection = 0x0002, + IsSplitterMove = 0x0004, + IsSpecialKey = 0x0008, + InPropertySet = 0x0010, + DropDownClosing = 0x0020, + DropDownCommit = 0x0040, NeedUpdateUIBasedOnFont = 0x0080, /// /// The editor is currently launched via the drop-down button. /// - ButtonLaunchedEditor = 0x0100, - NoDefault = 0x0200, - ResizableDropDown = 0x0400 + ButtonLaunchedEditor = 0x0100, + NoDefault = 0x0200, + ResizableDropDown = 0x0400 } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.GridViewTextBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.GridViewTextBox.cs index 03973f0a195..2f7c1f62a81 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.GridViewTextBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.GridViewTextBox.cs @@ -176,6 +176,7 @@ protected override void OnMouseEnter(EventArgs e) } } + [RequiresUnreferencedCode("Calls System.Windows.Forms.PropertyGrid.OnPropertyValueSet(GridItem, Object)")] protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { // Make sure we allow the Edit to handle ctrl-z. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.cs index 703e725487f..b6854763fbb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.cs @@ -4756,6 +4756,7 @@ private bool CommitValue(object value) return CommitValue(currentEntry, value); } + [RequiresUnreferencedCode("Calls System.Windows.Forms.PropertyGrid.OnPropertyValueSet(GridItem, Object)")] internal bool CommitValue(GridEntry entry, object value, bool closeDropDown = true) { CompModSwitches.DebugGridView.TraceVerbose($"PropertyGridView:CommitValue({value?.ToString() ?? "null"})"); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/SingleSelectRootGridEntry.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/SingleSelectRootGridEntry.cs index d01d9210e9f..e4d65c79152 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/SingleSelectRootGridEntry.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/SingleSelectRootGridEntry.cs @@ -23,6 +23,7 @@ internal class SingleSelectRootGridEntry : GridEntry, IRootGridEntry private IComponentChangeService? _changeService; protected bool _forceReadOnlyChecked; + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetClassName(Object)")] internal SingleSelectRootGridEntry( PropertyGridView ownerGridView, object target, @@ -119,6 +120,7 @@ internal sealed override IDesignerHost? DesignerHost internal override bool ForceReadOnly { + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetAttributes(Object)")] get { if (!_forceReadOnlyChecked) @@ -175,6 +177,7 @@ public override string? PropertyLabel public override object PropertyValue { get => Target; + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetClassName(Object)")] set { object old = Target; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TabControl/TabPage.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TabControl/TabPage.cs index 36b6a8fa764..4adf57f9f62 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TabControl/TabPage.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TabControl/TabPage.cs @@ -108,6 +108,8 @@ public override Color BackColor return color; } + + [RequiresUnreferencedCode("")] set { if (DesignMode) @@ -336,6 +338,7 @@ public bool UseVisualStyleBackColor remove => base.LocationChanged -= value; } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [DefaultValue(typeof(Size), "0, 0")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/OpacityConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/OpacityConverter.cs index 304e0c58096..e32b2a8e281 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/OpacityConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/OpacityConverter.cs @@ -29,6 +29,7 @@ public override bool CanConvertFrom(ITypeDescriptorContext? context, Type source /// /// Converts the given object to the converter's native type. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) { if (value is string valueString) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStrip.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStrip.cs index 23abca95b0f..8ed8f9f6c8b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStrip.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStrip.cs @@ -954,6 +954,7 @@ internal bool HasVisibleItems get => base.HorizontalScroll; } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [DefaultValue(typeof(Size), "16,16")] [SRCategory(nameof(SR.CatAppearance))] [SRDescription(nameof(SR.ToolStripImageScalingSizeDescr))] diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStripMenuItem.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStripMenuItem.cs index f067e7539bf..653e1f3470d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStripMenuItem.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStripMenuItem.cs @@ -1112,6 +1112,7 @@ internal void SetNativeTargetWindow(IWin32Window window) /// this is to support routing to native menu commands internal void SetNativeTargetMenu(HMENU hmenu) => _nativeMenuHandle = hmenu; + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] internal static string? ShortcutToText(Keys shortcutKeys, string? shortcutKeyDisplayString) { if (!string.IsNullOrEmpty(shortcutKeyDisplayString)) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TreeView/TreeView.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TreeView/TreeView.cs index 7b95d2b739b..363c7106ac6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TreeView/TreeView.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TreeView/TreeView.cs @@ -844,6 +844,7 @@ public bool LabelEdit /// /// This is the color of the lines that connect the nodes of the TreeView. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [SRCategory(nameof(SR.CatBehavior))] [SRDescription(nameof(SR.TreeViewLineColorDescr))] [DefaultValue(typeof(Color), "Black")] diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TreeView/TreeViewImageIndexConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TreeView/TreeViewImageIndexConverter.cs index 052e6213aab..aee3a163a52 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TreeView/TreeViewImageIndexConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TreeView/TreeViewImageIndexConverter.cs @@ -72,6 +72,7 @@ protected override bool IncludeNoneAsStandardValue /// will return null if the data type does not support a /// standard set of values. /// + [RequiresUnreferencedCode("")] public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context) { if (context is not null && context.Instance is not null) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/WebBrowser/WebBrowserBase.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/WebBrowser/WebBrowserBase.cs index f984c8d300c..680f1ed13c1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/WebBrowser/WebBrowserBase.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/WebBrowser/WebBrowserBase.cs @@ -740,6 +740,7 @@ internal void SetEditMode(WebBrowserHelper.AXEditMode em) _axEditMode = em; } + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetProperties(Object)")] internal void SetSelectionStyle(WebBrowserHelper.SelectionStyle selectionStyle) { if (DesignMode) @@ -1062,6 +1063,7 @@ private void DetachInterfacesInternal() // // We need to do special stuff (convert window messages to interface calls) // during design time when selection changes. + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetProperties(Object)")] private void OnNewSelection(object? sender, EventArgs e) { if (DesignMode) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/WebBrowser/WebBrowserContainer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/WebBrowser/WebBrowserContainer.cs index 3473d69bce0..e70ad176d2a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/WebBrowser/WebBrowserContainer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/WebBrowser/WebBrowserContainer.cs @@ -86,6 +86,7 @@ HRESULT IOleInPlaceFrame.Interface.GetWindow(HWND* phwnd) HRESULT IOleInPlaceFrame.Interface.SetBorderSpace(RECT* pborderwidths) => HRESULT.E_NOTIMPL; + [RequiresUnreferencedCode("Calls System.Windows.Forms.WebBrowserBase.SetSelectionStyle(SelectionStyle)")] HRESULT IOleInPlaceFrame.Interface.SetActiveObject(IOleInPlaceActiveObject* pActiveObject, PCWSTR pszObjName) { if (pActiveObject is null) @@ -387,6 +388,7 @@ internal void OnUIActivate(WebBrowserBase site) } } + [RequiresUnreferencedCode("Calls System.Windows.Forms.WebBrowserBase.SetSelectionStyle(SelectionStyle)")] internal void OnUIDeactivate(WebBrowserBase site) { #if DEBUG diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/Binding.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/Binding.cs index ab44263b41c..cd938d8d7c5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/Binding.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/Binding.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel; @@ -133,6 +133,7 @@ public Binding( { } + [RequiresUnreferencedCode("")] public Binding( string propertyName, object? dataSource, @@ -188,6 +189,7 @@ internal static bool IsComponentCreated(IBindableComponent? component) /// internal bool ComponentCreated => IsComponentCreated(BindableComponent); + [RequiresUnreferencedCode("Calls System.Windows.Forms.Binding.CheckBinding()")] private void FormLoaded(object? sender, EventArgs e) { Debug.Assert(sender == BindableComponent, "which other control can send us the Load event?"); @@ -195,6 +197,7 @@ private void FormLoaded(object? sender, EventArgs e) CheckBinding(); } + [RequiresUnreferencedCode("Calls System.Windows.Forms.Binding.CheckBinding()")] internal void SetBindableComponent(IBindableComponent? value) { if (BindableComponent != value) @@ -237,6 +240,7 @@ internal void SetBindableComponent(IBindableComponent? value) public BindingManagerBase? BindingManagerBase { get => _bindingManagerBase; + [RequiresUnreferencedCode("Calls System.Windows.Forms.Binding.CheckBinding()")] internal set { if (_bindingManagerBase != value) @@ -462,12 +466,14 @@ private void BindTarget(bool bind) } } + [RequiresUnreferencedCode("Calls System.Windows.Forms.Binding.CheckBinding()")] private void binding_MetaDataChanged(object? sender, EventArgs e) { Debug.Assert(sender == _bindingManagerBase, "we should only receive notification from our binding manager base"); CheckBinding(); } + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetAttributes(Object)")] private void CheckBinding() { _bindToObject.CheckBinding(); @@ -668,6 +674,7 @@ protected virtual void OnFormat(ConvertEventArgs cevent) } } + [RequiresUnreferencedCode("Calls System.ComponentModel.PropertyDescriptor.Converter")] private object? ParseObject(object? value) { Type? type = _bindToObject.BindToType; @@ -736,6 +743,7 @@ protected virtual void OnFormat(ConvertEventArgs cevent) } } + [RequiresUnreferencedCode("Calls System.ComponentModel.PropertyDescriptor.Converter")] private object? FormatObject(object? value) { // We will not format the object when the control is in design time. @@ -823,6 +831,7 @@ protected virtual void OnFormat(ConvertEventArgs cevent) internal bool PullData(bool reformat) => PullData(reformat, force: false); + [RequiresUnreferencedCode("Calls System.Windows.Forms.Binding.ParseObject(Object)")] internal bool PullData(bool reformat, bool force) { // Don't update the control if the control update mode is never. @@ -959,6 +968,7 @@ internal bool PullData(bool reformat, bool force) /// internal bool PushData() => PushData(force: false); + [RequiresUnreferencedCode("Calls System.Windows.Forms.Binding.FormatObject(Object)")] internal bool PushData(bool force) { object? dataSourceValue = null; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/BindingManagerBase.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/BindingManagerBase.cs index 2bb8fae9c1d..bf7c1cb9445 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/BindingManagerBase.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/BindingManagerBase.cs @@ -73,6 +73,7 @@ internal BindingManagerBase(object? dataSource) public virtual PropertyDescriptorCollection GetItemProperties() => GetItemProperties(listAccessors: null); + [RequiresUnreferencedCode("Calls System.Windows.Forms.BindingManagerBase.GetItemProperties(Type, Int32, ArrayList, ArrayList)")] protected internal virtual PropertyDescriptorCollection? GetItemProperties(ArrayList dataSources, ArrayList listAccessors) { IList? list = null; @@ -91,6 +92,7 @@ internal BindingManagerBase(object? dataSource) return GetItemProperties(BindType, 0, dataSources, listAccessors); } + [RequiresUnreferencedCode("")] protected virtual PropertyDescriptorCollection? GetItemProperties( [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type listType, int offset, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/BindingSource.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/BindingSource.cs index f34ba1e69a5..60dcf21807f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/BindingSource.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/BindingSource.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections; @@ -510,6 +510,7 @@ private void ThrowIfBindingSourceRecursionDetected(object? newDataSource) } } + [RequiresUnreferencedCode("Calls System.Windows.Forms.BindingSource.IsDataMemberValid()")] private void ClearInvalidDataMember() { if (!IsDataMemberValid()) @@ -711,6 +712,7 @@ private static IList GetListFromType(Type type) /// Decides whether this would be a good time to blow away the data member field, since it /// might not refer to a valid data source property any more. /// + [RequiresUnreferencedCode("Calls System.Windows.Forms.ListBindingHelper.GetListItemProperties(Object)")] private bool IsDataMemberValid() { // Don't mess with things during initialization because the data @@ -872,6 +874,7 @@ protected virtual void OnPositionChanged(EventArgs e) /// In either case, we only have to change lists, not metadata, since we can assume /// that the new list has the same item properties as the old list. /// + [RequiresUnreferencedCode("Calls System.Windows.Forms.BindingSource.SetList(IList, Boolean, Boolean)")] private void ParentCurrencyManager_CurrentItemChanged(object? sender, EventArgs e) { if (_initializing) @@ -1072,6 +1075,7 @@ public void ResetItem(int itemIndex) /// Binds the BindingSource to the list specified by its DataSource and DataMember /// properties. /// + [RequiresUnreferencedCode("Calls System.Windows.Forms.ListBindingHelper.GetList(Object, String)")] private void ResetList() { // Don't bind during initialization, since the data source may not have been initialized yet. @@ -1152,6 +1156,7 @@ private void ResetList() /// Binds the BindingSource to the specified list, rewiring internal event handlers, /// firing any appropriate external events, and updating all relevant field members. /// + [RequiresUnreferencedCode("Calls System.Windows.Forms.ListBindingHelper.GetListItemProperties(Object)")] private void SetList(IList list, bool metaDataChanged, bool applySortAndFilter) { if (list is null) @@ -1469,6 +1474,7 @@ public virtual int Count [Browsable(false)] public virtual object SyncRoot => List.SyncRoot; + [RequiresUnreferencedCode("")] public virtual int Add(object? value) { int ret = -1; @@ -1555,6 +1561,7 @@ public virtual object? this[int index] public virtual string GetListName(PropertyDescriptor[]? listAccessors) => ListBindingHelper.GetListName(List, listAccessors); + [RequiresUnreferencedCode("")] public virtual PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[]? listAccessors) { object? ds = ListBindingHelper.GetList(_dataSource); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/ListBindingConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/ListBindingConverter.cs index d55152baf4f..9d88a3a9a34 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/ListBindingConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/ListBindingConverter.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections; @@ -61,6 +61,7 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destina /// type is string. If this cannot convert to the destination type, this will /// throw a NotSupportedException. /// + [RequiresUnreferencedCode("")] public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType) { ArgumentNullException.ThrowIfNull(destinationType); @@ -111,6 +112,7 @@ public override bool GetCreateInstanceSupported(ITypeDescriptorContext? context) /// Gets the best matching ctor for a given binding and fills it out, based on the /// state of the Binding and the optimal ctor. /// + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetProperties(Object)")] private static InstanceDescriptor GetInstanceDescriptorFromValues(Binding b) { // The BindingFormattingDialog turns on Binding::FormattingEnabled property. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/ListBindingHelper.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/ListBindingHelper.cs index a8165cdeb45..6f08589a849 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/ListBindingHelper.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/ListBindingHelper.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections; @@ -33,6 +33,7 @@ private static Attribute[] BrowsableAttributeList } } + [RequiresUnreferencedCode("")] public static object? GetList(object? dataSource, string? dataMember) { // @@ -124,6 +125,7 @@ public static string GetListName(object? list, PropertyDescriptor[]? listAccesso return name; } + [RequiresUnreferencedCode("")] public static PropertyDescriptorCollection GetListItemProperties(object? list) { PropertyDescriptorCollection pdc; @@ -157,6 +159,7 @@ public static PropertyDescriptorCollection GetListItemProperties(object? list) return pdc; } + [RequiresUnreferencedCode("")] public static PropertyDescriptorCollection GetListItemProperties(object? list, PropertyDescriptor[]? listAccessors) { if (listAccessors is null || listAccessors.Length == 0) @@ -182,6 +185,7 @@ public static PropertyDescriptorCollection GetListItemProperties(object? list, P return GetListItemPropertiesByInstance(target, listAccessors, 0); } + [RequiresUnreferencedCode("")] public static PropertyDescriptorCollection GetListItemProperties(object? dataSource, string? dataMember, PropertyDescriptor[]? listAccessors) { dataSource = GetList(dataSource); @@ -281,6 +285,7 @@ public static PropertyDescriptorCollection GetListItemProperties(object? dataSou return instancedObject; } + [RequiresUnreferencedCode("")] public static Type GetListItemType(object? dataSource, string? dataMember) { // No data source @@ -353,6 +358,7 @@ private static string GetListNameFromType(Type type) return name; } + [RequiresUnreferencedCode("Calls System.Windows.Forms.ListBindingHelper.GetListItemProperties(Object)")] private static PropertyDescriptorCollection GetListItemPropertiesByType(Type type, PropertyDescriptor[] listAccessors, int startIndex) { PropertyDescriptorCollection? pdc = null; @@ -388,6 +394,7 @@ private static PropertyDescriptorCollection GetListItemPropertiesByType(Type typ return pdc; } + [RequiresUnreferencedCode("Calls System.Windows.Forms.ListBindingHelper.GetListItemPropertiesByEnumerable(IEnumerable)")] private static PropertyDescriptorCollection GetListItemPropertiesByEnumerable(IEnumerable iEnumerable, PropertyDescriptor[] listAccessors, int startIndex) { PropertyDescriptorCollection? pdc = null; @@ -452,6 +459,7 @@ private static Type GetListItemTypeByEnumerable(IEnumerable iEnumerable) return (instance is not null) ? instance.GetType() : typeof(object); } + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetProperties(Object, Attribute[])")] private static PropertyDescriptorCollection GetListItemPropertiesByInstance(object? target, PropertyDescriptor[] listAccessors, int startIndex) { Debug.Assert(listAccessors is not null); @@ -572,11 +580,13 @@ private static bool IsListBasedType(Type type) return indexer; } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] private static PropertyDescriptorCollection GetListItemPropertiesByType(Type type) { return TypeDescriptor.GetProperties(GetListItemType(type), BrowsableAttributeList); } + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetProperties(Type, Attribute[])")] private static PropertyDescriptorCollection GetListItemPropertiesByEnumerable(IEnumerable enumerable) { PropertyDescriptorCollection? pdc = null; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/PropertyManager.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/PropertyManager.cs index cda490d611f..c765187828d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/PropertyManager.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataBinding/PropertyManager.cs @@ -24,6 +24,7 @@ private void PropertyChanged(object? sender, EventArgs ea) OnCurrentChanged(EventArgs.Empty); } + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetProperties(Object)")] private protected override void SetDataSource(object? dataSource) { if (_dataSource is not null && !string.IsNullOrEmpty(_propName)) @@ -67,6 +68,7 @@ internal override PropertyDescriptorCollection GetItemProperties(PropertyDescrip internal override Type BindType => _dataSource!.GetType(); + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetClassName(Object)")] internal override string GetListName() { return $"{TypeDescriptor.GetClassName(_dataSource!)}.{_propName}"; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Design/EventsTab.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Design/EventsTab.cs index 07e709cf318..29c16888213 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Design/EventsTab.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Design/EventsTab.cs @@ -30,6 +30,7 @@ public class EventsTab : PropertyTab private void OnActiveDesignerChanged(object? sender, ActiveDesignerEventArgs e) => _currentHost = e.NewDesigner; + [RequiresUnreferencedCode("")] public override PropertyDescriptor? GetDefaultProperty(object obj) { if (GetEventBindingService(obj, context: null) is not IEventBindingService eventPropertyService) @@ -94,6 +95,7 @@ public override PropertyDescriptorCollection GetProperties(object component, Att /// The uses /// to get property descriptors from . /// + [RequiresUnreferencedCode("")] public override PropertyDescriptorCollection GetProperties( ITypeDescriptorContext? context, object component, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Design/PropertyTab.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Design/PropertyTab.cs index 0de5eed8566..35e32747bad 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Design/PropertyTab.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Design/PropertyTab.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel; @@ -103,6 +103,7 @@ protected virtual void Dispose(bool disposing) /// /// Gets the default property of the specified . /// + [RequiresUnreferencedCode("")] public virtual PropertyDescriptor? GetDefaultProperty(object component) => TypeDescriptor.GetDefaultProperty(component); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Dialogs/CommonDialogs/FontDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Dialogs/CommonDialogs/FontDialog.cs index 082b7d26fcc..2d197d4952c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Dialogs/CommonDialogs/FontDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Dialogs/CommonDialogs/FontDialog.cs @@ -89,6 +89,7 @@ public bool AllowScriptChange /// /// Gets or sets a value indicating the selected font color. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [SRCategory(nameof(SR.CatData))] [SRDescription(nameof(SR.FnDcolorDescr))] [DefaultValue(typeof(Color), "Black")] diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs index e20273d3e2a..13c814a03ad 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs @@ -1252,6 +1252,7 @@ public event EventHandler? MaximizedBoundsChanged /// /// Gets the maximum size the form can be resized to. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [SRCategory(nameof(SR.CatLayout))] [Localizable(true)] [SRDescription(nameof(SR.FormMaximumSizeDescr))] diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ImageIndexConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ImageIndexConverter.cs index 4889b6b27b5..d223fb997f7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ImageIndexConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ImageIndexConverter.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel; @@ -85,6 +85,7 @@ protected virtual bool IncludeNoneAsStandardValue /// If no image list is found, this collection will contain a single object with a value of -1. /// This returns if the data type doesn't support a standard set of values. /// + [RequiresUnreferencedCode("")] public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context) { if (context is not null && context.Instance is not null) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ImageKeyConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ImageKeyConverter.cs index d4eb3b8f166..ff1e53d72d0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ImageKeyConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ImageKeyConverter.cs @@ -102,6 +102,7 @@ public override bool CanConvertFrom(ITypeDescriptorContext? context, Type source /// will return null if the data type does not support a /// standard set of values. /// + [RequiresUnreferencedCode("")] public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context) { if (context is not null && context.Instance is not null) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Formatter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Formatter.cs index 2872982211b..1aa980957b2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Formatter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Formatter.cs @@ -25,6 +25,7 @@ internal static class Formatter /// If the caller is expecting a nullable value back, we must also re-wrap the final result /// inside a nullable value before returning. /// + [RequiresUnreferencedCode("Calls System.Windows.Forms.Formatter.FormatObjectInternal(Object, Type, TypeConverter, TypeConverter, String, IFormatProvider, Object)")] public static object? FormatObject( object? value, Type targetType, @@ -82,6 +83,7 @@ internal static class Formatter /// - Uses TypeConverters or IConvertible where appropriate /// - Throws a FormatException is no suitable conversion can be found /// + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetConverter(Type)")] private static object? FormatObjectInternal( object? value, Type targetType, @@ -212,6 +214,7 @@ internal static class Formatter /// If the caller is expecting a nullable value back, we must also re-wrap the final result /// inside a nullable value before returning. /// + [RequiresUnreferencedCode("Calls System.Windows.Forms.Formatter.ParseObjectInternal(Object, Type, Type, TypeConverter, TypeConverter, IFormatProvider, Object)")] public static object? ParseObject( object? value, Type targetType, @@ -263,6 +266,7 @@ internal static class Formatter /// - Uses TypeConverters or IConvertible where appropriate /// - Throws a FormatException if no suitable conversion can be found /// + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetConverter(Type)")] private static object? ParseObjectInternal( object? value, Type targetType, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/CommonProperties.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/CommonProperties.cs index f9383ccc796..6442b5192a6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/CommonProperties.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/CommonProperties.cs @@ -719,6 +719,7 @@ internal static void SetLayoutState(IArrangedElement element, BitVector32 state) internal static readonly TraceSwitch PreferredSize = new("PreferredSize", "Debug preferred size assertion"); + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetProperties(Object)")] internal static string Debug_GetChangedProperties(IArrangedElement element) { string diff = string.Empty; @@ -747,6 +748,7 @@ internal static string Debug_GetChangedProperties(IArrangedElement element) return diff; } + [RequiresUnreferencedCode("Calls System.Windows.Forms.Layout.CommonProperties.Debug_GetCurrentPropertyState(Object)")] internal static void Debug_SnapProperties(IArrangedElement element) { // DEBUG - store off the old state so we can figure out what has changed in a GPS assert @@ -759,6 +761,7 @@ internal static void Debug_ClearProperties(IArrangedElement element) element.Properties.SetObject(_lastKnownStateProperty, null); } + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetProperties(Object)")] public static Dictionary Debug_GetCurrentPropertyState(object obj) { Dictionary propertyHash = new(); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/Containers/SplitContainer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/Containers/SplitContainer.cs index 0be88c30f0a..78620da032e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/Containers/SplitContainer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/Containers/SplitContainer.cs @@ -129,6 +129,7 @@ public override bool AutoScroll set => base.AutoScroll = value; } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] [DefaultValue(typeof(Point), "0, 0")] diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MDI/MDIWindowDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MDI/MDIWindowDialog.cs index ab5e06b7f3d..34418ee1ceb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MDI/MDIWindowDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MDI/MDIWindowDialog.cs @@ -11,6 +11,7 @@ internal sealed partial class MdiWindowDialog : Form private TableLayoutPanel _okCancelTableLayoutPanel; private Form? _active; + [RequiresUnreferencedCode("Calls System.Windows.Forms.MdiWindowDialog.InitializeComponent()")] public MdiWindowDialog() : base() { @@ -72,6 +73,7 @@ private void ItemList_selectedIndexChanged(object? source, EventArgs e) [MemberNotNull(nameof(_okButton))] [MemberNotNull(nameof(_cancelButton))] [MemberNotNull(nameof(_okCancelTableLayoutPanel))] + [RequiresUnreferencedCode("Calls System.ComponentModel.ComponentResourceManager.ApplyResources(Object, String)")] private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new(typeof(MdiWindowDialog)); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/OLE/DataObject.ComDataObjectAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/OLE/DataObject.ComDataObjectAdapter.cs index 5afb3e86528..b108128688b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/OLE/DataObject.ComDataObjectAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/OLE/DataObject.ComDataObjectAdapter.cs @@ -116,6 +116,7 @@ static unsafe string ReadUtf8StringFromHGLOBAL(HGLOBAL hglobal) return files; } + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] static object ReadObjectFromHGLOBAL(HGLOBAL hglobal, bool restrictDeserialization) { Stream stream = ReadByteStreamFromHGLOBAL(hglobal, out bool isSerializedObject); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/OLE/DataObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/OLE/DataObject.cs index 3eabd52462d..fda2c4563b7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/OLE/DataObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/OLE/DataObject.cs @@ -662,6 +662,7 @@ DataFormats.DibConstant when data is Image _ => HRESULT.E_FAIL }; + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] private static HRESULT SaveObjectToHGLOBAL(ref HGLOBAL hglobal, object data, bool restrictSerialization) { using MemoryStream stream = new(); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Panels/TableLayoutPanel/TableLayoutPanel.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Panels/TableLayoutPanel/TableLayoutPanel.cs index cf0a18b92cb..d75c81b9e91 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Panels/TableLayoutPanel/TableLayoutPanel.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Panels/TableLayoutPanel/TableLayoutPanel.cs @@ -219,6 +219,7 @@ public void SetRow(Control control, int row) } // get the row and column position of the control + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [DefaultValue(typeof(TableLayoutPanelCellPosition), "-1,-1")] // if change this value, also change the SerializeViaAdd in TableLayoutControlCollectionCodeDomSerializer [SRDescription(nameof(SR.GridPanelCellPositionDescr))] [SRCategory(nameof(SR.CatLayout))] diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Panels/TableLayoutPanel/TableLayoutSettings.TableLayoutSettingsStub.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Panels/TableLayoutPanel/TableLayoutSettings.TableLayoutSettingsStub.cs index 0e80b9b989e..be0ab2794bd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Panels/TableLayoutPanel/TableLayoutSettings.TableLayoutSettingsStub.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Panels/TableLayoutPanel/TableLayoutSettings.TableLayoutSettingsStub.cs @@ -26,6 +26,7 @@ public TableLayoutSettingsStub() /// as a result of calling this function. We hand as much over to the other settings /// so we don't have to reallocate anything /// + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetProperties(Object)")] internal void ApplySettings(TableLayoutSettings settings) { // apply row,column,rowspan,colspan diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Panels/TableLayoutPanel/TableLayoutSettings.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Panels/TableLayoutPanel/TableLayoutSettings.cs index 507439fd616..f3745c5176b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Panels/TableLayoutPanel/TableLayoutSettings.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Panels/TableLayoutPanel/TableLayoutSettings.cs @@ -39,6 +39,7 @@ internal TableLayoutSettings(IArrangedElement owner) { } + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetConverter(Object)")] private TableLayoutSettings(SerializationInfo serializationInfo, StreamingContext context) : this() { @@ -213,6 +214,7 @@ internal bool IsStub } } + [RequiresUnreferencedCode("Calls System.Windows.Forms.TableLayoutSettings.TableLayoutSettingsStub.ApplySettings(TableLayoutSettings)")] internal void ApplySettings(TableLayoutSettings settings) { if (settings.IsStub) @@ -465,6 +467,7 @@ internal TableLayoutPanelCellPosition GetPositionFromControl(IArrangedElement? e #endregion + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetConverter(Object)")] void ISerializable.GetObjectData(SerializationInfo si, StreamingContext context) { TypeConverter converter = TypeDescriptor.GetConverter(this); @@ -476,6 +479,7 @@ void ISerializable.GetObjectData(SerializationInfo si, StreamingContext context) } } + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetProperties(Object)")] internal List GetControlsInformation() { if (IsStub) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Panels/TableLayoutPanel/TableLayoutSettingsTypeConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Panels/TableLayoutPanel/TableLayoutSettingsTypeConverter.cs index 9df984039b7..9e76a5382fb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Panels/TableLayoutPanel/TableLayoutSettingsTypeConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Panels/TableLayoutPanel/TableLayoutSettingsTypeConverter.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel; @@ -60,6 +60,7 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destina return base.ConvertFrom(context, culture, value); } + [RequiresUnreferencedCode("")] public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType) { if (value is TableLayoutSettings tableLayoutSettings && (destinationType == typeof(string))) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewDialog.cs index d35337cf6a5..97d02445a47 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewDialog.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel; @@ -48,6 +48,7 @@ public partial class PrintPreviewDialog : Form /// /// Initializes a new instance of the class. /// + [RequiresUnreferencedCode("")] public PrintPreviewDialog() { base.AutoScaleBaseSize = new Size(5, 13); @@ -751,6 +752,7 @@ public PrintDocument? Document [MemberNotNull(nameof(_pageCounterItem))] [MemberNotNull(nameof(_pageCounter))] [MemberNotNull(nameof(_pageToolStripLabel))] + [RequiresUnreferencedCode("Calls System.ComponentModel.ComponentResourceManager.ApplyResources(Object, String)")] private void InitForm() { ComponentResourceManager resources = new(typeof(PrintPreviewDialog)); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Rendering/DrawingEventFlags.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Rendering/DrawingEventFlags.cs index 28005ae2fce..92e0829d232 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Rendering/DrawingEventFlags.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Rendering/DrawingEventFlags.cs @@ -11,18 +11,18 @@ internal enum DrawingEventFlags : ushort /// /// If true, consider the object to potentially have a clip or transform applied. /// - GraphicsStateUnclean = 0b0000_0001, + GraphicsStateUnclean = 0b0000_0001, /// /// Only used in . Saves the state of the at construction /// so it can be restored via . /// - SaveState = 0b0000_0010, + SaveState = 0b0000_0010, /// /// If true, will validate the state stays clean of transforms and clipping in debug builds. This is the /// default when constructing via an as it, by definition, has no /// state. /// - CheckState = 0b0000_0100 + CheckState = 0b0000_0100 } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Rendering/TextFormatFlags.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Rendering/TextFormatFlags.cs index 812cf1f9423..8562cf0b07f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Rendering/TextFormatFlags.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Rendering/TextFormatFlags.cs @@ -9,40 +9,40 @@ namespace System.Windows.Forms; [Flags] public enum TextFormatFlags { - Bottom = (int)DRAW_TEXT_FORMAT.DT_BOTTOM, - EndEllipsis = (int)DRAW_TEXT_FORMAT.DT_END_ELLIPSIS, - ExpandTabs = (int)DRAW_TEXT_FORMAT.DT_EXPANDTABS, - ExternalLeading = (int)DRAW_TEXT_FORMAT.DT_EXTERNALLEADING, - Default = default, - HidePrefix = (int)DRAW_TEXT_FORMAT.DT_HIDEPREFIX, - HorizontalCenter = (int)DRAW_TEXT_FORMAT.DT_CENTER, - Internal = (int)DRAW_TEXT_FORMAT.DT_INTERNAL, + Bottom = (int)DRAW_TEXT_FORMAT.DT_BOTTOM, + EndEllipsis = (int)DRAW_TEXT_FORMAT.DT_END_ELLIPSIS, + ExpandTabs = (int)DRAW_TEXT_FORMAT.DT_EXPANDTABS, + ExternalLeading = (int)DRAW_TEXT_FORMAT.DT_EXTERNALLEADING, + Default = default, + HidePrefix = (int)DRAW_TEXT_FORMAT.DT_HIDEPREFIX, + HorizontalCenter = (int)DRAW_TEXT_FORMAT.DT_CENTER, + Internal = (int)DRAW_TEXT_FORMAT.DT_INTERNAL, /// /// This is the default. /// - Left = (int)DRAW_TEXT_FORMAT.DT_LEFT, + Left = (int)DRAW_TEXT_FORMAT.DT_LEFT, [Obsolete("ModifyString mutates strings and should be avoided. It will be blocked in a future release.")] - ModifyString = (int)DRAW_TEXT_FORMAT.DT_MODIFYSTRING, - NoClipping = (int)DRAW_TEXT_FORMAT.DT_NOCLIP, - NoPrefix = (int)DRAW_TEXT_FORMAT.DT_NOPREFIX, - NoFullWidthCharacterBreak = (int)DRAW_TEXT_FORMAT.DT_NOFULLWIDTHCHARBREAK, - PathEllipsis = (int)DRAW_TEXT_FORMAT.DT_PATH_ELLIPSIS, - PrefixOnly = (int)DRAW_TEXT_FORMAT.DT_PREFIXONLY, - Right = (int)DRAW_TEXT_FORMAT.DT_RIGHT, - RightToLeft = (int)DRAW_TEXT_FORMAT.DT_RTLREADING, - SingleLine = (int)DRAW_TEXT_FORMAT.DT_SINGLELINE, - TextBoxControl = (int)DRAW_TEXT_FORMAT.DT_EDITCONTROL, + ModifyString = (int)DRAW_TEXT_FORMAT.DT_MODIFYSTRING, + NoClipping = (int)DRAW_TEXT_FORMAT.DT_NOCLIP, + NoPrefix = (int)DRAW_TEXT_FORMAT.DT_NOPREFIX, + NoFullWidthCharacterBreak = (int)DRAW_TEXT_FORMAT.DT_NOFULLWIDTHCHARBREAK, + PathEllipsis = (int)DRAW_TEXT_FORMAT.DT_PATH_ELLIPSIS, + PrefixOnly = (int)DRAW_TEXT_FORMAT.DT_PREFIXONLY, + Right = (int)DRAW_TEXT_FORMAT.DT_RIGHT, + RightToLeft = (int)DRAW_TEXT_FORMAT.DT_RTLREADING, + SingleLine = (int)DRAW_TEXT_FORMAT.DT_SINGLELINE, + TextBoxControl = (int)DRAW_TEXT_FORMAT.DT_EDITCONTROL, /// /// This is the default. /// - Top = (int)DRAW_TEXT_FORMAT.DT_TOP, + Top = (int)DRAW_TEXT_FORMAT.DT_TOP, - VerticalCenter = (int)DRAW_TEXT_FORMAT.DT_VCENTER, - WordBreak = (int)DRAW_TEXT_FORMAT.DT_WORDBREAK, - WordEllipsis = (int)DRAW_TEXT_FORMAT.DT_WORD_ELLIPSIS, + VerticalCenter = (int)DRAW_TEXT_FORMAT.DT_VCENTER, + WordBreak = (int)DRAW_TEXT_FORMAT.DT_WORDBREAK, + WordEllipsis = (int)DRAW_TEXT_FORMAT.DT_WORD_ELLIPSIS, /// The following flags are exclusive of TextRenderer (no Windows native flags) /// and apply to methods receiving a Graphics as the IDeviceContext object, and @@ -52,14 +52,14 @@ public enum TextFormatFlags /// These get stripped off by TextExtensions before we call DrawText or MeasureText /// (see: GdiUnsupportedFlagMask). - PreserveGraphicsClipping = 0x0100_0000, - PreserveGraphicsTranslateTransform = 0x0200_0000, + PreserveGraphicsClipping = 0x0100_0000, + PreserveGraphicsTranslateTransform = 0x0200_0000, /// /// Adds padding related to the drawing binding box, computed according to the font size. /// Match the System.Internal.GDI.TextPaddingOptions. /// - GlyphOverhangPadding = 0x0000_0000, - NoPadding = 0x1000_0000, - LeftAndRightPadding = 0x2000_0000 + GlyphOverhangPadding = 0x0000_0000, + NoPadding = 0x1000_0000, + LeftAndRightPadding = 0x2000_0000 } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip/ToolTip.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip/ToolTip.cs index 1e246200444..b7cb9d48d9e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip/ToolTip.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip/ToolTip.cs @@ -170,6 +170,7 @@ public int AutoPopDelay /// /// Gets or sets the BackColor for the control. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [SRDescription(nameof(SR.ToolTipBackColorDescr))] [DefaultValue(typeof(Color), "Info")] public Color BackColor @@ -234,6 +235,7 @@ protected virtual CreateParams CreateParams /// /// Gets or sets the ForeColor for the control. /// + [UnconditionalSuppressMessage("Trimming", "IL2026:", Justification = "")] [SRDescription(nameof(SR.ToolTipForeColorDescr))] [DefaultValue(typeof(Color), "InfoText")] public Color ForeColor diff --git a/src/System.Windows.Forms/src/misc/ImageListUtils.cs b/src/System.Windows.Forms/src/misc/ImageListUtils.cs index f21f9e589fc..c19548c07f3 100644 --- a/src/System.Windows.Forms/src/misc/ImageListUtils.cs +++ b/src/System.Windows.Forms/src/misc/ImageListUtils.cs @@ -8,6 +8,7 @@ namespace System.Windows.Forms; // Miscellaneous utilities internal static class ImageListUtils { + [RequiresUnreferencedCode("Calls System.ComponentModel.TypeDescriptor.GetProperties(Object)")] public static PropertyDescriptor? GetImageListProperty(PropertyDescriptor? currentComponent, ref object instance) { // Multiple selection is not supported.