RSSAmplifier

Blog

Jonathan Channon's Blog

Recent content on Jonathan Channon's Blog

blog.jonathanchannon.comRSS feed ↗70 posts

Latest posts

Agentic Semantic Data Modelling in C#

Over the last few weeks I’ve been working on a feature that allows us to take advantage of AI within businesses and providing increased value to stakeholders. It’s a natural language query interface that allows non-technical users to ask questions about data in plain English and get back meaningful results. No SQL to write, no reports to configure, just ask a question and get an…

Running C# against Ollama

In my previous posts I introduced AI concepts and then showed how to use AI in a C# app using the cloud providers. In this post I want to expand on Ollama and show you how to build a chat agent in C# that runs entirely on your local machine.

Using AI in a C# app

Following on my from my previous introduction to AI post I thought I would now introduce how to use the AI providers in a C# application. We may want to build some AI features inside a new or existing app and so where do we start as a C# developer? This blog post will go through a fairly simple example just to illustrate the “how” and then you can adapt it for your needs and maybe…

Introduction to AI

If you can’t beat them, join them is probably the best quote to sum up my experience with AI. We have known for a long time AI is changing the way we work however, we all know how unreliable it is and personally I have seen that for a long time when it “helpfully” suggests code suggestions as I type. I have also seen how unreliable it is when using an AI Assistant to do something…

Using Azure AD authentication for a Go API

So after a long time I thought I’d take another look at Go and whilst struggling to think what little app should I write to get back in the saddle with, the legend that is Christos Matskas mentioned he wanted to try using a Go api against Azure AD for authentication. So I fired up GoLand and got to work writing an API. Setting up Azure AD You will need to create an Azure Directory in your…

Terminology Glossary

This page will list and describe common words and terms that you might come across as a software developer which you can refer to at a later date knowing there’s a place to go to when someone uses a term that you don’t know, are unsure of or can’t remember Terms Cohesion - Composition Root - Coupling - Cross-Cutting - KPI - Lift & Shift - OKR - Orthogonal - Projection - Shift…

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…

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…

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…

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!

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:

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…

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…

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…

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: Is Travis still the go to Linux CI tool for OSS? — Jonathan Channon (@jchannon) May…

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…

Building all and current dotnet core projects in VSCode

As you may or may not know I try to work on OSX as much as possible and with .Net that’s quite painful to be honest. Things are moving along nicely with Jetbrains Rider, VSCode, Xamarin and Omnisharp. I’ll be honest, none of them are perfect and I often find myself using Visual Studio in a VM because it just works (yes, its clunky etc etc). Recently, VSCode got a 1.3 release with some…

Porting OWIN middleware to ASP.Net Core

In our application at work we make use of various middleware and as we are making everything run on .Net Core the time has come to port said middleware to .Net Core. If you don’t already know ASP.Net Core has a bridge that allows you to use OWIN components in an ASP.Net Core application. This will convert the HttpContext into a OWIN environment dictionary on input and then back again on…

What is a Hypermedia client?

I’ve been interested in Hypermedia for quite a while. I bugged Darrel Miller and Glenn Block (Glenn Miller) so much so they created a YouTube show called “In The Mood for HTTP”. I bought their book “Designing Evolvable Web APIs with ASP.NET” , I am waiting for “RESTful Web Clients Enabling Reuse Through Hypermedia” by Mike Amundsen , I have written about…

VQ Communications Funds NancyFX to run on CoreCLR

Nearly 2 years ago I was employed by VQ Communications primarily because of my open source contributions to NancyFX . They had started work on a v2 of their flagship product and had begun work with Nancy and needed someone to help drive a HTTP API and architect a scaling solution as their v2 product was addressing a requirement they had for it cope with large volumes of traffic. Also of interest…

Profiling a CoreCLR application with dotMemory

I had ported an application over to CoreCLR (that’s a whole other blog post), along with my colleague James Humphries put it in a docker image and sat back and watched it do its thing. After 6 hours of running the docker container had crashed. Ah nuts we thought, so pulled up the logs from docker and the last line looked like this 2016-02-10T20:18:31.728783069Z Killed . I’m pretty sure…

Introducing Negotiator - a GoLang content negotiation library

In my continued experience learning GoLang I started looking at how to best use it when dealing with HTTP. The idiomatic way to use GoLang and HTTP is to use the standard library which keeps things minimal but there are a few features missing. The first thing is a router. OOTB GoLang doesn’t have a router and the majority seem to suggest using a package called Mux from Gorilla Toolkit, a set…

Introducing PoGo - a GoLang, Twitter favourites to Pocket importer

I’ve always kept myself up to date with the latest languages arriving on the scene and I’ve spent time in the past learning Node and last year I learnt Python by doing the Omnisharp plugin for Sublime. I have recently been looking for a static language that I can transfer my C# skills too and I had narrowed it down to 3; Swift, Kotlin and GoLang. I started out with Kotlin and setting…

