SSDT gotcha – Moving a file erases code analysis suppressions

Posted by jamiet on SQL Blog See other posts from SQL Blog or by jamiet
Published on Thu, 10 Oct 2013 16:42:09 GMT Indexed on 2013/10/17 16:17 UTC
Read the original article Hit count: 378

Filed under:
|

I discovered a little wrinkle in SSDT today that is worth knowing about if you are managing your database schemas using SSDT. In short, if a file is moved to a different folder in the project then any code analysis suppressions that reference that file will disappear from the suppression file. This makes sense if you think about it because the paths stored in the suppression file are no longer valid, but you probably won’t be aware of it until it happens to you. If you don’t know what code analysis is or you don’t know what the suppression file is then you can probably stop reading now, otherwise read on for a simple short demo.

Let’s create a new project and add a stored procedure to it called sp_dummy.

image

Naming stored procedures with a sp_ prefix is generally frowned upon and hence SSDT static code analysis will look for occurrences of this and flag them. So, the next thing we need to do is turn on static code analysis in the project properties:

image

A subsequent build causes a code analysis warning as we might expect:

image

Let’s suppose we actually don’t mind stored procedures with sp_ prefixes, we can just right-click on the message to suppress and get rid of it:

image

That causes a suppression file to get created in our project:

image

Notice that the suppression file contains a relative path to the file that has had the suppression placed upon it. Now if we simply move the file within our project to a new folder notice that the suppression that we just created gets removed from the suppression file:

image

As I alluded above this behaviour is intuitive because the path originally stored in the suppression file is no longer relevant but you’re probably not going to be aware of it until it happens to you and messages that you thought you had suppressed start appearing again. Definitely one to be aware of.

@Jamiet 

 

© SQL Blog or respective owner

Related posts about SQL Server Data Tools

Related posts about SSDT

  • SSDT - What's in a name?

    as seen on SQL Blog - Search for 'SQL Blog'
    SQL Server Data Tools (SSDT) recently got released as part of SQL Server 2012 and depending on who you believe it can be described as either: a suite of tools for building SQL Server database solutions or a suite of tools for building SQL Server database, Integration Services, Analysis… >>> More

  • Redistribution of sqlpackage.exe [SSDT]

    as seen on SQL Blog - Search for 'SQL Blog'
    This is a short note for anyone that may be interested in redistributing sqlpackage.exe. If this isn’t you then no need to keep reading. Ostensibly this is here for anyone that bingles for this information. sqlpackage.exe is a command-line that ships with SQL Server Development Tools (SSDT) in SQL… >>> More

  • Smart defaults [SSDT]

    as seen on SQL Blog - Search for 'SQL Blog'
    I’ve just discovered a new, somewhat hidden, feature in SSDT that I didn’t know about and figured it would be worth highlighting here because I’ll bet not many others know it either; the feature is called Smart Defaults. It gets around the problem of adding a NOT NULLable column to an existing table… >>> More

  • Smart defaults [SSDT]

    as seen on SQL Blog - Search for 'SQL Blog'
    I’ve just discovered a new, somewhat hidden, feature in SSDT that I didn’t know about and figured it would be worth highlighting here because I’ll bet not many others know it either; the feature is called Smart Defaults. It gets around the problem of adding a NOT NULLable column to an existing table… >>> More

  • Want a headless build server for SSDT without installing Visual Studio? You’re out of luck!

    as seen on SQL Blog - Search for 'SQL Blog'
    An issue that regularly seems to rear its head on my travels is that of headless build servers for SSDT. What does that mean exactly? Let me give you my interpretation of it. A SQL Server Data Tools (SSDT) project incorporates a build process that will basically parse all of the files within the… >>> More