Skip to content

Commit feda849

Browse files
committed
Fix over population of DependencyFiles, add test
1 parent 3d09b43 commit feda849

File tree

2 files changed

+51
-44
lines changed

2 files changed

+51
-44
lines changed

src/fsharp/vs/IncrementalBuild.fs

Lines changed: 21 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -675,42 +675,20 @@ module internal IncrementalBuild =
675675
| VectorBuildRule ve -> visitVector optSlot ve acc
676676

677677
/// Compute the max timestamp on all available inputs
678-
let ComputeMaxTimeStamp (Target(output, optSlot)) bt acc =
679-
let rec VisitVector optSlot (ve: VectorBuildRule) acc =
680-
match ve with
681-
| VectorInput _ ->acc
682-
| VectorScanLeft(_id,_taskname,accumulatorExpr,inputExpr,_func) ->
683-
// Check each slot for an action that may be performed.
684-
VisitVector None inputExpr (VisitScalar accumulatorExpr acc)
685-
686-
| VectorMap(_id, _taskname, inputExpr, _func) ->
687-
VisitVector optSlot inputExpr acc
688-
689-
| VectorStamp(_id, _taskname, inputExpr, func) ->
690-
let acc =
691-
match GetVectorWidthByExpr(bt,ve) with
692-
| Some(cardinality) ->
693-
let CheckStamp acc slot =
694-
match GetVectorExprResult(bt,inputExpr,slot) with
695-
| Available(ires,_,_) -> max acc (func ires)
696-
| _ -> acc
697-
[0..cardinality-1] |> List.fold CheckStamp acc
698-
| None -> acc
699-
VisitVector optSlot inputExpr acc
700-
701-
| VectorMultiplex(_id, _taskname, inputExpr, _func) ->
702-
VisitScalar inputExpr acc
703-
704-
and VisitScalar (se:ScalarBuildRule) acc =
705-
match se with
706-
| ScalarInput _ ->acc
707-
| ScalarDemultiplex(_id,_taskname,inputExpr,_func) -> VisitVector None inputExpr acc
708-
| ScalarMap(_id,_taskname,inputExpr,_func) -> VisitScalar inputExpr acc
709-
678+
let ComputeMaxTimeStamp output (bt: PartialBuild) acc =
710679
let expr = bt.Rules.RuleList |> List.find (fun (s,_) -> s = output) |> snd
711-
match expr with
712-
| ScalarBuildRule se -> VisitScalar se acc
713-
| VectorBuildRule ve -> VisitVector optSlot ve acc
680+
match expr with
681+
| VectorBuildRule (VectorStamp(_id, _taskname, inputExpr, func) as ve) ->
682+
match GetVectorWidthByExpr(bt,ve) with
683+
| Some(cardinality) ->
684+
let CheckStamp acc slot =
685+
match GetVectorExprResult(bt,inputExpr,slot) with
686+
| Available(ires,_,_) -> max acc (func ires)
687+
| _ -> acc
688+
[0..cardinality-1] |> List.fold CheckStamp acc
689+
| None -> acc
690+
691+
| _ -> failwith "expected a VectorStamp"
714692

715693

716694
/// Given the result of a single action, apply that action to the Build
@@ -794,7 +772,6 @@ module internal IncrementalBuild =
794772
let MaxTimeStampInDependencies target bt =
795773
ComputeMaxTimeStamp target bt DateTime.MinValue
796774

797-
798775
/// Get a scalar vector. Result must be available
799776
let GetScalarResult<'T>(node:Scalar<'T>,bt): ('T*DateTime) option =
800777
match GetTopLevelExprByName(bt,node.Name) with
@@ -905,10 +882,8 @@ module internal IncrementalBuild =
905882
/// Creates a new vector with the same items but with
906883
/// timestamp specified by the passed-in function.
907884
let Stamp (taskname:string) (task:'I -> DateTime) (input:Vector<'I>): Vector<'I> =
908-
let BoxingTouch i =
909-
task(unbox i)
910885
let input = input.Expr
911-
let expr = VectorStamp(NextId(),taskname,input,BoxingTouch)
886+
let expr = VectorStamp(NextId(),taskname,input,unbox >> task)
912887
{ new Vector<'I>
913888
interface IVector with
914889
override __.Name = taskname
@@ -1550,10 +1525,10 @@ type IncrementalBuilder(frameworkTcImportsCache: FrameworkImportsCache, tcConfig
15501525
let file = if FileSystem.IsPathRootedShim(referenceText) then referenceText else Path.Combine(projectDirectory,referenceText)
15511526
yield file
15521527

1553-
for r in nonFrameworkResolutions do
1528+
for r in nonFrameworkResolutions do
15541529
yield r.resolvedPath
15551530

1556-
for (_,f,_) in sourceFiles do
1531+
for (_,f,_) in sourceFiles do
15571532
yield f ]
15581533

15591534
let buildInputs = [ VectorInput (fileNamesNode, sourceFiles)
@@ -1567,8 +1542,8 @@ type IncrementalBuilder(frameworkTcImportsCache: FrameworkImportsCache, tcConfig
15671542
partialBuild <- newPartialBuild
15681543
newPartialBuild
15691544

1570-
let MaxTimeStampInDependencies (output:INode) optSlot =
1571-
IncrementalBuild.MaxTimeStampInDependencies (Target(output.Name, optSlot)) partialBuild
1545+
let MaxTimeStampInDependencies (output:INode) =
1546+
IncrementalBuild.MaxTimeStampInDependencies output.Name partialBuild
15721547

15731548
member this.IncrementUsageCount() =
15741549
assertNotDisposed()
@@ -1664,7 +1639,9 @@ type IncrementalBuilder(frameworkTcImportsCache: FrameworkImportsCache, tcConfig
16641639
| None -> failwith "Build was not evaluated, expcted the results to be ready after 'Eval'."
16651640

16661641
member __.GetLogicalTimeStampForProject() =
1667-
MaxTimeStampInDependencies finalizedTypeCheckNode None
1642+
let t1 = MaxTimeStampInDependencies stampedFileNamesNode
1643+
let t2 = MaxTimeStampInDependencies stampedReferencedAssembliesNode
1644+
max t1 t2
16681645

16691646
member __.GetSlotOfFileName(filename:string) =
16701647
// Get the slot of the given file and force it to build.

tests/service/ProjectAnalysisTests.fs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4336,6 +4336,9 @@ let ``Test project34 should report correct accessibility for System.Data.Listene
43364336

43374337
listenerFuncEntity.Accessibility.IsPrivate |> shouldEqual true
43384338

4339+
4340+
//------------------------------------------------------
4341+
43394342
module Project35 =
43404343
open System.IO
43414344

@@ -4412,6 +4415,33 @@ let ``Test project35 CurriedParameterGroups should be available for nested funct
44124415

44134416
| _ -> failwith "Unexpected symbol type"
44144417

4418+
//------------------------------------------------------
4419+
4420+
module Project35b =
4421+
open System.IO
4422+
4423+
let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fsx")
4424+
let fileSource1 = """
4425+
#r "System.dll"
4426+
#r "notexist.dll"
4427+
"""
4428+
File.WriteAllText(fileName1, fileSource1)
4429+
let cleanFileName a = if a = fileName1 then "file1" else "??"
4430+
4431+
let fileNames = [fileName1]
4432+
let options = checker.GetProjectOptionsFromScript(fileName1, fileSource1) |> Async.RunSynchronously
4433+
4434+
4435+
[<Test>]
4436+
let ``Test project35b Dependency files`` () =
4437+
let parseFileResults = checker.ParseFileInProject(Project35b.fileName1, Project35b.fileSource1, Project35b.options) |> Async.RunSynchronously
4438+
parseFileResults.DependencyFiles.Length |> shouldEqual 3
4439+
parseFileResults.DependencyFiles |> List.exists (fun s -> s.Contains "notexist.dll") |> shouldEqual true
4440+
parseFileResults.DependencyFiles |> List.exists (fun s -> s.Contains Project35b.fileName1) |> shouldEqual true
4441+
parseFileResults.DependencyFiles |> List.exists (fun s -> s.Contains "FSharp.Compiler.Interactive.Settings.dll") |> shouldEqual true
4442+
4443+
//------------------------------------------------------
4444+
44154445
module Project36 =
44164446
open System.IO
44174447

0 commit comments

Comments
 (0)