Caliburn.Micro icon indicating copy to clipboard operation
Caliburn.Micro copied to clipboard

Action message select overloaded function #314

Open KasperSK opened this issue 4 years ago • 9 comments

This is a proposal on how to fix #314, the implementation in this pull request is more strict than Caliburn.Micro has been in the past.

If there is no method found that matches the parameter types supplied it will return null. This means that a string wont be converted to int even if it is possible. It will take into account derived classes.

I would love some feedback on this @vb2ae, @nigel-sampson.

KasperSK avatar Jan 29 '21 13:01 KasperSK

@KasperSK the code looks good to me. When the code gets merged to master could you add a blog post about this?

vb2ae avatar Jan 29 '21 17:01 vb2ae

@vb2ae Sure a blog post would make sense, and I would love to write it.

I had a thought what if we made the strict parsing optional? That way we could still get the old behavior where strings are converted to numbers.

KasperSK avatar Jan 29 '21 18:01 KasperSK

@KasperSK true a flag to turn it on or off would be a good idea. Do you think strict parsing should be on or off by default?

vb2ae avatar Jan 29 '21 19:01 vb2ae

Yeah, I suggest making this an opt in feature as it potentially could cause a breaking change in what action gets called.

nigel-sampson avatar Feb 01 '21 18:02 nigel-sampson

@vb2ae I think current behavior should be the default. I was thinking about making a global flag to opt in for all action messages and a local flag to overwrite behavior for a single action message. This will enable the old functionality when needed otherwise I think we need to look into having the Parser assigning type when parsing and I don't think that would be a good idea.

@nigel-sampson Do you think it would be best to put the global flag on the ActionMessage class as a static property?

KasperSK avatar Feb 02 '21 08:02 KasperSK

I'd suggest making it a global fun with some relevant parameters, this way the behavior could be dynamic based on the inputs.

If you're making this on by default then I'd suggest adding some good docs around the change in behavior for the migration documentation.

nigel-sampson avatar Feb 02 '21 21:02 nigel-sampson

@KasperSK keeping the same behavior by default is probably the best way to do it

vb2ae avatar Feb 03 '21 01:02 vb2ae

@KasperSK should we Merge this in?

vb2ae avatar Jun 13 '21 18:06 vb2ae

I believe that I still need to make it so that you can change between the old and the new behavior. Might look at it this week. Then we should be able to merge this in.

KasperSK avatar Jun 14 '21 07:06 KasperSK