Video: What’s New in ASP.NET Core 2.2

,
April 24, 2019 / No Comment

Who doesn’t like new features?
Michael Stokesbary, senior software architect and trainer at IntelliTect and C# instructor at Eastern Washington University, was excited about the performance enhancements made to ASP.NET Core 2.2. He wrote a blog about the simplified web API authentication and decided to share what he learned in even more detail with the Spokane .Net User Group on […]
Read more

AUTHOR: CATEGORY: .NET Core, Blog

Decoupling – Making Your C# Program More Testable

,
April 23, 2019 / No Comment

 How and Why to Implement Decoupling Classes in Your Code

Decoupling is a strategy for writing testable code when dealing with hard-to-test classes and it can be an incredibly powerful tool to help you write clean, effective and bug-free code.
What Is Decoupling?
Decoupling is a coding strategy that involves taking the key parts of your classes’ functionality (specifically […]
Read more

AUTHOR: CATEGORY: Blog, C#

Securing Web APIs in .NET Core 2.2

,
December 10, 2018 / No Comment

Microsoft will simplify Web API authentication in a soon-to-be-released update!
This week’s release of ASP.NET 2.2 gave us some performance enhancements, ability to do health checks on the application and code analyzers to help you improve your web API discoverability. Expect an out of band release that creates a dependency on IdentityServer in the near future.
Microsoft will be […]
Read more

Using Tuples for overriding Equality() and GetHashCode()

,
March 28, 2018 / No Comment

The implementation of Equals() and GetHashCode() used to be complex, but with C# 7.0 Tuples, the actual code is boilerplate.

For Equals(): It’s necessary to compare all the contained identifying data structures while avoiding infinite recursion or null reference exceptions.
For GetHashCode(): It’s necessary to combine the unique hash code of each of the non-null contained identifying data structures […]
Read more

AUTHOR: CATEGORY: Blog, C#

Timers Prior to Async/Await Pattern of C# 5.0

,
October 9, 2017 / No Comment

There are multiple ways to use Task.Delay() when a timer is required.
For scenarios prior to .NET 4.5, several timer classes are available, including System.Windows.Forms.Timer, System.Timers.Timer, and System.Threading.Timer.
The development team designed System.Windows.Forms.Timer specifically for use within a rich client user interface. Programmers can drag it onto a form as a nonvisual control and regulate the behavior from within the […]
Read more

Error: “Predefined type ‘System.ValueTuple’ is not defined or imported”

,
April 10, 2017 / No Comment

As soon as you start programming tuples in C# 7.0, you are likely to encounter the compiler error, “Predefined type ‘System.ValueTuple’ is not defined or imported.”
 
This issue is easily corrected. When encountered, the error will look like this on the code editor:

The issue is that the C# 7.0 compiler is trying to generate the underlying […]
Read more

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#

Guidelines for Exception Handling in C#

,
September 14, 2015 / 1 Comment

The following is a list of C# Exceptions Handling Guidelines taken from Essential C# by Mark Michaelis.
Exception handling provides much-needed structure to the error-handling mechanisms that preceded it. However, it can still lead to some unwieldy results if used haphazardly. The following guidelines offer some best practices for exception handling.

Catch only the exceptions that you can handle.
Read more

AUTHOR: CATEGORY: .Net, C#