platform-compat icon indicating copy to clipboard operation
platform-compat copied to clipboard

(ReadOnly)Span Slice isn't supported on Linux, macOS, and Windows

Open samcragg opened this issue 7 years ago • 3 comments

Using the analyser with the new Span classes from System.Memory on .NET Core 2.1 and I'm getting warnings that the Slice method is not supported, yet the program does run. Steps to reproduce:

dotnet new console
dotnet add package System.Memory --version 4.5.1
dotnet add package Microsoft.DotNet.Analyzers.Compatibility --version 0.2.12-alpha

Modify Program.cs to be:

using System;

class Program
{
    static void Main(string[] args)
    {
        ReadOnlySpan<char> greeting = "Hello World".AsSpan().Slice(0, 5);
        Console.WriteLine(greeting.ToString());
    }
}

When running dotnet run on dotnet core 2.1.301 on Windows I get this output:

Program.cs(9,66): warning PC001: ReadOnlySpan<T>.Slice(int, int) isn't supported on Linux, macOS, and Windows [...]
Hello

I haven't tested on the other OS's, but the message states Windows is not supported yet it does work.

samcragg avatar Jul 20 '18 05:07 samcragg

This was surprising.

jnm2 avatar Apr 15 '19 00:04 jnm2

Given that Span is a big part of the changes in core flagging it as a compat problem is very noisy. this could really do with fixing.

Wraith2 avatar May 10 '19 16:05 Wraith2

Is there any hope of getting this fixed?

#125 clearly is a dupe, but is not closed for >1 year now. Meanwhile, #135 is offering a fix, but no maintainer looked at it. Is this repository not maintained anymore?

bddckr avatar Feb 11 '20 10:02 bddckr