File tree Expand file tree Collapse file tree 1 file changed +26
-4
lines changed
Rubberduck.CodeAnalysis/Inspections/Concrete Expand file tree Collapse file tree 1 file changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,10 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
60
60
var component = GetVBComponentMatchingSheetName ( reference ) ;
61
61
if ( component != null )
62
62
{
63
- reference . Properties . CodeName = ( string ) component . Properties . Single ( property => property . Name == "CodeName" ) . Value ;
63
+ using ( var properties = component . Properties )
64
+ {
65
+ reference . Properties . CodeName = ( string ) properties . Single ( property => property . Name == "CodeName" ) . Value ;
66
+ }
64
67
issues . Add ( reference ) ;
65
68
}
66
69
}
@@ -98,9 +101,28 @@ private IVBComponent GetVBComponentMatchingSheetName(IdentifierReferenceInspecti
98
101
var sheetName = FormatSheetName ( sheetArgumentContext . GetText ( ) ) ;
99
102
var project = State . Projects . First ( p => p . ProjectId == reference . QualifiedName . ProjectId ) ;
100
103
101
- return project . VBComponents . FirstOrDefault ( c =>
102
- c . Type == ComponentType . Document &&
103
- ( string ) c . Properties . First ( property => property . Name == "Name" ) . Value == sheetName ) ;
104
+ using ( var components = project . VBComponents )
105
+ {
106
+ for ( var i = 0 ; i < components . Count ; i ++ )
107
+ {
108
+ using ( var component = components [ i ] )
109
+ using ( var properties = component . Properties )
110
+ {
111
+ for ( var j = 0 ; j < properties . Count ; j ++ )
112
+ {
113
+ using ( var property = properties [ j ] )
114
+ {
115
+ if ( component . Type == ComponentType . Document && property . Name == "Name" && ( string ) property . Value == sheetName )
116
+ {
117
+ return component ;
118
+ }
119
+ }
120
+ }
121
+ }
122
+ }
123
+
124
+ return null ;
125
+ }
104
126
}
105
127
106
128
private static string FormatSheetName ( string sheetName )
You can’t perform that action at this time.
0 commit comments