How To Debug PowerShell Core Binary Cmdlets

Just a few minor tweaks is all it takes to get going with PowerShell Core cmdlets. I just wish it was documented better....

October 23, 2018 · 3 min · Nick Spreitzer

FluentConsole: Now With Automatic Word-Boundary Line Wrapping

When writing sentences to a console window, by default, the text will wrap at the exact width of the current window. Unless your sentences happen to consistently have word boundaries at exactly the same intervals as the window width, your text will wrap right in the middle words…...

May 26, 2016 · 2 min · Nick Spreitzer

XML Comment Outlining In Visual Studio 2015 'Fixed'

When I look at a class file, I will frequently collapse it down to its method signatures. Maybe I want to scan the file for a particular method. Maybe I want to get an overview of what functionality the class contains. Could be any number of reasons. Ultimately it’s a quick way to minimize the noise and isolate what I really want to see. In a C# class file, the noisiest bits - easily - are the XML comments that decorate everything from the class itself to all its containing methods and properties....

March 17, 2016 · 2 min · Nick Spreitzer

Unit Testing HostingEnvironment.MapPath()

Without getting into all the whys and wtfs, the other day I had a need to dynamically render and inject html snippets into various webpages at runtime. The project I’m working on originally created the html in C# by concatenating string fragments and formatting them with runtime values. With all the requisite escape sequences needed to create valid html (including encapsulated JavaScript), this approach struck me as a bit messy and I decided to take a different route....

January 14, 2015 · 4 min · Nick Spreitzer

How To Get The Custom Format String For An Excel/OpenXml Cell

Getting the custom number format string for an Excel cell using OpenXml is not entirely intuitive. But once you understand how this information is laid out, it starts making sense....

May 30, 2014 · 1 min · Nick Spreitzer

Get Rendered LocalReport Values with OpenXml

How oh how is one to get XML from a local (not server) SSRS report? As it turns out, via Excel. The LocalReport.Render() method only supports Excel, PDF, and Image formats, but since the Excel 2007+ file format is just compressed XML, it didn’t take too much finagling to get what I was really after. The only thing I needed was the Microsoft OpenXml SDK, easily acquired through Nuget. This code snippet shows how to get the rendered values from a LocalReport in memory:...

February 12, 2014 · 1 min · Nick Spreitzer

C# UNC Path

For some odd reason, System.IO doesn’t include a method to get the UNC path for a file or directory. Even stranger, many code samples resort to using p/invoke in order to get that information. But then I came across this StackOverflow answer that explained a pure .NET way to do the same thing. I gave the original code a good refactoring and turned it into the extension method below. While the most obvious place to stick something like this is the Path class, since it’s static that’s not possible....

May 20, 2013 · 1 min · Nick Spreitzer

Coded UI: Failed To Perform Action On Blocked Control Exception

Today I encountered a very aggravating exception while playing back some coded ui tests. I consistently got a “Failed To Perform Action On Blocked Control Exception”. Yet nothing was blocking the row...

May 14, 2013 · 1 min · Nick Spreitzer