Do not access SharePoint API via reflection |
It is not supported to access non public properties or methods of the SharePoint API, e.g. via reflection.
CheckId | SPC030202 |
---|---|
TypeName | DoNotUseReflectionToAccessSharePointAPI |
Severity | CriticalError |
Type | Assembly |
Remove the statement for accessing the SharePoint API via a reflection call.
The rule can lead to wrong results. The rule checks for appearances of Type.GetMethod(), Type.GetProperty(), Type.GetMethods(), Type.GetProperties() with BindingFlags.NonPublic and checks if the assembly references SharePoint assemblies. This indicates a non allowed access to a non public property or method. The rule cannot check if this operation has been applied for the SharePoint API but assumes that.
To suppress this violation in managed code add the following attribute to the method which contains the instruction (available since SPCAF version v5.2). Learn more about SuppressMessage here.
[SuppressMessage("SPCAF.Rules.SupportabilityGroup", "SPC030202:DoNotUseReflectionToAccessSharePointAPI", Justification = "Provide reason for suppression here")]