Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed Feb 25, 2025
1 parent 9a4cb61 commit f28b968
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/BUTR.NativeAOT.Shared/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ private return_value_string(char* value, char* error)
IReturnValueWithError<return_value_json>,
IReturnValueWithException<return_value_json>
{
public static return_value_json* AsValue<TValue>(TValue value, JsonTypeInfo<TValue> jsonTypeInfo, bool isOwner) where TValue : class => AsValue(Utils.SerializeJsonCopy(value, jsonTypeInfo, isOwner), isOwner);
public static return_value_json* AsValue<TValue>(TValue? value, JsonTypeInfo<TValue> jsonTypeInfo, bool isOwner) where TValue : class => AsValue(Utils.SerializeJsonCopy(value, jsonTypeInfo, isOwner), isOwner);
public static return_value_json* AsValue(char* value, bool isOwner) => Utils.Create(new return_value_json(value, null), isOwner);
public static return_value_json* AsError(char* error, bool isOwner) => Utils.Create(new return_value_json(null, error), isOwner);
public static return_value_json* AsException(Exception e, bool isOwner) => Utils.AsException<return_value_json>(e, isOwner);
Expand Down
8 changes: 4 additions & 4 deletions src/BUTR.NativeAOT.Shared/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ internal static class Utils
public static unsafe TSelf* AsException<TSelf>(Exception e, bool isOwner)
where TSelf : unmanaged, IReturnValueWithError<TSelf> => TSelf.AsError(Copy(e.ToString(), isOwner), isOwner);

public static SafeStringMallocHandle SerializeJsonCopy<TValue>(TValue value, JsonTypeInfo<TValue> jsonTypeInfo, bool isOwner)
public static SafeStringMallocHandle SerializeJsonCopy<TValue>(TValue? value, JsonTypeInfo<TValue> jsonTypeInfo, bool isOwner)
where TValue : class => Copy(SerializeJson(value, jsonTypeInfo), isOwner);

public static string SerializeJson<TValue>(TValue? value, JsonTypeInfo<TValue> jsonTypeInfo)
where TValue : class => value is null ? string.Empty : JsonSerializer.Serialize(value, jsonTypeInfo);

public static TValue? DeserializeJson<TValue>(SafeStringMallocHandle json, JsonTypeInfo<TValue?> jsonTypeInfo, [CallerMemberName] string? caller = null)
public static TValue? DeserializeJson<TValue>(SafeStringMallocHandle json, JsonTypeInfo<TValue> jsonTypeInfo, [CallerMemberName] string? caller = null)
where TValue : class => json.IsInvalid ? null : DeserializeJson(json.ToSpan(), jsonTypeInfo, caller);

[return: NotNullIfNotNull(nameof(json))]
public static unsafe TValue? DeserializeJson<TValue>(param_json* json, JsonTypeInfo<TValue?> jsonTypeInfo, [CallerMemberName] string? caller = null)
public static unsafe TValue? DeserializeJson<TValue>(param_json* json, JsonTypeInfo<TValue> jsonTypeInfo, [CallerMemberName] string? caller = null)
where TValue : class => json is null ? null : DeserializeJson(param_json.ToSpan(json), jsonTypeInfo, caller);

private static TValue? DeserializeJson<TValue>([StringSyntax(StringSyntaxAttribute.Json)] ReadOnlySpan<char> json, JsonTypeInfo<TValue?> jsonTypeInfo, [CallerMemberName] string? caller = null)
private static TValue? DeserializeJson<TValue>([StringSyntax(StringSyntaxAttribute.Json)] ReadOnlySpan<char> json, JsonTypeInfo<TValue> jsonTypeInfo, [CallerMemberName] string? caller = null)
{
try
{
Expand Down

0 comments on commit f28b968

Please sign in to comment.