Skip to content

Refactor pass with Unsafe.NullRef<T> and Unsafe.IsNullRef<T> #3509

@Sergio0694

Description

@Sergio0694

Overview

Follow up from @michael-hawker's comment here: #3380 (comment)

There are places in the toolkit were we have verbose expressions to check for null refs or get null refs, eg:

https://github.com/windows-toolkit/WindowsCommunityToolkit/blob/070d69014d8e7e85aa2be2359c0ee564e25b66bc/Microsoft.Toolkit.HighPerformance/Buffers/StringPool.cs#L497

https://github.com/windows-toolkit/WindowsCommunityToolkit/blob/49a88c7d570854026855becbd25ae53c1873417f/Microsoft.Toolkit.HighPerformance/Extensions/ArrayExtensions.cs#L47-L50

There are now portable .NET Standard APIs to do this in a less verbose manner (added in dotnet/runtime#40008), which will be in stable release when .NET 5 drops in November (though they'll just target .NET Standard like the current System.Runtime.CompilerServices.Unsafe package). This issue is for tracking a refactoring pass on the whole toolkit to update all the current instances of those workarounds mentioned above, using these new APIs. Notes:

  • No target framework changes
  • No API changes
  • Purely a refactoring

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions