Tuesday, July 19, 2022

Modernize legacy .Net Framework Console apps with .Net Core ILogger & DI

There are already lot of  tools and techniques to modernize .Net Framework applications by migrating to .Net. There is a question what modernization we are getting by changing the runtime without changing the architecture or at the minimum UI? That question we are keeping aside and taking the requirement of modernizing a decade old legacy monolith .Net Framework app having a million lines of code. 

Here the tools can do limited things. That app may be not at all having the concept of Dependency Injection, lot of COM components used and built on top of WCF and old remoting. On top of that if there is no budget to reserve a release just to modernize.

None of the quick techniques works there. One strategy could be to modernize it part by part. At least to start with we can start refactoring to the Dependency Injection using ServiceCollection and ILogger usage similar to .Net Core and .Net Application. 

The question may come can we use these .Net Core programming model in .Net Framework apps. The answer is yes if we are in .Net 4.8 or a version that supports the nugets. We should really thanks to the concept of .Net Standard and design of modern .Net as modular using nuget packages.

One such mechanism is explained in the below video. 

We can still stay in .Net Framework and we can use .Net Core Programming model such as Dependency Injection and ILogger usage.


  

Source code is available in GitHub.

No comments: