| |

NET 8 – Include non-public members in JSON serialization

Starting with .NET 8 you can include non public properties in the serialization when using System.Text.Json. To do so, simply decorate the non-public property with the JsonIncludeAttribute attribute. The attribute works with any non-public modifier, such as private, protected or internal. Let’s look at an example: As expected, this will output the following:

|

dotnet workload clean

Note: this command is only available starting with .NET 8. This command cleans up workload packs that might be left over after an .NET SDK or Visual Studio update. It can be useful when encountering issues while managing workloads. dotnet workload clean will clean up orphaned packs resulted from uninstalling .NET SDKs. The command will…

|

NET 8 – Deserialize into read-only properties

Starting with .NET 8 you can deserialize into properties which do not have a set accessor. You can opt-in for this behavior using JsonSerializerOptions, or on a per-type basis using the JsonObjectCreationHandling attribute. Using JsonObjectCreationHandling attribute You can annotate your type with the System.Text.Json.Serialization.JsonObjectCreationHandling attribute, passing your option as a parameter. Using JsonSerializerOptions You can…

NET 8 – Handle missing members during JSON deserialization
|

NET 8 – Handle missing members during JSON deserialization

By default, if you have additional properties in a JSON payload you are trying to deserialize, they are simply ignored. But what if you wanted the deserialization to fail and throw an exception when there are extra properties in the JSON? That is possible starting with .NET 8. There are several in which you can…

SqlLiteNet – no parameterless constructor defined for this object on ExecuteQuery

You are likely trying to retrieve a single column from a table in your database by passing something similar with SELECT <column_name> FROM <table_name> to an ExecuteQuery<string> or ExecuteQuery<int>. The problem with that is that ExecuteQuery<string> expects a type having a parameterless constructor – for which string does not qualify. There are two possible solutions:…

C# 12 – Inline arrays

C# 12 – Inline arrays

Inline arrays enable you to create an array of fixed size in a struct type. Such a struct, with an inline buffer, should provide performance comparable to an unsafe fixed size buffer. Inline arrays are mosly to be used by the runtime team and some library authors to improve performance in certain scenarios. You likely…

Flutter – Fix The getter ‘accentColor’ isn’t defined for the class ‘ThemeData’

Flutter – Fix The getter ‘accentColor’ isn’t defined for the class ‘ThemeData’

The most likely cause of this error is an update to Flutter (flutter upgrade) which led to some imcompatibility with your existing code or your project’s dependencies. The Theme.of(context).accentColor property has been deprecated since Flutter 1.17 and is entirely removed from the current version, thus the error your are seeing. What to use instead Or, if…