2
2
using System . Linq ;
3
3
using FineCodeCoverage ;
4
4
using System . Diagnostics ;
5
- using Microsoft . VisualStudio ;
6
5
using System . Collections . Generic ;
7
6
using Microsoft . VisualStudio . Shell ;
8
7
using System . Diagnostics . CodeAnalysis ;
9
8
using Microsoft . VisualStudio . Shell . Interop ;
10
9
using System . ComponentModel . Composition ;
11
10
using Microsoft ;
12
- using EnvDTE ;
11
+ using Task = System . Threading . Tasks . Task ;
12
+ using EnvDTE80 ;
13
13
14
14
interface IShowFCCOutputPane
15
15
{
16
- System . Threading . Tasks . Task ShowAsync ( ) ;
16
+ Task ShowAsync ( ) ;
17
17
}
18
18
[ Export ( typeof ( IShowFCCOutputPane ) ) ]
19
19
[ Export ( typeof ( ILogger ) ) ]
20
20
public class Logger : ILogger , IShowFCCOutputPane
21
21
{
22
22
private IVsOutputWindowPane _pane ;
23
23
private IVsOutputWindow _outputWindow ;
24
- private DTE dte ;
24
+ private DTE2 dte ;
25
25
private readonly IServiceProvider _serviceProvider ;
26
26
private Guid fccPaneGuid = Guid . Parse ( "3B3C775A-0050-445D-9022-0230957805B2" ) ;
27
27
@@ -35,33 +35,27 @@ IServiceProvider serviceProvider
35
35
staticLogger = this ;
36
36
}
37
37
38
- IVsOutputWindowPane CreatePane ( Guid paneGuid , string title ,
39
- bool visible , bool clearWithSolution )
40
- {
41
-
42
- ThreadHelper . ThrowIfNotOnUIThread ( ) ;
43
- _outputWindow = ( IVsOutputWindow ) _serviceProvider . GetService ( typeof ( SVsOutputWindow ) ) ;
44
- Assumes . Present ( _outputWindow ) ;
45
- dte = ( EnvDTE . DTE ) _serviceProvider . GetService ( typeof ( EnvDTE . DTE ) ) ;
46
- Assumes . Present ( dte ) ;
47
-
48
- // Create a new pane.
49
- _outputWindow . CreatePane (
50
- ref paneGuid ,
51
- title ,
52
- Convert . ToInt32 ( visible ) ,
53
- Convert . ToInt32 ( clearWithSolution ) ) ;
54
-
55
- // Retrieve the new pane.
56
- _outputWindow . GetPane ( ref paneGuid , out IVsOutputWindowPane pane ) ;
57
- return pane ;
58
- }
59
-
60
38
private void SetPane ( )
61
39
{
62
- ThreadHelper . ThrowIfNotOnUIThread ( ) ;
63
- // do not clear with solution otherwise will not get initialize methods
64
- _pane = CreatePane ( fccPaneGuid , "FCC" , true , false ) ;
40
+ ThreadHelper . JoinableTaskFactory . Run ( async ( ) =>
41
+ {
42
+ await ThreadHelper . JoinableTaskFactory . SwitchToMainThreadAsync ( ) ;
43
+ _outputWindow = ( IVsOutputWindow ) _serviceProvider . GetService ( typeof ( SVsOutputWindow ) ) ;
44
+ Assumes . Present ( _outputWindow ) ;
45
+ dte = ( DTE2 ) _serviceProvider . GetService ( typeof ( EnvDTE . DTE ) ) ;
46
+ Assumes . Present ( dte ) ;
47
+
48
+ // Create a new pane.
49
+ _outputWindow . CreatePane (
50
+ ref fccPaneGuid ,
51
+ "FCC" ,
52
+ Convert . ToInt32 ( true ) ,
53
+ Convert . ToInt32 ( false ) ) ; // do not clear with solution otherwise will not get initialize methods
54
+
55
+ // Retrieve the new pane.
56
+ _outputWindow . GetPane ( ref fccPaneGuid , out IVsOutputWindowPane pane ) ;
57
+ _pane = pane ;
58
+ } ) ;
65
59
}
66
60
67
61
[ SuppressMessage ( "Usage" , "VSTHRD102:Implement internal logic asynchronously" ) ]
@@ -154,7 +148,7 @@ public void LogWithoutTitle(IEnumerable<string> message)
154
148
LogImpl ( message . ToArray ( ) , false ) ;
155
149
}
156
150
157
- public async System . Threading . Tasks . Task ShowAsync ( )
151
+ public async Task ShowAsync ( )
158
152
{
159
153
await ThreadHelper . JoinableTaskFactory . SwitchToMainThreadAsync ( ) ;
160
154
0 commit comments