Skip to content

Commit 9982b70

Browse files
committed
Add (if needed) additionalIncludeDirectories instead of overriding them
1 parent 6138d97 commit 9982b70

6 files changed

+31
-47
lines changed

GenerateFilter/GenerateFilter.cs

+16-16
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ private GenerateFilter(Package package)
5858
if (commandService != null)
5959
{
6060
var menuCommandID = new CommandID(CommandSet, CommandId);
61-
//var menuItem = new MenuCommand(this.MenuItemCallback, menuCommandID);
6261
var menuItem = new OleMenuCommand(this.MenuItemCallback, menuCommandID);
6362
menuItem.BeforeQueryStatus += OnBeforeQueryStatus;
6463

@@ -145,19 +144,12 @@ static private void SetAdditionalIncludeDirectories(Project project, Dictionary<
145144
{
146145
if (!filesPerItemType.ContainsKey("ClInclude"))
147146
return;
148-
149-
var stringBuilder = new StringBuilder();
150-
var hashSet = new HashSet<string>();
147+
148+
var includePaths = new HashSet<string> { @"$(StlIncludeDirectories)" };
151149
foreach (var file in filesPerItemType["ClInclude"])
152150
{
153-
var directoryName = GetRelativePathIfNeeded(projectPath, Path.GetDirectoryName(file));
154-
if (!hashSet.Contains(directoryName))
155-
{
156-
stringBuilder.Append(directoryName + ';');
157-
hashSet.Add(directoryName);
158-
}
151+
includePaths.Add(GetRelativePathIfNeeded(projectPath, Path.GetDirectoryName(file)));
159152
}
160-
stringBuilder.Append(@"$(StlIncludeDirectories);");
161153

162154
var vcProject = project.Object as VCProject;
163155
foreach (VCConfiguration vcConfiguration in vcProject.Configurations)
@@ -167,10 +159,19 @@ static private void SetAdditionalIncludeDirectories(Project project, Dictionary<
167159
var compilerTool = genericTool as VCCLCompilerTool;
168160
if (compilerTool != null)
169161
{
170-
var includeDirectories = stringBuilder.ToString();
171-
// Avoid updating AdditionalIncludeDirectories when applicable to avoid reloading the project
172-
if (includeDirectories != compilerTool.AdditionalIncludeDirectories)
173-
compilerTool.AdditionalIncludeDirectories = includeDirectories;
162+
if (compilerTool.AdditionalIncludeDirectories == null)
163+
compilerTool.AdditionalIncludeDirectories = string.Empty;
164+
165+
var sss = compilerTool.AdditionalIncludeDirectories;
166+
var currentAdditionalIncludeDirectories = new HashSet<string>(compilerTool.AdditionalIncludeDirectories.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
167+
var pathsToAdd = new StringBuilder();
168+
foreach (var includePath in includePaths)
169+
// Avoid updating AdditionalIncludeDirectories when applicable to avoid reloading the project
170+
if (!currentAdditionalIncludeDirectories.Contains(includePath))
171+
pathsToAdd.Append(includePath + ';');
172+
173+
if (pathsToAdd.Length > 0)
174+
compilerTool.AdditionalIncludeDirectories = pathsToAdd.ToString() + compilerTool.AdditionalIncludeDirectories;
174175
}
175176
}
176177
}
@@ -387,7 +388,6 @@ private void MenuItemCallback(object sender, EventArgs e)
387388
var projectFilename = project.FileName;
388389
var projectPath = Path.GetDirectoryName(projectFilename);
389390
SetAdditionalIncludeDirectories(project, filesPerItemType, projectPath);
390-
// Check if user is prompted? (what if he made his own change and want to discard them? i.e. can use project.Saved first)
391391
project.DTE.ExecuteCommand("Project.UnloadProject");
392392

393393
var xmlSettings = new XmlWriterSettings() { Indent = true };

GenerateFilter/GenerateFilter.csproj

+9-5
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,10 @@
6060
</ItemGroup>
6161
<ItemGroup>
6262
<None Include="Key.snk" />
63-
<Content Include="LICENSE">
64-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
63+
<None Include="packages.config" />
64+
<Content Include="Resources\LICENSE">
6565
<IncludeInVSIX>true</IncludeInVSIX>
6666
</Content>
67-
<None Include="packages.config" />
68-
<None Include="Resources\LICENSE" />
6967
<None Include="source.extension.vsixmanifest">
7068
<SubType>Designer</SubType>
7169
</None>
@@ -76,11 +74,16 @@
7674
<SubType>Designer</SubType>
7775
</VSCTCompile>
7876
<Content Include="index.html" />
79-
<Content Include="Resources\GenerateFilterPackage.ico" />
77+
<Content Include="Resources\GenerateFilterPackage.ico">
78+
<IncludeInVSIX>true</IncludeInVSIX>
79+
</Content>
8080
<Content Include="Resources\GenerateFilter.ico">
8181
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
8282
<IncludeInVSIX>true</IncludeInVSIX>
8383
</Content>
84+
<Content Include="Resources\PreviewImage.png">
85+
<IncludeInVSIX>true</IncludeInVSIX>
86+
</Content>
8487
<Content Include="stylesheet.css" />
8588
</ItemGroup>
8689
<ItemGroup>
@@ -194,6 +197,7 @@
194197
<EmbeddedResource Include="VSPackage.resx">
195198
<MergeWithCTO>true</MergeWithCTO>
196199
<ManifestResourceName>VSPackage</ManifestResourceName>
200+
<SubType>Designer</SubType>
197201
</EmbeddedResource>
198202
</ItemGroup>
199203
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

GenerateFilter/LICENSE

-21
This file was deleted.
Binary file not shown.
5.5 KB
Loading

GenerateFilter/source.extension.vsixmanifest

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
33
<Metadata>
4-
<Identity Id="VisualStudioCppExtensions.Company.5fdbeaec-89c7-4773-997c-f46757c67a2d" Version="1.0" Language="en-US" Publisher="Stephane Molina" />
4+
<Identity Id="VisualStudioCppExtensions.Company.5fdbeaec-89c7-4773-997c-f46757c67a2d" Version="1.1" Language="en-US" Publisher="Stephane Molina" />
55
<DisplayName>Generate C++ Filters</DisplayName>
6-
<Description xml:space="preserve">Simple Extension which provide the ability to generate C++ project filters to replicate the folder hierarchy of existing underlying sources / headers</Description>
7-
<License>LICENSE</License>
8-
<Icon>GenerateFilter.ico</Icon>
9-
<Tags>c++;folder;import</Tags>
6+
<Description xml:space="preserve">Simple Extension which provide the ability to generate C++ project filters to replicate the folder hierarchy of underlying sources</Description>
7+
<License>Resources\LICENSE</License>
8+
<Icon>Resources\GenerateFilter.ico</Icon>
9+
<PreviewImage>Resources\PreviewImage.png</PreviewImage>
10+
<Tags>c++;folder;import;filter</Tags>
1011
</Metadata>
1112
<Installation>
1213
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[14.0]" />

0 commit comments

Comments
 (0)