Kategorier
Techblog

What’s new in .NET 5?

September 2020 marked the release of .NET 5 RC1, with a probable release for first stable version in November 2020. But what is .NET 5 and why should you care?

A unified .NET
One of the goals with .NET 5 was to create one .NET platform. Fusing .NET Framework, .NET Core and Mono/Xamarin into one.

There will only be one SDK. No matter if you’re making a desktop application, a web API or a mobile application – you’ll be using the same base class libraries and common APIs.

Performance improvements

  • 30% socket performance improvement on Linux over .NET Core 3.1
  • 19% Json serialization performance improvement over .NET core 3.1
  • 300% improvement in serialization of large collections and arrays – whilst not allocating any memory doing this thanks to the new zero alloc feature
  • Significant improvements to the System.Text.Json API
  • gRPC server performance exceeds Go, C++ and Java

Other new features in .NET 5

  • Support for C# 9 and F# 5
  • Introducing the ‘record’ keyword – a C# 9 feature allowing you to easily create immutable types
  • Smaller container image sizes
  • Support for ARM64 architecture
  • Greater support for assembly trimming – allowing unused types and members to be removed and thereby reducing the size of your applications
  • Single file applications. Applications that can be compiled within themselves without any version of .NET being installed on the machine(?!)
  • Out of the box OpenAPI support for web APIs
  • HttpRepl, allowing you to test and debug your APIs via command line

What’s next?

Microsoft will now try to make their releases of .NET more cyclic. Starting with .NET 5 in November 2020, Microsoft aims to release a new version of .NET every November. Even version numbers will also have long time support. This means that the version will have guaranteed support for a minimum of 3 years after release.

If you’ve installed Visual Studio 2019 v16.8 Preview 3 on your machine, .NET 5 RC1 can be downloaded here: https://dotnet.microsoft.com/download/dotnet/5.0

Happy coding!

– Magnus Sundström, System Developer B3 CodeRight

Kategorier
Techblog

Setup Jest unit testing with Svelte

Yesterday I discovered that it’s actually possible to do unit testing with Svelte! When I last tried to find how to unit test with Svelte at the end of 2019 it seemed that was something that wasn’t yet possible. Svelte still says there’s no good answer to this yet so I’d taken their word for it. But it’s very possible!

This together with the recently released TypeScript support really feels like a game changer for using Svelte in bigger projects and pushing it as an alternative when working with clients and colleagues.

So how do you do it?

According to the setup page that should be enough. For me, that was not the case. All import statements in .js files broke when I ran the tests. Svelte takes care of .svelte files, so those imports work. But if you’ve written Svelte apps before, you might know that sometimes you include regular .js files for utils or services, and they might use import statements too. The case for me was my stores.js that had import { writable } from 'svelte/stores', as well as all of my test files.

The test files are all .js files, unless you work with TypeScript, so imports will be broken there too.

Some error messages you might come across:

Test suite failed to run
import ‘@testing-library/jest-dom/extend-expect’;
SyntaxError: Unexpected string

or

Jest encountered an unexpected token
import { render, fireEvent } from ‘@testing-library/svelte’;
SyntaxError: Unexpected token {

You could of course get around this by using require() instead of importthroughout your app. The Testing Library says Babel and TypeScript are optional, but I’m not sure I agree. I don’t know of anyone who uses requirestatements for imports in a frontend application. This leads us to…

2. Setup Babel for Jest

3. That’s it. Your tests should run.

I didn’t really find anyone else with this problem because everyone seemed to be using Babel or Typescript from the start.

Tips for testing Svelte components

Here are some tips on how to test events, and how to render the components in the test files.

Here are some more good to knows for using jest-svelte.


Let me know if this helped you out, if it’s not working for you, or if something’s missing!

Thanks for reading ❤

– Bill Kurtson, Senior Frontend-developer