NancyFX and Hypermedia

I’ve been slowly educating my self on hypermedia; what it is, how does it help and how to use it. I must say I’ve found it a very interesting topic and I thought it was time I put some information into a blog post just in case the 2 people that read this blog might find it useful. In my day job I’m responsible for a HTTP API (notice I didn’t use REST) and some months ago I…

Cookie Authentication & CRSF with AngularJs, Owin & Mono

I’m currently working on a project that has Nancy serving up an API. For the UI there is AngularJS. We were using JWT for authentication just to get us up and running but then as things became more final in the product we knew it would be better to swap to cookies for security plus we may as well leverage the browser capabilities for cookie handling. I’m not going to get into the…

Running Gulp in Visual & Xamarin Studio

I was going to write a long post explaining about all the pain I went through to get this working but then realised you probably don’t really care and you just want the code!

Microsoft Endorsing C# as a First Class Citizen in Sublime Text

At the end of my last post on using ASP.Net vNext with Sublime Text I briefly mentioned a plugin that aimed at giving intellisense for C# within the editor. Well 2 months later and I’m happy to announce that intellisense works and I’ve added a slew of other features that will hopefully make you feel at home away from Visual Studio. I discovered the plugin thanks to Jason Imison but at…

Nancy, ASP.Net vNext, OSX and Sublime Text

One of the great things that ASP.Net vNext is bringing is the ability to use it cross platform with Microsoft actively testing their libraries against Mono . Along with this MS are developing a web server that is cross platform and goes by the name of Kestrel . One thing they aren’t doing, yet, is making Visual Studio cross platform so we need something to write our code in. There a few…

Nancy, ASP.Net vNext, VS2014 & Azure

By now we know of Microsoft’s plans for the next version of ASP.Net and they’ve turned it on its head and from the looks of it, its goooooood! Here is a blog post from Scott Hanselman introducing ASP.Net vNext. There are introductory and deep dive videos available for your perusal which are also well worth a watch. The TL;DR is ASP.Net vNext will take heavy influence from Node.js by…

Modifying the bash prompt and adding Git completion to terminal

At work we use Git and I use Console2 to control my terminal envrionments eg/Git Bash, Powershell, Dos and when using Git I can type part type a git command press tab and it will auto complete the command or offer suggestions to commands. By default on OSX this behaviour is not present and it frustrated me enough to go and find out how to enable that behaviour. Fire up your terminal and type in…

Introducing Owin.StatelessAuth with Nancy/Angular demo

