@@ -1629,16 +1629,30 @@ type ScriptTests() as this =
16291629let totalDisposalsMeth = providerCounters.GetMethod( " GetTotalDisposals" )
16301630 Assert.IsNotNull( totalDisposalsMeth, " totalDisposalsMeth should not be null" )
16311631
1632+ let providerCounters2 = providerAssembly.GetType( " Microsoft.FSharp.TypeProvider.Emit.GlobalCountersForInvalidation" )
1633+ Assert.IsNotNull( providerCounters2, " provider counters #2 module should not be null" )
1634+ let totalInvaldiationHandlersAddedMeth = providerCounters2.GetMethod( " GetInvalidationHandlersAdded" )
1635+ Assert.IsNotNull( totalInvaldiationHandlersAddedMeth, " totalInvaldiationHandlersAddedMeth should not be null" )
1636+ let totalInvaldiationHandlersRemovedMeth = providerCounters2.GetMethod( " GetInvalidationHandlersRemoved" )
1637+ Assert.IsNotNull( totalInvaldiationHandlersRemovedMeth, " totalInvaldiationHandlersRemovedMeth should not be null" )
1638+
16321639let totalCreations () = totalCreationsMeth.Invoke( null , [| |]) :?> int
16331640let totalDisposals () = totalDisposalsMeth.Invoke( null , [| |]) :?> int
1641+ let totalInvaldiationHandlersAdded () = totalInvaldiationHandlersAddedMeth.Invoke( null , [| |]) :?> int
1642+ let totalInvaldiationHandlersRemoved () = totalInvaldiationHandlersRemovedMeth.Invoke( null , [| |]) :?> int
16341643
16351644
16361645let startCreations = totalCreations()
16371646let startDisposals = totalDisposals()
1647+ let startInvaldiationHandlersAdded = totalInvaldiationHandlersAdded()
1648+ let startInvaldiationHandlersRemoved = totalInvaldiationHandlersRemoved()
16381649let countCreations () = totalCreations() - startCreations
16391650let countDisposals () = totalDisposals() - startDisposals
1651+ let countInvaldiationHandlersAdded () = totalInvaldiationHandlersAdded() - startInvaldiationHandlersAdded
1652+ let countInvaldiationHandlersRemoved () = totalInvaldiationHandlersRemoved() - startInvaldiationHandlersRemoved
16401653
16411654 Assert.IsTrue( startCreations>= startDisposals, " Check0" )
1655+ Assert.IsTrue( startInvaldiationHandlersAdded>= startInvaldiationHandlersRemoved, " Check0" )
16421656for iin 1 .. 50 do
16431657let solution = this.CreateSolution()
16441658let project = CreateProject( solution, " testproject" + string( i% 20 ))
@@ -1662,20 +1676,25 @@ type ScriptTests() as this =
16621676 Assert.IsTrue( countDisposals() < i, " Check1, countDisposals() < i, iteration" + string i)
16631677 Assert.IsTrue( countCreations() >= countDisposals(), " Check2, countCreations() >= countDisposals(), iteration" + string i)
16641678 Assert.IsTrue( countCreations() = i, " Check3, countCreations() = i, iteration" + string i)
1679+ Assert.IsTrue( countInvaldiationHandlersAdded() = i, " Check3b, countInvaldiationHandlersAdded() = i, iteration" + string i)
16651680if not clearingthen
16661681// By default we hold 3 build incrementalBuilderCache entries and 5 typeCheckInfo entries, so if we're not clearing
16671682// there should be some roots to project builds still present
16681683if i>= 3 then
16691684 Assert.IsTrue( i>= countDisposals() + 3 , " Check4a, i >= countDisposals() + 3, iteration" + string i+ " , i =" + string i+ " , countDisposals() =" + string( countDisposals()))
1685+ Assert.IsTrue( i>= countInvaldiationHandlersRemoved() + 3 , " Check4a2, i >= countInvaldiationHandlersRemoved() + 3, iteration" + string i+ " , i =" + string i+ " , countDisposals() =" + string( countDisposals()))
16701686
16711687// If we forcefully clear out caches and force a collection, then we can say much stronger things...
16721688if clearingthen
16731689 ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients( this.VS)
16741690 Assert.IsTrue(( i= countDisposals()), " Check4b, countCreations() = countDisposals(), iteration" + string i)
1691+ Assert.IsTrue(( i= countInvaldiationHandlersRemoved()), " Check4b2, countCreations() = countInvaldiationHandlersRemoved(), iteration" + string i)
16751692
16761693 Assert.IsTrue( countCreations() = 50 , " Check5, at end, countCreations() = 50" )
1694+ Assert.IsTrue( countInvaldiationHandlersAdded() = 50 , " Check5, at end, countCreations() = 50" )
16771695 ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients( this.VS)
1678- Assert.IsTrue( countDisposals() = 50 , " Check6b, at end, countDisposals() = 50 when clearing" )
1696+ Assert.IsTrue( countDisposals() = 50 , " Check6b, at end, countDisposals() = 50 after explicit clearing" )
1697+ Assert.IsTrue( countInvaldiationHandlersRemoved() = 50 , " Check5, at end, countInvaldiationHandlersRemoved() = 50 after explicit cleraring" )
16791698
16801699[<Test>]
16811700[<Category( " TypeProvider" ) >]