From 7936cdc4dc7db2320f45e547b48c6a54a1c1a573 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Tue, 3 Oct 2006 16:21:03 +0000 Subject: [PATCH] Fixed SD2-1048: Fully qualified names base types are added after 'global::' as keywords Converting from VB to C#. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1870 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs | 6 +++--- .../Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs | 2 +- .../Test/Output/CSharp/VBToCSharpConverterTest.cs | 6 ++++++ .../NRefactory/Test/Output/VBNet/CSharpToVBConverterTest.cs | 6 ++++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs index 033e5d75cb..9896fd3b8f 100644 --- a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs @@ -167,16 +167,16 @@ namespace ICSharpCode.NRefactory.PrettyPrinter if (typeReference.IsGlobal) { outputFormatter.PrintText("global::"); } - if (typeReference.Type == null || typeReference.Type.Length ==0) { + if (typeReference.Type == null || typeReference.Type.Length == 0) { outputFormatter.PrintText("void"); } else if (typeReference.SystemType == "System.Nullable" && typeReference.GenericTypes != null - && typeReference.GenericTypes.Count == 1) + && typeReference.GenericTypes.Count == 1 && !typeReference.IsGlobal) { nodeTracker.TrackedVisit(typeReference.GenericTypes[0], null); outputFormatter.PrintText("?"); } else { if (typeReference.SystemType.Length > 0) { - if (printFullSystemType) { + if (printFullSystemType || typeReference.IsGlobal) { outputFormatter.PrintIdentifier(typeReference.SystemType); } else { outputFormatter.PrintText(ConvertTypeString(typeReference.SystemType)); diff --git a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs index b4d4a37b18..3b8532f90e 100644 --- a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs @@ -153,7 +153,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter } if (typeReference.Type == null || typeReference.Type.Length ==0) { outputFormatter.PrintText("Void"); - } else if (printFullSystemType) { + } else if (printFullSystemType || typeReference.IsGlobal) { outputFormatter.PrintIdentifier(typeReference.SystemType); } else { string shortTypeName = ConvertTypeString(typeReference.SystemType); diff --git a/src/Libraries/NRefactory/Test/Output/CSharp/VBToCSharpConverterTest.cs b/src/Libraries/NRefactory/Test/Output/CSharp/VBToCSharpConverterTest.cs index 7348cb0c09..26efaf1039 100644 --- a/src/Libraries/NRefactory/Test/Output/CSharp/VBToCSharpConverterTest.cs +++ b/src/Libraries/NRefactory/Test/Output/CSharp/VBToCSharpConverterTest.cs @@ -555,5 +555,11 @@ static int static_Test2_j = 0;"); { TestProgram("Imports T = System.Boolean", "using T = System.Boolean;\r\n"); } + + [Test] + public void GlobalTypeReference() + { + TestStatement("Dim a As Global.System.String", "global::System.String a;"); + } } } diff --git a/src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBConverterTest.cs b/src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBConverterTest.cs index 1020b0f3bb..62e7adc5b9 100644 --- a/src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBConverterTest.cs +++ b/src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBConverterTest.cs @@ -429,5 +429,11 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter End Class "); } + + [Test] + public void GlobalTypeReference() + { + TestStatement("global::System.String a;", "Dim a As Global.System.String"); + } } }