Skip to content

Commit

Permalink
Fixes for project up-to-date check. Fixes fsharp#184 and fsharp#189.
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
latkin committed Dec 5, 2014
1 parent 4f94347 commit cb97ccb
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
7 changes: 5 additions & 2 deletions vsintegration/src/unittests/Tests.ProjectSystem.UpToDate.fs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type UpToDate() =
<Content Include=""content.txt"" />
<Resource Include=""resource.txt"" />
<EmbeddedResource Include=""embedresource.txt"" />
<None Include=""App.config"" />
<None Include=""none.txt"" />
</ItemGroup>
", (fun project ->
Expand All @@ -44,6 +45,7 @@ type UpToDate() =
let sourcePath = Path.Combine(project.ProjectFolder, "file1.fs")
let contentPath = Path.Combine(project.ProjectFolder, "content.txt")
let resourcePath = Path.Combine(project.ProjectFolder, "resource.txt")
let configPath = Path.Combine(project.ProjectFolder, "App.config")
let nonePath = Path.Combine(project.ProjectFolder, "none.txt")
let embedPath = Path.Combine(project.ProjectFolder, "embedresource.txt")

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

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

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

for path in [sourcePath; contentPath; resourcePath; embedPath] do
for path in [sourcePath; contentPath; resourcePath; embedPath; configPath] do
printfn "Testing path %s" path

// touch file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@ public class GroupingReferenceNode : ReferenceNode
public string Identity { get; private set; }
public string ResolutionPath { get; private set; }
public string Version { get; private set; }
public string[] GroupedItems { get; private set; }

public GroupingReferenceNode(ProjectNode project, string name, string identity, string resolutionPath, string version)
public GroupingReferenceNode(ProjectNode project, string name, string identity, string resolutionPath, string version, string[] groupedItems)
: base(project)
{
Name = name;
Identity = identity;
ResolutionPath = resolutionPath;
Version = version;
GroupedItems = groupedItems;
}

public override string Caption
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1484,16 +1484,44 @@ internal bool GetUTDCheckInputs(ref HashSet<string> inputs)
inputs.Add(Utilities.CanonicalizeFileNameNoThrow(Path.Combine(projDir, propVal)));
}

// other well-known special files that were otherwise missed
var specialFiles = this.project.InteropSafeIVsHierarchy as IVsProjectSpecialFiles;
if (specialFiles == null)
return false;

for (int fileId = (int)__PSFFILEID5.PSFFILEID_FIRST5; fileId <= (int)__PSFFILEID.PSFFILEID_LAST; fileId++)
{
uint itemId;
string fileName;
if (ErrorHandler.Succeeded(specialFiles.GetFile(fileId, (uint)__PSFFLAGS.PSFF_FullPath, out itemId, out fileName))
&& itemId != (uint)VSConstants.VSITEMID.Nil)
{
inputs.Add(Utilities.CanonicalizeFileNameNoThrow(fileName));
}
}

// assembly and project references
foreach (var reference in this.project .GetReferenceContainer().EnumReferences())
foreach (var reference in this.project.GetReferenceContainer().EnumReferences())
{
if (reference is AssemblyReferenceNode)
inputs.Add(Utilities.CanonicalizeFileNameNoThrow(reference.Url));
else if (reference is ProjectReferenceNode)
inputs.Add(Utilities.CanonicalizeFileNameNoThrow((reference as ProjectReferenceNode).ReferencedProjectOutputPath));
else if (reference is ComReferenceNode)
inputs.Add(Utilities.CanonicalizeFileNameNoThrow((reference as ComReferenceNode).InstalledFilePath));
else if (reference is GroupingReferenceNode)
{
foreach (var groupedRef in ((GroupingReferenceNode)reference).GroupedItems)
{
inputs.Add(Utilities.CanonicalizeFileNameNoThrow(groupedRef));
}
}
else
{
// some reference type we don't know about
System.Diagnostics.Debug.Assert(false, "Unexpected reference type", "{0}", reference);
return false;
}
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ public void LoadReferencesFromBuildProject(Microsoft.Build.Evaluation.Project bu
}
// pick property values from the first item - they should be the same for all elements in the grouping
var first = grouping.First();
var groupedFiles = grouping.Select(x => x.file).ToArray();

var versonText = string.Format(
"{0}.{1}.{2}.{3}",
version.Major,
Expand All @@ -380,7 +382,7 @@ public void LoadReferencesFromBuildProject(Microsoft.Build.Evaluation.Project bu
version.Revision != -1 ? version.Revision : 0
);

var node = new GroupingReferenceNode(ProjectMgr, first.referenceGroupingDisplayName, first.referenceGrouping, Path.GetDirectoryName(first.file), versonText);
var node = new GroupingReferenceNode(ProjectMgr, first.referenceGroupingDisplayName, first.referenceGrouping, Path.GetDirectoryName(first.file), versonText, groupedFiles);
AddChild(node);
}
}
Expand Down

0 comments on commit cb97ccb

Please sign in to comment.