requestHandling of WPF interfaces subtleties

dlebansais's picture

Objects created for the .NET environment must usually expose feature Equals, an implementation of the interface specified in .NET documentation as follow (warning, C# syntax incoming):


EiffelStudio provides a default implementation if the source code of a .NET Eiffel project doesn't.

For most projects this is fine, however it becomes a problem for classes that inherit from the WPF graphic classes, because those have a different definition of Equals, that must not be redefined. Yet, if the source code doesn't redefine Equals, then the compiler will do it by default.

This support is located in lines 1537 to 1544 of cil_code_generator.e in the compiler source code.

I'm requesting that the Eiffel compiler for .NET analyze whether it must provide a default implementation of Equals (and possibly other features) depending on parent assemblies, instead of always doing it like today.

Benefits: with this change, applications taking advantage of the WPF user interface become, if not practical, at least possible.

Your rating: None


Yes but what says that Equals

manus_eiffel's picture

Yes but what says that Equals should not be redefined, the documentation? As a workaround, you can redefine it and call the precursor, no? Maybe not the ideal solution but probably a good workaround. Is there any metadata associated to the Equals from WPF that says one should not redefine it? Or do you mean that it can be redefined but we should always call the precursor first?

I should have posted

dlebansais's picture

I should have posted something clearer, but I didn't want to be too technical either.

The situation is akin to redefining a frozen feature, except it crashes at runtime. Equals, as the documentation states, must not be redefined and this enforced in the system (more on this below). So, if I redefine Equals then my code will crash i.e. trigger an unrecoverable exception upon loading. The easy answer would be to not redefine it, unfortunately, and there lies the problem, the compiler does it for you if you don't.

So the request is to not provide a default implementation of Equals in the compiler.

Yes but what says that Equals should not be redefined, the documentation?

You are right, the compiler must have a way to know if a feature can/must be redefined. I digged into assemblies info using the IL disassembler, and it seems the original implementation of Equals comes from WindowsBase.dll, namespace, DependencyObject class. This is also what the documentation states.

Disassembling the feature showed that it has the tag 'final', which is probably the reason of the failure. I hope the assembly consumer has access to this information, and could for instance mark this feature as frozen in its Eiffel incarnation (if appropriate).

If the method is marked final

manus_eiffel's picture

If the method is marked final then indeed it is incorrect that we try to redefine it. You should submit a problem report to with your ECF and a typical example using WPF.

Heh, I did a year ago. Issue

dlebansais's picture

Heh, I did a year ago. Issue #15392, with a project to reproduce (probably outdated now, unfortunately).

Admitedly, I didn't know as much at the time. Would you like me to reopen a new issue?

Syndicate content