Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Appwrite/Appwrite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
<PackageId>Appwrite</PackageId>
<Version>0.21.1</Version>
<Version>0.21.2</Version>
<Authors>Appwrite Team</Authors>
<Company>Appwrite Team</Company>
<Description>
Expand Down
4 changes: 2 additions & 2 deletions Appwrite/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ public Client(
_headers = new Dictionary<string, string>()
{
{ "content-type", "application/json" },
{ "user-agent" , $"AppwriteDotNetSDK/0.21.1 ({Environment.OSVersion.Platform}; {Environment.OSVersion.VersionString})"},
{ "user-agent" , $"AppwriteDotNetSDK/0.21.2 ({Environment.OSVersion.Platform}; {Environment.OSVersion.VersionString})"},
{ "x-sdk-name", ".NET" },
{ "x-sdk-platform", "server" },
{ "x-sdk-language", "dotnet" },
{ "x-sdk-version", "0.21.1"},
{ "x-sdk-version", "0.21.2"},
{ "X-Appwrite-Response-Format", "1.8.0" }
};

Expand Down
13 changes: 13 additions & 0 deletions Appwrite/Extensions/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;

namespace Appwrite.Extensions
Expand All @@ -12,6 +13,18 @@ public static string ToJson(this Dictionary<string, object?> dict)
return JsonSerializer.Serialize(dict, Client.SerializerOptions);
}

public static List<T> ConvertToList<T>(this object value)
{
return value switch
{
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)}>")
};
}
Comment on lines +16 to +26
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix null handling and use Client.SerializerOptions in ConvertToList

  • Null input currently triggers a NullReferenceException via value.GetType().
  • Deserialize with Client.SerializerOptions for consistency.

Apply:

-        public static List<T> ConvertToList<T>(this object value)
-        {
-            return value switch
-            {
-                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)}>")
-            };
-        }
+        public static List<T> ConvertToList<T>(this object value)
+        {
+            return value switch
+            {
+                null => throw new InvalidCastException($"Cannot convert null to List<{typeof(T)}>"),
+                JsonElement jsonElement => jsonElement.Deserialize<List<T>>(Client.SerializerOptions) ?? 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)}>")
+            };
+        }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public static List<T> ConvertToList<T>(this object value)
{
return value switch
{
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)}>")
};
}
public static List<T> ConvertToList<T>(this object value)
{
return value switch
{
null => throw new InvalidCastException($"Cannot convert null to List<{typeof(T)}>"),
JsonElement jsonElement => jsonElement.Deserialize<List<T>>(Client.SerializerOptions)
?? 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)}>")
};
}
🤖 Prompt for AI Agents
In Appwrite/Extensions/Extensions.cs around lines 16 to 26, add a null check at
the top to avoid calling value.GetType() on null (throw an InvalidCastException
with a clear message like "Cannot convert null to List<T>"), and when handling
JsonElement use jsonElement.Deserialize<List<T>>(Client.SerializerOptions)
instead of the parameterless overload; keep the other branches the same and
ensure all thrown InvalidCastException messages remain descriptive.


public static string ToQueryString(this Dictionary<string, object?> parameters)
{
var query = new List<string>();
Expand Down
1 change: 1 addition & 0 deletions Appwrite/Models/AlgoArgon2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down
1 change: 1 addition & 0 deletions Appwrite/Models/AlgoBcrypt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down
1 change: 1 addition & 0 deletions Appwrite/Models/AlgoMd5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down
1 change: 1 addition & 0 deletions Appwrite/Models/AlgoPhpass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down
1 change: 1 addition & 0 deletions Appwrite/Models/AlgoScrypt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down
1 change: 1 addition & 0 deletions Appwrite/Models/AlgoScryptModified.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down
1 change: 1 addition & 0 deletions Appwrite/Models/AlgoSha.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down
1 change: 1 addition & 0 deletions Appwrite/Models/AttributeBoolean.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down
1 change: 1 addition & 0 deletions Appwrite/Models/AttributeDatetime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down
1 change: 1 addition & 0 deletions Appwrite/Models/AttributeEmail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down
3 changes: 2 additions & 1 deletion Appwrite/Models/AttributeEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down Expand Up @@ -78,7 +79,7 @@ public AttributeEnum(
array: (bool?)map["array"],
createdAt: map["$createdAt"].ToString(),
updatedAt: map["$updatedAt"].ToString(),
elements: map["elements"] is JsonElement jsonArrayProp9 ? jsonArrayProp9.Deserialize<List<string>>()! : (List<string>)map["elements"],
elements: map["elements"].ConvertToList<string>(),
format: map["format"].ToString(),
xdefault: map.TryGetValue("default", out var xdefault) ? xdefault?.ToString() : null
);
Expand Down
1 change: 1 addition & 0 deletions Appwrite/Models/AttributeFloat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down
1 change: 1 addition & 0 deletions Appwrite/Models/AttributeInteger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down
1 change: 1 addition & 0 deletions Appwrite/Models/AttributeIp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down
3 changes: 2 additions & 1 deletion Appwrite/Models/AttributeLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down Expand Up @@ -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>()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Null handling missing for nullable field.

The Default property is nullable (List<object>?), but ConvertToList<object>() does not handle null input. If map["default"] is null, this will throw a NullReferenceException.

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 ConvertToList<T> extension method in Appwrite/Extensions/Extensions.cs to handle null input (see comment on AttributePoint.cs for details).

🤖 Prompt for AI Agents
In Appwrite/Models/AttributeLine.cs around line 72, the mapping for xdefault
uses map["default"].ConvertToList<object>() which will throw if map["default"]
is null; change it to use a null-safe call so Default is assigned null when the
source is null (e.g., use map["default"]?.ConvertToList<object>() or conditional
null coalescing to return null), or alternatively update ConvertToList<T> in
Appwrite/Extensions/Extensions.cs to accept null input and return null so
existing calls remain safe.

);

public Dictionary<string, object?> ToMap() => new Dictionary<string, object?>()
Expand Down
3 changes: 2 additions & 1 deletion Appwrite/Models/AttributeList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand All @@ -26,7 +27,7 @@ List<object> attributes

public static AttributeList From(Dictionary<string, object> map) => new AttributeList(
total: Convert.ToInt64(map["total"]),
attributes: map["attributes"] is JsonElement jsonArrayProp2 ? jsonArrayProp2.Deserialize<List<object>>()! : (List<object>)map["attributes"]
attributes: map["attributes"].ConvertToList<object>()
);

public Dictionary<string, object?> ToMap() => new Dictionary<string, object?>()
Expand Down
3 changes: 2 additions & 1 deletion Appwrite/Models/AttributePoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down Expand Up @@ -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>()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Null handling missing for nullable field.

The Default property is nullable (List<object>?), but ConvertToList<object>() does not handle null input. If map["default"] is null, this will throw a NullReferenceException when the extension method attempts to call value.GetType() in the default switch case.

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 ConvertToList<T> extension method to handle null input:

 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 List<T>? if the return can be null.

🤖 Prompt for AI Agents
In Appwrite/Models/AttributePoint.cs around line 72, the Nullable Default
property is assigned using map["default"].ConvertToList<object>() which will
throw if map["default"] is null; update the assignment to handle null (e.g.,
xdefault: map["default"] == null ? null :
map["default"].ConvertToList<object>()) or alternatively change the
ConvertToList<T> extension to accept a nullable input and return List<T>? so
null inputs produce null instead of throwing — implement one of these fixes and
update the property's usage/type accordingly.

);

public Dictionary<string, object?> ToMap() => new Dictionary<string, object?>()
Expand Down
3 changes: 2 additions & 1 deletion Appwrite/Models/AttributePolygon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down Expand Up @@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Blocker: Optional default must be null-safe; current code throws on missing/null (incl. JsonElement.Null)

Handle absence/null safely before ConvertToList to preserve List<object>? semantics:

-            xdefault: map["default"].ConvertToList<object>()
+            xdefault: (map.TryGetValue("default", out var d) && d is not JsonElement { ValueKind: JsonValueKind.Null } && d != null)
+                ? d.ConvertToList<object>()
+                : null

Also 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.cs

Length 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.cs

Length of output: 9058


Guard missing for nullable default field in From constructor
Prevent crashes when "default" is absent or null by wrapping its access:

-            xdefault: map["default"].ConvertToList<object>()
+            xdefault: map.TryGetValue("default", out var d) && d is not JsonElement { ValueKind: JsonValueKind.Null } && d != null
+                ? d.ConvertToList<object>()
+                : null

Optional: update ConvertToList<T> to pass Client.SerializerOptions into JsonElement.Deserialize<> to ensure consistent deserialization.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
xdefault: map["default"].ConvertToList<object>()
);
// … other properties …
xdefault: map.TryGetValue("default", out var d)
&& d is not JsonElement { ValueKind: JsonValueKind.Null }
&& d != null
? d.ConvertToList<object>()
: null
);
🤖 Prompt for AI Agents
In Appwrite/Models/AttributePolygon.cs around lines 72-73, the From constructor
unguardedly accesses map["default"] and calls ConvertToList<object>(), which
will throw if "default" is missing or null; update the constructor to check for
the key and that its value is not null (e.g., conditional access or TryGetValue)
and only call ConvertToList<object>() when present, otherwise pass null or an
empty list to the xdefault parameter; optionally, update ConvertToList<T> to
forward Client.SerializerOptions into JsonElement.Deserialize<T> so
deserialization respects the shared serializer options.


