Browse Source

Fix VBPretty Async test

pull/2853/head
ElektroKill 3 years ago
parent
commit
684be5c13a
No known key found for this signature in database
GPG Key ID: 7E3C5C084E40E3EC
  1. 4
      ICSharpCode.Decompiler.Tests/TestCases/VBPretty/.gitignore
  2. 40
      ICSharpCode.Decompiler.Tests/TestCases/VBPretty/Async.cs
  3. 3
      ICSharpCode.Decompiler.Tests/TestCases/VBPretty/Async.vb
  4. 2
      ICSharpCode.Decompiler.Tests/VBPrettyTestRunner.cs

4
ICSharpCode.Decompiler.Tests/TestCases/VBPretty/.gitignore vendored

@ -1 +1,3 @@ @@ -1 +1,3 @@
*.dll
/*.dll
/*.exe
/*.pdb

40
ICSharpCode.Decompiler.Tests/TestCases/VBPretty/Async.cs

@ -2,44 +2,50 @@ @@ -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)
{
var task = new Task(ProcessDataAsync);
Task task = new Task(ProcessDataAsync);
task.Start();
task.Wait();
Console.ReadLine();
}
public async static void ProcessDataAsync()
public static async void ProcessDataAsync()
{
Task<int> task = HandleFileAsync("C:\\enable1.txt");
Console.WriteLine("Please wait, processing");
int result = await task;
Console.WriteLine("Count: " + result.ToString());
Console.WriteLine("Count: " + await task);
}
public async static Task<int> HandleFileAsync(string file)
public static async Task<int> HandleFileAsync(string file)
{
Console.WriteLine("HandleFile enter");
int count = 0;
using (StreamReader reader = new StreamReader(file))
int num = 0;
checked
{
using (StreamReader streamReader = new StreamReader(file))
{
string text = await streamReader.ReadToEndAsync();
num += text.Length;
int num2 = 0;
do
{
string value = await reader.ReadToEndAsync();
count += value.Length;
for (var i = 0; i <= 10000; i += 1)
if (text.GetHashCode() == 0)
{
var x = value.GetHashCode();
if (x == 0)
count -= 1;
num--;
}
num2++;
} while (num2 <= 10000);
}
Console.WriteLine("HandleFile exit");
return count;
return num;
}
}
}

3
ICSharpCode.Decompiler.Tests/TestCases/VBPretty/Async.vb

@ -1,7 +1,8 @@ @@ -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)

2
ICSharpCode.Decompiler.Tests/VBPrettyTestRunner.cs

@ -89,7 +89,7 @@ namespace ICSharpCode.Decompiler.Tests @@ -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);

Loading…
Cancel
Save