Reputation: 17288
I am using CloudNative.CloudEvents nuget package from https://cloudevents.io/ for cloudevents issues.
I am getting the below error in my extension for binary serializer by using SerializeToUtf8Bytes() method.
Serialization and deserialization of 'System.Type' instances are not supported. Path: $.SpecVersion.IdAttribute.Type.ClrType.
public static bool IsEventBatchReachedLimits<T>(this IEnumerable<T> list)
{
var options = new JsonSerializerOptions() { Encoder = JavaScriptEncoder.Create(UnicodeRanges.All) };
var resultBytes = JsonSerializer.SerializeToUtf8Bytes(list, options);
string[] sizes = { "B", "KB", "MB", "GB", "TB" };
var len = Convert.ToDouble(resultBytes.Length);
var order = 0;
while (len >= 1024D && order < sizes.Length - 1)
{
order++;
len /= 1024;
}
return (sizes[order] == "MB" && len >= 1) ? true : false;
}
Can you tell me the reason why I can not serialize List to utf8 Bytes ?
Usage above extension: Type of cloudEvents list is List
Actually, my real question is How can I learn my list size as MB or KB?
Upvotes: 0
Views: 201