Expand Minimize

SPC030202: 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.

// Important: Ensure to have #define CODE_ANALYSIS at the beginning of your .cs file
[SuppressMessage("SPCAF.Rules.SupportabilityGroup", "SPC030202:DoNotUseReflectionToAccessSharePointAPI", Justification = "Provide reason for suppression here")]
Disclaimer: The views and opinions expressed in this documentation and in SPCAF do not necessarily reflect the opinions and recommendations of Microsoft or any member of Microsoft. SPCAF and RENCORE are registered trademarks of RENCORE AB. All other trademarks, service marks, collective marks, copyrights, registered names, and marks used or cited by this documentation are the property of their respective owners.