Hiccup with WPF/Button events

Hi there,

I finally found the time to play around with IronRuby today, so I
compiled the latest build and tried some of the example code out there.
When extending some WPF examples though, I ran into a problem with
Buttons and their assigned events, which looks like a bug to me.

I basically created a simple WPF Window and added several items to it,
including 2 buttons. Each button has its own event block.
Unfortunately, only one of the event blocks gets triggered, no matter
which button I press.

I put together some example code here: http://pastebin.ca/751924

I’ve looked over the my code several times and can’t make out any
problem with it.
What am I doing wrong? Am I even doing anything wrong at all?

Thanks for taking a look!

On 10/27/07, Frank A. [email protected] wrote:

I basically created a simple WPF Window and added several items to it,
including 2 buttons. Each button has its own event block.
Unfortunately, only one of the event blocks gets triggered, no matter
which button I press.

Interesting. I can reproduce this when I run from a file but not when I
interactively type the text.

On 10/27/07, Frank A. [email protected] wrote:

I basically created a simple WPF Window and added several items to it,
including 2 buttons. Each button has its own event block.
Unfortunately, only one of the event blocks gets triggered, no matter
which button I press.

In RubyActionBinder.HookEvent is the following code:

rule.SetTarget(rule.MakeReturn(wiringContext.LanguageContext.Binder,
Ast.SimpleCallHelper(rule.Parameters[0], addMethod,
Ast.CodeBlockReference(handler, eventInfo.EventHandlerType))));

The rule is subsequently cached so that all handlers added to
System.Windows.Controls.Button.Click will get the same rule. The rule
is
only parameterized by target event – not by code block – which means
that
subsequent code generation results in the same code block getting
attached
to the event.

Frank A.:

But how come it works in the interactive console but not when executed
from a file?

We’re trying to track down the cause of this, but we know that we’re not
building the correct rules for all cases in our ActionBinder. It’s
likely related to this, but we’re not sure right now.

Thanks,
-John

Curt H. wrote:

In RubyActionBinder.HookEvent is the following code:

rule.SetTarget(rule.MakeReturn(wiringContext.LanguageContext.Binder,
Ast.SimpleCallHelper(rule.Parameters[0], addMethod,
Ast.CodeBlockReference(handler, eventInfo.EventHandlerType))));

The rule is subsequently cached so that all handlers added to
System.Windows.Controls.Button.Click will get the same rule. The rule
is
only parameterized by target event – not by code block – which means
that
subsequent code generation results in the same code block getting
attached
to the event.

But how come it works in the interactive console but not when executed
from a file?