-
-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fails to get subarray #8
Comments
This is expected. Slicing on arrays needs RuntimeHelpers.GetSubArray, which can't be polyfilled because the type already exists (so one can't just "generate one more API" for it). You can use index and slices on all types that expose a For your specific example, you can just update that to: using System;
internal class Class1
{
readonly string[] ns = "Foo.Bar.Baz".Split('.').AsSpan()[..^1].ToArray();
} You'll want the System.Memory package in case you don't have |
I will also add, the reason that works with PolyFill.NET is because they're shadowing the existing |
The argument for "you should not really slice over arrays anyway most of the time" is a bit weak, I'd say, provided it's a feature supported in .NET :). I'd say emitting the relevant extension method so that this scenario Just Works would be pretty nice. Otherwise, you now have to either document a known limitation or provide a code analyzer that will flag this at compile time (better), so we don't have to go fishing on why something that (we're told) should Just Work, actually doesn't (in "some" cases). But I'm happy to change my code, for sure. I just think it's a better experience if this is supported OOB in whichever way is deemed "better". |
Thanks for the project, looking forward its evolution!
Reproduction Steps
This works with PolyFill.NET but not
PolyShary. Build error is:
The text was updated successfully, but these errors were encountered: