To get a trial key
fill out the form below
Team License (standard version)
Enterprise License (extended version)
* By clicking this button you agree to our Privacy Policy statement

** This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
GBP
RUB
* By clicking this button you agree to our Privacy Policy statement

** This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

** This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

** This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

** This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
Message submitted.

Your message has been sent. We will email you at


If you haven't received our response, please do the following:
check your Spam/Junk folder and click the "Not Spam" button for our message.
This way, you won't miss messages from our team in the future.

>
>
The first step towards PVS-Studio for C#

The first step towards PVS-Studio for C#

Sep 30 2015
Author:

The PVS-Studio team would like to share some news and heat up the audience interest a bit. We have started C# analyzer development. From the user's point of view it'll still be our good old PVS-Studio, but now we'll teach it how to look for bugs in C# programs.

0350_PVS-Studio_CSharp/image1.png

At this moment (September, 2015) the PVS-Studio analyzer supports Visual Studio 2005-2015 and can analyze C, C++, C++/CLI, C++/CX (WinRT) programs. Also the PVS-Studio Standalone utility allows checking projects which are built not only with Visual C++, but also with MinGW, for instance. There were some experiments in running PVS-Studio on Linux, but it's not of a big interest to us, as it's quite hard to make profit in the Linux world by means of creating developer tools. We have a bigger liking for Windows, that's why we decided to bring some joy to C# developers.

We've said many times that the C# language is less subject to errors. In this language there were changed or removed many constructions that are enough to shoot yourself in the foot by banal or exotic means. But we know that there is no developer who is totally immune to inadvertence, typos and slip ups.

The PVS-Studio is famous for its diagnostics which allow you to detect typos, Copy-Paste related errors and many more. So we've decided to use our experience in analysis and create a nice handy tool for C# as well.

Today we've heard the birth cry of C# PVS-Studio. We have adapted our favorite V501 diagnostic for C#. It has lots of great findings on its credit. And here is the very first result. Having launched PVS-Studio on MSBuild project we found such an issue:

public int Compare(ITaskItem x, ITaskItem y)
{
  if (x.ItemSpec != y.ItemSpec)
  {
    return -1;
  }

  if (x.CloneCustomMetadata().Count !=
      x.CloneCustomMetadata().Count)
  {
    return -1;
  } 
  ....
}

PVS-Studio warning: V3001 There are identical sub-expressions to the left and to the right of the '!=' operator x.CloneCustomMetadata().Count != x.CloneCustomMetadata().Count. Microsoft.Build.Engine.UnitTests TaskItemComparer.cs 51

By accident the 'x' variable is used twice. Correct variant:

if (x.CloneCustomMetadata().Count !=
    y.CloneCustomMetadata().Count)

Of course, it's one of the first steps along the way of creating a great tool for C# programmers. But we feel enough strength and wish to make it to the end.

We plan to have the first C# version released by the New Year. Of course by this time we will have only a several diagnostics implemented which will be mainly taken from the C++ module. But even with the help of this New Year version you'll be able to find quite a number of amusing errors. Then gradually we will implement other diagnostics that can be adapted for C#. Later on there will appear some specific diagnostics, applicable only to C# code.

Note: As soon as C++ & C# version is released we plan to cease supporting Visial Sudio 2005, 2008. It becomes more and more troublesome for us due to some technical and organizational reasons.

Most likely there will be questions concerning the technology that the analyzer will be built upon. Here is the answer. We are using Roslyn.

Thanks a lot for your attention. For those C# programmers who are not aware of what PVS-Studio is and what it's capable of, I'll give a recommendation to visit this section. I'm sure it'll impress you and you'll want to try out the PVS-Studio on your C# projects.

Popular related articles
The Last Line Effect

Date: May 31 2014

Author: Andrey Karpov

I have studied many errors caused by the use of the Copy-Paste method, and can assure you that programmers most often tend to make mistakes in the last fragment of a homogeneous code block. I have ne…
The Ultimate Question of Programming, Refactoring, and Everything

Date: Apr 14 2016

Author: Andrey Karpov

Yes, you've guessed correctly - the answer is "42". In this article you will find 42 recommendations about coding in C++ that can help a programmer avoid a lot of errors, save time and effort. The au…
PVS-Studio for Java

Date: Jan 17 2019

Author: Andrey Karpov

In the seventh version of the PVS-Studio static analyzer, we added support of the Java language. It's time for a brief story of how we've started making support of the Java language, how far we've co…
The way static analyzers fight against false positives, and why they do it

Date: Mar 20 2017

Author: Andrey Karpov

In my previous article I wrote that I don't like the approach of evaluating the efficiency of static analyzers with the help of synthetic tests. In that article, I give the example of a code fragment…
Characteristics of PVS-Studio Analyzer by the Example of EFL Core Libraries, 10-15% of False Positives

Date: Jul 31 2017

Author: Andrey Karpov

After I wrote quite a big article about the analysis of the Tizen OS code, I received a large number of questions concerning the percentage of false positives and the density of errors (how many erro…
Technologies used in the PVS-Studio code analyzer for finding bugs and potential vulnerabilities

Date: Nov 21 2018

Author: Andrey Karpov

A brief description of technologies used in the PVS-Studio tool, which let us effectively detect a large number of error patterns and potential vulnerabilities. The article describes the implementati…
PVS-Studio ROI

Date: Jan 30 2019

Author: Andrey Karpov

Occasionally, we're asked a question, what monetary value the company will receive from using PVS-Studio. We decided to draw up a response in the form of an article and provide tables, which will sho…
The Evil within the Comparison Functions

Date: May 19 2017

Author: Andrey Karpov

Perhaps, readers remember my article titled "Last line effect". It describes a pattern I've once noticed: in most cases programmers make an error in the last line of similar text blocks. Now I want t…
Static analysis as part of the development process in Unreal Engine

Date: Jun 27 2017

Author: Andrey Karpov

Unreal Engine continues to develop as new code is added and previously written code is changed. What is the inevitable consequence of ongoing development in a project? The emergence of new bugs in th…
Appreciate Static Code Analysis!

Date: Oct 16 2017

Author: Andrey Karpov

I am really astonished by the capabilities of static code analysis even though I am one of the developers of PVS-Studio analyzer myself. The tool surprised me the other day as it turned out to be sma…

Comments (0)

Next comments

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site.
Learn More →
Accept