# Marko Apfel - Afghanistan/Belgium/Germany

Management, Architecture, Programming, QA, Coach, GIS, EAI

Home  |   Contact  |   Syndication    |   Login

# Code Analysis

Problem Jenkins dashboard shows following simian analysis: But after clicking one item I get: Solution My simian call was: .\tools\Simian\bin\simian-2... ./src/**/*.cs -formatter=xml:.\bin\Simian... -threshold=10 -excludes="**/*.Designer.cs" -excludes="**/*Fixture*.cs" -excludes="**/*.g.cs" -excludes="**/*.xaml.cs" -failOnDuplication- but the folder prefix (‘./’) for current folder in front of (‘src/**/*.cs’) is wrong. Deleting the unnecessary chars lets the system work: ......

Problem Normally I try to have my continuous integration as most a possible toolset free to ensure that no local stuff could have an impact to my build. My Silverlight app references a special compile target in a folder outside my developer tree: <Import Project="$(MSBuildExtension... /> So I copied the stuff from this folder to a local one and changed the call to this target in my csproj: <Import Project="..\..\..\tools\Web... ...... Problem Our global Jenkins continuous integration server throws this error during compile step. My local TeamCity continuous integration server runs fine. What is the difference. Background I integrate some static code analysis steps via MSBuild-targets in the csproj files. To allow a fast developing without a code analysis for ever compiling I bound these targets only to RELEASE-configuration. With the MSBuild element <ImportGroup> only one condition must be specified. So my construct was: ...... Problem A continuous integration server should only have a minimal toolset installed. This ensures that no unwanted libraries could affect the build and other steps. Clearly that with this slogan also StyleCop should not be installed to the CI server. But we wanna have this analysis as an part of the whole build. Solution Prerequisites First at all we need the necessary files from StyleCop (the core assemblies and the target). The easiest way is to download the MSI of StyleCop, install the software ...... Toggeling the checkbox “Perform Runtime Contract Checking” lets run the next application start with the new set option. But for unit test an explicit new build will apply the option for the next run. Vorkenntnisse: Kenntnisse einer Programmiersprache sind hilfreich. Zielgruppe: Dieser Workshop richtet sich an alle Softwareentwickler und Softwarearchitekten, die Lösungen in Form von ArcGIS Desktop Erweiterungen oder ArcGIS Engine Anwendungen planen und entwickeln. Kurzbeschreibung: Professionelle Softwareentwicklung hat primär nichts mit Geld zu tun, oder mit der Verwendung teurer Entwicklungstools. Vielmehr basiert Professionelle Softwareentwicklung auf Werten mit dem Ziel, dauerhaft guten, fehlerfreien ...... Installing StyleCop for ReSharper under an administrative account does not activate this ReSharper plugin under my developer account. A system analysis show, that this plugin is installed under %userprofile%\Local Settings\Application Data\JetBrains\ReSharper\v4... StyleCop for ReSharper This gives the hint, that the msi must be started for each individual user separately – maybe the is the possibility to move the stuff to all users or that there is also an administrative installation ...... If AgentSmith throws a warning that some term is not spelled correctly for this term the spell checking could be suppressed with: //agentsmith spellcheck disable ... //agentsmith spellcheck enable ...... Today Patrick gives me a new license for his static code analysis tool NDepend for my fresh machine with Win7/64. This platform is new for me, so some things are different to Win XP. Maybe that till yet some of these things are not well enough understandanded from me. So i stepped in some traps. Here are my notes to get NDepend running. Download of NDepend Professional Edition from http://www.ndepend.com/NDep... Extracted to c:\program files (x86)\NDepend Started NDepend.Install.VisualStudi... ...... Today my FxCop-GUI stated, that a new release is available – but the link to this release is broken. After googling a little bit i realized, that the new release of FxCop ist actually only included in “Windows SDK for Windows 7.1”. This is downloadable under Microsoft Windows SDK for Windows 7 and .NET Framework 4 (ISO) Extract the ISO Open the Setup\WinSDKNetFxTools\cab1... Extract WinSDK_FxCopSetup.exe_all_e... Run Install.Exe ...... StyleCop issues inheritedoc-comment Using <inheritdoc />-comment is not recognized by StyleCop. So this needs a suppression: // <inheritdoc /> [SuppressMessage( "Microsoft.StyleCop.CSharp.... "SA1604:ElementDocumentatio... Justification = "InheritDoc")] FxCop issues Too few namespaces [module: SuppressMessage( "Microsoft.Design", "CA1020:AvoidNamespacesWith... Scope = "namespace", Target = "EsriDE.Core.Service.Logging", Justification = "We want to ...... Using a project-specific custom disctionary for FxCop and FxCop build tasks is very simple. The FxCopCmd call in the FxCop-target offers the parameter /dictionary:<DictionaryN... for that. But for Visual Studio a little bit more steps are needed. And these steps musst me gone for all projects. Add the custom dictionary as a link to each project. I organize such links under the special Properties-folder. So normally these links dont violate my eyes ;-) Next step requieres editing of the csproj-files. ...... Renaming the default custom dictionary from CustomDictionary.xml to an other name – for instance FxCop.CustomDictionary.xml needs some additional changes to work in involved applications. Visual Studio Team System code analysis For Visual Studio Team System code analysis this file should be added as a link to all projects and setted to be the Build Action CodeAnalysisDirectory. Build target In a build target the command line tool FxCopCmd should be called with the /dictionary parameter: <Target ...... After installing VS2005 TE on my machine (which previously runs Visual Studio 2008 TE) all mixed projects (VS2005/VS2008 compatibility with TargetFramework=2.0 and ToolsVersion=2.0 options) thrown an error during compilation: C:\Program Files\MSBuild\Microsoft\Vis... error : In order to perform Code Analysis on managed binaries, MSBuild needs to launch FxCop. MSBuild is unable to locate the FxCop binaries. Make sure Visual Studio Team ...... if you see the following warnings in your code: You have two choices: deactivate the rule but this disables this rule for all documentations – also the wanted tune the detail settings In the settings editor you see additional options if you select the “Documentation Rules” root node Normally i want to ignore the warnings for missing private and internal documentations and also for documentation of fields ...... see also Working with Microsoft FxCop As described in the previous post a custom dictionary could be referenced in a FxCop-call of a target by using the option: /dictionary:&quot;$(Pro... But how is it possible to publish this custom dictionary for the Visual Studio integrated code analysis? This analysis runs an other FxCop.exe than my special FxCop-target. So the custom dictionary which is specified in the FxCop-call of my target is not used. The ......

Run FxCop as a post build event Since FxCop 1.36 it is possible to include FxCop in a post-build event. So FxCop runs after compiling in Visual Studio and allows you directly jumping to the warned line. Description of the command line In the sample above the command line is IF $(ConfigurationName) == Debug$(ProjectDir)..\..\..\..\to... /console /file:"$(TargetPath)" /directory:"$(ProjectDir)..... Interop Assemblies" /directory:"\$(ProjectDir)..... ......

Today a colleague ask me to help. On his system all ReSharper menus are grayed out. Also the Visual Studio Add-In Manager does not show this add-in. He tried: a new installation: without success, running with administrative privilegeg: without success, looking in event- and application-logs: no entries. After searching a little bit with old buddy google we found this message: Wild World of Visual Studio -- Mysterious Component We downloaded and installed the latest Microsoft Core XML Services (MSXML) ......

This error during compilation annoys me in a legacy project. Apparently because of performance issues the Visual Studio development team decided to limit the warnings of code analysis to 200 items. This behaviour could be parameterized under: HKEY_LOCAL_MACHINE\SOFTWARE... Unfortunately a value of 0 does not abrogate this behaviour but deleting/renaming this key helps a little bit. It seems that there is a default value of 1000 ......