Skip to content

ICheeseknifeObserver: an activity implementing this interface will be notified about all event handlers being invoked#14

Open
csm101 wants to merge 5 commits intoMarcelBraghetto:masterfrom
csm101:master
Open

ICheeseknifeObserver: an activity implementing this interface will be notified about all event handlers being invoked#14
csm101 wants to merge 5 commits intoMarcelBraghetto:masterfrom
csm101:master

Conversation

@csm101
Copy link

@csm101 csm101 commented Jul 27, 2021

I added a sample app for it.

In this pull request you will find also some minor changes:

  1. I added an .editorconfig file, that forces Visual Studio to use the formatting style intended for your project, regardless of the local settings of the development environment of your contributors
  2. I added a new CheeseKnifeException for when someone is trying to inject a method for a non-existent resource id. before this it just crashed with a NullReferenceException
  3. I added the name of the method that doesn't match the event handler declaration in the message of the exception that gets rised (otherwise it is quite difficult to find the offending method if your class contains many of them

A note about ICheseknifeObserver.AfterCheeseKnifeEvent: it works perfectly (it gets fired exactly at the end of the execution of the method) when the method is a plain void (not async) method, but if the method is declared as "async void" it gets fired immediately. I managed to get it handled correctly, instead, if the method is declared as "async Task"

csm101 added 5 commits July 26, 2021 22:58
…ins the name of the method violating the check (making it easier to locate the problem in the sources)
…exception indicating the name of the offending event handler instead of a NullReferenceException
…ore and after the execution of each event handler (useful automatically logging user actions, trace exceptions, avoid multiple invocations of the same OnClick handler)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant