33using System . Collections . Generic ;
44using System . Collections . Immutable ;
55using System . Diagnostics ;
6+ using System . Globalization ;
67using System . IO ;
78using System . Linq ;
89using System . Reactive . Linq ;
910using System . Threading ;
1011using System . Threading . Tasks ;
12+ using Microsoft . CodeAnalysis ;
13+ using Microsoft . CodeAnalysis . CSharp ;
1114using Microsoft . Extensions . Logging ;
1215using Uno . Disposables ;
1316using Uno . Extensions ;
@@ -249,8 +252,13 @@ void LoadInfos(HotReloadServerOperation? operation)
249252 state = HotReloadState . Processing ;
250253 }
251254
255+ var diagnosticsResult = operation . Diagnostics
256+ ? . Where ( d => d . Severity >= DiagnosticSeverity . Warning )
257+ . Select ( d => CSharpDiagnosticFormatter . Instance . Format ( d , CultureInfo . InvariantCulture ) )
258+ . ToImmutableList ( ) ?? ImmutableList < string > . Empty ;
259+
252260 foundCompleting |= operation == completing ;
253- infos . Add ( new ( operation . Id , operation . StartTime , operation . FilePaths , operation . CompletionTime , operation . Result ) ) ;
261+ infos . Add ( new ( operation . Id , operation . StartTime , operation . FilePaths , operation . CompletionTime , operation . Result , diagnosticsResult ) ) ;
254262 operation = operation . Previous ! ;
255263 }
256264 }
@@ -281,6 +289,7 @@ private class HotReloadServerOperation
281289 private ImmutableHashSet < string > _filePaths ;
282290 private int /* HotReloadResult */ _result = - 1 ;
283291 private CancellationTokenSource ? _deferredCompletion ;
292+ private ImmutableArray < Diagnostic > ? _diagnostics ;
284293
285294 // In VS we forcefully request to VS to hot-reload application, but in some cases the changes are not detected by VS and it returns a NoChanges result.
286295 // In such cases we can retry the hot-reload request to VS to let it process the file updates.
@@ -297,6 +306,8 @@ private class HotReloadServerOperation
297306
298307 public ImmutableHashSet < string > FilePaths => _filePaths ;
299308
309+ public ImmutableArray < Diagnostic > ? Diagnostics => _diagnostics ;
310+
300311 public HotReloadServerResult ? Result => _result is - 1 ? null : ( HotReloadServerResult ) _result ;
301312
302313 /// <param name="previous">The previous hot-reload operation which has to be considered as aborted when this new one completes.</param>
@@ -384,10 +395,10 @@ public async ValueTask DeferComplete(HotReloadServerResult result, Exception? ex
384395 }
385396 }
386397
387- public ValueTask Complete ( HotReloadServerResult result , Exception ? exception = null )
388- => Complete ( result , exception , isFromNext : false ) ;
398+ public ValueTask Complete ( HotReloadServerResult result , Exception ? exception = null , ImmutableArray < Diagnostic > ? diagnostics = null )
399+ => Complete ( result , exception , isFromNext : false , diagnostics : diagnostics ) ;
389400
390- private async ValueTask Complete ( HotReloadServerResult result , Exception ? exception , bool isFromNext )
401+ private async ValueTask Complete ( HotReloadServerResult result , Exception ? exception , bool isFromNext , ImmutableArray < Diagnostic > ? diagnostics )
391402 {
392403 if ( _result is - 1
393404 && result is HotReloadServerResult . NoChanges
@@ -416,6 +427,8 @@ private async ValueTask Complete(HotReloadServerResult result, Exception? except
416427 return ; // Already completed
417428 }
418429
430+ _diagnostics = diagnostics ;
431+
419432 CompletionTime = DateTimeOffset . Now ;
420433 await _timeout . DisposeAsync ( ) ;
421434
@@ -425,7 +438,8 @@ private async ValueTask Complete(HotReloadServerResult result, Exception? except
425438 await _previous . Complete (
426439 HotReloadServerResult . Aborted ,
427440 new TimeoutException ( "An more recent hot-reload operation has completed." ) ,
428- isFromNext : true ) ;
441+ isFromNext : true ,
442+ diagnostics : null ) ;
429443 }
430444
431445 if ( ! isFromNext ) // Only the head of the list should request update
0 commit comments