11using System ;
22using System . Collections . Generic ;
33using OmniSharp . Models . Events ;
4- using OmniSharp ;
54using OmniSharp . Models ;
65using System . Linq ;
6+ using System . Threading ;
7+ using System . Threading . Tasks ;
78
89namespace OmniSharp . Eventing
910{
1011 public static class IEventEmitterExtensions
1112 {
12- public static void Error ( this IEventEmitter emitter , Exception ex , string fileName = null )
13- {
14- emitter . Emit (
13+ public static ValueTask ErrorAsync ( this IEventEmitter emitter , Exception ex , string fileName = null , CancellationToken cancellationToken = default ) =>
14+ emitter . EmitAsync (
1515 EventTypes . Error ,
16- new ErrorMessage { FileName = fileName , Text = ex . ToString ( ) } ) ;
17- }
16+ new ErrorMessage { FileName = fileName , Text = ex . ToString ( ) } ,
17+ cancellationToken ) ;
1818
19- public static void RestoreStarted ( this IEventEmitter emitter , string projectPath )
20- {
21- emitter . Emit (
19+ public static ValueTask RestoreStartedAsync ( this IEventEmitter emitter , string projectPath , CancellationToken cancellationToken = default ) =>
20+ emitter . EmitAsync (
2221 EventTypes . PackageRestoreStarted ,
23- new PackageRestoreMessage { FileName = projectPath } ) ;
24- }
22+ new PackageRestoreMessage { FileName = projectPath } ,
23+ cancellationToken ) ;
2524
26- public static void RestoreFinished ( this IEventEmitter emitter , string projectPath , bool succeeded )
27- {
28- emitter . Emit (
25+ public static ValueTask RestoreFinishedAsync ( this IEventEmitter emitter , string projectPath , bool succeeded , CancellationToken cancellationToken = default ) =>
26+ emitter . EmitAsync (
2927 EventTypes . PackageRestoreFinished ,
3028 new PackageRestoreMessage
3129 {
3230 FileName = projectPath ,
3331 Succeeded = succeeded
34- } ) ;
35- }
32+ } ,
33+ cancellationToken ) ;
3634
37- public static void UnresolvedDepdendencies ( this IEventEmitter emitter , string projectFilePath , IEnumerable < PackageDependency > unresolvedDependencies )
38- {
39- emitter . Emit (
35+ public static ValueTask UnresolvedDependenciesAsync ( this IEventEmitter emitter , string projectFilePath , IEnumerable < PackageDependency > unresolvedDependencies , CancellationToken cancellationToken = default ) =>
36+ emitter . EmitAsync (
4037 EventTypes . UnresolvedDependencies ,
4138 new UnresolvedDependenciesMessage
4239 {
4340 FileName = projectFilePath ,
4441 UnresolvedDependencies = unresolvedDependencies
45- } ) ;
46- }
42+ } ,
43+ cancellationToken ) ;
4744
48- public static void ProjectLoadingStarted ( this IEventEmitter emitter , string projectPath ) =>
49- emitter . Emit (
45+ public static ValueTask ProjectLoadingStartedAsync ( this IEventEmitter emitter , string projectPath , CancellationToken cancellationToken = default ) =>
46+ emitter . EmitAsync (
5047 EventTypes . ProjectLoadingStarted ,
51- projectPath ) ;
48+ projectPath ,
49+ cancellationToken ) ;
50+
51+ public static ValueTask ProjectLoadingFinishedAsync ( this IEventEmitter emitter , string projectPath , CancellationToken cancellationToken = default ) =>
52+ emitter . EmitAsync (
53+ EventTypes . ProjectLoadingFinished ,
54+ projectPath ,
55+ cancellationToken ) ;
5256
53- public static void ProjectInformation ( this IEventEmitter emitter ,
57+ public static async Task ProjectInformationAsync ( this IEventEmitter emitter ,
5458 HashedString projectId ,
5559 HashedString sessionId ,
5660 int outputKind ,
@@ -61,7 +65,7 @@ public static void ProjectInformation(this IEventEmitter emitter,
6165 IEnumerable < HashedString > fileExtensions ,
6266 IEnumerable < int > fileCounts ,
6367 bool sdkStyleProject ,
64- string projectFilePath )
68+ CancellationToken cancellationToken = default )
6569 {
6670 var projectConfiguration = new ProjectConfigurationMessage ( )
6771 {
@@ -74,13 +78,13 @@ public static void ProjectInformation(this IEventEmitter emitter,
7478 References = references . Select ( hashed => hashed . Value ) ,
7579 FileExtensions = fileExtensions . Select ( hashed => hashed . Value ) ,
7680 FileCounts = fileCounts ,
77- SdkStyleProject = sdkStyleProject ,
78- ProjectFilePath = projectFilePath
81+ SdkStyleProject = sdkStyleProject
7982 } ;
8083
81- emitter . Emit (
84+ await emitter . EmitAsync (
8285 EventTypes . ProjectConfiguration ,
83- projectConfiguration ) ;
86+ projectConfiguration ,
87+ cancellationToken ) ;
8488 }
8589 }
8690}
0 commit comments