Skip to content

Commit

Permalink
Fixed nullability warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ElektroKill committed Sep 6, 2023
1 parent efe9817 commit 03b586d
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ public static ResourceElement Serialize(ResourceElement resElem, SerializationFo
}
else if (format == SerializationFormat.TypeConverterByteArray) {
var converter = TypeDescriptor.GetConverter(obj.GetType());
serializedData = (byte[])converter.ConvertTo(obj, typeof(byte[]));
var byteArr = converter.ConvertTo(obj, typeof(byte[]));
if (byteArr is not byte[] d)
throw new InvalidOperationException("Failed to serialize image");
serializedData = d;
}
else if (format == SerializationFormat.ActivatorStream) {
using (var stream = new MemoryStream()) {
Expand All @@ -192,7 +195,7 @@ public static ResourceElement Serialize(ResourceElement resElem, SerializationFo
}
}
else
throw new ArgumentOutOfRangeException();
throw new ArgumentOutOfRangeException(nameof(format));

return new ResourceElement {
Name = resElem.Name,
Expand Down

0 comments on commit 03b586d

Please sign in to comment.