Mark Michaelis (Blog)is the founder of IntelliTect and serves as the Chief Technical Architect and Trainer. Since 1996, he has been a Microsoft MVP for C#, Visual Studio Team System, and the Windows SDK and in 2007, he was recognized as a Microsoft Regional Director. He also serves on several Microsoft software design review teams, including C#, the Connected Systems Division, and VSTS. Mark speaks at developer conferences and has written numerous articles and books - Essential C# 6.0 is his most recent. Mark holds a Bachelor of Arts in Philosophy from the University of Illinois and a Masters in Computer Science from the Illinois Institute of Technology. When not bonding with his computer, Mark is busy with his family or training for another Ironman (having completed his first in 2008). Mark lives in Spokane, Washington, with his wife Elisabeth and three children, Benjamin, Hanna and Abigail.

Generalized Async Return Types in C# 7.0

,
October 14, 2016 / No Comment

Ever since C# 5.0 when the async/await pattern was introduced, the only supported return types were Task<TResult>, Task, and void (the latter only in exceptional cases). The problem with this limitation is that on occasions when the result is known immediately, it is still necessary to proceed with the formality of instantiating a Task even though no task is actually required […]
Read more

AUTHOR: CATEGORY: .Net, Blog, C#

Implementing an Implicit Conversion With C# 7.0 Deconstructors

,
October 14, 2016 / No Comment

While the deconstruct syntax is interesting for its convenience in assigning to a set of variables, what I believe has far broader implications is its potential to provide an “implicit conversion operator” and in a syntax that, quite frankly, is far easier to recall than the implicit cast operator.  For example, I can provide deconstructors that map to a string […]
Read more

AUTHOR: CATEGORY: .Net, Blog, C#

Deterministic Finalization with IDisposable and the Using Statement

,
October 14, 2016 / No Comment

The problem with finalizers on their own is that they don’t support deterministic finalization (the ability to know when a finalizer will run). Rather, finalizers serve the important role of being a backup mechanism for cleaning up resources if a developer using a class neglects to call the requisite cleanup code explicitly.
For example, consider the TemporaryFileStream, which includes not […]
Read more

AUTHOR: CATEGORY: .Net, Blog, C#

Finalizers in C#

,
October 14, 2016 / No Comment

The following is an Expert from Chapter 9 of Essential C#.
Finalizers allow developers to write code that will clean up a class’s resources. Unlike constructors that are called explicitly using the new operator, finalizers cannot be called explicitly from within the code. There is no new equivalent such as a delete operator. Rather, the garbage collector is responsible for […]
Read more

AUTHOR: CATEGORY: .Net, Blog, C#

Using PowerShell’s Invoke-RestMethod to Access VSTS OData

,
August 23, 2016 / No Comment

Given that Microsoft has abandoned their TFS CmdLets, one alternative is to access VSTS data is through the OData interface using the Invoke-RestMethod.
Before you begin you need to setup Alternate authentication credentials by navigating to https://<yourtenant>.visualstudio.com/_details/security/altcreds.  Once these are established, you will likely want to save them to a local PowerShell variable so that they can be reused for each […]
Read more

AUTHOR: CATEGORY: .Net, Blog, PowerShell, TFS, Uncategorized

.NET Core Dependency Injection

,
May 4, 2016 / 2 Comments

In my last two articles, Logging with .NET Core (bit.ly/1Vv3Q39) and Configuration with .NET Core (bit.ly/1OoqmkJ), I demonstrated how .NET Core functionality can be leveraged from both an ASP.NET Core project (project.json) as well as the more common .NET 4.6 C# project (*.csproj).  In other words, taking advantage of the new framework is not limited to those who are writing […]
Read more

AUTHOR: CATEGORY: .Net, .NET Core, Blog

Essential .NET – Logging with .NET Core

,
April 7, 2016 / 2 Comments

In the February issue, I delved into the new configuration API included in the newly named .NET Core 1.0 platform (see bit.ly/1OoqmkJ). (I assume most readers have heard about the recently renamed .NET Core 1.0, which was formerly referred to as .NET Core 5 and part of the ASP.NET 5 platform [see bit.ly/1Ooq7WI].) In that article I used unit testing […]
Read more

AUTHOR: CATEGORY: .Net, .NET Core, Uncategorized

Implementing a Custom ILogger with Exception Handling for .NET Core

,
March 4, 2016 / 2 Comments

This article corresponds with the MSDN article: Essential .NET – Logging with .NET Core. This github repo contains the code referenced in the article. Not in particular the unit test LogCritical_Exception_Success for an example of handling an exception using the custom logger.

The Custom Logger implementation is straightforward:

Here is the the extension method for adding a custom […]
Read more

AUTHOR: CATEGORY: .Net, .NET Core, C#