Tag Archives for " Redgate "

Empathy map

The Future of Engineering at Redgate — A futurespective empathy map approach

Few days ago, I come across to a bunch of tests that were using the null conditional operator in the wrong way and I think it is worth sharing it.

Have a look at this code and how I fixed it.

Dangerous use of null C# conditional operator in test

What's the problem with the original code?

When result is null, the test pass even if clearly shouldn't!

The reason is because of the "short-circuiting" behaviour.

When result is null, then the rest of the chain’s execution stops! The test then pass because the method ends and by default a test without assertions is a pass.

You can learn more about "short-circuiting"  with null conditional operators here

How did I fix it?

In this particular case I have just removed the null conditional operator and performed a simple comparison using equality instead of relying on calling ToString. 

So...

Be careful when using null conditional operators in assertions and remember about "short-circuiting".



2 Writing an SSMS Add-in using the SIP Framework

I spent a couple of hours to learn how to write add-ins for SQL Server Management Studio (SSMS). Microsoft never officially supported add-ins in SSMS but Redgate created a framework to help doing it hiding a lot of complexity. The nice thing is that this framework has being made available to everyone and it can be used to create add-ins for all versions of SSMS up to SSMS 2014 (SSMS 2016 finally add support for extensions as it is based on Visual Studio 2015 Isolated Shell even if I can’t find documentation on it yet).

You can find documentation on the SIP Framework at the following address:
https://documentation.red-gate.com/display/MA/SSMS+ecosystem+project

You can follow the instructions very easily and in a matter of minutes you will be able to get the sample add-in up and running in your SSMS. Debugging it from Visual Studio is also incredibly simple to do (and you can also edit and continue!). The idea is pretty simple, you install the framework, you add a registry key that points to your add-in dll and when you open SSMS the add-in will load.

The sample project really helped me to quickly understand how to add menu bars, toolbar buttons, menu items in the object explorer and opening query windows. There is no much information on the Internet on how to actually interact and managed the status of SSMS. I think I will learn more over time but I suspect that most of the job consist of doing some reverse engineering of the API and use of reflection. This is an article that go a bit deeper: The art and science of creating SSMS 2012 add-ins.

Redgate products are using this SIP Framework under the covers and there is a list of add-ins available from Redgate and third party companies at the following address http://www.red-gate.com/products/sql-development/add-ins

 

 

>