[API contract regression] SymbolDisplay.ToDisplayString(IntPtrTypeSymbol, FullnameFormat)
returns nint
instead of System.IntPtr
with .NET 8.0 SDK
#76895
Labels
Description:
In a simple compilation
SymbolDisplay.ToDisplayString(IntPtrTypeSymbol, FullnameFormat)
, withIntPtrTypeSymbol
the type symbol forSystem.IntPtr
andFullnameFormat
defined below, returnsnint
instead ofSystem.IntPtr
when compiled depending on .NET 8.0 SDK, despite noSymbolDisplayMiscellaneousOptions.UseSpecialTypes
is being used. If the same source is compiled depending on .NET 6.0 SDK the returned value isSystem.IntPtr
, as expected.FullnameFormat
is defined as:Version Used:
Microsoft.CodeAnalysis.CSharp 4.12
Steps to Reproduce:
IntPtrTest.sln
solutionNet6SystemIntPtr
project, it will printnet6.0 dependency: IntPtr fullname is System.IntPtr
;Net8nint
project, it will printnet8.0 dependency: IntPtr fullname is nint
.Expected Behavior:
I understand that using .NET 8.0 SDK
nint
is now an alias forSystem.IntPtr
(or the other way round). Despite thisSymbolDisplayMiscellaneousOptions.UseSpecialTypes
is documented in this way:Similarly I expect
nint
to be a special type, and not having used this flag I expectSymbolDisplay.ToDisplayString(IntPtrTypeSymbol, FullnameFormat)
to returnSystem.IntPtr
.Actual Behavior:
Depending on the dependent SDK used for the compilation,
SymbolDisplay.ToDisplayString
returns a different value for the ubiquitousSystem.IntPtr
type, which is burden when maintaining analyzers that will process code that can be dependent on a unpredictable SDK.The text was updated successfully, but these errors were encountered: