4
4
using System . Linq ;
5
5
using System . Threading ;
6
6
using System . Threading . Tasks ;
7
- using Microsoft . CodeAnalysis . Remote ;
8
7
using Microsoft . CodeAnalysis . Shared . Extensions ;
9
8
10
9
namespace Microsoft . CodeAnalysis . DesignerAttributes
11
10
{
12
11
internal struct DesignerAttributeResult
13
12
{
13
+ public string FilePath ;
14
14
public string DesignerAttributeArgument ;
15
15
public bool ContainsErrors ;
16
16
public bool NotApplicable ;
17
17
18
- public DesignerAttributeResult ( string designerAttributeArgument , bool containsErrors , bool notApplicable )
18
+ public DesignerAttributeResult ( string filePath , string designerAttributeArgument , bool containsErrors , bool notApplicable )
19
19
{
20
+ FilePath = filePath ;
20
21
DesignerAttributeArgument = designerAttributeArgument ;
21
22
ContainsErrors = containsErrors ;
22
23
NotApplicable = notApplicable ;
@@ -30,32 +31,6 @@ internal abstract class AbstractDesignerAttributeService : IDesignerAttributeSer
30
31
protected abstract bool HasAttributesOrBaseTypeOrIsPartial ( SyntaxNode typeNode ) ;
31
32
32
33
public async Task < DesignerAttributeResult > ScanDesignerAttributesAsync ( Document document , CancellationToken cancellationToken )
33
- {
34
- var workspace = document . Project . Solution . Workspace ;
35
-
36
- // same service run in both inproc and remote host, but remote host will not have RemoteHostClient service,
37
- // so inproc one will always run
38
- var client = await workspace . TryGetRemoteHostClientAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
39
- if ( client != null && ! document . IsOpen ( ) )
40
- {
41
- // run designer attributes scanner on remote host
42
- // we only run closed files to make open document to have better responsiveness.
43
- // also we cache everything related to open files anyway, no saving by running
44
- // them in remote host
45
- return await ScanDesignerAttributesInRemoteHostAsync ( client , document , cancellationToken ) . ConfigureAwait ( false ) ;
46
- }
47
-
48
- return await ScanDesignerAttributesInCurrentProcessAsync ( document , cancellationToken ) . ConfigureAwait ( false ) ;
49
- }
50
-
51
- private async Task < DesignerAttributeResult > ScanDesignerAttributesInRemoteHostAsync ( RemoteHostClient client , Document document , CancellationToken cancellationToken )
52
- {
53
- return await client . RunCodeAnalysisServiceOnRemoteHostAsync < DesignerAttributeResult > (
54
- document . Project . Solution , nameof ( IRemoteDesignerAttributeService . ScanDesignerAttributesAsync ) ,
55
- document . Id , cancellationToken ) . ConfigureAwait ( false ) ;
56
- }
57
-
58
- private async Task < DesignerAttributeResult > ScanDesignerAttributesInCurrentProcessAsync ( Document document , CancellationToken cancellationToken )
59
34
{
60
35
var root = await document . GetSyntaxRootAsync ( cancellationToken ) . ConfigureAwait ( continueOnCapturedContext : false ) ;
61
36
@@ -83,7 +58,7 @@ private async Task<DesignerAttributeResult> ScanDesignerAttributesInCurrentProce
83
58
{
84
59
// The DesignerCategoryAttribute doesn't exist. either not applicable or
85
60
// no idea on design attribute status, just leave things as it is.
86
- return new DesignerAttributeResult ( designerAttributeArgument , documentHasError , notApplicable : true ) ;
61
+ return new DesignerAttributeResult ( document . FilePath , designerAttributeArgument , documentHasError , notApplicable : true ) ;
87
62
}
88
63
}
89
64
@@ -114,7 +89,7 @@ private async Task<DesignerAttributeResult> ScanDesignerAttributesInCurrentProce
114
89
if ( attribute != null && attribute . ConstructorArguments . Length == 1 )
115
90
{
116
91
designerAttributeArgument = GetArgumentString ( attribute . ConstructorArguments [ 0 ] ) ;
117
- return new DesignerAttributeResult ( designerAttributeArgument , documentHasError , notApplicable : false ) ;
92
+ return new DesignerAttributeResult ( document . FilePath , designerAttributeArgument , documentHasError , notApplicable : false ) ;
118
93
}
119
94
}
120
95
}
@@ -126,7 +101,7 @@ private async Task<DesignerAttributeResult> ScanDesignerAttributesInCurrentProce
126
101
}
127
102
}
128
103
129
- return new DesignerAttributeResult ( designerAttributeArgument , documentHasError , notApplicable : false ) ;
104
+ return new DesignerAttributeResult ( document . FilePath , designerAttributeArgument , documentHasError , notApplicable : false ) ;
130
105
}
131
106
132
107
private static string GetArgumentString ( TypedConstant argument )
@@ -141,4 +116,4 @@ private static string GetArgumentString(TypedConstant argument)
141
116
return ( ( string ) argument . Value ) . Trim ( ) ;
142
117
}
143
118
}
144
- }
119
+ }
0 commit comments