Developing high quality SharePoint solutions/apps with SPCAF #SP24

2,028 views

Published on

SharePoint development and fun do not always have much in common! Everyone who has ever developed for SharePoint in Visual Studio might know what I mean. Even a small SharePoint solution consist already of a large amount of different files (xml, cs, js, css, resx, jpg, aspx, etc) which may be structured differently depending on the preferences and experience of the developer.
Particularly the extensive XML Schema for manifest.xml, feature.xml, element.xml, Content Types, List Definitions, etc. is an endless source of surprise and cannot be debugged at all in Visual Studio.

As a way out, many developers choose to develop standard SharePoint artefacts programmatically rather than following the declarative approach which make the solutions even more complex.
As a result it is really hard to analyze SharePoint solutions, find violations against the XML schema, best practices, coding guidelines or to pinpoint performance sinks and cyclomatic dependencies of artefacts.

Neither Visual Studio nor other tools like FXCop, StyleCop etc. allow to perform SharePoint specific automatic code analysis.

This session will show the SharePoint code analysis framework (SPCAF) available at www.spcaf.com which addresses exactly this gap and you will learn how to easily develop your own rules for it.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,028
On SlideShare
0
From Embeds
0
Number of Embeds
1,115
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Developing high quality SharePoint solutions/apps with SPCAF #SP24

  1. 1. Developing high quality SharePoint solutions/apps with SPCAF Matthias Einig Sweden,CEST(GMT+2) April 16th /17th, 2014
  2. 2. @mattein matthias.einig@rencore.se www.matthiaseinig.de www.spsstockholm.com @spssthlm 16th/17th April 2014 www.sp24conf.com @sp24conf www.spcaf.com / @spcaf CEO, Owner Stockholm, Sweden
  3. 3. Is my code correct and follows best practices? Developer Will the code harm my farm? Administrator Is the code well designed and maintainable? Architect Does the code comply with company policies and standards? Quality Manager
  4. 4. What do we have right now? FxCop Metrics SourceCode StyleCop MSOCAF Checks against general coding errors (not SharePoint-specific) Calculates code metrics (only .NET code, not SharePoint specific) Checks coding style guidelines (only .NET code, not SharePoint specific) Analyzes code security (not SharePoint-specific) Checks memory leaks (SharePoint-specific) Combination of FxCop and SPDisposeCheck for SharePoint Online
  5. 5. The Gap…
  6. 6. Meet…
  7. 7. Identifies coding violations against ~400 rules Visualizes dependencies between SharePoint elements Calculates metrics on SharePoint Code Creates content reports of packages What’s in it?
  8. 8. DEMO
  9. 9. • Run SPCAF manually or on solution build • Doubleclick results in Error List to open the line of code Visual Studio
  10. 10. Configure Rulesets
  11. 11. Run SPCAF in TeamBuild as Quality Gate Build in TFS on-premises Build in Team Foundation Services Continuous Integration
  12. 12. DEMO
  13. 13. SPCAF Client Application
  14. 14. DEMO
  15. 15. using SPCAF.Sdk; using SPCAF.Sdk.Rules; using SPCAF.Sdk.Model; using SPCAF.Sdk.Model.Extensions; 1. Create empty class library 2. Add SPCAF.SDK.dll assembly reference 3. Create class and add usings 4. Add method stub by inheriting from ”Rule” namespace SP24.Rules { public class FeatureNameStartsWithSP24 : Rule<FeatureDefinition> { public override void Visit(FeatureDefinition target, NotificationCollection notifications) {} } }
  16. 16. 5. Add Rule Metadata namespace SP24.Rules { [RuleMetadata(typeof(Naming), CheckId = "SPC99001", DisplayName = "Feature name should start with SP24", Description = "A feature name should be prefixed with 'SP24'.", DefaultSeverity = Severity.Warning, SharePointVersion = new string[] { "12", "14", "15" }, Message = "Feature '{0}' should start with 'SP24'.", Resolution = "Change the folder name of the feature and add the name at the beginning, e.g.‘SP24.Intranet.Components.ContentTypesFeature'.")] public class FeatureNameStartsWithSP24 : Rule<FeatureDefinition> { ...
  17. 17. 7. Build and drop the assembly into the SPCAF installation folder public class FeatureNameStartsWithSP24 : Rule<FeatureDefinition> { public override void Visit(FeatureDefinition target, NotificationCollection notifications) { if (!target.FeatureName.StartsWith("SP24")) { string message = string.Format(this.MessageTemplate(), target.FeatureName); Notify(target, message, notifications); } } } 6. Implement the rule
  18. 18. SharePoint Code Analysis • is important for the whole team! • helps to improve solution quality • helps to improve farm stability
  19. 19. www.spcaf.com/trial

×