matkv.dev


TIL - Today I Learned

Run C# files directly with dotnet run
25 Jun 2025

With .NET 10, it is possible to run C# files directly using dotnet run app.cs - no need to create a project/solution. It is also possible to add NuGet packages like this:

#:package Humanizer@2.14.1

using Humanizer;

var dotNet9Released = DateTimeOffset.Parse("2024-12-03");
var since = DateTimeOffset.Now - dotNet9Released;

Console.WriteLine($"It has been {since.Humanize()} since .NET 9 was released.");

Adding #!/usr/bin/dotnet run at the top of the file allows you to run it directly from the command line without needing to specify dotnet run every time. So this way we can use C# as a bash script alternative.

Asking for user input in a VSCode launch.json file
21 Apr 2025

While playing around with Zig (not that I’m actually going to try and learn it anytime soon I think) I had GitHub copilot generate the launch,json file for a little hello world app. Apparently you can ask for user input directly this way:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "lldb",
      "request": "launch",
      "name": "Debug Zig Executable",
      "program": "${workspaceFolder}/zig-out/bin/${input:executableName}",
      "preLaunchTask": "build",
      "args": [],
      "cwd": "${workspaceFolder}"
    }
  ],
  "inputs": [
    {
      "type": "promptString",
      "id": "executableName",
      "description": "Enter the name of the executable to debug (e.g., zig_hello_world)"
    }
  ]
}

When pressing F5, a little dialogue pops up and asks you to input some text which is then used in the config. Pretty neat.

Multiple authors in a git commit
22 Mar 2025

It is possible to add multiple authors to one git commit on Github.

You just need to add “Co-authored-by” to the end of the commit message followed by the co-authors’ name and email address. This works for multiple co-authors.

git commit -m "Your commit message" -m "Co-authored-by: Name <email>"

This will then show up in the commit history on Github. I don’t think it works on Azure DevOps.