Skip to content

Coding Practice

Keyboard Shortcuts for Visual Studio

Knowing just a few keyboard shortcuts can improve your workflow dramatically. That is true for a general-purpose tool like Microsoft Office and even more for Visual Studio. The only question is where to start, then Visual Studio can not only adapt to your needs but also change its shortcuts completely.

Make .Net Data Types Human Readable with Humanizer

Humanizer is a nice library to get human readable representations for strings, numbers and dates in .Net. Cutting strings down to a certain size or turning a TimeSpan into "an hour" isn't magic. Nevertheless, trying to do all that work on your own will take time that Humanizer has already spent. Let's look on a few use cases where this library has proven to be a great help.

DbUp: Variable X Has No Value Defined

A quick demo on how schema migrations works in DbUp took an interesting turn as we tried to insert some values into our database:

Beginning database upgrade
Fetching list of already executed scripts.
Executing SQL Server script 'DBMigration.Scripts.Script0004.sql'
Upgrade failed due to an unexpected exception:
System.InvalidOperationException: Variable a4 has no value defined
   at DbUp.Engine.Preprocessors.VariableSubstitutionPreprocessor.ReplaceToken(Match match, IDictionary`2 variables, Match commentMatch) in C:\projects\dbup\src\DbUp\Engine\Preprocessors\VariableSubstitutionPreprocessor.cs:line 62

How to Disable StyleCop for Certain Projects

StyleCop can be a great help to ensure that every developer in a project formats code the same way. However, what is great for production code may not be what you want for your little throw away experiments. Let’s look on our options to disable StyleCop when we don’t need it.

Consolidate the NuGet Packages in your Solution

As a .Net developer you use NuGet packages daily: You add them to projects and can use the functionality they offer without much effort. Adding those packages is one thing, updating them another. Especially with solutions containing many projects it’s common to forget one or another package. There is a simple solution to that problem: Solution wide management of NuGet packages.

Conference Videos: A Widely Underused Learning Opportunity

A great way to learn new things is to attend a conference. You can meet new people, listen to interesting talks and discuss the obstacles one needs to overcome to successfully adopt those new approaches and techniques. However, not everyone has the time to attend a conference or can afford the ticket. A much less costly way to profit from all those learning opportunities is to watch the videos of the talks. Let's look at a few conferences and how easy it is to get those videos.

Running DbUp Inside a Transaction

DbUp is a great tool to manage database migration scripts as I explained in the past. For more than two years we used it in multiple projects and never needed more than the setup example from the documentation. However, in the case of an error this snipped isn’t the best configuration and needs manual work to clean-up your database. Let’s look on the underlying problem and how one can fix it.