1010using Serilog ;
1111using System ;
1212using System . Collections . Generic ;
13- using System . IO ;
1413using System . IO . Abstractions ;
1514using System . Linq ;
1615using System . Threading . Tasks ;
@@ -26,21 +25,21 @@ internal sealed class ModVerifyApplication(ModVerifyAppSettings settings, IServi
2625 private readonly IFileSystem _fileSystem = services . GetRequiredService < IFileSystem > ( ) ;
2726 private readonly ModVerifyAppEnvironment _appEnvironment = services . GetRequiredService < ModVerifyAppEnvironment > ( ) ;
2827
29- public async Task < int > Run ( )
28+ public async Task < int > RunAsync ( )
3029 {
3130 using ( new UnhandledExceptionHandler ( services ) )
3231 using ( new UnobservedTaskExceptionHandler ( services ) )
33- return await RunCore ( ) . ConfigureAwait ( false ) ;
32+ return await RunCoreAsync ( ) . ConfigureAwait ( false ) ;
3433 }
3534
36- private async Task < int > RunCore ( )
35+ private async Task < int > RunCoreAsync ( )
3736 {
3837 _logger ? . LogDebug ( "Raw command line: {CommandLine}" , Environment . CommandLine ) ;
3938
4039 var interactive = settings . Interactive ;
4140 try
4241 {
43- return await RunVerify ( ) . ConfigureAwait ( false ) ;
42+ return await RunModVerifyAsync ( ) . ConfigureAwait ( false ) ;
4443 }
4544 catch ( Exception e )
4645 {
@@ -66,7 +65,7 @@ private async Task<int> RunCore()
6665 }
6766
6867
69- private async Task < int > RunVerify ( )
68+ private async Task < int > RunModVerifyAsync ( )
7069 {
7170 VerificationTarget verificationTarget ;
7271 try
@@ -102,28 +101,34 @@ private async Task<int> RunVerify()
102101 _logger ? . LogDebug ( "Verification taget: {Target}" , verificationTarget ) ;
103102 _logger ? . LogTrace ( "Verify settings: {Settings}" , settings ) ;
104103
105- var allErrors = await Verify ( verificationTarget , reportSettings )
104+ var allErrors = await VerifyTargetAsync ( verificationTarget , reportSettings )
106105 . ConfigureAwait ( false ) ;
107106
107+ // TODO: Refactor method to represent "verify" and "baseline" mode of the app.
108+ // Also display to user more prominently which mode is active.
109+
108110 try
109111 {
110112 await ReportErrors ( allErrors ) . ConfigureAwait ( false ) ;
111113 }
112114 catch ( GameVerificationException e )
113115 {
116+ _logger ? . LogInformation ( ModVerifyConstants . ConsoleEventId ,
117+ "The verification of {Target} completed with findings of the specified failure severity {Severity}" ,
118+ verificationTarget . Name , settings . AppThrowsOnMinimumSeverity ) ;
114119 return e . HResult ;
115120 }
116121
117122 if ( ! settings . CreateNewBaseline )
118123 return 0 ;
119124
120- await WriteBaseline ( verificationTarget , reportSettings , allErrors , settings . NewBaselinePath ) . ConfigureAwait ( false ) ;
125+ await WriteBaselineAsync ( verificationTarget , reportSettings , allErrors , settings . NewBaselinePath ) . ConfigureAwait ( false ) ;
121126 _logger ? . LogInformation ( ModVerifyConstants . ConsoleEventId , "Baseline successfully created." ) ;
122127
123128 return 0 ;
124129 }
125130
126- private async Task < IReadOnlyCollection < VerificationError > > Verify (
131+ private async Task < IReadOnlyCollection < VerificationError > > VerifyTargetAsync (
127132 VerificationTarget verificationTarget ,
128133 GlobalVerifyReportSettings reportSettings )
129134 {
@@ -181,22 +186,15 @@ private async Task ReportErrors(IReadOnlyCollection<VerificationError> errors)
181186 throw new GameVerificationException ( errors ) ;
182187 }
183188
184- private async Task WriteBaseline (
189+ private async Task WriteBaselineAsync (
185190 VerificationTarget target ,
186191 GlobalVerifyReportSettings reportSettings ,
187192 IEnumerable < VerificationError > errors ,
188193 string baselineFile )
189194 {
190- var baseline = new VerificationBaseline ( reportSettings . MinimumReportSeverity , errors , target ) ;
191-
192- var fullPath = _fileSystem . Path . GetFullPath ( baselineFile ) ;
193- _logger ? . LogInformation ( ModVerifyConstants . ConsoleEventId , "Writing Baseline to '{FullPath}'" , fullPath ) ;
194-
195- #if NET
196- await
197- #endif
198- using var fs = _fileSystem . FileStream . New ( fullPath , FileMode . Create , FileAccess . Write , FileShare . None ) ;
199- await baseline . ToJsonAsync ( fs ) ;
195+ var baselineFactory = services . GetRequiredService < BaselineFactory > ( ) ;
196+ var baseline = baselineFactory . CreateBaseline ( target , reportSettings , errors ) ;
197+ await baselineFactory . WriteBaselineAsync ( baseline , baselineFile ) ;
200198 }
201199
202200 private GlobalVerifyReportSettings CreateGlobalReportSettings ( VerificationTarget verificationTarget )
0 commit comments