@@ -11,21 +11,21 @@ namespace Rubberduck.UI.Command.MenuItems.CommandBars
11
11
{
12
12
public class SerializeProjectsCommandMenuItem : CommandMenuItemBase
13
13
{
14
- public SerializeProjectsCommandMenuItem ( SerializeDeclarationsCommand command ) : base ( command )
14
+ public SerializeProjectsCommandMenuItem ( SerializeProjectsCommand command ) : base ( command )
15
15
{
16
16
}
17
17
18
18
public override Func < string > Caption { get { return ( ) => "Serialize" ; } }
19
19
public override string Key => "SerializeProjects" ;
20
20
}
21
21
22
- public class SerializeDeclarationsCommand : CommandBase
22
+ public class SerializeProjectsCommand : CommandBase
23
23
{
24
24
private readonly RubberduckParserState _state ;
25
25
private readonly IComProjectSerializationProvider _serializationProvider ;
26
26
private readonly IComLibraryProvider _comLibraryProvider ;
27
27
28
- public SerializeDeclarationsCommand ( RubberduckParserState state , IComProjectSerializationProvider serializationProvider , IComLibraryProvider comLibraryProvider )
28
+ public SerializeProjectsCommand ( RubberduckParserState state , IComProjectSerializationProvider serializationProvider , IComLibraryProvider comLibraryProvider )
29
29
: base ( LogManager . GetCurrentClassLogger ( ) )
30
30
{
31
31
_state = state ;
@@ -49,19 +49,24 @@ protected override void OnExecute(object parameter)
49
49
50
50
foreach ( var project in _state . ProjectsProvider . Projects ( ) . Select ( proj => proj . Project ) )
51
51
{
52
- foreach ( var reference in project . References . Select ( lib => new ReferenceInfo ( lib ) ) )
52
+ using ( var references = project . References )
53
53
{
54
- var library = _comLibraryProvider . LoadTypeLibrary ( reference . FullPath ) ;
55
- if ( library == null )
54
+ foreach ( var reference in references )
56
55
{
57
- Logger . Warn ( $ "Could not load library { reference . FullPath } for serialization.") ;
58
- continue ;
59
- }
56
+ var info = new ReferenceInfo ( reference ) ;
57
+ reference . Dispose ( ) ;
58
+ var library = _comLibraryProvider . LoadTypeLibrary ( info . FullPath ) ;
59
+ if ( library == null )
60
+ {
61
+ Logger . Warn ( $ "Could not load library { info . FullPath } for serialization.") ;
62
+ continue ;
63
+ }
60
64
61
- var type = new ComProject ( library , reference . FullPath ) ;
62
- if ( ! toSerialize . ContainsKey ( type . Guid ) )
63
- {
64
- toSerialize . Add ( type . Guid , type ) ;
65
+ var type = new ComProject ( library , info . FullPath ) ;
66
+ if ( ! toSerialize . ContainsKey ( type . Guid ) )
67
+ {
68
+ toSerialize . Add ( type . Guid , type ) ;
69
+ }
65
70
}
66
71
}
67
72
}
0 commit comments