Posts

Showing posts with the label .NET Core

Evaluating NDepend on current codebase Part 2

Image
In Part 1 we saw a first approach to NDepend starting off with analyzing a project of 2 assemblies and focusing on the smaller assembly. In this part we will focus on the main executable and the gems NDepend discovered in it TL; DR Memory leak detected...


Enter 3 years old WPF project - Main executable Going back to the dashboard I see the "usual" long types or methods errors, some immutability warnings, which I would have set as errors and 400 violations of "Avoid namespaces mutually dependent" some with debt time of 4 days. "Oh come on.. what 4 days. How hard can it be..."
Drilling down into the code (a wpf application) I realize that there is a single class that is injected in the constructor of every view model and I hardly see any services in the system save for calls to the DAL assembly.
Without drilling down into the class I changed it's namespace and made the necessary, albeit sisyphic, changes to all the classes. While at it I noticed that so…

Evaluating NDepend on current code base Part 1

Image
A while ago I was asked by one of NDepend's founders to evaluate any .NET code base I wanted with NDepend and write a blog post about it. It turns out I came up with a two-part post. TL; DR Oh boy....


Enter 3 years old WPF project Without revealing the nature of the specific project I would just say it is a feature rich client, with UI elements customized to the customer's needs. It is written using MVVM, some third party grids and communicates with an SQL Server database via a classic  DAL class library. All and all the project is comprised of one executable and one DAL assembly.
So off I went and added the necessary assemblies to a new NDepend project and let the analysis run. Given the size of the project it was pretty swift and started off with a a dashboard (or at least this is the view I chose to start from).


At the same time a very nifty HTML based dashboard popped up in my browser



The dashboard (as expected from its name) gives one a very good 10000 feet overview of th…

Tests code coverage in Visual Studio Code with C# and .Net Core

Image
While writing tests for you code goes without saying, there is much to be said about code coverage of tests. How much of your code is actually covered by these tens of tests you just wrote? If you work in a TDD approach most probably you don't have such "mundane" questions. Of course you code is 100% covered. You did make sure every test failed before you added that line in your code to make it pass... and that conditional statement... or did you? While purists would argue there is no chance of no coverage I beg to differ. Let alone if you write your tests after the code is written... After such and such years and experience in the industry when we are nearing deadlines some things are thrown out the window. They shouldn't but they are. TL;DR tools help with coverage. In this case .Net Core Test Explorer with coverlet and Coverage Gutters.

Coverlet to the rescue As I blogged a while ago I have made myself a warm and cozy development environment for Visual Studio Code…

Visual Studio Code setup I use for C# development

Image
Visual Studio Code has been around a while. However most of the extensions or blog posts out there relate mainly to extensions that facilitate development in JavaScript environments such as Angular, React or NodeJs (to name a few) and even Rust! The IDE is getting great reviews as being fast to load and very responsive as opposed to its bloated and heavy bigger brother, Visual Studio. TL;DR I switched from Visual Studio for good

Having worked on Visual Studio since version 4.2 I was used to it being heavy to load and at times even slow to respond. After experiencing VS Code with a little bit of NodeJs development I decided to try and make it my daily driver for .Net Core and C# development. I sought to find extensions to ease my day in the cubicle and see how comfortable will I be with it. I would give it a month on various tasks and workloads.

The month became two months and then 3 months and here I am with a list of very handy (in my opinion) extensions for vscode. Some of them usef…

Using custom health checks with Asp.Net Core 2.2

Image
I almost burst with cries of joy when I saw the release of .Net Core 2.2 with the much needed built in and standardized health checks. The preview was great and with each version until the release new blog posts emerged eager to show to the world the new wonder. But as I do like my frameworks fully baked and released I waited patiently for the real deal.
TL;DR Implement your own service from IHealthCheck and inject it with whatever you want. It just works!
Reading the instructions... The best article I found for the new healthcheck API was this one based on preview code and the best code samples where of course the official samples. However by looking at them something was missing. So I went on a quest to achieve what suited my needs. And my needs are simple. I need to be able to inject some testing code to my custom health check module.
On to the code After I practiced a little bit with the concept of tags I just added a health checking service to the standard DI container as such Odd…

Running an Asp.Net Core 2.* Web API as a Windows Service

Image
At my current workplace there is a healthy hunger for new technologies and a pragmatic view of the software industry in our corner of the planet. As a Microsoft driven shop, previous reservations of moving to different ecosystems and operating systems have melted away with the arrival and wide adoption of .Net Core. After all the language is the same. The developers need "only" to catch up on their containers. When I joined a month ago as a tech lead, little did I know that putting my money where my mouth is would mean having to deal with outdated Microsoft documentation or even S.O answers to questions such as "How do I run an Asp.Net Core app as a windows service without IIS".
TL;DR add a reference to the NuGet package  Microsoft.Aspnetcore.Hosting.Windowsservices, publish and register your executable as a service.
A Prophecy? Almost a year ago I wrote a blog post about porting full framework projects to core. Ever since I have written my share of .Net Core, Pytho…

How to port a .NET framework project to .NET Core including tests - A Guide

Image
So you want to port your project to .Net Core and don't know how? Are you reluctant to let go of your traditional .Net Framework targeting but want to have a taste of the new .Net buzz?  Is the information on the subject incomplete or too confusing (yes it usually is). Well you have come to the right place. TL;DR This is guide. It will hopefully save you time. Rejoice.
A tale of two frameworks (well actually 3)  I will make this one short and sweet and let this article tell the tale. I recommend to read this article  before you continue: .NET Standard - Demystifying .NET Core and .NET Standard.
To port or not to port It depends If this is your production code and there is no prospect to run it in a platform other than windows then maybe not. If it is a huge complicated project then maybe notIf it is your open source baby maybe yesIf it is a new project and you see the benefit of it being cross platform maybe yes The considerations are many and it is up to you to decide. In any case…

.NET Core - a quick observation

.NET Core is:

A substantial rewrite of .NET in the makingA better .NETA multi-platform .NETA way to leverage an amazing language like C# over Linux and IoT (based on Linux) .NET Core is not:

A one stop shop  - yet Only for webOnly for cloud development