- Home /
Why doesn't Unity support default interface methods?
I recently tried to create an interface, for wich I only needed some of the methods in my class (and other methods in other classes). Unfortunately I was forced to implement all of interface methods, even the ones I didn't need, wich I left with an empty body.
Default Interfacemethods were added in C#8 and, as far as I'm concerned Unity versions up to 2020.1 are using an older version of C#: C#7.3, so I guess that's fine, but in the latest beta (currently 2020.2) C#8 support was added except for default interface methods (source)
So, why is it? Is it due to the compiler, or maybe for runtime reasons or what?
And if that's just because C#8 support was just added, is this feature going to be added in the future aswell or not?
They've must have had their reasons and only the dev team really knows what those were precisely.
$$anonymous$$y private guess is that although default interface method superficially seems rather straight forward - it's long tail of consequences can be very far from it. Hence some language features are being postponed. I wouldn't hold my breath for this feature co$$anonymous$$g out soon; it took years for c# Tuples.
Answer by Freznosis · Jan 03, 2021 at 05:11 AM
It's because default interfaces aren't supported by .Net Standard 2.0, Unity would have to implement .Net Standard 2.1 or higher. In that thread, Unity says they are working on moving to .NET 5.0 and we'll most likely get C#9.0 at that time too. So we have to wait until then. @MT714