Rule to build solution before check-in in Visual Studio - visual-studio

Is it possible to use StyleCop to enforce these two rules?
Get latest version before check in
Build solution with a
specific configuration before check in
Any other suggestions besides StyleCop are welcomed. Thank You.

No. Stylecop is an open source static code analysis tool from Microsoft that checks C# code for conformance to StyleCop's recommended coding styles and a subset of Microsoft's .NET Framework Design Guidelines.
(wikipedia)
To enforce the getting of the latest version before checking in, you could use a custom TFS policy. This seems to have been successful for other users.
To check that a particular solution builds before checking in, you could use a Gated Check-in for that solution. The code won't be committed if that solution (and it's tests do not pass).

Related

Visual studio c++ static analysis plugin for feeding into sonar

Is there any way to feed visual studio static analysis on c++ code base into sonar?
Thanks
Did you check out the VSSonarExtension? Some hints on how to use it your can find here.
Update:
The other way around there may be a plugin by jmecosta called VSSonarAddin. One of its features is
"c++, runs local analysis with cppcheck and reports violations added
by local changes. "
You can find the project on github.
The Community C++ Plugin supports feeding compiler warnings as violations into SonarQube. You usually need to build your code with code analysis enabled and later you can use that data during SonarQube analysis. See here for more details!

custom threshold for CA1502 in visual studio 2013 ultimate

This question: Custom threshold for CA1502
discusses how to set up custom thresholds for code metrics rules in code analysis.
I have the same problem, but think that the old question is out of date.
To repeat:
In particular, we would like our Build to fail when a method has a
code complexity of more than 20. Unfortunately, rule CA1502 has a
threshold of 25:
The rule reports a violation when the cyclomatic complexity is more
than 25.
Can we somehow change this?
The accepted answer is to edit an .fxcop file to include the rules.
In visual studio 2013 ultimate we have integrated Code Analysis and Code metrics; but we don't appear to have .fxcop rules - I think this used to be when fxcop was a separate extension.
Is there any way to edit the thresholds in the .ruleset files produced by visual studio?
Or have I missed how and where to get .fxcop files in the more recent versions?
The post you cited is actually pretty recent. The use of .fxcop files is still the only way to configure the rules. (If you're not fond of this limitation, you might want to vote at http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2406555-allow-code-analysis-rules-to-be-configured-via-ru.)
You can use the FxCop 10.0 UI to create a "seed" .fxcop file, but you will need to edit it by hand to add the settings. To integrate with Visual Studio, you can use the CodeAnalysisProject MSBuild property to specify the relative path to the .fxcop file.

Develop with VS and VS Express?

I currently develop C++ and C# applications with VS2008.
I have the need to have the IDE as well on our target demonstrator platform to debug and fix etc.
Could I use the Express editions for that task or are there any major drawbacks?
Any experience is welcome, also for VS2010.
You would only have to tweak things in order to compile for 64 bit (true only for 2008, that's easy in 2010), but no major functional drawback, except as Binary Worrier says it can be frustrating
However it is commonly accepted to have the full IDE on a target demo platform without buying another license, so why not deploying full IDE on it?
From About Licensing
Developer Tools – per user license
You must acquire a license for each
user you permit to access or use the
software. You may install any number
of copies on any number of devices for
access and use by one user to design,
develop, test and demonstrate
programs. Only licensed users may
access the software.
I normally don't like to just post links as answers, but this Wikipedia Article covers the differences in depth.
I've personally found coming down from the full- to the express-editions painful and limiting, you're forever "bumping your head" off some limitation or missing feature, very frustrating.
I use vs2008 at the buro and vs2008 c# excpess at home.
the limitations i come across were
c# express doesn-t like solution folders containing projects and cannot load other project types (ie setup-projects, mstest projects).
i had no painful and limiting experience yet because i use nunit instead of mstest and only ms-databases. express has advanced options (disabled by default) that give you the debug/release build feature.
by the way you donot need a visual studio to debug dotnet-applications. the dotnet-sdk has a gui debugger that can do the job but it is not as comfortable as vs. to rebuild you can use msbuild.

Planning to upgrade VS 2005 to VS 2010

I have installed VS 2010 and want to migrate all code written in VS 2005 to VS 2010.
Please note that we do not have VS 2008, all code are in C# 2.0 and Asp.net 2.0 only.
Can anyone please tell me now what all points need to be considered while migrating.
Update:
I have set target framework to 2.0 for all of my Libraries and web projects. It complies without any error!
However, when site opens in IE (Set to default.aspx), it gives me error as below:
InternalXmlHelper.vb(9) : error BC30560: 'ExtensionAttribute' is
ambiguous in the namespace 'System.Runtime.CompilerServices'.
<Global.System.Runtime.CompilerServices.ExtensionAttribute()> _
Keep all the target framework settings to .NET 2.0. This way, there should be no compilation problem at all.
The changes that you should see are the solution and project files only.
Start with known good solutions in source control (and label—you shouldn't need to go back, but easy to add an extra safety net).
Open each solution in VS2010, allow the conversion wizard to do the conversion.
Resolve any issues.
Honestly, if you're just upgrading VS 2010 you don't really need to consider much. Just keep backups (any real SCM product will do) and you're good. You don't have to upgrade your applications' runtime targets at all if you don't want to.
If you're building with CAS policy, you might run into issues with using MSBuild 4.0 to build you 2.0 applications. If you don't know what I'm talking about, never mind.
My advice is to make sure everyone's "checked in" to your source code provider, and run the conversion wizard and see how it goes.

Does visual studio 2010 Premium include the contract tools?

According to this feature matrix, Visual Studio 2010 Premium (RC) includes "static code analysis".
However, adding calls to Contract.Requires at the start of my methods doesn't seem to have any effect. I don't get runtime exceptions if the contract is violated. I don't get compiler warnings if a contract cannot be proven. I also can't find a "Code Contracts" tab in the project settings.
Am I missing something obvious or is this feature only available in the Ultimate edition?
There does indeed seem to be some confusion about whether or not Code Contracts is included in the framework that comes with beta 2 of VS2010, or even in VS2010 itself. The Code Contracts forum (and expecially this post) has several mentions of this with no answers as of yet.
I don't think that Code Contracts falls under the heading of static code analysis. I think static code analysis refers to other code analysis tools like FxCop.
I have tried using Contract.Requires in VS2010 beta 2 ultimate edition, but I get the same behaviour as you. If you look in the project properties under the Code Analysis tab, you can enable code analysis, but this doesn't relate to Code Contracts.
According to the comment by Melitta (from the Base Class Libraries Team) on the connect article Make data contract static checking available in Professional Edition:
...but the restriction on the static analysis tool stands for this upcoming release. It keeps the code analysis story consistent, in that the static analysis tools require VSTS.
This suggests that you (will) have to have the team system version to get the compile-time version of Code Contracts.
To get static analysis in Beta 2 you have to download and install the Code Contracts bits (1.2.21023.14 or higher) from MSDN DevLabs. Then under the project properties, there will now be a Code Contracts tab... from here you can turn on static analysis...
The behaviour you're seeing is because the Code Contracts API is in mscorlib assembly, which allows asserts to work, but nothing else.
I'm assuming this won't be necessary by RTM.
You need to turn on the code contracts runtime checking in the project properties. If that settings pane doesn't exist then you need to install the Code Contracts download from Microsoft (despite the fact that the Contract.Requires exists in the framework).
Only the runtime checking is available in the Professional editions.

Resources