Browse Source

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
shortcuts
Daniel Grunwald 20 years ago
parent
commit
7936cdc4dc
  1. 6
      src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs
  2. 2
      src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs
  3. 6
      src/Libraries/NRefactory/Test/Output/CSharp/VBToCSharpConverterTest.cs
  4. 6
      src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBConverterTest.cs

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

@ -167,16 +167,16 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
if (typeReference.IsGlobal) { if (typeReference.IsGlobal) {
outputFormatter.PrintText("global::"); outputFormatter.PrintText("global::");
} }
if (typeReference.Type == null || typeReference.Type.Length ==0) { if (typeReference.Type == null || typeReference.Type.Length == 0) {
outputFormatter.PrintText("void"); outputFormatter.PrintText("void");
} else if (typeReference.SystemType == "System.Nullable" && typeReference.GenericTypes != null } 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); nodeTracker.TrackedVisit(typeReference.GenericTypes[0], null);
outputFormatter.PrintText("?"); outputFormatter.PrintText("?");
} else { } else {
if (typeReference.SystemType.Length > 0) { if (typeReference.SystemType.Length > 0) {
if (printFullSystemType) { if (printFullSystemType || typeReference.IsGlobal) {
outputFormatter.PrintIdentifier(typeReference.SystemType); outputFormatter.PrintIdentifier(typeReference.SystemType);
} else { } else {
outputFormatter.PrintText(ConvertTypeString(typeReference.SystemType)); outputFormatter.PrintText(ConvertTypeString(typeReference.SystemType));

2
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) { if (typeReference.Type == null || typeReference.Type.Length ==0) {
outputFormatter.PrintText("Void"); outputFormatter.PrintText("Void");
} else if (printFullSystemType) { } else if (printFullSystemType || typeReference.IsGlobal) {
outputFormatter.PrintIdentifier(typeReference.SystemType); outputFormatter.PrintIdentifier(typeReference.SystemType);
} else { } else {
string shortTypeName = ConvertTypeString(typeReference.SystemType); string shortTypeName = ConvertTypeString(typeReference.SystemType);

6
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"); 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;");
}
} }
} }

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

@ -429,5 +429,11 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter
End Class End Class
"); ");
} }
[Test]
public void GlobalTypeReference()
{
TestStatement("global::System.String a;", "Dim a As Global.System.String");
}
} }
} }

Loading…
Cancel
Save