diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeDomSerializer.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeDomSerializer.cs index abe29458f3..904495b181 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeDomSerializer.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeDomSerializer.cs @@ -229,7 +229,8 @@ namespace ICSharpCode.PythonBinding void AppendTypeReference(CodeTypeReference typeRef) { - codeBuilder.Append(typeRef.BaseType); + string typeRefText = typeRef.BaseType.Replace('+', '.'); + codeBuilder.Append(typeRefText); } /// diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateFolderBrowserDialogRootFolderTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateFolderBrowserDialogRootFolderTestFixture.cs new file mode 100644 index 0000000000..a03388f8c9 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateFolderBrowserDialogRootFolderTestFixture.cs @@ -0,0 +1,70 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.Design; +using System.ComponentModel.Design.Serialization; +using System.Drawing; +using System.Windows.Forms; +using ICSharpCode.PythonBinding; +using NUnit.Framework; +using PythonBinding.Tests.Utils; + +namespace PythonBinding.Tests.Designer +{ + [TestFixture] + public class GenerateFolderBrowserDialogRootFolderTestFixture + { + string generatedPythonCode; + + [TestFixtureSetUp] + public void SetUpFixture() + { + using (DesignSurface designSurface = new DesignSurface(typeof(Form))) { + IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost)); + IEventBindingService eventBindingService = new MockEventBindingService(host); + Form form = (Form)host.RootComponent; + form.ClientSize = new Size(200, 300); + + PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form); + PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false); + namePropertyDescriptor.SetValue(form, "MainForm"); + + FolderBrowserDialog dialog = (FolderBrowserDialog)host.CreateComponent(typeof(FolderBrowserDialog), "folderBrowserDialog1"); + dialog.RootFolder = Environment.SpecialFolder.ApplicationData; + + DesignerSerializationManager serializationManager = new DesignerSerializationManager(host); + using (serializationManager.CreateSession()) { + PythonCodeDomSerializer serializer = new PythonCodeDomSerializer(" "); + generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager); + } + } + } + + [Test] + public void GeneratedCode() + { + string expectedCode = + "self._folderBrowserDialog1 = System.Windows.Forms.FolderBrowserDialog()\r\n" + + "self.SuspendLayout()\r\n" + + "# \r\n" + + "# folderBrowserDialog1\r\n" + + "# \r\n" + + "self._folderBrowserDialog1.RootFolder = System.Environment.SpecialFolder.ApplicationData\r\n" + + "# \r\n" + + "# MainForm\r\n" + + "# \r\n" + + "self.ClientSize = System.Drawing.Size(200, 300)\r\n" + + "self.Name = \"MainForm\"\r\n" + + "self.ResumeLayout(False)\r\n"; + + Assert.AreEqual(expectedCode, generatedPythonCode, generatedPythonCode); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj index 319b17c51b..7ae728263b 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj @@ -223,6 +223,7 @@ + diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyCodeDomSerializer.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyCodeDomSerializer.cs index a2b3882ab6..b80c679faf 100644 --- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyCodeDomSerializer.cs +++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyCodeDomSerializer.cs @@ -251,7 +251,9 @@ namespace ICSharpCode.RubyBinding void AppendTypeReference(CodeTypeReference typeRef) { - string typeName = typeRef.BaseType.Replace(".", "::"); + string baseTypeName = typeRef.BaseType; + string typeName = baseTypeName.Replace(".", "::"); + typeName = typeName.Replace("+", "::"); codeBuilder.Append(typeName); } diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/GenerateFolderBrowserDialogRootFolderTestFixture.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/GenerateFolderBrowserDialogRootFolderTestFixture.cs new file mode 100644 index 0000000000..872e67ecea --- /dev/null +++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/GenerateFolderBrowserDialogRootFolderTestFixture.cs @@ -0,0 +1,70 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.Design; +using System.ComponentModel.Design.Serialization; +using System.Drawing; +using System.Windows.Forms; +using ICSharpCode.RubyBinding; +using NUnit.Framework; +using RubyBinding.Tests.Utils; + +namespace RubyBinding.Tests.Designer +{ + [TestFixture] + public class GenerateFolderBrowserDialogRootFolderTestFixture + { + string generatedRubyCode; + + [TestFixtureSetUp] + public void SetUpFixture() + { + using (DesignSurface designSurface = new DesignSurface(typeof(Form))) { + IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost)); + IEventBindingService eventBindingService = new MockEventBindingService(host); + Form form = (Form)host.RootComponent; + form.ClientSize = new Size(200, 300); + + PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form); + PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false); + namePropertyDescriptor.SetValue(form, "MainForm"); + + FolderBrowserDialog dialog = (FolderBrowserDialog)host.CreateComponent(typeof(FolderBrowserDialog), "folderBrowserDialog1"); + dialog.RootFolder = Environment.SpecialFolder.ApplicationData; + + DesignerSerializationManager serializationManager = new DesignerSerializationManager(host); + using (serializationManager.CreateSession()) { + RubyCodeDomSerializer serializer = new RubyCodeDomSerializer(" "); + generatedRubyCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager); + } + } + } + + [Test] + public void GeneratedCode() + { + string expectedCode = + "@folderBrowserDialog1 = System::Windows::Forms::FolderBrowserDialog.new()\r\n" + + "self.SuspendLayout()\r\n" + + "# \r\n" + + "# folderBrowserDialog1\r\n" + + "# \r\n" + + "@folderBrowserDialog1.RootFolder = System::Environment::SpecialFolder.ApplicationData\r\n" + + "# \r\n" + + "# MainForm\r\n" + + "# \r\n" + + "self.ClientSize = System::Drawing::Size.new(200, 300)\r\n" + + "self.Name = \"MainForm\"\r\n" + + "self.ResumeLayout(false)\r\n"; + + Assert.AreEqual(expectedCode, generatedRubyCode, generatedRubyCode); + } + } +} diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyBinding.Tests.csproj b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyBinding.Tests.csproj index b4e5414902..7cf7264ceb 100644 --- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyBinding.Tests.csproj +++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyBinding.Tests.csproj @@ -212,6 +212,7 @@ +