Guidance on writing cross platform library code with C# 8.0 #2002
Replies: 8 comments
-
I think language features that will only work on some frameworks will behave almost the same as APIs that are only available on some frameworks. This means that:
I do think it would mean that these features will have very limited use in libraries for a while. |
Beta Was this translation helpful? Give feedback.
-
@svick, |
Beta Was this translation helpful? Give feedback.
-
I could imagine using conditional compilation to add a DIM in .Net Standard 2.1, or an extension method in .Net Framework, though I'm not sure how practical that would be. Similarly, I could imagine declaring a body for an interface member in .Net Standard 2.1, but leave it unimplemented in .Net Framework and force the consumer to implement it. |
Beta Was this translation helpful? Give feedback.
-
@DavidArno According to the proposal, DIM will require a |
Beta Was this translation helpful? Give feedback.
-
I don't think that would work well. Especially since it would require you to write more code than just using an extension method everywhere.
That actually makes sense. Those on platforms that don't support DIM would only lose some convenience and the amount of code you would have write twice probably wouldn't be that bad. |
Beta Was this translation helpful? Give feedback.
-
@svick, that's useful to know. Thanks. |
Beta Was this translation helpful? Give feedback.
-
This works if the interface has never existed before, but it fails in DIM's primary mission of enabling evolution after that point without breaking existing implementors. |
Beta Was this translation helpful? Give feedback.
-
In this recent blog post it was confirmed that various new C# 8.0 features would not be coming to the .Net Framework.
https://blogs.msdn.microsoft.com/dotnet/2018/11/12/building-c-8-0/
I'm sure the C# team has put some effort into writing library code with these new features, and has considered whether such features would bifurcate the ecosystem.
As such is there any, or will there be any, guidance available as to using the new features in cross platform libraries? Should they just not be used at all? Are there any ways around this problem, such as using conditional compilation for the default interface methods or their bodies?
etc.
Beta Was this translation helpful? Give feedback.
All reactions