If you’re writing an API, current thinking is to provide a token in the Authorization header for your app to validate when the request comes in. I have used the Nancy.Authentication.Stateless package in the past for my APIs and even have a demo of it here if you’re interested (there are more Nancy demos at http://samples.nancyfx.org ). This is a great package and does a great job but…

Using NodeJS and FTP with Promises

I’ve played with node in the past but as of the new year I decided to try and make a more concerted effort to get stuck into node properly. I decided to go back to the beginning to try and get a better appreciation for the language so read “JavaScript: The Good Parts by Douglas Crockford”. I found that exercise fulfilling and resulted in a few light bulb moments that made some…

Unit Testing with SqlException

So after a nice Christmas break I get to some code that needs some unit testing around a try/catch. Something similar to this: try { myService . DoSomethingThatMightTakeALongTime (); } catch ( EntityCommandExecutionException ex ) { var exception = ex . InnerException as SqlException ; if ( exception != null ) { if ( exception . Number == - 2 ) { //Do something special } } }

Using SQL Server with node.js

I like to keep eyes and ears open for new technologies and methodologies in order to become a better developer and I’d heard about edge.js many months ago but made a mental note of it and waved it goodbye. edge.js lets you have two-way communication between node and C# libraries. When I first looked at it I thought that sounded a bit hacky, I’ve spent my time communicating with COM…

Octopus XML Transformation in Services

We use Octopus Deploy at work and its a superb tool for deploying your applications whether they be websites or *.exes. One of the great things it also provides is the ability to use Microsoft’s Transformation process for config files. However, when deploying a exe application its a bit trickier than a website. Unfortunately the documentation doesn’t mention the steps needed to get…

Using Git to update YouTrack via TeamCity

This post is mainly a reminder for me as I keep forgetting the command in Git to integrate commits to YouTrack items. YouTrack uses TeamCity to get the information about the commits and then scans the commit comment for a YouTrack item id and any commands that it can apply such as item status or time spent on said item. There is some documentation here but its not the greatest in terms of clarity…

Running Mocha tests within Sublime Text

I spend most of my day in Visual Studio with lots of the goodies an IDE can offer. One of them being able to run your tests from a keystroke. In a bid to expand my mind I’m working on a little project that is made up of JS entirely so I’ve dug out Sublime Text . It has lots of plugins that are very handy, especially Sublime-HTMLPrettify which will tidy your HTML, CSS & JS for you. When…

Blogging with Markdown & Deploying via Git - Introducing Sandra.Snow

There are many markdown blogging engines out there such as Calepin , Scriptogram and even WordPress allows you to write blog posts in Markdown but Sandra.Snow tries to add something different. Firstly, it is written in .Net and Nancy , secondly its a static blog generator and finally it supports Git deployment. Even if you don’t want to use Git deployment you can use FTP, its a great tool.…

Returning multiple fake objects with FakeItEasy

I was recently writing some unit tests where I needed to test that multiple calls to an interface returned different objects. With FakeItEasy this is easy: A . CallTo (() => myInterface . GetSomething ( 1 )). Returns ( new Something ()) All very nice, but now if I have multiple calls to myInterface I have to execute the above statement ‘x’ amount of times: [Fact] public void…

Enabling CORS in IISExpress

I was playing around with swagger-ui and was trying to point it to a local endpoint that I started with IIS Express. I was getting an error saying that it needed the endpoint to accept Access-Control-Allow-Origin requests. I went Googling and it couldn’t find anything specific to IIS Express but managed to use some guidance for full blown IIS. The solution is to go to C:\Program Files…

Keeping SQL Data Organised in Integration Tests

In my latest project I had kept my solution tidy with my main app project, my unit test project and integration test project. I tend to stick with a naming convention such as MainApp, MainApp.Tests.Unit & MainApp.Tests.Integration. I had begun writing my integration tests for a repository that hits the database and returns data. Currently it was one method being called in the repository. xUnit…

Comparing object instances with FakeItEasy

I had the task of writing a new application recently and of course I chose Nancy . One of the many great reasons is the testing capabilites it offers (For more on that see this great series of articles). The basics of a test with Nancy looks like this: [Fact] public void Should_return_status_ok_when_route_exists () { // Given var bootstrapper = new DefaultNancyBootstrapper (); var browser = new…

Async Route Handling with Nancy

I don’t know about you but all I hear is “ASYNC ALL THE THINGS!”, I think this is partly down to its new and shiny and us developers love “the shiny” and partly a lot of the things we do in our applications are I/O based whether that be database or file system. The problem that comes with the new and shiny bandwagon is you need to understand what you’re…

A quick look at Visual Node

I came across Visual Node a few months ago and was excited by the looks of it. For those that didn’t click that link, it basically brings the power of Visual Studio debugging to a node.js app. You can write your node.js app in Visual Studio, fire up the debugger by hitting F5 and use breakpoints and watches to see what’s going on. The hipster in me is screaming saying “You should…

Modifying files within Git history

If you have been doing code changes and committing as you go and then look back at the changes you may see something you don’t like the look of. Assuming no-one has a copy of your code changes you can go back and modify the files at a certain point in time within your commit history. I use Git Bash by default but the editor sucks compared to Sublime Text so first things first lets setup the Git…

Why .Net should become independent!

I recently changed jobs and as usual was at the mercy of recruitment agents. The advert for my job contained things like ASP.Net MVC, Entity Framework & TFS (luckily there were other cool pieces of technology on that list and what the role entailed interested me and once I had joined the company I saw they were open to other tech/approaches that made people’s workflow and output more beneficial to…

Mocking HttpContext with Fake It Easy

Lets start with the conclusion first and say “use Nancy for your web applications and APIs” as its brilliant! If you want to continue reading lets crack on. I’m currently working on a ASP.Net MVC project and one of the controller methods writes directly to the Response, eg. Response.Write(“How will I mock thee?”); Having moved over to xUnit and FakeItEasy recently I wanted to write a unit or…

Up & Running with TypeScript and WebStorm

I love my iMac and I’m on a mission to find a language I enjoy that I can use my Mac for (no Windows fan boy jokes please). There’s something in my mind I associate with work and my Windows laptop. Therefore, I don’t feel to excited about getting my laptop out of my bag in the evenings/weekends to play with other stuff. As I want to broaden my knowledge I wanted to find something ideally…

Using a Markdown ViewEngine with Nancy

Whilst using stackoverflow.com and Github gists I’ve become a frequent user of Markdown . For those of you that don’t know what Markdown is, its essentially a shorter/cleaner syntax that can be parsed to produce HTML. Below are a few examples: #Hello World! ## You're awesome! The quick brown fox jumped over the lazy coder What the **hell** is this? This is an [ example link ]( http://example.com/…

Using DateTime in C# and SQL

I’m sure there are millions of blog posts out there that already discuss this but I think its worth noting down even if its just something for me to remember. Store your datetimes in UTC format into the database. Unfortunately this mean executing something like: myObject.ExpiryDate = TimeZoneInfo.ConvertTimeToUtc(dateTime, TimeZoneInfo.FindSystemTimeZoneById(“timezoneid of users”) In every central…