Showing posts from 2017

Git Fundamentals video from Visual Studio Toolbox | Channel 9

Having been TFS-only for the last 2 years, I needed to brush up on my git basics as a new project ramps up at work. The video below, from the the Visual Studio Toolbox team at Microsoft, is pretty good at covering the essentials: Git Fundamentals The video is about an hour and ten minutes long.

A virtual file system for .NET written in C# (found on Github)

For later review:

C# chars, bytes, and strings, Oh My.

Some simple code to show the conversions between the different data types: // establish a base line System. Console .WriteLine(" Testing bytes, chars, encoding, etc. "); char myChar = ' a '; byte myCharBytes = Convert.ToByte(myChar); System. Console .WriteLine(" The number of bytes in a char is 1 byte. "); System. Console .WriteLine(" The value of myCharBytes is " + myCharBytes); // the following is wrong because it converts 97 to a string of "97" string myByteString = myCharBytes.ToString(); System. Console .WriteLine(" myByteString.Length = " + myByteString.Length); System. Console .WriteLine(" myByteString = " + myByteString); // the following is correct because it converts 97 to "a" char myGoodByteChar = Convert.ToChar(myCharBytes); string myGoodByteCharString = Convert.ToString(myGoodByteChar); System. Console .WriteLine(" myGoodByteCharString = " + myGoodByteCharString); Sys

List of Visual Studio Keyboard Shortcuts

Here's a link to a great list of keyboard shortcuts for Visual Studio: 149 Shortcuts for Visual Studio 2015 (Windows) While there's no need to memorize the list (that's why someone has created a cheat sheet, after all), it certainly doesn't hurt to look over the list from time to time and try to add one more command to your repertoire.

Quick Example of System.IO.Abstractions Use

I just got on a new project and am trying from the get-go to structure all my code so that it's easily testable. Academically, that is a no-brainer. In practice, though, some chunks of code are more difficult to structure so that they're easily testable. Towards that end, I've been pushing System.IO.Abstractions again. And, to get that going I decided it was time to refresh my examples. In the code below, we see how injecting the file system into the repository ultimately allows us to write testable code. If structured correctly, then our repository requires no subsequent refactoring to run in a unit test environment versus a "real" environment even when dealing with something like the file system. Let's take a look at our code. The Console Application The console application is straightforward. We have a private method (at the bottom) that assembles and returns a mock file system. Next, we perform the following steps: We feed that mock file system

Quick Reminder: Transact-SQL OUTPUT Clause

The OUTPUT clause is a useful tool for getting values just inserted, updated, or deleted from a table. You'll find several uses for the OUTPUT clause on your own but here's a few examples to get you started. Getting the Identify Value of a Just-inserted Row You can use the OUTPUT clause to get the value of an identify column for a newly inserted row. Traditionally, you'd have to jump through a hoop or two to get the value and in some cases that value couldn't be relied upon to be accurate. (For instance, if several updates were occurring at the same time, you might get the identify column value of another insertion -- not the one you performed.) -- example #1 CREATE TABLE #BrgTest ( [TestID] int identity primary key not null, [Name] varchar (50), [Description] varchar (255) ); INSERT INTO #BrgTest ([Name], [Description]) OUTPUT INSERTED.[TestID], INSERTED.[Name], INSERTED.[Description] VALUES (' Pancake ', ' A goofy dog ') DROP TA