|
|
|
@ -41,9 +41,6 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
@@ -41,9 +41,6 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
|
|
|
|
|
BreakUnlessContinue(true); |
|
|
|
|
BreakUnlessContinue(false); |
|
|
|
|
TestConditionals(); |
|
|
|
|
ThisIsNotAUsingBlock(); |
|
|
|
|
NoUsing(); |
|
|
|
|
UsingObject(); |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -152,61 +149,5 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
@@ -152,61 +149,5 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
|
|
|
|
|
byte answer = (byte)(value == 128 ? 255 : 0); |
|
|
|
|
return answer; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void ThisIsNotAUsingBlock() |
|
|
|
|
{ |
|
|
|
|
var obj = new System.IO.StringWriter(); |
|
|
|
|
IDisposable disposable; |
|
|
|
|
try { |
|
|
|
|
obj.WriteLine("ThisIsNotAUsingBlock"); |
|
|
|
|
} finally { |
|
|
|
|
disposable = (object)obj as IDisposable; |
|
|
|
|
if (disposable != null) { |
|
|
|
|
disposable.Dispose(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Console.WriteLine(disposable); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private class PrintOnDispose : IDisposable |
|
|
|
|
{ |
|
|
|
|
private string v; |
|
|
|
|
|
|
|
|
|
public PrintOnDispose(string v) |
|
|
|
|
{ |
|
|
|
|
this.v = v; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void Dispose() |
|
|
|
|
{ |
|
|
|
|
Console.WriteLine(this.v); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void NoUsing() |
|
|
|
|
{ |
|
|
|
|
PrintOnDispose printOnDispose = new PrintOnDispose("NoUsing(): Wrong"); |
|
|
|
|
try { |
|
|
|
|
printOnDispose = new PrintOnDispose("NoUsing(): Correct"); |
|
|
|
|
} finally { |
|
|
|
|
IDisposable disposable = (object)printOnDispose as IDisposable; |
|
|
|
|
if (disposable != null) { |
|
|
|
|
disposable.Dispose(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void UsingObject() |
|
|
|
|
{ |
|
|
|
|
object obj = new object(); |
|
|
|
|
try { |
|
|
|
|
Console.WriteLine("UsingObject: {0}", obj); |
|
|
|
|
} finally { |
|
|
|
|
IDisposable disposable = obj as IDisposable; |
|
|
|
|
if (disposable != null) { |
|
|
|
|
disposable.Dispose(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |