Skip to content

Commit 0ab7aba

Browse files
committed
fixed ProjectName extension method for locked projects
1 parent f3dad99 commit 0ab7aba

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

Rubberduck.VBEEditor/Extensions/VbProjectExtensions.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,21 @@ public static class ProjectExtensions
1010
public static string ProjectName(this VBProject project)
1111
{
1212
var projectName = project.Name;
13-
var documentModule = project
14-
.VBComponents.Cast<VBComponent>()
15-
.FirstOrDefault(item => item.Type == vbext_ComponentType.vbext_ct_Document);
16-
17-
if (documentModule != null)
13+
if (project.Protection == vbext_ProjectProtection.vbext_pp_none)
1814
{
19-
var hostDocumentNameProperty = documentModule.Properties.Item("Name");
20-
if (hostDocumentNameProperty != null)
15+
var documentModule = project
16+
.VBComponents.Cast<VBComponent>()
17+
.FirstOrDefault(item => item.Type == vbext_ComponentType.vbext_ct_Document);
18+
19+
if (documentModule != null)
2120
{
22-
projectName += string.Format(" ({0})", hostDocumentNameProperty.Value);
21+
var hostDocumentNameProperty = documentModule.Properties.Item("Name");
22+
if (hostDocumentNameProperty != null)
23+
{
24+
projectName += string.Format(" ({0})", hostDocumentNameProperty.Value);
25+
}
2326
}
2427
}
25-
2628
return projectName;
2729
}
2830

0 commit comments

Comments
 (0)