Skip to content

Commit cb97ccb

Browse files
committed
Fixes for project up-to-date check. Fixes #184 and #189.
Added support for identifying an expanded set of special files as inputs that were not captures before (e.g. App.config files) Added support for properly identifying synthetic grouped reference nodes (and COM reference nodes) as inputs (e.g. those used to reference full portable .NET subset) (changeset 1381885)
1 parent 4f94347 commit cb97ccb

File tree

4 files changed

+40
-5
lines changed

4 files changed

+40
-5
lines changed

vsintegration/src/unittests/Tests.ProjectSystem.UpToDate.fs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type UpToDate() =
3333
<Content Include=""content.txt"" />
3434
<Resource Include=""resource.txt"" />
3535
<EmbeddedResource Include=""embedresource.txt"" />
36+
<None Include=""App.config"" />
3637
<None Include=""none.txt"" />
3738
</ItemGroup>
3839
", (fun project ->
@@ -44,6 +45,7 @@ type UpToDate() =
4445
let sourcePath = Path.Combine(project.ProjectFolder, "file1.fs")
4546
let contentPath = Path.Combine(project.ProjectFolder, "content.txt")
4647
let resourcePath = Path.Combine(project.ProjectFolder, "resource.txt")
48+
let configPath = Path.Combine(project.ProjectFolder, "App.config")
4749
let nonePath = Path.Combine(project.ProjectFolder, "none.txt")
4850
let embedPath = Path.Combine(project.ProjectFolder, "embedresource.txt")
4951

@@ -52,18 +54,19 @@ type UpToDate() =
5254
File.AppendAllText(sourcePath, "printfn \"hello\"")
5355
File.AppendAllText(contentPath, "some content")
5456
File.AppendAllText(resourcePath, "some resource")
57+
File.AppendAllText(configPath, """<?xml version="1.0" encoding="utf-8" ?><configuration></configuration>""")
5558
File.AppendAllText(nonePath, "none")
5659
File.AppendAllText(embedPath, "some embedded resource")
5760

5861
Assert.IsFalse(config.IsUpToDate(logger, true))
5962
project.Build(configNameDebug, output, "Build") |> ignore
6063
Assert.IsTrue(config.IsUpToDate(logger, true))
6164

62-
// None items should not affect up-to-date
65+
// None items should not affect up-to-date (unless captured by well-known items, e.g. App.config)
6366
File.SetLastWriteTime(nonePath, DateTime.Now.AddMinutes(5.))
6467
Assert.IsTrue(config.IsUpToDate(logger, true))
6568

66-
for path in [sourcePath; contentPath; resourcePath; embedPath] do
69+
for path in [sourcePath; contentPath; resourcePath; embedPath; configPath] do
6770
printfn "Testing path %s" path
6871

6972
// touch file

vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/GroupingReferenceNode.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,16 @@ public class GroupingReferenceNode : ReferenceNode
3535
public string Identity { get; private set; }
3636
public string ResolutionPath { get; private set; }
3737
public string Version { get; private set; }
38+
public string[] GroupedItems { get; private set; }
3839

39-
public GroupingReferenceNode(ProjectNode project, string name, string identity, string resolutionPath, string version)
40+
public GroupingReferenceNode(ProjectNode project, string name, string identity, string resolutionPath, string version, string[] groupedItems)
4041
: base(project)
4142
{
4243
Name = name;
4344
Identity = identity;
4445
ResolutionPath = resolutionPath;
4546
Version = version;
47+
GroupedItems = groupedItems;
4648
}
4749

4850
public override string Caption

vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ProjectConfig.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,16 +1484,44 @@ internal bool GetUTDCheckInputs(ref HashSet<string> inputs)
14841484
inputs.Add(Utilities.CanonicalizeFileNameNoThrow(Path.Combine(projDir, propVal)));
14851485
}
14861486

1487+
// other well-known special files that were otherwise missed
1488+
var specialFiles = this.project.InteropSafeIVsHierarchy as IVsProjectSpecialFiles;
1489+
if (specialFiles == null)
1490+
return false;
1491+
1492+
for (int fileId = (int)__PSFFILEID5.PSFFILEID_FIRST5; fileId <= (int)__PSFFILEID.PSFFILEID_LAST; fileId++)
1493+
{
1494+
uint itemId;
1495+
string fileName;
1496+
if (ErrorHandler.Succeeded(specialFiles.GetFile(fileId, (uint)__PSFFLAGS.PSFF_FullPath, out itemId, out fileName))
1497+
&& itemId != (uint)VSConstants.VSITEMID.Nil)
1498+
{
1499+
inputs.Add(Utilities.CanonicalizeFileNameNoThrow(fileName));
1500+
}
1501+
}
1502+
14871503
// assembly and project references
1488-
foreach (var reference in this.project .GetReferenceContainer().EnumReferences())
1504+
foreach (var reference in this.project.GetReferenceContainer().EnumReferences())
14891505
{
14901506
if (reference is AssemblyReferenceNode)
14911507
inputs.Add(Utilities.CanonicalizeFileNameNoThrow(reference.Url));
14921508
else if (reference is ProjectReferenceNode)
14931509
inputs.Add(Utilities.CanonicalizeFileNameNoThrow((reference as ProjectReferenceNode).ReferencedProjectOutputPath));
1510+
else if (reference is ComReferenceNode)
1511+
inputs.Add(Utilities.CanonicalizeFileNameNoThrow((reference as ComReferenceNode).InstalledFilePath));
1512+
else if (reference is GroupingReferenceNode)
1513+
{
1514+
foreach (var groupedRef in ((GroupingReferenceNode)reference).GroupedItems)
1515+
{
1516+
inputs.Add(Utilities.CanonicalizeFileNameNoThrow(groupedRef));
1517+
}
1518+
}
14941519
else
1520+
{
14951521
// some reference type we don't know about
1522+
System.Diagnostics.Debug.Assert(false, "Unexpected reference type", "{0}", reference);
14961523
return false;
1524+
}
14971525
}
14981526

14991527
return true;

vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ReferenceContainerNode.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ public void LoadReferencesFromBuildProject(Microsoft.Build.Evaluation.Project bu
372372
}
373373
// pick property values from the first item - they should be the same for all elements in the grouping
374374
var first = grouping.First();
375+
var groupedFiles = grouping.Select(x => x.file).ToArray();
376+
375377
var versonText = string.Format(
376378
"{0}.{1}.{2}.{3}",
377379
version.Major,
@@ -380,7 +382,7 @@ public void LoadReferencesFromBuildProject(Microsoft.Build.Evaluation.Project bu
380382
version.Revision != -1 ? version.Revision : 0
381383
);
382384

383-
var node = new GroupingReferenceNode(ProjectMgr, first.referenceGroupingDisplayName, first.referenceGrouping, Path.GetDirectoryName(first.file), versonText);
385+
var node = new GroupingReferenceNode(ProjectMgr, first.referenceGroupingDisplayName, first.referenceGrouping, Path.GetDirectoryName(first.file), versonText, groupedFiles);
384386
AddChild(node);
385387
}
386388
}

0 commit comments

Comments
 (0)