Skip to content

Commit

Permalink
VS Go to definition from C# to F# (#14377)
Browse files Browse the repository at this point in the history
* WIP

* WIP

* WIP

* WIP

* WIP: get a .ctor fixup

* WIP: Events are just properties

* WIP: Events are just properties

* WIP

* WIP: Strip generic parameters while searching

* WIP: Add generic params when filtering for entity

* Added operators suport

* Added DUs and Records support

* Small refactoring

* PR suggestions + possible short-circuit in search based on the xmlsig

* wip

* wip

* Added tests
  • Loading branch information
vzarytovskii authored Jan 9, 2023
1 parent 24291f2 commit 006d7c2
Show file tree
Hide file tree
Showing 7 changed files with 371 additions and 79 deletions.
22 changes: 11 additions & 11 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@
<SystemRuntimeCompilerServicesUnsafeVersion>6.0.0</SystemRuntimeCompilerServicesUnsafeVersion>
<SystemValueTupleVersion>4.5.0</SystemValueTupleVersion>
<!-- Versions for package groups -->
<RoslynVersion>4.4.0-3.22470.1</RoslynVersion>
<VisualStudioEditorPackagesVersion>17.4.196-preview</VisualStudioEditorPackagesVersion>
<MicrosoftVisualStudioShellPackagesVersion>17.4.0-preview-3-32916-145</MicrosoftVisualStudioShellPackagesVersion>
<VisualStudioProjectSystemPackagesVersion>17.4.342-pre</VisualStudioProjectSystemPackagesVersion>
<MicrosoftVisualStudioThreadingPackagesVersion>17.4.23-alpha</MicrosoftVisualStudioThreadingPackagesVersion>
<RoslynVersion>4.5.0-1.22520.13</RoslynVersion>
<VisualStudioEditorPackagesVersion>17.5.49-preview</VisualStudioEditorPackagesVersion>
<MicrosoftVisualStudioShellPackagesVersion>17.5.0-preview-1-33020-520</MicrosoftVisualStudioShellPackagesVersion>
<VisualStudioProjectSystemPackagesVersion>17.5.202-pre-g89e17c9f72</VisualStudioProjectSystemPackagesVersion>
<MicrosoftVisualStudioThreadingPackagesVersion>17.4.27</MicrosoftVisualStudioThreadingPackagesVersion>
<MicrosoftBuildOverallPackagesVersion>17.4.0-preview-22469-04</MicrosoftBuildOverallPackagesVersion>
<!-- Roslyn packages -->
<MicrosoftCodeAnalysisEditorFeaturesVersion>$(RoslynVersion)</MicrosoftCodeAnalysisEditorFeaturesVersion>
Expand All @@ -116,7 +116,7 @@
<!-- Visual Studio Shell packages -->
<MicrosoftVisualStudioInteropVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioInteropVersion>
<MicrosoftInternalVisualStudioInteropVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftInternalVisualStudioInteropVersion>
<MicrosoftVisualStudioImagingInterop140DesignTimeVersion>17.4.0-preview-3-32916-053</MicrosoftVisualStudioImagingInterop140DesignTimeVersion>
<MicrosoftVisualStudioImagingInterop140DesignTimeVersion>17.5.0-preview-1-33019-447</MicrosoftVisualStudioImagingInterop140DesignTimeVersion>
<MicrosoftVisualStudioShellInterop80Version>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioShellInterop80Version>
<MicrosoftVisualStudioShellInterop90Version>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioShellInterop90Version>
<MicrosoftVisualStudioShellInterop100Version>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioShellInterop100Version>
Expand All @@ -133,8 +133,8 @@
<MicrosoftVisualStudioShellDesignVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioShellDesignVersion>
<MicrosoftVisualStudioShellFrameworkVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioShellFrameworkVersion>
<MicrosoftVisualStudioPackageLanguageService150Version>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioPackageLanguageService150Version>
<MicrosoftVisualStudioManagedInterfacesVersion>17.4.0-preview-3-32916-053</MicrosoftVisualStudioManagedInterfacesVersion>
<MicrosoftVisualStudioProjectAggregatorVersion>17.4.0-preview-3-32916-053</MicrosoftVisualStudioProjectAggregatorVersion>
<MicrosoftVisualStudioManagedInterfacesVersion>17.5.0-preview-1-33019-447</MicrosoftVisualStudioManagedInterfacesVersion>
<MicrosoftVisualStudioProjectAggregatorVersion>17.5.0-preview-1-33019-447</MicrosoftVisualStudioProjectAggregatorVersion>
<MicrosoftVisualStudioGraphModelVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioGraphModelVersion>
<MicrosoftVisualStudioImagingVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioImagingVersion>
<MicrosoftVisualStudioDesignerInterfacesVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioDesignerInterfacesVersion>
Expand Down Expand Up @@ -171,7 +171,7 @@
<MicrosoftVisualStudioProjectSystemManagedVersion>2.3.6152103</MicrosoftVisualStudioProjectSystemManagedVersion>
<!-- Misc. Visual Studio packages -->
<MicrosoftVSSDKBuildToolsVersion>17.1.4054</MicrosoftVSSDKBuildToolsVersion>
<MicrosoftVisualStudioRpcContractsVersion>17.4.7-alpha</MicrosoftVisualStudioRpcContractsVersion>
<MicrosoftVisualStudioRpcContractsVersion>17.5.9-alpha-g84529e7115</MicrosoftVisualStudioRpcContractsVersion>
<MicrosoftVisualFSharpMicrosoftVisualStudioShellUIInternalVersion>17.0.0</MicrosoftVisualFSharpMicrosoftVisualStudioShellUIInternalVersion>
<MicrosoftVisualStudioValidationVersion>17.0.64</MicrosoftVisualStudioValidationVersion>
<MicrosoftVisualStudioWCFReferenceInteropVersion>9.0.30729</MicrosoftVisualStudioWCFReferenceInteropVersion>
Expand Down Expand Up @@ -204,8 +204,8 @@
<NUnitLiteVersion>3.11.0</NUnitLiteVersion>
<NunitXmlTestLoggerVersion>2.1.80</NunitXmlTestLoggerVersion>
<RoslynToolsSignToolVersion>1.0.0-beta2-dev3</RoslynToolsSignToolVersion>
<StreamJsonRpcVersion>2.13.23-alpha</StreamJsonRpcVersion>
<NerdbankStreamsVersion>2.9.87-alpha</NerdbankStreamsVersion>
<StreamJsonRpcVersion>2.14.6-alpha</StreamJsonRpcVersion>
<NerdbankStreamsVersion>2.9.112</NerdbankStreamsVersion>
<XUnitVersion>2.4.1</XUnitVersion>
<XUnitRunnerVersion>2.4.2</XUnitRunnerVersion>
<FluentAssertionsVersion>5.10.3</FluentAssertionsVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Symbols/Symbols.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1777,7 +1777,7 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
if isUnresolved() then false else
match fsharpInfo() with
| None -> false
| Some v ->
| Some v ->
v.IsCompilerGenerated

