Breaking changes for migration from Version 3.0 Preview 6 to 3.0 Preview 7

Important

This article is under construction. This is not a complete list of .NET Core breaking changes. For more information on .NET Core breaking changes, you can examine individual breaking changes issues in the dotnet/docs repository on GitHub.

If you are migrating from 3.0 Preview 6 to 3.0 Preview 7 of .NET Core, ASP.NET Core, or EF Core, review the following topics for breaking changes that may affect your app:

CoreFx

JsonElement API changes

Starting with .NET Core 3.0 Preview 7, some JsonElement APIs have changed to allow for easier discovery and greater usability.

Change description

In .NET Core 3.0 Preview 7, JsonElement APIs have changed as follows to allow for easier discovery and greater usability.

  1. All WriteProperty method overloads were removed from JsonElement. This affects code such as the following:

    using (JsonDocument doc = JsonDocument.Parse(jsonString))
    {
       JsonElement root = doc.RootElement;
       root.WriteProperty(propertyNameString, writer);
       // ..
       root.WriteProperty(propertyNameSpan, writer);
       // ..
       root.WriteProperty(propertyNameJsonEncoded, writer);
       // ..
       root.WriteProperty(utf8PropertyName, writer);
       //..
    }
    
  2. WriteValue was renamed as WriteTo. This affects code such as the following:

     using (JsonDocument doc = JsonDocument.Parse(jsonString))
     {
         JsonElement root = doc.RootElement;
         root.WriteValue(writer);
     }
    
  3. WriteTo now throws an ArgumentNullException when its method parameter is null.

Version introduced

3.0 Preview 7

If your code is affected by these changes, you can do the following:

  • There is no replacement API for the WriteProperty overloads in JsonElement. Instead, you can call one of the Utf8JsonWriter.WritePropertyName overloads along with the WriteTo method to achive the same result. For example:

    using (JsonDocument doc = JsonDocument.Parse(jsonString))
    {
         JsonElement root = doc.RootElement;
         writer.WritePropertyName(propertyNameString);
         root.WriteTo(writer);
    }
    
  • Rename the WriteValue method to WriteTo(Utf8JsonWriter). The method parameter remains unchanged. For example, the previous code should be changed to the following:

    using (JsonDocument doc = JsonDocument.Parse(jsonString))
    {
         JsonElement root = doc.RootElement;
         root.WriteTo(writer);
    }
    
  • Handle the ArgumentNullException in calls to the WriteTo method.

Affected APIs