kekekeks / XamlX

General purpose pluggable XAML compiler with no runtime dependencies.
MIT License
319 stars 55 forks source link

Implement IEnumerator interface explicitly to satisfy dotnet linker #80

Closed maxkatz6 closed 1 year ago

maxkatz6 commented 1 year ago

See this unusual stack trace for more context: https://github.com/AvaloniaUI/Avalonia/issues/9127#issuecomment-1327976983

For some unknown reason that would be unreasonably complicated to find out why, dotnet/linker removes IEnumerator interface method implementations from the Enumerator class which we generate. Might be something related to their issues with cecil https://github.com/dotnet/linker/issues/1187

NativeAOT linked works just fine with implicit methods. But for mono/linker changing methods to explicitly implement interface helps here. Other possible reasons: linker doesn't have enough information, because we use this enumerator from "object GetService(Type)" method, or we simply have a mistake in IL generation somewhere (or Cecil has). Like, our methods unnecessarily marked as "virtual" by default.