From 80959b824c85fb6e28989aeed547fbc60e47df49 Mon Sep 17 00:00:00 2001 From: Michael Rybakin Date: Thu, 20 Jun 2024 12:27:12 +0400 Subject: [PATCH] =?UTF-8?q?fix=20#1419:=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5?= =?UTF-8?q?=D1=80=D0=BA=D0=B0=20=D0=BF=D1=80=D0=B5=D0=BE=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20=D1=82=D0=B8=D0=BF?= =?UTF-8?q?=D0=BE=D0=B2=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80?= =?UTF-8?q?=D0=BE=D0=B2,=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D1=87=D0=B8=D1=81=D0=BB=D0=B5=D0=BD=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Machine/Contexts/ContextValuesMarshaller.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/ScriptEngine/Machine/Contexts/ContextValuesMarshaller.cs b/src/ScriptEngine/Machine/Contexts/ContextValuesMarshaller.cs index 8f5de8357..7d51675e9 100644 --- a/src/ScriptEngine/Machine/Contexts/ContextValuesMarshaller.cs +++ b/src/ScriptEngine/Machine/Contexts/ContextValuesMarshaller.cs @@ -132,6 +132,17 @@ private static object ConvertValueType(IValue value, Type type) } else { + var rawValue = value.GetRawValue(); + if (rawValue is IObjectWrapper wrapped) + { + if (!type.IsInstanceOfType(wrapped.UnderlyingObject)) + throw new InvalidCastException(); ; + } + else if (!type.IsInstanceOfType(rawValue)) + { + throw new InvalidCastException(); + } + valueObj = CastToClrObject(value); }