dotnet / dotnet-api-docs

.NET API reference documentation (.NET 5+, .NET Core, .NET Framework)
https://docs.microsoft.com/dotnet/api/
Other
725 stars 1.56k forks source link

ReadOnlySpan created from a null array does not return a null ReadOnlySpan #10611

Open steveharter opened 6 days ago

steveharter commented 6 days ago

Type of issue

Typo

Description

For the ReadOnlySpan<T>(T[]?) constructor that can take a null array, the doc says If the array is null, this constructor returns a null ReadOnlySpan<T>.

However, the method instead creates an empty span. A span, being a ref struct cannot be nullable. It should say "This method returns default when array is null." as described in the other constructor ReadOnlySpan<T>(T[], Int32, Int32).

Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1.-ctor?view=net-8.0

Content source URL

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System/ReadOnlySpan`1.xml

Document Version Independent Id

d7b1c5b6-cdec-e856-0d48-533861086507

Article author

@steveharter

dotnet-issue-labeler[bot] commented 6 days ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

dotnet-issue-labeler[bot] commented 6 days ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

dotnet-policy-service[bot] commented 1 day ago

Tagging subscribers to this area: @dotnet/area-system-runtime