Blog

My Top 3 Features of SPCAF Developer

6 min read
6 min read

Introduction

SPCAF, or the SharePoint Code Analysis Framework, comes with some pretty exciting features which a lot of different roles in an organization can utilize. In this post, I will try and highlight some of my favorite SPCAF developer features, including Visual Studio integration.

Having used this tool in anything from the smallest to the enterprise-grade projects over the last few years, I’ve seen it grow from a good utility to one of the must-have tools in your toolbox for SharePoint- and Office 365 developers. This is also one of the reasons I joined Rencore recently – to work on a great set of tools together with some of the brightest minds in the business.

With that said, let’s take a look on some of my own personal favorite features.

1. Visual Studio Integration

One of the features I’ve used on a daily basis when building software for SharePoint is the Visual Studio integration of SPCAF. Be it a console application, WSP/Full Trust Code solutions, CSOM or otherwise – a quality gate is always needed before shipping anything into production. With the Visual Studio integration, you can easily check the quality of your code in the solution before you even commit it into your source control system.

The entire toolset and services from Rencore, and specifically SPCAF, has been built by seasoned and senior consultants and SharePoint professionals who’s been working in the field for a long time. One thing that was missing for a long time was a proper code quality and guidance tool, which a developer could utilize directly from Visual Studio. Hence, SPCAF developer was designed to fill that void amongst other things.

Analyze your Solution or Project

Analyze your Solution or Project directly from Visual Studio simply by right-clicking the project or solution, and run SPCAF Code Analysis.

SPCAF developer

The benefit of using the SPCAF developer edition is that it is very easy to customize execution, select which rules you want to analyze your code against and configure what types of reports you want to generate – all within Visual Studio and SPCAF.

Detailed warnings directly at the developers’ fingertips

Once you have run analysis on a solution or project, you will find the detailed error report in a familiar place – the Error List in Visual Studio:

SPCAF developer

With the integration into the Error List, you can simply double-click an error message and you’ll be automatically directed to the exact line of code which is violating the rule:

SPCAF developer

Once you’ve reached the point where your code is violating the rule, as in the picture above, you can correct it and move on. By fixing the issue and re-running analysis on your development environment you can make sure to lower the amount of errors that flows into the code repositories when you commit/check-in your code.

Digging into each error message with the Guidance

There’s a lot of different rules that the engine is running your code through. If there is a rule which is hard to understand or if a developer is looking for more details about why the rules were broken, the built-in help for each rule comes in handy.

Simply right-click the error message, and select “Show Error Help”:

SPCAF developer

This will bring up the built-in help for SPCAF, detailing why this specific error was reported for your code:

SPCAF developer

For more information about the Visual Studio integration and a quick demo tour of the tool – please check out our SPCAF Training video where I talk about the SPCAF developer edition, plus more:

2. CSOM add-ins can be analyzed directly from VS

Originally, SPCAF was a tool that focused on the development of farm solutions (Full Trust Code).

With the evolvement made in the Microsoft product stack, including SharePoint on-premises and SharePoint Online, SPCAF have also evolved to cope with those changes.
Last year, we introduced a set of CSOM rules to analyze the Client Side Object Model for SharePoint (.NET managed code) as well.

While this CSOM support exists in all editions of SPCAF (SPCAF developer included), I think it’s important to highlight it since it might be a hidden gem.

Enable CSOM analysis (if it isn’t already)

To enable the support for CSOM analysis, if it isn’t already in your rule configuration, you can simply right-click the project or solution and select “SPCAF SharePoint Code Analysis” and then “Ruleset” as seen here:

SPCAF developer

Then select the rule set you want to edit, and click “Open”:

SPCAF developer

This will bring up the SPCAF Settings Editor. This tool allows you to design and select which analyzers and reports should be available when running analysis.

Make sure the “SPCop CSOM Analyzer” is checked, and save the ruleset either as a new file or as the current one. A personal recommendation is to always create new rules instead of modifying any existing default-rules.

When running SPCAF developer on your solution now, you’ll see that it reports errors for CSOM as well. This brings me quite naturally to the next favorite feature of mine, building custom rules.

SPCAF developer

3. Building Custom Rules

When you’ve used SPCAF for a while, you will see how powerful it is to quickly and fully automated give you a report of the quality, issues and warnings in the code base. But sometimes an organization has policies or rules which couldn’t possibly be covered by the built-in rules.

Say for example that your organization would put these requirements on your code:

  • A feature name must start with “Contoso.”
  • You must never deploy a HideCustomAction in your organization
  • You must create RemoteEventReceiver instead of Event Receiver

The list of custom rules that your organization would want to enforce can be made very long. This is why we’ve made SPCAF come with as many powerful generic rules as possible – but in order to fully cover all the bases you need, building a custom rule could be the solution to making sure everything that is committed into source control is complying with all company policies.

Read more about building custom rules here.

Summary

In this post I talked briefly about some of my personal favorite features from the SPCAF developer edition. There’s a lot more features in the tool, and in the future you might see more detailed posts from me about specific feature sets.

Also, if there’s any specific feature or functionality you’d like to learn more about – reach out to me and I’ll see if I can publish a post on that topic.

Merken

Subscribe to our newsletter