Skip to main content
Home  ›  Blog

2sxc 16.03 Released - even more Typed

2sxc 16.03 is another big step in strictly typed code. 


  1. We've massively improved the new typed mode introduced in 16.01 and 16.02.
  2. Note that this does introduce some small breaking changes to very new code - so it should not affect most users.
  3. Plus a lot of other enhancements

Typed Mode Very Strict by Default

The new typed mode should help developers detect problems during development and not at runtime. In addition to having a strictly typed C# API, we've now also ensured that getting any property such as FirstName or Birthday will also verify that this field exists. Here's why: 

  1. We discovered a lot of code such as if (item.Bool("HasImage")) { ... } which was using fields that didn't even exist! This led us to believe that as code evolves, things are left over which don't do anything.
  2. We also discoved code where bad naming lead the developer to believe the item contained a different object than expected (eg. a Tag instead of a BlogPost).

We know that there are scenarios where you need a less-strict approach, eg. when looping through a list of items of different types (eg. Person and PersonExtended). This is still possible using (..., required: false) and other tricks.

Note that if you do access a field that doesn't exist, you'll get some really nice help, as shown in the image here: 

📖 Read more about this in the docs

More Checking-APIs in Typed Mode

As things get more strict, so does the need for the C# code to check if a property exists and has useful content. We added the following APIs:

  • ContainsKey(name)
  • Keys() - lists all keys, or just specific ones
  • IsEmpty(name)
  • IsNotEmpty(name)

These are useful in many scenarios, so stay tuned for samples in the tutorial coming up soon.

More APIs in Typed Mode

  1. item.Picture(name, ...) is great for adding Picture tags, and much simpler than going through the previous Kit.Image.Picture(item.Field(name), ...) APIs
  2. The .String(name, scrubHtml: ...) was improved. You can now still provide true/false, or you can provide a list of tags such as "p" to only scrub specific tags from the HTML. This is great for teaser-texts and more.
  3. AsItem(..., mock: true) allows you to create virtual/fake/mock items, which have the same API like a real item, but with data that was invented in the code. This is great to provide alternate items when the query doesn't result with anything real.
  4. Json Wrappers like var jsonObj = Kit.Json.ToTyped(someJson) now support path queries, so you can do jsonObj.String("Parent.Child.Id") and more. 

More Image Enhancements

  1. The ImageService on Kit.Image now can better handle IFile objects to automatically find descriptive metadata for an image and crop-configurations 💃🏽
  2. We now include a new settings preset called Square for - you guessed it - square images. 

Error Help

A minor but helpful feature is that the error messages now try to spot your code file and mark it with a target emoji: 🎯. This will help you figure out problems even faster. 


Get it now from Github releases ☁️

Love from Switzerland, and Croatia,

Daniel Mettler grew up in the jungles of Indonesia and is founder and CEO of 2sic internet solutions in Switzerland and Liechtenstein, an 20-head web specialist with over 800 DNN projects since 1999. He is also chief architect of 2sxc (see github), an open source module for creating attractive content and DNN Apps.

Read more posts by Daniel Mettler