Month: April 2019

Method color in Visual Studio 2019

I didn’t like the new color on methods in VS 2019. I tried to find which color I should change. I didn’t find one but you can revert to the 2017 style by disabling Tools > Options > Text Editor > C# > Advanced > Use enhanced colors for C# and Basic.

Sadly this reverts all of the 2019 color enhancements back to 2017. If any one know which color controls the method only please drop me a line.

Stub User.Identity.IsAuthenticated in ASP Core

I’m writing this article strictly because google do not have any obvious solutions in the hope it will be indexed and presented for fellow devs.

We use identity server and to make things easier in dev I want to stub it. ClaimsIdentity takes a second argument AuthenticationType. Its important you set this property. You can set it to what ever you like. Once set IsAuthenticated will return true.

            if (env.IsDevelopment())
                app.Use(async (ctx, next) =>
                   ctx.User = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, "local") }, "Authenticated"));
                   await next.Invoke();