CA1413: Avoid non-public fields in COM visible value types
TypeName | AvoidNonpublicFieldsInComVisibleValueTypes |
CheckId | CA1413 |
Category | Microsoft.Interoperability |
Breaking Change | Breaking |
Nonpublic instance fields of COM-visible value types are visible to COM clients. Review the content of the field for information that should not be exposed, or that will have an unintended design or security effect.
By default, all public value types are visible to COM. However, to reduce false positives, this rule requires the COM visibility of the type to be explicitly stated. The containing assembly must be marked with the System.Runtime.InteropServices.ComVisibleAttribute set to false and the type must be marked with the ComVisibleAttribute set to true.
To fix a violation of this rule and keep the field hidden, change the value type to a reference type or remove the ComVisibleAttribute attribute from the type.