member _.InlineAnnotation =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ module internal MetadataAsSource =

[<Sealed>]
[<Export(typeof<FSharpMetadataAsSourceService>); Composition.Shared>]
type internal FSharpMetadataAsSourceService() =
type FSharpMetadataAsSourceService() =

let serviceProvider = ServiceProvider.GlobalProvider
let projs = System.Collections.Concurrent.ConcurrentDictionary<string, IFSharpWorkspaceProjectContext>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,16 @@ module private CheckerExtensions =
}

[<RequireQualifiedAccess>]
module private ProjectCache =
module internal ProjectCache =

/// This is a cache to maintain FSharpParsingOptions and FSharpProjectOptions per Roslyn Project.
/// The Roslyn Project is held weakly meaning when it is cleaned up by the GC, the FSharParsingOptions and FSharpProjectOptions will be cleaned up by the GC.
/// At some point, this will be the main caching mechanism for FCS projects instead of FCS itself.
let Projects = ConditionalWeakTable<Project, FSharpChecker * FSharpProjectOptionsManager * FSharpParsingOptions * FSharpProjectOptions>()

type Solution with

/// Get the instance of IFSharpWorkspaceService.
member private this.GetFSharpWorkspaceService() =
member internal this.GetFSharpWorkspaceService() =
this.Workspace.Services.GetRequiredService<IFSharpWorkspaceService>()

type Document with
Expand Down Expand Up @@ -247,3 +246,20 @@ type Project with
do! doc.FindFSharpReferencesAsync(symbol, (fun textSpan range -> onFound doc textSpan range), userOpName)
|> RoslynHelpers.StartAsyncAsTask ct
}

member this.GetFSharpCompilationOptionsAsync(ct: CancellationToken) =
backgroundTask {
if this.IsFSharp then
match ProjectCache.Projects.TryGetValue(this) with
| true, result -> return result
| _ ->
let service = this.Solution.GetFSharpWorkspaceService()
let projectOptionsManager = service.FSharpProjectOptionsManager
match! projectOptionsManager.TryGetOptionsByProject(this, ct) with
| None -> return raise(OperationCanceledException("FSharp project options not found."))
| Some(parsingOptions, projectOptions) ->
let result = (service.Checker, projectOptionsManager, parsingOptions, projectOptions)
return ProjectCache.Projects.GetValue(this, ConditionalWeakTable<_,_>.CreateValueCallback(fun _ -> result))
else
return raise(OperationCanceledException("Project is not a FSharp project."))
}
Loading

0 comments on commit 006d7c2

Please sign in to comment.