From d29719d790435a609e7537fa96bb9e9c3b1e2af1 Mon Sep 17 00:00:00 2001 From: Eugene Auduchinok Date: Mon, 16 Feb 2026 15:31:39 +0100 Subject: [PATCH 1/3] FSharpType: add ImportILType --- src/Compiler/Service/FSharpCheckerResults.fs | 12 ++++++++++++ src/Compiler/Service/FSharpCheckerResults.fsi | 3 +++ ...rp.Compiler.Service.SurfaceArea.netstandard20.bsl | 1 + 3 files changed, 16 insertions(+) diff --git a/src/Compiler/Service/FSharpCheckerResults.fs b/src/Compiler/Service/FSharpCheckerResults.fs index b215075fb0e..7dd77e6001a 100644 --- a/src/Compiler/Service/FSharpCheckerResults.fs +++ b/src/Compiler/Service/FSharpCheckerResults.fs @@ -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 @@ -2108,6 +2110,13 @@ 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 @@ -3522,6 +3531,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 diff --git a/src/Compiler/Service/FSharpCheckerResults.fsi b/src/Compiler/Service/FSharpCheckerResults.fsi index 25c38a49d50..d602c7ab1d5 100644 --- a/src/Compiler/Service/FSharpCheckerResults.fsi +++ b/src/Compiler/Service/FSharpCheckerResults.fsi @@ -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 + /// Get the items for a declaration list /// /// diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.bsl index 1954ef2367b..07430812215 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.bsl @@ -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]) From b8464b7fb1866c05852159676a4027c308794dca Mon Sep 17 00:00:00 2001 From: Eugene Auduchinok Date: Mon, 16 Feb 2026 16:09:58 +0100 Subject: [PATCH 2/3] Release notes --- docs/release-notes/.FSharp.Compiler.Service/10.0.300.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/.FSharp.Compiler.Service/10.0.300.md b/docs/release-notes/.FSharp.Compiler.Service/10.0.300.md index 471abbfb982..04f5ea6ef71 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/10.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/10.0.300.md @@ -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 From a9028a2790abbce323fc46bc2b3733bfdb1cbcea Mon Sep 17 00:00:00 2001 From: Eugene Auduchinok Date: Mon, 16 Feb 2026 16:55:12 +0100 Subject: [PATCH 3/3] Fantomas --- src/Compiler/Service/FSharpCheckerResults.fs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Compiler/Service/FSharpCheckerResults.fs b/src/Compiler/Service/FSharpCheckerResults.fs index 7dd77e6001a..05eae26a388 100644 --- a/src/Compiler/Service/FSharpCheckerResults.fs +++ b/src/Compiler/Service/FSharpCheckerResults.fs @@ -2114,7 +2114,10 @@ type internal TypeCheckInfo 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 + + let typ = + ImportILTypeFromMetadata amap range0 scopeRef [] [] NullableAttributesSource.Empty ty + FSharpType(cenv, typ) /// Get the auto-complete items at a location