Skip to content

Commit 8228545

Browse files
committed
Fix SetupProjectFile passing in the wrong IVsHierarchy to CreateProjectContext
1 parent 95e1ec3 commit 8228545

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

vsintegration/src/FSharp.Editor/Common/LanguageService.fs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ open System.Collections.Generic
1010
open System.ComponentModel.Composition
1111
open System.Runtime.InteropServices
1212
open System.IO
13+
open System.Diagnostics
1314

1415
open Microsoft.FSharp.Compiler.CompileOps
1516
open Microsoft.FSharp.Compiler.SourceCodeServices
@@ -329,9 +330,19 @@ and
329330
let projectContextFactory = package.ComponentModel.GetService<IWorkspaceProjectContextFactory>();
330331
let errorReporter = ProjectExternalErrorReporter(projectId, "FS", this.SystemServiceProvider)
331332

333+
let hierarchy =
334+
site.ProjectProvider
335+
|> Option.map (fun p -> p :?> IVsHierarchy)
336+
|> Option.toObj
337+
338+
// Roslyn is expecting site to be an IVsHierarchy.
339+
// It just so happens that the object that implements IProvideProjectSite is also
340+
// an IVsHierarchy. This assertion is to ensure that the assumption holds true.
341+
Debug.Assert(hierarchy <> null, "About to CreateProjectContext with a non-hierarchy site")
342+
332343
let projectContext =
333344
projectContextFactory.CreateProjectContext(
334-
FSharpCommonConstants.FSharpLanguageName, projectDisplayName, projectFileName, projectGuid, siteProvider, null, errorReporter)
345+
FSharpCommonConstants.FSharpLanguageName, projectDisplayName, projectFileName, projectGuid, hierarchy, null, errorReporter)
335346

336347
let project = projectContext :?> AbstractProject
337348

0 commit comments

Comments
 (0)