Browse Source

Fixed forum-12661: Missing parenthesis when converting CastExpression from VB to C#.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1940 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
53739a9c31
  1. 11
      src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/ConvertVisitor.cs
  2. 6
      src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs
  3. 6
      src/Libraries/NRefactory/Test/Output/CSharp/VBToCSharpConverterTest.cs

11
src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/ConvertVisitor.cs

@ -431,10 +431,13 @@ namespace Grunwald.BooBinding.CodeCompletion @@ -431,10 +431,13 @@ namespace Grunwald.BooBinding.CodeCompletion
//LoggingService.Debug("Method: " + node.FullName + " (" + node.Modifiers + ")");
DefaultMethod method = new DefaultMethod(node.Name, null, GetModifier(node), GetRegion(node), GetClientRegion(node), OuterClass);
// Removed, the newer Boo builds implement extension methods differently
// if ((node.ImplementationFlags & AST.MethodImplementationFlags.Extension) == AST.MethodImplementationFlags.Extension) {
// method.IsExtensionMethod = true;
// }
foreach (AST.Attribute a in node.Attributes) {
if (a.Name == "Extension" || a.Name == "Boo.Lang.Extension"
|| a.Name == "ExtensionAttribute" || a.Name == "Boo.Lang.ExtensionAttribute")
{
method.IsExtensionMethod = true;
}
}
ConvertAttributes(node, method);
ConvertTemplates(node, method);

6
src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs

@ -2354,7 +2354,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2354,7 +2354,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
target = ((WithStatement)withExpressionStack.Peek()).Expression;
}
if (target is BinaryOperatorExpression || target is CastExpression) {
outputFormatter.PrintToken(Tokens.OpenParenthesis);
}
nodeTracker.TrackedVisit(target, data);
if (target is BinaryOperatorExpression || target is CastExpression) {
outputFormatter.PrintToken(Tokens.CloseParenthesis);
}
outputFormatter.PrintToken(Tokens.Dot);
outputFormatter.PrintIdentifier(fieldReferenceExpression.FieldName);
return null;

6
src/Libraries/NRefactory/Test/Output/CSharp/VBToCSharpConverterTest.cs

@ -561,5 +561,11 @@ static int static_Test2_j = 0;"); @@ -561,5 +561,11 @@ static int static_Test2_j = 0;");
{
TestStatement("Dim a As Global.System.String", "global::System.String a;");
}
[Test]
public void FieldReferenceOnCastExpression()
{
TestStatement("CType(obj, IDisposable).Dispose()", "((IDisposable)obj).Dispose();");
}
}
}

Loading…
Cancel
Save