Default ctor injected private member names with underscore prefix in Visual Studio 2019

After a bit of experimentation, you might want to change the default member generation when you add an injected member to your C# constructor in Visual Studio 2019.

Here’s what you likely want to use as a private member in your class:

private readonly IHttpContextAccessor _httpContextAccessor;

Here’s what the constructor (ctor) looks like:

public BearerTokenHandler(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor ??
throw new ArgumentNullException(nameof(httpContextAccessor));
}

To get that automatically, you’ll need to change the option for it which is deep inside the Visual Studio options menu.

First, navigate to:

Tools->Options->TextEditor->C#->CodeStyle->Naming

Click on the “Manage naming styles” button.

manage1

Fill it out like this:

manage2

Close that and then choose your new specification naming style for “Private or Internal Field”:

manage3

Click “OK” and it should immediately take effect next time you use the “Quick Refactorings” wizard to add a new member.  Try it out!

Arnold Schwarzenegger Movie Ranking

Arnold-Schwarzenegger-The-Terminator-1984

Like a lot of people trying to stay sane during the pandemic, I’ve come up with a few diversions to keep myself occupied.   I’ve been a fan like many others of Arnold’s movies, and I decided to watch them in release order.  Last week I came up with the idea of ranking them as I watched them in order of how much I liked them compared to the others I had watched.  I am going to skip all of the “Conan” movie roles he was in because I’ve seen them all way too many times.   I’m going to start the list with “The Terminator” and end with the second “The Expendables” movie.   That’s 21 movies!  I’m not going to watch movies where he is just appearing as a cameo. Asterisk by the movie indicates I’ve never seen it before.

Ranking

  1. The Terminator (1984)
  2. Predator (1987)
  3. Terminator 2: Judgment Day (1991)
  4. Total Recall (1990)
  5. Kindergarten Cop (1990) *
  6. The Running Man (1987)
  7. Commando (1985)
  8. Last Action Hero (1993) *
  9. Twins (1988) *
  10. Raw Deal (1986)
  11. Red Heat (1988)

Next up

  1. True Lies (1994)
  2. Junior (1994) *
  3. Eraser (1996) *
  4. Jingle All the Way (1996) *
  5. Batman & Robin (1997)
  6. End of Days (1999) *
  7. The 6th Day (2000) *
  8. Collateral Damage (2002) *
  9. Terminator 3: Rise of the Machines (2003)
  10. The Expendables 2 (2012) *

 

June 13 Update

Total Recall gets slotted at the #3 spot.   It has just as much 80s cheese as The Running Man, but it has a much better storyline.   The violence was IMHO a bit on the egregious side, but then again this was a Verhoeven movie.

June 22 Update

I’m surprised at myself for how I ranked Kindergarten Cop so high in the current list.  It was a completely enjoyable comedy/action movie that had a solid plot, great acting by Arnold and others, and a believable villain.    Terminator 2 did not disappoint.  I think this was only the 3rd time I’ve watched this movie and that was a long time ago.  The special effects were still great compared to today – but my main complaint was that the T-1000 terminator was way too powerful.  They should have degraded his capabilities as the injuries mounted, ESPECIALLY after he was completely frozen by liquid nitrogen.  Ok, onward to Last Action Hero which I’ve never seen and I’m excited to watch it.

June 24 Update

I was disappointed with Last Action Hero.  It started very, very, very slow.  Then it had a few interesting parts and then – credits.  Best part about the movie was the soundtrack.

.NET Core Middleware bridge for NPM

The late, great .Net guru K Scott Allen created and supported a middleware bridge for .Net Core projects that provide support for using NPM modules (“package.json”) in .Net projects.   This NuGet library will install the support for you.

What it will get you is the ability to reference external libraries such as jQuery and bootstrap within a web project in .Net Core.

Usage is quite simple.  Simply pull the package down via NuGet, install your npm packages and then add this simple line in startup.cs:

app.UseNodeModules();

That’s it.   Then in your source html and razor pages you can reference the /node_modules directory as if it was a child of the wwwroot folder which is where .Net core normally looks for static files.