Steve Collins

Information & Communications Technology

c# .NET ASP.NET Core Configuration Managent

Worthing, England, United Kingdom

Steve Collins

Freelance software developer

Steve Collins is an independent software developer/architect with over 25 years’ experience in the industry working with Microsoft technologies.

Steve blogs at https://SteveTalksCode.co.uk and tweets @SteveTalksCode

Steve has given talks about configuration at events and user groups around the UK and has also discussed configuration as a guest on the Dot Net Core Show podcast https://dotnetcore.show/episode-49-configuration-in-net-core-with-steve-collins/ and the Documentation Not Included podcast https://www.youtube.com/watch?v=kXoprCDHBZM

Current sessions

.Net Configuration is Easy ... Right?

Let's face it, we've all done it at some point. You have a value in your code that you don't want to hard code as it will vary in different environments or needs to change in a runtime environment, so you want to make it configurable in a file. That's where the fun begins.

In the.NET Framework, you usually create an XML configuration file and reference it using some static methods. Or maybe you use the designer in Visual Studio to do the work for you? In .NET Core, you are given a JSON file by default and access it through the IConfiguration interface. Job done ...or so you think.

• How do you code the keys to access the values?
• How do you unit test it and what if you need to test different values?
• What if you want to store values other than primitive types?
• What if you want to have secure passwords, but don't want them in your source control?
• What if you don't want to use JSON files ... or come to that, don't want to use files at all?
• What if you want to change values in a Docker container
.. and the questions go on and on.

In this talk, we start with a brief overview of the history of configuration in .NET Framework and how Microsoft handed developers a loaded gun to shoot themselves in the foot. Moving on to .NET Core, things are much better, but there are still some gotchas.

Lastly, the talk goes on to deal with the questions raised above with a "SOLID" based approach that makes configuration not only fully testable, but adds enhancements to handle encrypted configuration values (because you're not storing passwords as clear text in source control are you?) and validation of the configuration data before it hits your code.

The talk aims to help new and intermediate developers avoid the pitfalls that others have fallen down and give experienced developers some food for thought as to how they might want to reconsider how they do configuration.

I have presented this at

* DDD East Anglia
* DDD Reading
* DDD North
* Dot Net Sheff user group - video at https://www.youtube.com/watch?v=kLl2Mt3eYxU&t=1s

Early versions of my other talk Dependency Injection - The Booster Jab have been given at Dot Net Milton Keynes and Dot Net Notts user groups in the UK. https://youtu.be/zo7TBLv4JxM?t=2836

I have spoken about configuration in .NET on two podcasts

https://dotnetcore.show/episode-49-configuration-in-net-core-with-steve-collins/

https://www.dnistream.live/show/12-file-configuration-blues


.NET Core Dependency Injection – The Booster Jab

With the release of .NET Core 3.x and the promise of a unified .NET 5 based on it, more developers have now got to grips with the basics of using the default Microsoft Dependency Injection container that comes with .NET Core. However, the story does not end there...

This talk will take you beyond the basics and cover more complex topics such as

* Avoiding unintended multiple registrations
* Conflicts between service lifetimes
* Understanding the Root and Scoped service providers
* Automated service registration packages
* Registering and resolving open generics, classes with multiple interfaces; and interfaces with multiple class implementation
* Integrating with other DI containers
* Key named registrations are not supported ... but I need it!
* Getting better startup performance from your registered services
* Thread safety and avoiding memory leaks
* Validating and unit testing your service registrations

The talk assumes that you have already had an initial dose of DI knowledge and are now ready for a top up to avoid some nasty bugs.

Early versions of this talk has been given at Dot Net Milton Keynes and Dot Net Notts user groups in the UK.

Dot Net Notts - Now That's What I Call Dependency Injection - https://youtu.be/zo7TBLv4JxM?t=2836

The talk was accepted for DDD East Midlands 2020, but due to COVID the event has been postponed.

I have presented my other talk - Configuration in .NET is Easy ... Right at

* DDD East Anglia
* DDD Reading
* DDD North
* Dot Net Sheff user group - video at https://www.youtube.com/watch?v=kLl2Mt3eYxU&t=1s

The session includes references to two of my blog posts

https://stevetalkscode.co.uk/named-dependencies-part-2
https://stevetalkscode.co.uk/simplifying-di-with-functions

I have appeared on two podcasts talking about configuration with reference to .NET Core DI


https://dotnetcore.show/episode-49-configuration-in-net-core-with-steve-collins/
https://www.dnistream.live/show/12-file-configuration-blues