Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/10.0.300.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* Fix FS3356 false positive for instance extension members with same name on different types, introduced by [#18821](https://github.com/dotnet/fsharp/pull/18821). ([PR #19260](https://github.com/dotnet/fsharp/pull/19260))

### Added
* FSharpType: add ImportILType ([PR #19300](https://github.com/dotnet/fsharp/pull/19300))

### Changed

Expand Down
15 changes: 15 additions & 0 deletions src/Compiler/Service/FSharpCheckerResults.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ open System.Diagnostics
open System.IO
open System.Threading
open FSharp.Compiler.IO
open FSharp.Compiler.Import.Nullness
open FSharp.Compiler.NicePrint
open FSharp.Compiler.TypeHierarchy
open Internal.Utilities.Library
open Internal.Utilities.Library.Extras
open Internal.Utilities.TypeHashing
Expand Down Expand Up @@ -2108,6 +2110,16 @@ type internal TypeCheckInfo
|> Seq.tryFindBack (fun (_, _, _, m) -> equals m range)
|> Option.map (fun (_, q, _, _) -> FSharpDisplayContext(fun _ -> q.DisplayEnv))

member scope.ImportILType(ty: ILType) : FSharpType =
let amap = tcImports.GetImportMap()
let assemblyRef = ILAssemblyRef.Create("", None, None, false, None, None)
let scopeRef = ILScopeRef.Assembly assemblyRef

let typ =
ImportILTypeFromMetadata amap range0 scopeRef [] [] NullableAttributesSource.Empty ty

FSharpType(cenv, typ)

/// Get the auto-complete items at a location
member _.GetDeclarations(parseResultsOpt, line, lineStr, partialName, completionContextAtPos, getAllEntities, options) =
let isSigFile = SourceFileImpl.IsSignatureFile mainInputFileName
Expand Down Expand Up @@ -3522,6 +3534,9 @@ type FSharpCheckFileResults
| None -> None
| Some(scope, _) -> scope.TryGetCapturedDisplayContext(range)

member _.ImportILType(ty: ILType) =
scopeOptX |> Option.map _.ImportILType(ty)

member _.GetAllUsesOfAllSymbolsInFile(?cancellationToken: CancellationToken) =
match details with
| None -> Seq.empty
Expand Down
3 changes: 3 additions & 0 deletions src/Compiler/Service/FSharpCheckerResults.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ type public FSharpCheckFileResults =
member TryGetCapturedType: range -> FSharpType option
member TryGetCapturedDisplayContext: range -> FSharpDisplayContext option

/// Imports a compiled type for subsequent Symbols API use
member ImportILType: ILType -> FSharpType option

/// <summary>Get the items for a declaration list</summary>
///
/// <param name="parsedFileResults">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2085,6 +2085,7 @@ FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: Microsoft.FSharp.Core.FShar
FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Symbols.FSharpDisplayContext] TryGetCapturedDisplayContext(FSharp.Compiler.Text.Range)
FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Symbols.FSharpImplementationFileContents] ImplementationFile
FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Symbols.FSharpImplementationFileContents] get_ImplementationFile()
FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Symbols.FSharpType] ImportILType(ILType)
FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Symbols.FSharpType] TryGetCapturedType(FSharp.Compiler.Text.Range)
FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.ISourceText] GenerateSignature(Microsoft.FSharp.Core.FSharpOption`1[System.Int32])
FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.CodeAnalysis.FSharpSymbolUse]] GetMethodsAsSymbols(Int32, Int32, System.String, Microsoft.FSharp.Collections.FSharpList`1[System.String])
Expand Down
Loading