Skip to content

Commit

Permalink
Add os guards for System.Drawing
Browse files Browse the repository at this point in the history
  • Loading branch information
saintentropy committed Oct 22, 2023
1 parent f092690 commit d089075
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Libraries/CoreNodes/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private static object DynamoJObjectToNative(JObject jObject)
(int)jObject["R"],
(int)jObject["G"],
(int)jObject["B"]);

#if _WINDOWS
case "dynamo.graphics:png-1.0.0":
jObject.TryGetValue(ImageFormat.Png.ToString(), out var value);

Expand All @@ -128,6 +128,7 @@ private static object DynamoJObjectToNative(JObject jObject)

return bitmap;
}
#endif

return null;

Expand All @@ -141,7 +142,7 @@ private static object DynamoJObjectToNative(JObject jObject)
return null;
}
}

if (jObject.ContainsKey("typeid"))
{
var typeid = jObject["typeid"].ToString();
Expand All @@ -168,7 +169,9 @@ public static string StringifyJSON([ArbitraryDimensionArrayImport] object values
new DesignScriptGeometryConverter(),
new ColorConveter(),
new LocationConverter(),
new ImageConverter()
#if _WINDOWS
new ImageConverter(),
#endif
});
}

Expand Down Expand Up @@ -318,6 +321,9 @@ public override bool CanConvert(Type objectType)
}
}

#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
private class ImageConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
Expand Down

0 comments on commit d089075

Please sign in to comment.