Skip to content

Commit 739bd97

Browse files
committed
Made ProjectDeclaration disposable with disposal barring access to the COM wrapper.
1 parent dc17662 commit 739bd97

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Rubberduck.Parsing/Symbols/ProjectDeclaration.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
using Rubberduck.Parsing.ComReflection;
1+
using System;
2+
using Rubberduck.Parsing.ComReflection;
23
using Rubberduck.VBEditor;
34
using System.Collections.Generic;
45
using System.Linq;
56
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
67

78
namespace Rubberduck.Parsing.Symbols
89
{
9-
public sealed class ProjectDeclaration : Declaration
10+
public sealed class ProjectDeclaration : Declaration, IDisposable
1011
{
1112
private readonly List<ProjectReference> _projectReferences;
1213

@@ -60,7 +61,7 @@ public IReadOnlyList<ProjectReference> ProjectReferences
6061
/// <remarks>
6162
/// This property is intended to differenciate identically-named VBProjects.
6263
/// </remarks>
63-
public override IVBProject Project => _project;
64+
public override IVBProject Project => IsDisposed ? null : _project;
6465

6566
public void AddProjectReference(string referencedProjectId, int priority)
6667
{
@@ -89,9 +90,17 @@ public override string ProjectDisplayName
8990
{
9091
return _displayName;
9192
}
92-
_displayName = _project != null ? _project.ProjectDisplayName : string.Empty;
93+
_displayName = !IsDisposed && _project != null ? _project.ProjectDisplayName : string.Empty;
9394
return _displayName;
9495
}
9596
}
97+
98+
99+
public bool IsDisposed { get; private set; }
100+
101+
public void Dispose()
102+
{
103+
IsDisposed = true;
104+
}
96105
}
97106
}

0 commit comments

Comments
 (0)