Browse Source

Add 'import clr' if clr.GetType used in converted python code.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@4261 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 17 years ago
parent
commit
9e9c0c657e
  1. 1
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/NRefactoryToPythonConverter.cs
  2. 4
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ForeachConversionWithMethodCallTestFixture.cs
  3. 5
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/TypeofConversionTestFixture.cs

1
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/NRefactoryToPythonConverter.cs

@ -1124,6 +1124,7 @@ namespace ICSharpCode.PythonBinding @@ -1124,6 +1124,7 @@ namespace ICSharpCode.PythonBinding
public object VisitTypeOfExpression(TypeOfExpression typeOfExpression, object data)
{
codeBuilder.InsertIndentedLine("import clr");
Append("clr.GetClrType(");
Append(GetTypeName(typeOfExpression.TypeReference));
Append(")");

4
src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ForeachConversionWithMethodCallTestFixture.cs

@ -32,7 +32,9 @@ namespace PythonBinding.Tests.Converter @@ -32,7 +32,9 @@ namespace PythonBinding.Tests.Converter
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
converter.IndentString = " ";
string code = converter.Convert(environmentSpecialFolderCode);
string expectedCode = "class Foo(object):\r\n" +
string expectedCode = "import clr\r\n" +
"\r\n" +
"class Foo(object):\r\n" +
" def PrintEnvironmentVariables(self):\r\n" +
" enumerator = Environment.SpecialFolder.GetValues(clr.GetClrType(Environment.SpecialFolder)).GetEnumerator()\r\n" +
" while enumerator.MoveNext():\r\n" +

5
src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/TypeofConversionTestFixture.cs

@ -29,12 +29,13 @@ namespace PythonBinding.Tests.Converter @@ -29,12 +29,13 @@ namespace PythonBinding.Tests.Converter
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
converter.IndentString = " ";
string python = converter.Convert(typeofIntCode);
string expectedPython = "class Foo(object):\r\n" +
string expectedPython = "import clr\r\n" +
"\r\n" +
"class Foo(object):\r\n" +
" def ToString(self):\r\n" +
" clr.GetClrType(int).FullName";
Assert.AreEqual(expectedPython, python);
}
}
}

Loading…
Cancel
Save