diff --git a/ICSharpCode.Decompiler.Tests/TestCases/VBPretty/.gitignore b/ICSharpCode.Decompiler.Tests/TestCases/VBPretty/.gitignore index 6a7461313..701b61388 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/VBPretty/.gitignore +++ b/ICSharpCode.Decompiler.Tests/TestCases/VBPretty/.gitignore @@ -1 +1,3 @@ -*.dll +/*.dll +/*.exe +/*.pdb \ No newline at end of file diff --git a/ICSharpCode.Decompiler.Tests/TestCases/VBPretty/Async.cs b/ICSharpCode.Decompiler.Tests/TestCases/VBPretty/Async.cs index 43b6ab950..cac0b02fe 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/VBPretty/Async.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/VBPretty/Async.cs @@ -2,44 +2,50 @@ using System.IO; using System.Threading.Tasks; -namespace EquivalentCSharpConsoleApp +using Microsoft.VisualBasic.CompilerServices; + +[StandardModule] +internal sealed class AsyncProgram { - static class Program + [STAThread] + public static void Main(string[] args) { - public static void Main(string[] args) - { - var task = new Task(ProcessDataAsync); - task.Start(); - task.Wait(); - Console.ReadLine(); - } + Task task = new Task(ProcessDataAsync); + task.Start(); + task.Wait(); + Console.ReadLine(); + } - public async static void ProcessDataAsync() - { - Task task = HandleFileAsync("C:\\enable1.txt"); - Console.WriteLine("Please wait, processing"); - int result = await task; - Console.WriteLine("Count: " + result.ToString()); - } + public static async void ProcessDataAsync() + { + Task task = HandleFileAsync("C:\\enable1.txt"); + Console.WriteLine("Please wait, processing"); + Console.WriteLine("Count: " + await task); + } - public async static Task HandleFileAsync(string file) + public static async Task HandleFileAsync(string file) + { + Console.WriteLine("HandleFile enter"); + int num = 0; + checked { - Console.WriteLine("HandleFile enter"); - int count = 0; - using (StreamReader reader = new StreamReader(file)) + using (StreamReader streamReader = new StreamReader(file)) { - string value = await reader.ReadToEndAsync(); - count += value.Length; - for (var i = 0; i <= 10000; i += 1) + string text = await streamReader.ReadToEndAsync(); + num += text.Length; + int num2 = 0; + do { - var x = value.GetHashCode(); - if (x == 0) - count -= 1; - } + if (text.GetHashCode() == 0) + { + num--; + } + num2++; + } while (num2 <= 10000); } Console.WriteLine("HandleFile exit"); - return count; + return num; } } -} \ No newline at end of file +} diff --git a/ICSharpCode.Decompiler.Tests/TestCases/VBPretty/Async.vb b/ICSharpCode.Decompiler.Tests/TestCases/VBPretty/Async.vb index 9f16b85c4..e618022a7 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/VBPretty/Async.vb +++ b/ICSharpCode.Decompiler.Tests/TestCases/VBPretty/Async.vb @@ -1,7 +1,8 @@ Imports System Imports System.IO +Imports System.Threading.Tasks -Module Program +Module AsyncProgram ' Sample taken verbatim from https://www.dotnetperls.com/async-vbnet Sub Main(args As String()) Dim task = New Task(AddressOf ProcessDataAsync) diff --git a/ICSharpCode.Decompiler.Tests/VBPrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/VBPrettyTestRunner.cs index b9a609cda..72ede5084 100644 --- a/ICSharpCode.Decompiler.Tests/VBPrettyTestRunner.cs +++ b/ICSharpCode.Decompiler.Tests/VBPrettyTestRunner.cs @@ -89,7 +89,7 @@ namespace ICSharpCode.Decompiler.Tests CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest, }; - [Test, Ignore("Implement VB async/await")] + [Test] public async Task Async([ValueSource(nameof(defaultOptions))] CompilerOptions options) { await Run(options: options);