diff --git a/data/resources/StringResources.de.resources b/data/resources/StringResources.de.resources
index e6e71e9c41..8adf019690 100644
Binary files a/data/resources/StringResources.de.resources and b/data/resources/StringResources.de.resources differ
diff --git a/data/resources/StringResources.es-mx.resources b/data/resources/StringResources.es-mx.resources
index fdec13be23..a2bf3655e5 100644
Binary files a/data/resources/StringResources.es-mx.resources and b/data/resources/StringResources.es-mx.resources differ
diff --git a/data/resources/StringResources.es.resources b/data/resources/StringResources.es.resources
index f9ccdcffba..2ad8688626 100644
Binary files a/data/resources/StringResources.es.resources and b/data/resources/StringResources.es.resources differ
diff --git a/data/resources/StringResources.nl.resources b/data/resources/StringResources.nl.resources
index 6054187cdc..04df4ca98c 100644
Binary files a/data/resources/StringResources.nl.resources and b/data/resources/StringResources.nl.resources differ
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonComponentWalker.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonComponentWalker.cs
index 0e327d81f5..a4c6593d71 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonComponentWalker.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonComponentWalker.cs
@@ -16,6 +16,7 @@ using System.Resources;
using System.Text;
using System.Windows.Forms;
+using ICSharpCode.Core;
using IronPython.Compiler.Ast;
namespace ICSharpCode.PythonBinding
@@ -111,7 +112,10 @@ namespace ICSharpCode.PythonBinding
} else if (lhsNameExpression != null) {
CallExpression callExpression = node.Right as CallExpression;
if (callExpression != null) {
- CreateInstance(lhsNameExpression.Name.ToString(), callExpression);
+ object instance = CreateInstance(lhsNameExpression.Name.ToString(), callExpression);
+ if (instance == null) {
+ ThrowCouldNotFindTypeException(callExpression.Target as MemberExpression);
+ }
}
}
}
@@ -275,7 +279,7 @@ namespace ICSharpCode.PythonBinding
} else if (IsResource(memberExpression)) {
fieldExpression.SetPropertyValue(componentCreator, GetResource(node));
} else {
- throw new PythonComponentWalkerException(String.Format("Could not find type '{0}'.", PythonControlFieldExpression.GetMemberName(memberExpression)));
+ ThrowCouldNotFindTypeException(memberExpression);
}
}
} else if (node.Target is IndexExpression) {
@@ -393,5 +397,11 @@ namespace ICSharpCode.PythonBinding
object array = deserializer.Deserialize(callExpression);
fieldExpression.SetPropertyValue(componentCreator, array);
}
+
+ void ThrowCouldNotFindTypeException(MemberExpression memberExpression)
+ {
+ string typeName = PythonControlFieldExpression.GetMemberName(memberExpression);
+ throw new PythonComponentWalkerException(String.Format(StringParser.Parse("${res:ICSharpCode.PythonBinding.UnknownTypeName}"), typeName));
+ }
}
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/UnknownTypeTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/UnknownTypeTestFixture.cs
index 3b50ce0a2f..c606534880 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/UnknownTypeTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/UnknownTypeTestFixture.cs
@@ -9,8 +9,10 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
+using System.Resources;
using System.Windows.Forms;
+using ICSharpCode.Core;
using ICSharpCode.PythonBinding;
using IronPython.Compiler.Ast;
using Microsoft.Scripting;
@@ -25,23 +27,56 @@ namespace PythonBinding.Tests.Designer
///
[TestFixture]
public class UnknownTypeTestFixture
- {
- string pythonCode = "from System.Windows.Forms import Form\r\n" +
- "\r\n" +
- "class MainForm(System.Windows.Forms.Form):\r\n" +
- " def __init__(self):\r\n" +
- " self.InitializeComponent()\r\n" +
- "\r\n" +
- " def InitializeComponent(self):\r\n" +
- " self.ClientSize = Unknown.Type(10)\r\n";
+ {
+ [TestFixtureSetUp]
+ public void SetUpFixture()
+ {
+ ResourceManager rm = new ResourceManager("PythonBinding.Tests.Strings", GetType().Assembly);
+ ResourceService.RegisterNeutralStrings(rm);
+ }
[Test]
- [ExpectedException(typeof(PythonComponentWalkerException))]
- public void PythonFormWalkerExceptionThrown()
+ public void SelfAssignmentWithUnknownTypeRhs()
{
- PythonComponentWalker walker = new PythonComponentWalker(new MockComponentCreator());
- walker.CreateComponent(pythonCode);
- Assert.Fail("Exception should have been thrown before this.");
+ string pythonCode = "from System.Windows.Forms import Form\r\n" +
+ "\r\n" +
+ "class MainForm(System.Windows.Forms.Form):\r\n" +
+ " def __init__(self):\r\n" +
+ " self.InitializeComponent()\r\n" +
+ "\r\n" +
+ " def InitializeComponent(self):\r\n" +
+ " self.ClientSize = Unknown.Type(10)\r\n";
+
+ try {
+ PythonComponentWalker walker = new PythonComponentWalker(new MockComponentCreator());
+ walker.CreateComponent(pythonCode);
+ Assert.Fail("Exception should have been thrown before this.");
+ } catch (PythonComponentWalkerException ex) {
+ string expectedMessage = String.Format(StringParser.Parse("${res:ICSharpCode.PythonBinding.UnknownTypeName}"), "Unknown.Type");
+ Assert.AreEqual(expectedMessage, ex.Message);
+ }
+ }
+
+ [Test]
+ public void LocalVariableAssignmentWithUnknownTypeRhs()
+ {
+ string pythonCode = "from System.Windows.Forms import Form\r\n" +
+ "\r\n" +
+ "class MainForm(System.Windows.Forms.Form):\r\n" +
+ " def __init__(self):\r\n" +
+ " self.InitializeComponent()\r\n" +
+ "\r\n" +
+ " def InitializeComponent(self):\r\n" +
+ " abc = Unknown.Type(10)\r\n";
+
+ try {
+ PythonComponentWalker walker = new PythonComponentWalker(new MockComponentCreator());
+ walker.CreateComponent(pythonCode);
+ Assert.Fail("Exception should have been thrown before this.");
+ } catch (PythonComponentWalkerException ex) {
+ string expectedMessage = String.Format(StringParser.Parse("${res:ICSharpCode.PythonBinding.UnknownTypeName}"), "Unknown.Type");
+ Assert.AreEqual(expectedMessage, ex.Message);
+ }
}
}
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
index 9c26ae483e..45259294a7 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
@@ -377,6 +377,7 @@
+
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Strings.resx b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Strings.resx
new file mode 100644
index 0000000000..0a28739c88
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Strings.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Could not find type '{0}'. Are you missing an assembly reference?
+
+
\ No newline at end of file
diff --git a/src/Main/StartUp/Project/Resources/StringResources.resources b/src/Main/StartUp/Project/Resources/StringResources.resources
index 698fbfbc82..960b8376d1 100644
Binary files a/src/Main/StartUp/Project/Resources/StringResources.resources and b/src/Main/StartUp/Project/Resources/StringResources.resources differ