Skip to content

Use Span-based path manipulation #6977

@ladipro

Description

@ladipro

MSBuild still uses the old string-based path manipulation almost everywhere, which leads to avoidable allocations in cases where the result of e.g. Path.GetFileName() is not stored on the heap.

Here's one example use of Path.GetFileName() which could be easily converted to Span:

if (String.Equals(Path.GetFileName(ProjectFullPath), "dirs.proj", StringComparison.OrdinalIgnoreCase))

but there are many more, for other Path APIs as well as for helpers implemented in the MSBuild codebase. Some of them are trivial to fix, some will require deeper changes.

Note that the new Span-based public surface is available in the Microsoft.IO.Redist package on .NET Framework under the namespace Microsoft.IO instead of System.IO.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions