diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerComponent.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerComponent.cs
index 9bc6f1a591..a2c85c2172 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerComponent.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerComponent.cs
@@ -543,7 +543,7 @@ namespace ICSharpCode.PythonBinding
}
} else if (IsResourcePropertyValue(propertyValue)) {
AppendResourceProperty(codeBuilder, propertyName, propertyValue);
- } else if (propertyValue.GetType().IsArray) {
+ } else if (IsArray(propertyValue)) {
codeBuilder.AppendIndented(propertyName + " = ");
AppendSystemArray(codeBuilder, GetArrayType(propertyValue).FullName, propertyValue as ICollection, false);
codeBuilder.AppendLine();
@@ -891,5 +891,13 @@ namespace ICSharpCode.PythonBinding
Type type = obj.GetType();
return obj.GetType().GetElementType();
}
+
+ static bool IsArray(object obj)
+ {
+ if (obj != null) {
+ return obj.GetType().IsArray;
+ }
+ return false;
+ }
}
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/AppendNullPropertyValueTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/AppendNullPropertyValueTestFixture.cs
new file mode 100644
index 0000000000..3ec311e371
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/AppendNullPropertyValueTestFixture.cs
@@ -0,0 +1,43 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.ComponentModel;
+using ICSharpCode.PythonBinding;
+using NUnit.Framework;
+
+namespace PythonBinding.Tests.Designer
+{
+ ///
+ /// Tests that a null property value does not cause a NullReferenceException in the
+ /// PythonControl's AppendProperty method.
+ ///
+ [TestFixture]
+ public class AppendNullPropertyValueTestFixture
+ {
+ string fooBar;
+
+ public string FooBar {
+ get { return fooBar; }
+ set { fooBar = value; }
+ }
+
+ [Test]
+ public void GeneratedCode()
+ {
+ string expectedCode = "self._myObject.FooBar = None\r\n";
+ PropertyDescriptor propertyDescriptor = TypeDescriptor.GetProperties(this).Find("FooBar", false);
+
+ PythonDesignerComponent designerComponent = new PythonDesignerComponent(null);
+ PythonCodeBuilder codeBuilder = new PythonCodeBuilder();
+ designerComponent.AppendProperty(codeBuilder, "self._myObject", this, propertyDescriptor);
+ string generatedCode = codeBuilder.ToString();
+
+ Assert.AreEqual(expectedCode, generatedCode, generatedCode);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
index fe0314fe14..1339946002 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
@@ -161,6 +161,7 @@
+