@@ -22,15 +22,18 @@ open System.Threading
2222open Microsoft.VisualStudio .Shell .Interop
2323open Microsoft.VisualStudio .LanguageServices .Implementation .TaskList
2424
25+ type private CpsStamp = DateTime
26+
2527[<AutoOpen>]
2628module private FSharpProjectOptionsHelpers =
2729
28- let mapCpsProjectToSite ( workspace : VisualStudioWorkspaceImpl , project : Project , serviceProvider : System.IServiceProvider , cpsCommandLineOptions : IDictionary < ProjectId , DateTime * string [] * string [] * string []>) =
30+ let mapCpsProjectToSite ( workspace : VisualStudioWorkspaceImpl , project : Project , serviceProvider : System.IServiceProvider , cpsCommandLineOptions : IDictionary < ProjectId , CpsStamp * string [] * string [] * string []>) =
2931let hier = workspace.GetHierarchy( project.Id)
30- let getCommandLineOptionsWithProjectId ( projectId ) =
31- match cpsCommandLineOptions.TryGetValue( projectId) with
32- | true , (_, sourcePaths, referencePaths, options) -> sourcePaths, referencePaths, options
33- | false , _ -> [||], [||], [||]
32+ let cpsStampOpt , sourcePaths , referencePaths , options =
33+ match cpsCommandLineOptions.TryGetValue( project.Id) with
34+ | true , ( cpsStamp, sourcePaths, referencePaths, options) -> Some( cpsStamp), sourcePaths, referencePaths, options
35+ | false , _ -> None, [||], [||], [||]
36+ cpsStampOpt,
3437{
3538new IProvideProjectSitewith
3639member x.GetProjectSite () =
@@ -43,11 +46,10 @@ module private FSharpProjectOptionsHelpers =
4346{
4447new IProjectSitewith
4548member __.Description = project.Name
46- member __.CompilationSourceFiles = getCommandLineOptionsWithProjectId ( project.Id ) |> fst
49+ member __.CompilationSourceFiles = sourcePaths
4750member __.CompilationOptions =
48- let _ , references , options = getCommandLineOptionsWithProjectId( project.Id)
49- Array.concat[ options; references|> Array.map( fun r -> " -r:" + r)]
50- member __.CompilationReferences = getCommandLineOptionsWithProjectId( project.Id) |> snd
51+ Array.concat[ options; referencePaths|> Array.map( fun r -> " -r:" + r)]
52+ member __.CompilationReferences = referencePaths
5153member site.CompilationBinOutputPath = site.CompilationOptions|> Array.tryPick( fun s -> if s.StartsWith( " -o:" ) then Some s.[ 3 ..] else None)
5254member __.ProjectFileName = project.FilePath
5355member __.AdviseProjectSiteChanges ( _ , _ ) = ()
@@ -94,7 +96,7 @@ type private FSharpProjectOptionsReactor (workspace: VisualStudioWorkspaceImpl,
9496// Hack to store command line options from HandleCommandLineChanges
9597let cpsCommandLineOptions = new ConcurrentDictionary< ProjectId, DateTime* string[] * string[] * string[]>()
9698
97- let cache = Dictionary< ProjectId, VersionStamp* FSharpParsingOptions* FSharpProjectOptions>()
99+ let cache = Dictionary< ProjectId, CpsStamp option * VersionStamp* FSharpParsingOptions* FSharpProjectOptions>()
98100
99101let rec tryComputeOptions ( project : Project ) =
100102let projectId = project.Id
@@ -131,14 +133,14 @@ type private FSharpProjectOptionsReactor (workspace: VisualStudioWorkspaceImpl,
131133else
132134
133135let hier = workspace.GetHierarchy( projectId)
134- let projectSite =
136+ let cpsStampOpt , projectSite =
135137match hierwith
136138// Legacy
137- | (:? IProvideProjectSiteas provideSite) -> provideSite.GetProjectSite()
139+ | (:? IProvideProjectSiteas provideSite) -> None , provideSite.GetProjectSite()
138140// Cps
139141| _ ->
140- let provideSite = mapCpsProjectToSite( workspace, project, serviceProvider, cpsCommandLineOptions)
141- provideSite.GetProjectSite()
142+ let cpsStampOpt , provideSite = mapCpsProjectToSite( workspace, project, serviceProvider, cpsCommandLineOptions)
143+ cpsStampOpt , provideSite.GetProjectSite()
142144
143145let projectOptions =
144146{
@@ -164,12 +166,16 @@ type private FSharpProjectOptionsReactor (workspace: VisualStudioWorkspaceImpl,
164166
165167let parsingOptions , _ = checkerProvider.Checker.GetParsingOptionsFromProjectOptions( projectOptions)
166168
167- cache.[ projectId] <- ( projectStamp, parsingOptions, projectOptions)
169+ cache.[ projectId] <- ( cpsStampOpt , projectStamp, parsingOptions, projectOptions)
168170
169171 Some( parsingOptions, projectOptions)
170172
171- | true , ( projectStamp2, parsingOptions, projectOptions) ->
172- if projectStamp<> projectStamp2then
173+ | true , ( cpsStampOpt, projectStamp2, parsingOptions, projectOptions) ->
174+ let cpsStampOpt2 =
175+ match cpsCommandLineOptions.TryGetValue( projectId) with
176+ | true , ( cpsStampOpt2, _, _, _) -> Some( cpsStampOpt2)
177+ | _ -> None
178+ if projectStamp<> projectStamp2|| cpsStampOpt<> cpsStampOpt2then
173179 cache.Remove( projectId) |> ignore
174180 tryComputeOptions project
175181else
@@ -280,7 +286,7 @@ type internal FSharpProjectOptionsManager
280286member this.GetCompilationDefinesForEditingDocument ( document : Document ) =
281287let parsingOptions =
282288match reactor.TryGetCachedOptionsByProjectId( document.Project.Id) with
283- | Some(_, parsingOptions, _) -> parsingOptions
289+ | Some(_, _, parsingOptions, _) -> parsingOptions
284290| _ -> { FSharpParsingOptions.Defaultwith IsInteractive= IsScript document.Name}
285291 CompilerEnvironment.GetCompilationDefinesForEditing parsingOptions
286292