8
8
using System . Text . Json ;
9
9
using System . Text . Json . Serialization ;
10
10
using System . Text . RegularExpressions ;
11
+ using System . Threading . Tasks ;
11
12
using PlaywrightSharp . Tooling . Extensions ;
12
13
using PlaywrightSharp . Tooling . Models . Api ;
13
14
using PlaywrightSharp . Tooling . Models . Mismatch ;
@@ -21,12 +22,13 @@ internal class ApiChecker
21
22
22
23
public string AssemblyPath { get ; set ; }
23
24
24
- public bool Execute ( )
25
+ public async Task < bool > ExecuteAsync ( )
25
26
{
26
27
var assembly = Assembly . LoadFrom ( AssemblyPath ) ;
27
28
28
29
var report = new StringBuilder ( "<html><body><ul>" ) ;
29
- string json = File . ReadAllText ( Path . Combine ( BasePath , "src" , "PlaywrightSharp" , "Drivers" , "api.json" ) ) ;
30
+ string json = await File . ReadAllTextAsync ( Path . Combine ( BasePath , "src" , "PlaywrightSharp" , "Drivers" , "api.json" ) ) . ConfigureAwait ( false ) ;
31
+
30
32
var api = JsonSerializer . Deserialize < PlaywrightEntity [ ] > ( json , new JsonSerializerOptions
31
33
{
32
34
PropertyNameCaseInsensitive = true ,
@@ -37,7 +39,7 @@ public bool Execute()
37
39
} ) ;
38
40
39
41
string mismatchJsonFile = Path . Combine ( BasePath , "src" , "PlaywrightSharp" , "Drivers" , "expected_api_mismatch.json" ) ;
40
- string mismatchJson = File . ReadAllText ( mismatchJsonFile ) ;
42
+ string mismatchJson = await File . ReadAllTextAsync ( mismatchJsonFile ) . ConfigureAwait ( false ) ;
41
43
Mismatch mismatches ;
42
44
43
45
try
@@ -58,19 +60,22 @@ public bool Execute()
58
60
}
59
61
60
62
report . Append ( "</ul></body></html>" ) ;
61
- File . WriteAllText (
63
+ await File . WriteAllTextAsync (
62
64
Path . Combine ( BasePath , "src" , "PlaywrightSharp" , "Drivers" , "report.html" ) ,
63
- report . ToString ( ) ) ;
65
+ report . ToString ( ) ) . ConfigureAwait ( false ) ;
64
66
65
67
return true ;
66
68
}
67
69
68
- internal static void Run ( ApiCheckerOptions o )
69
- => new ApiChecker
70
+ internal static Task RunAsync ( ApiCheckerOptions o )
71
+ {
72
+ ApiChecker apiChecker = new ApiChecker
70
73
{
71
74
BasePath = o . BasePath ,
72
75
AssemblyPath = Path . Combine ( o . BasePath , "src" , "PlaywrightSharp" , "bin" , "Debug" , "net5.0" , "PlaywrightSharp.dll" ) ,
73
- } . Execute ( ) ;
76
+ } ;
77
+ return apiChecker . ExecuteAsync ( ) ;
78
+ }
74
79
75
80
private static string TranslateMethodName ( string memberName )
76
81
=> memberName
0 commit comments