44using System . Linq ;
55using System . Threading ;
66using System . Threading . Tasks ;
7- using Microsoft . CodeAnalysis . Remote ;
87using Microsoft . CodeAnalysis . Shared . Extensions ;
98
109namespace Microsoft . CodeAnalysis . DesignerAttributes
1110{
1211 internal struct DesignerAttributeResult
1312 {
13+ public string FilePath ;
1414 public string DesignerAttributeArgument ;
1515 public bool ContainsErrors ;
1616 public bool NotApplicable ;
1717
18- public DesignerAttributeResult ( string designerAttributeArgument , bool containsErrors , bool notApplicable )
18+ public DesignerAttributeResult ( string filePath , string designerAttributeArgument , bool containsErrors , bool notApplicable )
1919 {
20+ FilePath = filePath ;
2021 DesignerAttributeArgument = designerAttributeArgument ;
2122 ContainsErrors = containsErrors ;
2223 NotApplicable = notApplicable ;
@@ -30,32 +31,6 @@ internal abstract class AbstractDesignerAttributeService : IDesignerAttributeSer
3031 protected abstract bool HasAttributesOrBaseTypeOrIsPartial ( SyntaxNode typeNode ) ;
3132
3233 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 )
5934 {
6035 var root = await document . GetSyntaxRootAsync ( cancellationToken ) . ConfigureAwait ( continueOnCapturedContext : false ) ;
6136
@@ -83,7 +58,7 @@ private async Task<DesignerAttributeResult> ScanDesignerAttributesInCurrentProce
8358 {
8459 // The DesignerCategoryAttribute doesn't exist. either not applicable or
8560 // 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 ) ;
8762 }
8863 }
8964
@@ -114,7 +89,7 @@ private async Task<DesignerAttributeResult> ScanDesignerAttributesInCurrentProce
11489 if ( attribute != null && attribute . ConstructorArguments . Length == 1 )
11590 {
11691 designerAttributeArgument = GetArgumentString ( attribute . ConstructorArguments [ 0 ] ) ;
117- return new DesignerAttributeResult ( designerAttributeArgument , documentHasError , notApplicable : false ) ;
92+ return new DesignerAttributeResult ( document . FilePath , designerAttributeArgument , documentHasError , notApplicable : false ) ;
11893 }
11994 }
12095 }
@@ -126,7 +101,7 @@ private async Task<DesignerAttributeResult> ScanDesignerAttributesInCurrentProce
126101 }
127102 }
128103
129- return new DesignerAttributeResult ( designerAttributeArgument , documentHasError , notApplicable : false ) ;
104+ return new DesignerAttributeResult ( document . FilePath , designerAttributeArgument , documentHasError , notApplicable : false ) ;
130105 }
131106
132107 private static string GetArgumentString ( TypedConstant argument )
@@ -141,4 +116,4 @@ private static string GetArgumentString(TypedConstant argument)
141116 return ( ( string ) argument . Value ) . Trim ( ) ;
142117 }
143118 }
144- }
119+ }
0 commit comments