SDK |
SDK |
SPCAF provides a Software Development Kit (SDK) to allow you to create your own rules, metrics or dependency checks. With the SDK you can create a new library with rules which can be dropped into the SPCAF installation and will be used automatically.
To create your custom analyzer follow these steps:
To integrate your extension into SPCAF the following metadat must be provided as attributes of your rules, metrics etc. The following table describes the metadata in detail:
Name | Description |
---|---|
Category | Defines in which category of the SPCAF reports your results should appear (e.g. 'Naming'). |
CheckId | Defines the unique ID of your rule or metric etc. The Id should start with 3 characters, like 'SPC' (for 'SharePoint Code Check'), followed by 6 digits. Follow the SPCAF Conventions for CheckId for your own CheckId. Sample: 'SPC082199' |
DisplayName | Defines the display name in reports. |
Description | Defines a description (e.g. reasons for the rule). |
DefaultSeverity | Defines the severity ('CriticalError', 'Error', 'CriticalWarning', 'Warning' or 'Info'). For rules see Rules Severity for a description of the severity. |
SharePointVersion | Defines for which SharePoint versions the extension applies. "12", "14" and "15" are supported values. |
Message | Defines the message template. |
Resolution | Provides a description of steps to solve the issue. |
Links | List of further hyperlinks to help solving the issue. A single link contains of 2 entries in the list, title and url of the link. |
For debugging of your library in Visual Studio you can use the command line tools of SPCAF, e.g. 'spcop.exe'. You have to attach the debugger of Visual Studio to one of these comannd line tools and finally can step through the code of our custom rule. Depending on the type of your custom SPCAF extension choose the appropriate command line tool:
To configure debugging follow these steps:
D:\temp\SPCAFDebug
'. This is recommended to avoid damages of the SPCAF installation.copy $(TargetPath) "D:\Temp\SPCAFDebug\"$(TargetFileName)
' to copy your assembly to the temporary folder.D:\Temp\SPCAFDebug\spcop.exe
'. -i "[DirectoryWithWSPFiles]" -r "HTML;XML" -o "D:\Temp\SPCAFDebug\SPCop.html"
'.D:\Temp\SPCAFDebug
'.
If configured correctly the SPCAF command line tool will start in a command window and your break point will be entered.
During the analysis SPCAF writes log messages to a log file. Sometimes it may be necessary for your custom rule to write to the log file too. This can be done via SPCAF.Sdk.LoggingService. See sample below:
If it is necessary to write message to the output (e.g. to the output window in Visual Studio or to the output of command line tools) you can use the following code:
To allow SPCAF to load your custom rules or metrics you need to copy your custom assembly into the installation directory of SPCAF (typically 'C:\Program Files (x86)\SPCAF\'. SPCAF will load your assembly during the next analysis.
Use the following samples as a starting point for your own SharePoint code analyzer:
comments powered by Disqus
Copyright © 2013 RENCORE AB. All Rights Reserved
Disclaimer: The views and opinions expressed in this documentation and in SPCAF are those of the creators and do not necessarily reflect the opinions and recommendations of Microsoft or any member of Microsoft. All trademarks, service marks, collective marks, copyrights, registered names, and marks used or cited by this documentation are the property of their respective owners. SharePoint Code Analysis Framework, Version 4.5.2.7855, see www.spcaf.com for more information |