Browse Source

Fixed SD2-1079: Cast statements not converted correctly from C# to VB.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2034 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
f399bed9de
  1. 10
      src/Libraries/NRefactory/Project/Src/Visitors/ToVBNetConvertVisitor.cs
  2. 6
      src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBConverterTest.cs

10
src/Libraries/NRefactory/Project/Src/Visitors/ToVBNetConvertVisitor.cs

@ -24,6 +24,7 @@ namespace ICSharpCode.NRefactory.Visitors @@ -24,6 +24,7 @@ namespace ICSharpCode.NRefactory.Visitors
// Anonymous methods are put into new methods
// Simple event handler creation is replaced with AddressOfExpression
// Move Imports-statements out of namespaces
// Parenthesis around Cast expressions remove - these are syntax errors in VB.NET
List<INode> nodesToMoveToCompilationUnit = new List<INode>();
@ -316,5 +317,14 @@ namespace ICSharpCode.NRefactory.Visitors @@ -316,5 +317,14 @@ namespace ICSharpCode.NRefactory.Visitors
constructorDeclaration.Modifier |= Modifiers.Private;
return base.VisitConstructorDeclaration(constructorDeclaration, data);
}
public override object VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data)
{
base.VisitParenthesizedExpression(parenthesizedExpression, data);
if (parenthesizedExpression.Expression is CastExpression) {
ReplaceCurrentNode(parenthesizedExpression.Expression); // remove parenthesis
}
return null;
}
}
}

6
src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBConverterTest.cs

@ -435,5 +435,11 @@ End Class @@ -435,5 +435,11 @@ End Class
{
TestStatement("global::System.String a;", "Dim a As Global.System.String");
}
[Test]
public void TestMethodCallOnCastExpression()
{
TestStatement("((IDisposable)o).Dispose();", "DirectCast(o, IDisposable).Dispose()");
}
}
}

Loading…
Cancel
Save