-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Documentation for unsupported, runtime-dependent features. #47
Comments
Default interface implementations are definitely out. I'm working on a git repo now that tests each C# language feature from 8.0 forward to test which polyfills are available. (The project targets .NET 4.7.2 with C# 11). It looks like ranges are also not supported. When I attempt to use them, I am presented with the following error:
I am unable to add a direct reference to System.Runtime to the project, and there's already a reference to System.Runtime.CompilerServices.Unsafe. The code I'm using comes directly from Microsoft's documentation and is as follows:
Oddly, the index from end operator works just fine. For example, the code below compiles and runs without error:
|
Ranges are only not supported when slicing arrays. If you try to slice eg. a |
Sergio - Thank you. I'll note that in the git repo I'm working on. (I'm trying to convince our company to use the package.) |
I will also say, from the point of view of users, it's actually pretty straightforward. If something can be used, it'll just work. If something requires runtime support and that's not available, Roslyn will just emit an error with a nice explanation about it 🙂 |
Sergio: Hmm, I see that that actually does work. Thanks!
Actually, I wonder how that functions for class libraries targeting .NET Standard 2.0 (which obviously isn't, itself, a runtime). |
.Net Standard is a "contract" for runtimes. All runtimes that support default inheritance also support the .Net Standard 2.0 API-s, but not all runtimes that support .Net Standard 2.0 have default interface implementations. Hence Roslyn is careful enough to not allow using default interface implementations if the target is .Net Standard 2.0. Great library btw, makes one wonder why Microsoft didn't bother with something like this. |
I couldnt get expression-bodied property to work on a legacy project using .Net Framework 4.0 |
Those will work just fine, but you need to set the C# language version to at least C# 7 🙂 |
@GetCurious That should still work, I think, if you're have the latest But that's all out of the scope of PolySharp, afaik. |
@DreadLordMikey Try creating the following class in your project: https://gist.github.com/bgrainger/fb2c18659c2cdfce494c82a8c4803360 |
Feel free to use my notes as a base for this. |
Is there any documentation here (or elsewhere) on which C# language features depend on runtime support, and therefore can never be polyfilled?
I know the readme mentions static abstract members, and I'm pretty sure default interface methods are out too.
It would be helpful to have some list of the features that we should not expect this project to ever be able to polyfill, (if only to preempt people opening feature requests for them 😆).
The text was updated successfully, but these errors were encountered: