I often find myself building little .Net tools to help me with repetitive jobs. And fairly often these need some config data to drive their behaviour. If I have a tool that runs on my home server as a Scheduled Task then providing a way to edit that config remotely can be important. A web app is one way of solving this problem - but it tends to be fairly high effort. Remoting to the server is another, but network security can make that a challenge. So an alternative solution is to expose the config file via WebDAV so that a simple remote tool can use HTTP protocols to edit it. Here's a basic example of setting that up...
I have a complicated relationship with WPF. When you know what you're doing, it's great for building desktop apps. It's much easier to handle scenarios like apps getting used across varying DPIs, or doing complex UI layouts. But there are a few bits of it which, when you don't know how to do them, aren't intuitive. I bumped into another one the other day: Needing to trigger an animation on-demand. And so I can remember this next time I need to do this, here's a quick write-up of one way to achieve it...
The pace of change with .Net is pretty relentless these days. And every so often they ship a thing that fixes a challenge I've been mulling over addressing myself. That's happened again with Process API changes in preview 4 of .Net 11. So if you have code which spawns other executables, you might want to look at what they've changed...
Sometimes it's the simplest things that can trip up development work. A case in point is a bug ticket I got handed recently, which I think shows the need to understand your tools when writing code. Read on to avoid an interesting mistake with code flow in Razor views...
One of the fun things about defining objects and their APIs in C# is thinking about which bits you want your consumers to see, and which bits need to be there just for you, and consumers should avoid using. Most developers are aware of keywords like
public
/
private
and
internal
for achieving this, but Explicit Interfaces are another approach to this...
Having been in development for a long time I've come across a lot of headscratching odd behaviour in code. Those issus have lead to a fair few conversations where people have looked at the odd behaviour and asked "is it a compiler/runtime bug?". And in all these years it never has been that sort of bug. But for the first time I have recently found a situation where some odd behaviour is C#'s fault...
So here's some info about the issue I saw this time, and what Microsoft are fixing as a result:
Over the festive break I spent a bit of time trying some of the challenges in this year's Advent of Code. I wrote the logic for my answers using LINQPad, and it struck me that this has become one of my favourite developer tools. So here are a few of the reasons why it's become a key part of my toolkit, and why it might be a useful thing to add to yours too.
A while back I wrote about the transition from T4 templates to using Roslyn Source Generators for generating code in .Net Core solutions. While that worked for me, and I was able to get it to do what I needed, I was never really happy with all the output source as literal strings in the generator code. Recently I had another potential use for generated code, so I decided to try and fix this issue...
There are certain "rules of programming" that I keep hearing about in my career. One that came up in an interesting work debate recently was "you should never use regular expressions to parse HTML". Don't get me wrong - there can be a lot of useful knowledge wrapped up in these rules, but should we always follow them to the letter? I think it's an interesting question...
Recently I found myself looking at a Visual Studio project where the build was not behaving in the way I expected. So I was forced to try a few debugging techniques to work out what was up. And in the process of trying to resolve the problem, I discovered an interesting tool to help with scenarios like this. So if you find yourself stuck with a misbehaving MSBuild script here are a couple of ideas: