Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/KubernetesClient/KubernetesJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Xml;

#if NET8_0_OR_GREATER
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization.Metadata;
#endif

Expand Down Expand Up @@ -127,6 +128,13 @@ public static void AddJsonOptions(Action<JsonSerializerOptions> configure)
configure(JsonSerializerOptions);
}

#if NET8_0_OR_GREATER
[RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")]
[RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
#endif
public static object Deserialize(string json, Type returnType, JsonSerializerOptions jsonSerializerOptions = null)
=> JsonSerializer.Deserialize(json, returnType, jsonSerializerOptions ?? JsonSerializerOptions);

public static TValue Deserialize<TValue>(string json, JsonSerializerOptions jsonSerializerOptions = null)
{
#if NET8_0_OR_GREATER
Expand Down Expand Up @@ -217,4 +225,4 @@ public static string Serialize(JsonNode value, JsonSerializerOptions jsonSeriali
#endif
}
}
}
}