Posts

Showing posts with the label C#

NUnit Console Runner and NLog extension logging for your tests

Image
Have you experienced the frustration of tests running perfectly well on your local machine and then failing in CI? This all too familiar "It worked on my machine" comes to mind. You set off to investigate and after a while you realize you are too far into the rabbit hole between code and logs in Kibana and this investigation is getting you nowhere. Wouldn't it be nice if you could hijack the logger and print the logs in the test runner's console? TL;DR NLog can be extended easily and NUnit  Console Runner does not play well with simple console logs.   Photo by  Kaboompics .com  from  Pexels Enter Console logging In .Net in general it is not advisable to log to console in a multi-threaded environment, because the console is not thread safe. While logging simple strings may not cause any problems logging strings with interpolated variables may very well be sub optimal to say the least. Should you use any such debugging technique you are better off with a thread safe f

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... Photo by  Daan Mooij  on  Unsplash 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, chan

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.... Photo by geralt on Picabay 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). NDepend desktop Dashboard At the same time a very nifty HTML based dashboard popped up in my browser NDepend HT

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. VSCode showing off extensions The month became two months and then 3 months and here I am with a list of very handy (in my opinion)