Your source of geek knowledge

Y

Latest stories

Our journey to F#: C#-F# Interop

O

When we started with TimeRocket in 2015, we used C# as the programming language for our backend. In 2020, we started using F# for our new code. We see little value in rewriting existing C# code to F# and do so only when major changes are due in existing C# code. As a result, we have quite a bit of C#-F# interop in our system. Both from C# to F# and from F# to C#. This post overviews what we learned about C#-F# interop. This blog post is part of the F# Advent Calendar 2022 – check out the...

Using System.Text.Json alongside Newtonsoft Json.Net

U
Fast car

In June 2019, Microsoft introduced System.Text.Json as a feature of .NET (core) 3.0 to the public. The reason they gave for creating this new namespace was that they were unhappy with the old built-in solution for serializing / deserializing JSON. The poor built-in capabilities to work with JSONs –of course- was the reason for James Newton-King to create Json.Net (for many of us just called Newtonsoft, which actually is his company and not the name of the library). Newtonsoft’s Json.Net...

Creating a lazy-loading wrapper component in Angular

C
Report

A couple of weeks ago, one of my colleagues was tasked with implementing multiple customizable reports for our software. So, he did some research and found ActiveReportsJS by Grapecity. It allows us to create templates for reports, which could then be edited by our users to fully customize the appearance of those reports. Not only that, but it allows for PDF previewing on the one hand and headless exporting the PDFs on the other.   To my surprise, the PDF rendering takes place in the...

Our journey to F#: The effect of F# on our (unit) tests

O

On our journey from C# to F#, we were at a point where we changed our (unit) testing strategy. Our approach just didn’t feel right anymore. We struggled to do TDD because we didn’t get the tests to fail first. We wrote tests that didn’t increase our confidence and started thinking of them as waste.

This post is part of the F# Advent Calendar 2021 
Thanks to Sergey Tihon for organising the Advent Calendar.

Pimping Unquote

P

Unquote is a great library for writing test assertions in F#. In our acceptance tests, we frequently check data structures for equality. When these data structures get bigger, reading test failure messages gets harder. That’s why I implemented an F# data structure differ around Unquote that lets me quickly see the differences.

Type-safety across .Net and TypeScript – Testing JSON serialization and deserialization

T

This is part 7 of how we generate types from our .Net backend to be used in our TypeScript client. Why do we even bother?Generating TypeScript constants from .Net constantsFinding the types used in communication between the .Net backend and the TypeScript clientGenerating TypeScript classes from .Net typesGenerating Angular Services from .Net WebApi ControllersTypeScript-friendly JSON serialization of F# typesTesting JSON serialization and deserializationPutting all the parts together In the...

Our journey to F#: making async understand Tasks

O

In our F# code, we have a lot of asynchronicity: query the DB, call external services, write messages to the service bus, etc. Inside of our happy F# bubble we use async workflows, either by using Async or by using the computation expression async { ... }. But we are surrounded by a world of Tasks. So we often need to call functions or methods that return a Task. Of course, that is no big problem, we can just add |> Async.AwaitTask, but that leads to a lot of visual clutter in our precious...

Recent Posts