al-codeactions icon indicating copy to clipboard operation
al-codeactions copied to clipboard

Idea: Add var to Eventpublisher Variables

Open innonav-dev opened this issue 6 years ago • 7 comments

We love your functionality to automatically create missing Eventpublishers. Having the var keyword on all variables would make it even more useful. If this is not suitable for everyone we would suggest to at least add them to variables called "IsHandled" and "ReturnValue".

innonav-dev avatar Jun 17 '20 06:06 innonav-dev

Good Point, makes sense :) The var keyword is always a discussion point. I don't know yet how to make it suitable for all. I thought about going into the snippet mode after the procedure is created, so that you can tab through (and delete) the var keywords if you want to. Or maybe I should make it configurable:

  • "add var always"
  • "add var never"
  • "use snippet mode"

and maybe also:

  • "add var to variables which contain the following words" as you suggested.

But I don't like to make everything configurable and keep it simple instead, so I tend to use the snippet mode, even if you then always jump to the procedure definition and have to go back to the calling position manually (But you do that anyway to check the var keywords, don't you?)...

I would love to hear your thoughts on that. :)

DavidFeldhoff avatar Jun 17 '20 07:06 DavidFeldhoff

Yes, currently we have to jump to the definition anyway to check the var assignment. Adding the var keyword to all variables would eliminate this process (at least for us). So a configuration would help us a lot. With a DropDown field for the three possible options it should still be a pretty lean configuration.

We didn’t think to much about adding the var only to specific variable names, because we have to add a lot of var keywords to variables that do not follow a specific naming convention. But the two I suggested are used widely, also by Microsoft. So from our point of view you could add the keyword to those without a configuration.

If you decide to not add a configuration, a snippet mode would be very beneficial, since we have to check the definition in nine out of ten cases.

innonav-dev avatar Jun 17 '20 08:06 innonav-dev

Okay, thanks for your input. Unfortunately I'm currently quite busy, so that I'm most probably not able to make it this week, but I'll keep you posted.

DavidFeldhoff avatar Jun 17 '20 10:06 DavidFeldhoff

Hi InnoNavSupport, it has been some time that you've posted the issue and I didn't kept my promise to keep you posted - sorry for that. I just re-read my issues and changed my mind on this topic and decided to pick your idea up, that for event publishers, all parameters will be var. Hope that's still helpful for you, even a year later :)

Thanks for your idea and cheers, David

DavidFeldhoff avatar May 01 '21 13:05 DavidFeldhoff

Small sitenote: "All parameters will be var" is not entirely correct. I'll only pass them as 'var' if it's possible. So literals or something like that won't have the 'var' keyword (see code-sample in #69 )

DavidFeldhoff avatar May 01 '21 13:05 DavidFeldhoff

Based on the response in issue 69, I changed it again a little bit. There will be two new settings for your needs:

  • varParameters: string[]. Parameters with these names will always be declared as var-Parameters. Default: ["IsHandled"]
  • publisherHasVarParametersOnly: boolean. All parameters of new publishers will be declared as var-parameters. Default: false

I hope that fits your needs.

Best regards & Cheers David

DavidFeldhoff avatar May 03 '21 20:05 DavidFeldhoff

And it's released. Please check out the issue #69 how it's solved. I'll close this now to focus any feedback on that issue. But thanks ofr reporting!

DavidFeldhoff avatar May 08 '21 12:05 DavidFeldhoff