In a normal comparison of types
typeof(nint)==typeof(System.IntPtr) is true
so I was expecting that the SpecialType of System.IntPtr is nint, just like System.Int32 and int, when doing CodeAnalysis using Microsoft.CodeAnalysis.
but it turns out the SpecialType of System.IntPtr is still System.IntPtr.
here's my code
string GetSpecialTypeForDisplayIfAny(ISymbol symbol)
{
return symbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat
.WithGlobalNamespaceStyle(SymbolDisplayGlobalNamespaceStyle.Omitted)
.AddMiscellaneousOptions(SymbolDisplayMiscellaneousOptions.IncludeNullableReferenceTypeModifier)
.AddMiscellaneousOptions(SymbolDisplayMiscellaneousOptions.UseSpecialTypes)
.AddMiscellaneousOptions(SymbolDisplayMiscellaneousOptions.IncludeNullableReferenceTypeModifier)
.AddMiscellaneousOptions(SymbolDisplayMiscellaneousOptions.IncludeNotNullableReferenceTypeModifier))
);
}
So my question is why is the SpecialType of System.IntPtr not nint in CodeAnalysis?
PS. I've already gone through this documentation. I understand that ".. the keywords are not simply aliases for the types." but why is this true then typeof(nint)==typeof(System.IntPtr)?