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