@@ -27,11 +27,11 @@ type private CpsStamp = DateTime
2727[<AutoOpen>]
2828module private FSharpProjectOptionsHelpers =
2929
30- let mapCpsProjectToSite ( workspace : VisualStudioWorkspaceImpl , project : Project , serviceProvider : System.IServiceProvider , cpsCommandLineOptions : IDictionary < ProjectId , CpsStamp * string [] * string [] * string [] >)=
30+ let mapCpsProjectToSite ( workspace : VisualStudioWorkspaceImpl , project : Project , serviceProvider : System.IServiceProvider , cpsCommandLineOptions : IDictionary < ProjectId , CpsStamp * string [] * string []>) =
3131let hier = workspace.GetHierarchy( project.Id)
3232let cpsStampOpt , sourcePaths , referencePaths , options =
3333match cpsCommandLineOptions.TryGetValue( project.Id) with
34- | true , ( cpsStamp, sourcePaths, referencePaths , options) -> Some( cpsStamp), sourcePaths, referencePaths , options
34+ | true , ( cpsStamp, sourcePaths, options) -> Some( cpsStamp), sourcePaths, [||] , options
3535| false , _ -> None, [||], [||], [||]
3636 cpsStampOpt,
3737{
@@ -94,7 +94,7 @@ type private FSharpProjectOptionsReactor (workspace: VisualStudioWorkspaceImpl,
9494let cancellationTokenSource = new CancellationTokenSource()
9595
9696// Hack to store command line options from HandleCommandLineChanges
97- let cpsCommandLineOptions = new ConcurrentDictionary< ProjectId, DateTime* string[] * string[] * string [] >()
97+ let cpsCommandLineOptions = new ConcurrentDictionary< ProjectId, DateTime* string[] * string[]>()
9898
9999let cache = Dictionary< ProjectId, CpsStamp option* VersionStamp* FSharpParsingOptions* FSharpProjectOptions>()
100100
@@ -142,20 +142,36 @@ type private FSharpProjectOptionsReactor (workspace: VisualStudioWorkspaceImpl,
142142let cpsStampOpt , provideSite = mapCpsProjectToSite( workspace, project, serviceProvider, cpsCommandLineOptions)
143143 cpsStampOpt, provideSite.GetProjectSite()
144144
145+ let otherOptions =
146+ project.ProjectReferences
147+ |> Seq.map( fun x -> " -r:" + project.Solution.GetProject( x.ProjectId) .OutputFilePath)
148+ |> Array.ofSeq
149+ |> Array.append(
150+ project.MetadataReferences.OfType< VisualStudioMetadataReference.Snapshot>()
151+ |> Seq.map( fun x -> " -r:" + x.FilePath)
152+ |> Array.ofSeq
153+ |> Array.append(
154+ // Clear any references from CompilationOptions.
155+ // We get the references from Project.ProjectReferences/Project.MetadataReferences.
156+ projectSite.CompilationOptions
157+ |> Array.filter( fun x -> not ( x.Contains( " -r:" )))
158+ )
159+ )
160+
145161let projectOptions =
146162{
147163 ProjectFileName= projectSite.ProjectFileName
148- ProjectId= None
164+ ProjectId= Some ( projectId.ToFSharpProjectIdString ())
149165 SourceFiles= projectSite.CompilationSourceFiles
150- OtherOptions= projectSite.CompilationOptions
166+ OtherOptions= otherOptions
151167 ReferencedProjects= referencedProjects
152168 IsIncompleteTypeCheckEnvironment= projectSite.IsIncompleteTypeCheckEnvironment
153169 UseScriptResolutionRules= SourceFile.MustBeSingleFileProject( Path.GetFileName( project.FilePath))
154170 LoadTime= projectSite.LoadTime
155171 UnresolvedReferences= None
156172 OriginalLoadReferences= []
157173 ExtraProjectInfo= None
158- Stamp= Some( int64<| projectStamp.GetHashCode())
174+ Stamp= Some( int64( projectStamp.GetHashCode() ))
159175}
160176
161177// This can happen if we didn't receive the callback from HandleCommandLineChanges yet.
@@ -173,7 +189,7 @@ type private FSharpProjectOptionsReactor (workspace: VisualStudioWorkspaceImpl,
173189| true , ( cpsStampOpt, projectStamp2, parsingOptions, projectOptions) ->
174190let cpsStampOpt2 =
175191match cpsCommandLineOptions.TryGetValue( projectId) with
176- | true , ( cpsStampOpt2, _, _, _ )-> Some( cpsStampOpt2)
192+ | true , ( cpsStampOpt2, _, _) -> Some( cpsStampOpt2)
177193| _ -> None
178194if projectStamp<> projectStamp2|| cpsStampOpt<> cpsStampOpt2then
179195 cache.Remove( projectId) |> ignore
@@ -203,8 +219,8 @@ type private FSharpProjectOptionsReactor (workspace: VisualStudioWorkspaceImpl,
203219member __.ClearOptionsByProjectId ( projectId ) =
204220 agent.Post( FSharpProjectOptionsMessage.ClearOptions( projectId))
205221
206- member __.SetCpsCommandLineOptions ( projectId , stamp , sourcePaths , referencePaths , options ) =
207- cpsCommandLineOptions.[ projectId] <- ( stamp, sourcePaths, referencePaths , options)
222+ member __.SetCpsCommandLineOptions ( projectId , stamp , sourcePaths , options ) =
223+ cpsCommandLineOptions.[ projectId] <- ( stamp, sourcePaths, options)
208224
209225member __.TryGetCachedOptionsByProjectId ( projectId ) =
210226match cache.TryGetValue( projectId) with
@@ -340,7 +356,7 @@ type internal FSharpProjectOptionsManager
340356/// This handles commandline change notifications from the Dotnet Project-system
341357/// Prior to VS 15.7 path contained path to project file, post 15.7 contains target binpath
342358/// binpath is more accurate because a project file can have multiple in memory projects based on configuration
343- member __.HandleCommandLineChanges ( path : string , sources : ImmutableArray < CommandLineSourceFile >, references : ImmutableArray < CommandLineReference >, options : ImmutableArray < string >) =
359+ member __.HandleCommandLineChanges ( path : string , sources : ImmutableArray < CommandLineSourceFile >, _references : ImmutableArray < CommandLineReference >, options : ImmutableArray < string >) =
344360use _logBlock= Logger.LogBlock( LogEditorFunctionId.LanguageService_ HandleCommandLineArgs)
345361
346362let projectId =
@@ -353,8 +369,7 @@ type internal FSharpProjectOptionsManager
353369if Path.IsPathRooted( p) || path= null then p
354370else Path.Combine( Path.GetDirectoryName( path), p)
355371let sourcePaths = sources|> Seq.map( fun s -> fullPath s.Path) |> Seq.toArray
356- let referencePaths = references|> Seq.map( fun r -> fullPath r.Reference) |> Seq.toArray
357372
358- reactor.SetCpsCommandLineOptions( projectId, DateTime.UtcNow, sourcePaths, referencePaths , options.ToArray())
373+ reactor.SetCpsCommandLineOptions( projectId, DateTime.UtcNow, sourcePaths, options.ToArray())
359374
360375member __.Checker = checkerProvider.Checker