• About
  • Privacy Policy
  • Utilities
Darchuk.NET

Autofac–Automatically registering generics via constructors

May 17, 2019 by Robert Leave a Comment

Recently I had a situation where I had a class and interface to make a generic service which would do something based on whatever type is provided.  (Obviously, it was not so contrived…) These would then get injected to other classes to be used as necessary: Which works fine… as long as you remember to … [Read more…]

Posted in: .NET Core, C#, Reflection Tagged: .NET, AutoFac, C#, Csharp, DependencyInjection, Generics, IoC, Reflection

Extending Autofac Modules

May 10, 2019 by Robert 1 Comment

Autofac is a popular dependency injection library that I like to use because they’ve done a lot of legwork to get things to work nicely in .NET Core – (some DI frameworks were not happy with Microsoft’s decision to make a public abstraction for their own DI library). Modules If you have a big solution … [Read more…]

Posted in: .NET Core, C# Tagged: .NET, AutoFac, C#, DependencyInjection, DI

C# Parsing HTML with regular expressions

May 3, 2019 by Robert Leave a Comment

Regular expressions are notoriously difficult.  But its just like programming.  Any errors or bugs produced end up being the fault of the programmer.  Good intentions give way to some small overlooked issue. via GIPHY Parsing HTML There are a lot of cool utilities for parsing HTML in C#.  One of the most popular one is … [Read more…]

Posted in: C#, HTML Tagged: C#, HTML, Regular Expressions

C# Inline If Gotcha

April 26, 2019 by Robert Leave a Comment

So I was writing an inline if statement the other day… you know the ones – booleanStatement ? resultIfTrue : resultIfFalse; It was pretty simple, so I didn’t think too much about it until I ran some unit tests…. via GIPHY Here’s what my code kind of looked like: So, what would you expect the … [Read more…]

Posted in: C#, Debugging Tagged: C#, Debugging, Inline If, Weird

ASP.NET Core 2–Enabling SignalR logging

April 19, 2019 by Robert 1 Comment

Sometimes you just need some logging to do a sanity check that things are actually working the way that you’re expecting. via GIPHY Here’s how to turn logging on in ASP.NET Core 2 for SignalR: I’ve had to look this up more than twice, and its not exactly easy to find in the Microsoft docs, … [Read more…]

Posted in: .NET Core, ASP.NET, C#, Debugging, SignalR Tagged: .NET Core, ASP.NET, C#, Logging, SignalR

Serializing XUnit test cases

April 12, 2019 by Robert Leave a Comment

XUnit has some cool stuff like Theory, which lets you write multiple test cases to run against the same test code.  This lets you test multiple paths with different inputs without having to write multiple tests.  This can save you a lot of time as you can cover a lot of ground with a single … [Read more…]

Posted in: .NET Core, C#, Unit Testing Tagged: C#, Csharp, IXunitSerializable, unit testing, XUnit

C# overwriting a static field with reflection

April 5, 2019 by Robert Leave a Comment

Imagine that you have a NuGet package containing a bunch of static strings.  These fields are intended to be used instead of magic strings, making it so anything that takes a dependency on this NuGet package will all be on the same page about these unique keys. Now suppose that these keys also represent the … [Read more…]

Posted in: .NET Core, C#, Reflection, Unit Testing Tagged: Csharp, Reflection, Static, Testing

ASP.NET Core – Unit Testing a file upload

March 29, 2019 by Robert 1 Comment

Last week I wrote about how to upload a file from a website using Angular and .NET Core.  Writing tests for this is mostly straightforward, but there’s a few gotchas that I thought I would write down for the next time I need to do this.  The front end tests are pretty trivial – you … [Read more…]

Posted in: .NET Core, C#, Unit Testing, Web API, Web Development Tagged: .NET Core, ASP.NET, ASP.NET Core, File Upload, IFormCollection, IFormFile, Testing, unit testing

Uploading a file from a website

March 22, 2019 by Robert 1 Comment

Uploading a file from a website is pretty simple, but I always have to look it up.  There’s all sorts of different technologies and frameworks that work with the web, so I just thought I would write down how I got it to work so that next time I can just come back here and … [Read more…]

Posted in: .NET Core, Angular, ASP.NET, C#, JavaScript, Typescript, Web API, Web Development Tagged: .NET Core, Angular, ASP.NET, File, MemoryStream, Typescript, Upload, Web API

NaN !== NaN

March 15, 2019 by Robert Leave a Comment

So there I was, minding my own business, again writing JavaScript tests… when suddenly I wanted to write a test to see what happens if NaN was supplied as a parameter. via GIPHY NaN Stands for “Not A Number”.  You can get a NaN in a few different ways: But when checking for NaN, there’s … [Read more…]

Posted in: JavaScript, Typescript Tagged: Falsy, JavaScript, NaN, Truthy, Typescript
« Previous 1 2 3 4 … 12 Next »

Recent Posts

  • Allowing trailing JSON commas in ASP.NET Core 3
  • YADNC3JSG–Yet Another .NET Core 3.0 JSON Serializer Gotcha
  • Logging in a .NET Core 3 SignalR client
  • .NET Core 3 unit testing project sdk
  • .NET Core 3.0 Upgrade–New JSON Serializer Gotchas

Recent Comments

  1. Robert on C# Setting Socket Keep-Alive
  2. Oliver Schramm on C# Setting Socket Keep-Alive
  3. John Anderson on Waiting for a keypress asynchronously in a C# console app
  4. Ronald Garlit on .NET Core 3 unit testing project sdk
  5. Ronald Garlit on .NET Core 3 unit testing project sdk

Copyright © 2025 Darchuk.NET.

Omega WordPress Theme by ThemeHall