Lance Larsen - .NET Architect Madison Wisconsin

Archive for February, 2015

( Download Code )

Was looking for a simple and elegant way to log some metric for methods (mainly method name, start time, stop time and elapsed time) – I’ve done this in PostSharp in my article “Holy Grail of Application Profiling with AOP” – but client wasn’t using them.

I’ve used reflection with success in the past, but was having some issues with Async methods not giving their real method names, was getting “MoveNext” instead — so sleuthed around for an alternative and found some awesome C# attributes that I’d never seen…

[CallerMemeberName] – gets the method name calling the attribute
[CallerFilePathAttribute] – gets the path to the C# file
[CallerLineNumberAttribute] – gets the line of the method in code

Combining those with the C# Stopwatch Class – and using the Dispose patter that I love because you can easily code the “using” statement around what you’re looking at ( see below ) – came up with the following cool code that – as always – I love to share.

Emphasis on elegant, to call this code – you can easily do the following…

using (StopwatchLog.Track())
{
   // Your code here...
}

It collects the information about executing method and logs metrics when the stopwatch log is disposed.

Read more


Surface Pro 3

A lot more Surface 3 owners out there as sales of the Surface topped $1 billion in revenue for Microsoft – so more tips for my primary development computer!

Screen Brightness Shortcut: Press “Fn” + “Del” to increase brightness, and “Fn” + “Backspace” to decrease brightness.  Love it. 

If there are more cool tips that others have – ping me, love to know them.


image As I always emphasize – invest in yourself first!  So attend education events, user group meetings, sent aside time specifically to learn, etc.

Today I drove down from Madison to Chicago area to attend a free Microsoft WebCamp event. Worth the ~3+ hour drive. :)

“The new release of ASP.NET and Web Tools for Visual Studio 2013 make it easier than ever to build cutting-edge websites – and once you create a beautiful, interactive site, you can quickly deploy and scale it with Microsoft Azure! … no-fluff events created for developers, by developers.”

For those in Wisconsin, there is another one coming up in Waukesha on March 24th 2015 – but I didn’t want to wait… :)

Click here to Register — and here’s the Source and Slides.

Thanks to David Giard, our Microsoft Evangelist for leading the event.

Twitter: @DavidGiard, Blog: http://davidgiard.com