public Dictionary<string, object?> ToMap() => new Dictionary<string, object?>()
Expand Down
1 change: 1 addition & 0 deletions Appwrite/Models/AttributeRelationship.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down
1 change: 1 addition & 0 deletions Appwrite/Models/AttributeString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down
1 change: 1 addition & 0 deletions Appwrite/Models/AttributeUrl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down
5 changes: 3 additions & 2 deletions Appwrite/Models/Bucket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down Expand Up @@ -78,12 +79,12 @@ bool antivirus
id: map["$id"].ToString(),
createdAt: map["$createdAt"].ToString(),
updatedAt: map["$updatedAt"].ToString(),
permissions: map["$permissions"] is JsonElement jsonArrayProp4 ? jsonArrayProp4.Deserialize<List<string>>()! : (List<string>)map["$permissions"],
permissions: map["$permissions"].ConvertToList<string>(),
fileSecurity: (bool)map["fileSecurity"],
name: map["name"].ToString(),
enabled: (bool)map["enabled"],
maximumFileSize: Convert.ToInt64(map["maximumFileSize"]),
allowedFileExtensions: map["allowedFileExtensions"] is JsonElement jsonArrayProp9 ? jsonArrayProp9.Deserialize<List<string>>()! : (List<string>)map["allowedFileExtensions"],
allowedFileExtensions: map["allowedFileExtensions"].ConvertToList<string>(),
compression: map["compression"].ToString(),
encryption: (bool)map["encryption"],
antivirus: (bool)map["antivirus"]
Expand Down
3 changes: 2 additions & 1 deletion Appwrite/Models/BucketList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand All @@ -26,7 +27,7 @@ List<Bucket> buckets

public static BucketList From(Dictionary<string, object> map) => new BucketList(
total: Convert.ToInt64(map["total"]),
buckets: map["buckets"] is JsonElement jsonArray2 ? jsonArray2.Deserialize<List<Dictionary<string, object>>>()!.Select(it => Bucket.From(map: it)).ToList() : ((IEnumerable<Dictionary<string, object>>)map["buckets"]).Select(it => Bucket.From(map: it)).ToList()
buckets: map["buckets"].ConvertToList<Dictionary<string, object>>().Select(it => Bucket.From(map: it)).ToList()
);

public Dictionary<string, object?> ToMap() => new Dictionary<string, object?>()
Expand Down
7 changes: 4 additions & 3 deletions Appwrite/Models/Collection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down Expand Up @@ -68,13 +69,13 @@ List<Index> indexes
id: map["$id"].ToString(),
createdAt: map["$createdAt"].ToString(),
updatedAt: map["$updatedAt"].ToString(),
permissions: map["$permissions"] is JsonElement jsonArrayProp4 ? jsonArrayProp4.Deserialize<List<string>>()! : (List<string>)map["$permissions"],
permissions: map["$permissions"].ConvertToList<string>(),
databaseId: map["databaseId"].ToString(),
name: map["name"].ToString(),
enabled: (bool)map["enabled"],
documentSecurity: (bool)map["documentSecurity"],
attributes: map["attributes"] is JsonElement jsonArrayProp9 ? jsonArrayProp9.Deserialize<List<object>>()! : (List<object>)map["attributes"],
indexes: map["indexes"] is JsonElement jsonArray10 ? jsonArray10.Deserialize<List<Dictionary<string, object>>>()!.Select(it => Index.From(map: it)).ToList() : ((IEnumerable<Dictionary<string, object>>)map["indexes"]).Select(it => Index.From(map: it)).ToList()
attributes: map["attributes"].ConvertToList<object>(),
indexes: map["indexes"].ConvertToList<Dictionary<string, object>>().Select(it => Index.From(map: it)).ToList()
);

public Dictionary<string, object?> ToMap() => new Dictionary<string, object?>()
Expand Down
3 changes: 2 additions & 1 deletion Appwrite/Models/CollectionList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand All @@ -26,7 +27,7 @@ List<Collection> collections

public static CollectionList From(Dictionary<string, object> map) => new CollectionList(
total: Convert.ToInt64(map["total"]),
collections: map["collections"] is JsonElement jsonArray2 ? jsonArray2.Deserialize<List<Dictionary<string, object>>>()!.Select(it => Collection.From(map: it)).ToList() : ((IEnumerable<Dictionary<string, object>>)map["collections"]).Select(it => Collection.From(map: it)).ToList()
collections: map["collections"].ConvertToList<Dictionary<string, object>>().Select(it => Collection.From(map: it)).ToList()
);

public Dictionary<string, object?> ToMap() => new Dictionary<string, object?>()
Expand Down
1 change: 1 addition & 0 deletions Appwrite/Models/ColumnBoolean.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down
1 change: 1 addition & 0 deletions Appwrite/Models/ColumnDatetime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down
1 change: 1 addition & 0 deletions Appwrite/Models/ColumnEmail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down
3 changes: 2 additions & 1 deletion Appwrite/Models/ColumnEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down Expand Up @@ -78,7 +79,7 @@ public ColumnEnum(
array: (bool?)map["array"],
createdAt: map["$createdAt"].ToString(),
updatedAt: map["$updatedAt"].ToString(),
elements: map["elements"] is JsonElement jsonArrayProp9 ? jsonArrayProp9.Deserialize<List<string>>()! : (List<string>)map["elements"],
elements: map["elements"].ConvertToList<string>(),
format: map["format"].ToString(),
xdefault: map.TryGetValue("default", out var xdefault) ? xdefault?.ToString() : null
);
Expand Down
1 change: 1 addition & 0 deletions Appwrite/Models/ColumnFloat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;

namespace Appwrite.Models
{
Expand Down
Loading