@@ -38,16 +38,18 @@ namespace SonarLint.VisualStudio.Integration
38
38
public class SolutionWorkspaceService : ISolutionWorkspaceService
39
39
{
40
40
private readonly ISolutionInfoProvider solutionInfoProvider ;
41
+ private readonly ILogger log ;
41
42
private readonly IServiceProvider serviceProvider ;
42
43
private readonly IThreadHandling threadHandling ;
43
44
44
45
[ ImportingConstructor ]
45
- public SolutionWorkspaceService ( ISolutionInfoProvider solutionInfoProvider , [ Import ( typeof ( SVsServiceProvider ) ) ] IServiceProvider serviceProvider )
46
- : this ( solutionInfoProvider , serviceProvider , ThreadHandling . Instance ) { }
46
+ public SolutionWorkspaceService ( ISolutionInfoProvider solutionInfoProvider , ILogger log , [ Import ( typeof ( SVsServiceProvider ) ) ] IServiceProvider serviceProvider )
47
+ : this ( solutionInfoProvider , log , serviceProvider , ThreadHandling . Instance ) { }
47
48
48
- internal SolutionWorkspaceService ( ISolutionInfoProvider solutionInfoProvider , IServiceProvider serviceProvider , IThreadHandling threadHandling )
49
+ internal SolutionWorkspaceService ( ISolutionInfoProvider solutionInfoProvider , ILogger log , IServiceProvider serviceProvider , IThreadHandling threadHandling )
49
50
{
50
51
this . solutionInfoProvider = solutionInfoProvider ;
52
+ this . log = log ;
51
53
this . serviceProvider = serviceProvider ;
52
54
this . threadHandling = threadHandling ;
53
55
}
@@ -76,7 +78,7 @@ private IReadOnlyCollection<string> GetAllFilesInSolution(IVsSolution solution)
76
78
. Where ( x => ! x . Contains ( "\\ .nuget\\ " ) )
77
79
. Where ( x => ! x . Contains ( "\\ node_modules\\ " ) )
78
80
. ToHashSet ( StringComparer . InvariantCultureIgnoreCase ) ) ; // move filtering closer to path extraction to avoid processing unnecessary items)
79
-
81
+
80
82
return result ;
81
83
}
82
84
@@ -149,24 +151,36 @@ private string GetProjectFilePath(IVsProject project)
149
151
}
150
152
151
153
[ ExcludeFromCodeCoverage ]
152
- private static VSConstants . VSITEMID FirstChild ( IVsHierarchy hierarchy , VSConstants . VSITEMID rootID )
154
+ private VSConstants . VSITEMID FirstChild ( IVsHierarchy hierarchy , VSConstants . VSITEMID rootID )
153
155
{
154
- hierarchy . GetProperty ( ( uint ) rootID , ( int ) __VSHPROPID . VSHPROPID_FirstChild , out var childIDObj ) ;
155
- if ( childIDObj != null )
156
+ try
157
+ {
158
+ if ( hierarchy . GetProperty ( ( uint ) rootID , ( int ) __VSHPROPID . VSHPROPID_FirstChild , out var childIDObj ) == VSConstants . S_OK && childIDObj != null )
159
+ {
160
+ return ( VSConstants . VSITEMID ) ( int ) childIDObj ;
161
+ }
162
+ }
163
+ catch ( Exception e )
156
164
{
157
- return ( VSConstants . VSITEMID ) ( int ) childIDObj ;
165
+ log . LogVerbose ( e . ToString ( ) ) ;
158
166
}
159
167
160
168
return VSConstants . VSITEMID . Nil ;
161
169
}
162
170
163
171
[ ExcludeFromCodeCoverage ]
164
- private static VSConstants . VSITEMID NextSibling ( IVsHierarchy hierarchy , VSConstants . VSITEMID firstID )
172
+ private VSConstants . VSITEMID NextSibling ( IVsHierarchy hierarchy , VSConstants . VSITEMID firstID )
165
173
{
166
- hierarchy . GetProperty ( ( uint ) firstID , ( int ) __VSHPROPID . VSHPROPID_NextSibling , out var siblingIDObj ) ;
167
- if ( siblingIDObj != null )
174
+ try
175
+ {
176
+ if ( hierarchy . GetProperty ( ( uint ) firstID , ( int ) __VSHPROPID . VSHPROPID_NextSibling , out var siblingIDObj ) == VSConstants . S_OK && siblingIDObj != null )
177
+ {
178
+ return ( VSConstants . VSITEMID ) ( int ) siblingIDObj ;
179
+ }
180
+ }
181
+ catch ( Exception e )
168
182
{
169
- return ( VSConstants . VSITEMID ) ( int ) siblingIDObj ;
183
+ log . LogVerbose ( e . ToString ( ) ) ;
170
184
}
171
185
172
186
return VSConstants . VSITEMID . Nil ;
0 commit comments