Tracing IO in .NET Core

I was made aware of OpenTelemetry a while ago by a blog series Jimmy Bogard and put it in my favourites to read at a later date. Of course I didn’t really get back to it in depth and gave it a quick scan at the time although it is a well written in depth blog series so I suggest you do check it out. A while later I saw a blog post by Rehan Saeed which gives an introduction on what OpenTelemetry is and how it works and the concepts behind it and is definitely worth a read. At the same time I saw a YouTube video by Elton Stoneman that whilst more aimed at using tracing using Kubernetes he demonstrates a .NET app running and the tracing details appear in Jaeger

Read more...

Understanding type aliases

I recently wrote a single case discriminated union which is what I wanted but was also confused why it didn’t behave like a type alias and then learnt that these two are different things. type CustomerId = int type CustomerId = CustomerId of int I was aware of both syntaxes and from a quick scan they look the same however they behave differently and rightly so. As I travel the F# road there is more emphasis on creating types for your functions.

Read more...

Understanding F# applicatives and custom operators

After discussing something with Ian Russell he suggested I take some time to read through another fine blog post he has written and understand F# applicatives and custom operators. I found myself in familiar territory when reading F# blog posts and it’s something similar to the five stages of grief. Nod, Nod, I understand what’s going on, Umm, WTF is going on. As Ian did in his Intro to F# series he sets out a simple domain problem and goes about how to address it. We want to return a ValidatedUser from a function but if the user fails validation we return a list of validation errors.

The code in the blog post was pretty self explanatory until, it wasn’t, which I have pasted below:

Read more...

Understanding F# map/bind

This blog post aims to explain map/bind in F# in a code only example. It took me a while so I’m writing it up here so I can come back to it and re-read it for the 100th time most likely!

Read more...

Feature Management in F#/Giraffe/ASP.NET Core

Following on from Joe’s post I thought I’d see how one would do this in F# and Giraffe because why not? Turns out its quite simple. First, create a features.json file:

Read more...

Goodbye NancyFX, Hello F#!

As some of you may already know, NancyFX has been archived 11 years after its first commit. You can read the announcement here for further information but I will never forget what I learnt from this codebase, the community around it and most especially the people involved with it. I am very proud and honoured to have been involved with it and a massive thank you to Andreas Håkansson for teaching me plenty via the 1:1 Skype calls we had in the early days. As many of you also know I created Carter which in my mind was Nancy v2 but sat on top of ASP.NET Core with the same approaches as Nancy, offering many things a web framework should have. The usage of Carter has steadily increased which is good to know people value similar things we achieved with Nancy. However, paradoxically I have had a feeling brewing for sometime that this effort is almost futile.

Read more...

Announcing Carter

As of beginning of April 2018 Botwin has been renamed to Carter. Whilst I thought the name was genius it became obvious that some people didn’t like it or understand it and tried to interpret it as a Bot framework for Windows. After spending too long trying to think of a new name I finally decided upon Carter. Carter comes from the surname of Jay-Z (Shawn Carter) and in his song Empire State of Mind he sings “I’m the new Sinatra”. Sinatra is a web framework which inspired Nancy which heavily inspired Botwin.

The last release of Botwin was 3.5.0 but the same package has also been released under Carter 3.5.0

Read more...

Debugging .Net Core apps inside Docker container with VSCode

So by now using .Net Core on Linux is old news, everyone is doing it and deploying their production apps on Kubernetes to reach peak “I can scale” points. However, one thing that can get tricky is when you have a requirement to debug an application in a container. I believe VS on Windows and VS for Mac has some sort of capability to do that (I have no idea what it does underneath but hey who cares I can right click debug right!?) but the information about doing this in VSCode is a bit sketchy. I tend to use VSCode on OSX the most so I wanted to see how I could do this.

For demonstration purposes lets take a very simple application and we are going to publish it as a self contained application ie/one that has all the runtime and application binaries outputted so you don’t have to install dotnet in a container.

To be able to debug that application we are going to need VSDBG(the .Net Core command line debugger) inside the container.

curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l ~/vsdbg

We are also going to need to append the launch.json for VSCode in your project’s root to have the below:

{
    "name": ".NET Core Remote Attach",
    "type": "coreclr",
    "request": "attach",
    "processId": "${command:pickRemoteProcess}",
    "pipeTransport": {
        "pipeProgram": "bash",
        "pipeArgs": [ "-c", "docker exec -i json ${debuggerCommand}" ],
        "debuggerPath": "/root/vsdbg/vsdbg",
        "pipeCwd": "${workspaceRoot}",
        "quoteArgs": true
    },
    "sourceFileMap": {
        "/Users/jonathan/Projects/jsonfile": "${workspaceRoot}"
    },
    "justMyCode": true
}

Read more...

Using Docker with .Net Core in CI for OSS

I recently wrote a project for ASP.NET Core 2 and the time had come to get a CI system up and running. I develop on OSX and mainly test on OSX & Linux and so the defacto place to go is TravisCI. I’ve used it in the past and all has been great but I put out a tweet asking if Travis was still the place to go:

Read more...

Announcing Botwin

Whilst keeping my eye on what’s going on in .NET Core v2 I came across some planned changes for ASP.NET Core regarding the routing. I had also read this blog post from Filip about using the planned changes for microservices and a lightbulb went off in my head. I thought to myself I wonder if I could adapt the new extensions to create Nancy-esque routing. Turns out, I could!

Sample

public class ActorsModule : BotwinModule
{
    public ActorsModule()
    {
        this.Get("/", async (req, res, routeData) =>
        {
            await res.WriteAsync("Hello World!");
        });
    }
}

Read more...