Browse Source

Fixed SD2-1021: Alias for namespaces not converted correctly between C#<-->VB.NET for base types.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1725 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
ddf419442b
  1. 12
      src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs
  2. 5
      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
  5. 65
      src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs

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

@ -24,8 +24,8 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -24,8 +24,8 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
CSharpOutputFormatter outputFormatter;
PrettyPrintOptions prettyPrintOptions = new PrettyPrintOptions();
NodeTracker nodeTracker;
// Stack<WithStatement> withExpressionStack = new Stack<WithStatement>();
Stack withExpressionStack = new Stack();
Stack<WithStatement> withExpressionStack = new Stack<WithStatement>();
bool printFullSystemType;
public string Text {
get {
@ -176,7 +176,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -176,7 +176,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.PrintText("?");
} else {
if (typeReference.SystemType.Length > 0) {
outputFormatter.PrintText(ConvertTypeString(typeReference.SystemType));
if (printFullSystemType) {
outputFormatter.PrintIdentifier(typeReference.SystemType);
} else {
outputFormatter.PrintText(ConvertTypeString(typeReference.SystemType));
}
} else {
outputFormatter.PrintText(typeReference.Type);
}
@ -289,7 +293,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -289,7 +293,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.Assign);
outputFormatter.Space();
printFullSystemType = true;
nodeTracker.TrackedVisit(@using.Alias, data);
printFullSystemType = false;
}
outputFormatter.PrintToken(Tokens.Semicolon);

5
src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs

@ -25,6 +25,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -25,6 +25,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
VBNetPrettyPrintOptions prettyPrintOptions = new VBNetPrettyPrintOptions();
NodeTracker nodeTracker;
TypeDeclaration currentType;
bool printFullSystemType;
Stack<int> exitTokenStack = new Stack<int>();
@ -152,6 +153,8 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -152,6 +153,8 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
}
if (typeReference.Type == null || typeReference.Type.Length ==0) {
outputFormatter.PrintText("Void");
} else if (printFullSystemType) {
outputFormatter.PrintIdentifier(typeReference.SystemType);
} else {
string shortTypeName = ConvertTypeString(typeReference.SystemType);
if (shortTypeName != null) {
@ -258,7 +261,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -258,7 +261,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.Assign);
outputFormatter.Space();
printFullSystemType = true;
nodeTracker.TrackedVisit(((Using)usingDeclaration.Usings[i]).Alias, data);
printFullSystemType = false;
}
if (i + 1 < usingDeclaration.Usings.Count) {
outputFormatter.PrintToken(Tokens.Comma);

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

@ -549,5 +549,11 @@ static int static_Test2_j = 0;"); @@ -549,5 +549,11 @@ static int static_Test2_j = 0;");
"\t}\n" +
"}");
}
[Test]
public void ImportAliasPrimitiveType()
{
TestProgram("Imports T = System.Boolean", "using T = System.Boolean;\r\n");
}
}
}

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

@ -407,5 +407,11 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter @@ -407,5 +407,11 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter
"\tProperty Name() As String\n" +
"End Interface");
}
[Test]
public void ImportAliasPrimitiveType()
{
TestProgram("using T = System.Boolean;", "Imports T = System.Boolean\r\n");
}
}
}

65
src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs

@ -100,19 +100,11 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -100,19 +100,11 @@ namespace ICSharpCode.SharpDevelop.Gui
/// </summary>
private class STAThreadCaller
{
delegate object PerformCallDelegate(object target, string methodName, object[] arguments);
Control ctl;
PerformCallDelegate performCallDelegate;
#if DEBUG
string callerStack;
#endif
public STAThreadCaller(Control ctl)
{
this.ctl = ctl;
performCallDelegate = new PerformCallDelegate(DoPerformCall);
}
public object Call(Delegate method, object[] arguments)
@ -123,19 +115,6 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -123,19 +115,6 @@ namespace ICSharpCode.SharpDevelop.Gui
return ctl.Invoke(method, arguments);
}
public object Call(object target, string methodName, object[] arguments)
{
if (target == null) {
throw new ArgumentNullException("target");
}
#if DEBUG
callerStack = Environment.StackTrace;
#endif
return ctl.Invoke(performCallDelegate, new object[] {target, methodName, arguments});
}
public void BeginCall(Delegate method, object[] arguments)
{
if (method == null) {
@ -143,50 +122,6 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -143,50 +122,6 @@ namespace ICSharpCode.SharpDevelop.Gui
}
ctl.BeginInvoke(method, arguments);
}
public void BeginCall(object target, string methodName, object[] arguments)
{
if (target == null) {
throw new ArgumentNullException("target");
}
#if DEBUG
callerStack = Environment.StackTrace;
#endif
ctl.BeginInvoke(performCallDelegate, new object[] {target, methodName, arguments});
}
object DoPerformCall(object target, string methodName, object[] arguments)
{
MethodInfo methodInfo = null;
if (target is Type) {
methodInfo = ((Type)target).GetMethod(methodName, BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic);
} else {
methodInfo = target.GetType().GetMethod(methodName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);
}
if (methodInfo == null) {
throw new System.ArgumentException("method not found : " + methodName);
} else {
try {
if (target is Type) {
return methodInfo.Invoke(null, arguments);
} else {
return methodInfo.Invoke(target, arguments);
}
} catch (Exception ex) {
if (ex is TargetInvocationException && ex.InnerException != null) {
ex = ex.InnerException;
}
MessageService.ShowError(ex, "Exception got.");
#if DEBUG
LoggingService.Info("Stacktrace of source thread:\n" + callerStack);
#endif
}
}
return null;
}
}
public static bool InvokeRequired {

Loading…
Cancel
Save