From b673d1da3acf4e81dd9827b46c3156d6c6c04a39 Mon Sep 17 00:00:00 2001 From: Eugene Auduchinok Date: Thu, 10 Sep 2026 10:10:37 +0200 Subject: [PATCH 1/2] Symbols: add WithNullnessAnnotations to the display context Co-authored-by: Claude --- src/Compiler/Symbols/Symbols.fs | 3 +++ src/Compiler/Symbols/Symbols.fsi | 2 ++ .../FSharp.Compiler.Service.SurfaceArea.netstandard20.bsl | 1 + 3 files changed, 6 insertions(+) diff --git a/src/Compiler/Symbols/Symbols.fs b/src/Compiler/Symbols/Symbols.fs index 4e439bde179..ae5c266cff5 100644 --- a/src/Compiler/Symbols/Symbols.fs +++ b/src/Compiler/Symbols/Symbols.fs @@ -567,6 +567,9 @@ type FSharpDisplayContext(denv: TcGlobals -> DisplayEnv) = member _.WithShortTypeNames shortNames = FSharpDisplayContext(fun g -> { denv g with shortTypeNames = shortNames }) + member _.WithNullnessAnnotations show = + FSharpDisplayContext(fun g -> { denv g with showNullnessAnnotations = Some show }) + member _.WithPrefixGenericParameters () = FSharpDisplayContext(fun g -> { denv g with genericParameterStyle = GenericParameterStyle.Prefix } ) diff --git a/src/Compiler/Symbols/Symbols.fsi b/src/Compiler/Symbols/Symbols.fsi index a01d72242a1..c77417c9209 100644 --- a/src/Compiler/Symbols/Symbols.fsi +++ b/src/Compiler/Symbols/Symbols.fsi @@ -66,6 +66,8 @@ type FSharpDisplayContext = member WithShortTypeNames: bool -> FSharpDisplayContext + member WithNullnessAnnotations: bool -> FSharpDisplayContext + /// Causes type signatures to be formatted with prefix-style generic parameters, /// for example `list`. member WithPrefixGenericParameters: unit -> FSharpDisplayContext 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 5c9c346b613..f088a6670e6 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 @@ -5269,6 +5269,7 @@ FSharp.Compiler.Symbols.FSharpDelegateSignature: System.Collections.Generic.ILis FSharp.Compiler.Symbols.FSharpDelegateSignature: System.Collections.Generic.IList`1[System.Tuple`2[Microsoft.FSharp.Core.FSharpOption`1[System.String],FSharp.Compiler.Symbols.FSharpType]] get_DelegateArguments() FSharp.Compiler.Symbols.FSharpDelegateSignature: System.String ToString() FSharp.Compiler.Symbols.FSharpDisplayContext: FSharp.Compiler.Symbols.FSharpDisplayContext Empty +FSharp.Compiler.Symbols.FSharpDisplayContext: FSharp.Compiler.Symbols.FSharpDisplayContext WithNullnessAnnotations(Boolean) FSharp.Compiler.Symbols.FSharpDisplayContext: FSharp.Compiler.Symbols.FSharpDisplayContext WithPrefixGenericParameters() FSharp.Compiler.Symbols.FSharpDisplayContext: FSharp.Compiler.Symbols.FSharpDisplayContext WithShortTypeNames(Boolean) FSharp.Compiler.Symbols.FSharpDisplayContext: FSharp.Compiler.Symbols.FSharpDisplayContext WithSuffixGenericParameters() From ece9ed9c27947a3e4297e7614266d960424bc542 Mon Sep 17 00:00:00 2001 From: Eugene Auduchinok Date: Thu, 10 Sep 2026 10:12:26 +0200 Subject: [PATCH 2/2] Release notes Co-authored-by: Claude --- docs/release-notes/.FSharp.Compiler.Service/11.0.100.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md b/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md index ed1e382d6c7..39654e99208 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md +++ b/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md @@ -179,6 +179,7 @@ * IL: hold custom attributes in fields rather than a union case ([PR #20287](https://github.com/dotnet/fsharp/pull/20287)) * IL: reuse the cached ILTypeRef in ILTypeInfo.FromType ([PR #20255](https://github.com/dotnet/fsharp/pull/20255)) * Name resolution: group C#-style extension members per `open` and extended type ([PR #20298](https://github.com/dotnet/fsharp/pull/20298)) +* Symbols: add `FSharpDisplayContext.WithNullnessAnnotations` ([PR #20507](https://github.com/dotnet/fsharp/pull/20507)) ### Improved