-
Notifications
You must be signed in to change notification settings - Fork 22
feat: .NET SDK update for version 0.21.2 #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| using System.Text.Json; | ||
| using System.Text.Json.Serialization; | ||
| using Appwrite.Enums; | ||
| using Appwrite.Extensions; | ||
|
|
||
| namespace Appwrite.Models | ||
| { | ||
|
|
@@ -68,7 +69,7 @@ public AttributeLine( | |
| array: (bool?)map["array"], | ||
| createdAt: map["$createdAt"].ToString(), | ||
| updatedAt: map["$updatedAt"].ToString(), | ||
| xdefault: map["default"] is JsonElement jsonArrayProp9 ? jsonArrayProp9.Deserialize<List<object>>()! : (List<object>)map["default"] | ||
| xdefault: map["default"].ConvertToList<object>() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Null handling missing for nullable field. The Apply this diff to add null-coalescing: - xdefault: map["default"].ConvertToList<object>()
+ xdefault: map["default"] as object == null ? null : map["default"].ConvertToList<object>()Alternatively, update the 🤖 Prompt for AI Agents |
||
| ); | ||
|
|
||
| public Dictionary<string, object?> ToMap() => new Dictionary<string, object?>() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| using System.Text.Json; | ||
| using System.Text.Json.Serialization; | ||
| using Appwrite.Enums; | ||
| using Appwrite.Extensions; | ||
|
|
||
| namespace Appwrite.Models | ||
| { | ||
|
|
@@ -68,7 +69,7 @@ public AttributePoint( | |
| array: (bool?)map["array"], | ||
| createdAt: map["$createdAt"].ToString(), | ||
| updatedAt: map["$updatedAt"].ToString(), | ||
| xdefault: map["default"] is JsonElement jsonArrayProp9 ? jsonArrayProp9.Deserialize<List<object>>()! : (List<object>)map["default"] | ||
| xdefault: map["default"].ConvertToList<object>() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Null handling missing for nullable field. The Apply this diff to add null-coalescing: - xdefault: map["default"].ConvertToList<object>()
+ xdefault: map["default"] as object == null ? null : map["default"].ConvertToList<object>()Alternatively, update the public static List<T> ConvertToList<T>(this object value)
{
return value switch
{
+ null => null,
JsonElement jsonElement => jsonElement.Deserialize<List<T>>() ?? throw new InvalidCastException($"Cannot deserialize {jsonElement} to List<{typeof(T)}>."),
object[] objArray => objArray.Cast<T>().ToList(),
List<T> list => list,
IEnumerable<T> enumerable => enumerable.ToList(),
_ => throw new InvalidCastException($"Cannot convert {value.GetType()} to List<{typeof(T)}>")
};
}Note: The second approach would require changing the return type to 🤖 Prompt for AI Agents |
||
| ); | ||
|
|
||
| public Dictionary<string, object?> ToMap() => new Dictionary<string, object?>() | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |||||||||||||||||||
| using System.Text.Json; | ||||||||||||||||||||
| using System.Text.Json.Serialization; | ||||||||||||||||||||
| using Appwrite.Enums; | ||||||||||||||||||||
| using Appwrite.Extensions; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| namespace Appwrite.Models | ||||||||||||||||||||
| { | ||||||||||||||||||||
|
|
@@ -68,7 +69,7 @@ public AttributePolygon( | |||||||||||||||||||
| array: (bool?)map["array"], | ||||||||||||||||||||
| createdAt: map["$createdAt"].ToString(), | ||||||||||||||||||||
| updatedAt: map["$updatedAt"].ToString(), | ||||||||||||||||||||
| xdefault: map["default"] is JsonElement jsonArrayProp9 ? jsonArrayProp9.Deserialize<List<object>>()! : (List<object>)map["default"] | ||||||||||||||||||||
| xdefault: map["default"].ConvertToList<object>() | ||||||||||||||||||||
| ); | ||||||||||||||||||||
|
Comment on lines
+72
to
73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainBlocker: Optional Handle absence/null safely before ConvertToList to preserve - xdefault: map["default"].ConvertToList<object>()
+ xdefault: (map.TryGetValue("default", out var d) && d is not JsonElement { ValueKind: JsonValueKind.Null } && d != null)
+ ? d.ConvertToList<object>()
+ : nullAlso ensure ConvertToList() uses Client.SerializerOptions as noted earlier, or inner values may be JsonElement and break downstream casts. 🏁 Script executed: #!/bin/bash
sed -n '1,200p' Appwrite/Models/AttributePolygon.csLength of output: 2640 🏁 Script executed: #!/bin/bash
rg -n "ConvertToList" -g "Appwrite/Extensions/*.cs"Length of output: 102 🏁 Script executed: #!/bin/bash
sed -n '1,200p' Appwrite/Extensions/Extensions.csLength of output: 9058 Guard missing for nullable - xdefault: map["default"].ConvertToList<object>()
+ xdefault: map.TryGetValue("default", out var d) && d is not JsonElement { ValueKind: JsonValueKind.Null } && d != null
+ ? d.ConvertToList<object>()
+ : nullOptional: update 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
|
|
||||||||||||||||||||
| public Dictionary<string, object?> ToMap() => new Dictionary<string, object?>() | ||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix null handling and use Client.SerializerOptions in ConvertToList
Apply:
📝 Committable suggestion
🤖 Prompt for AI Agents