Author Topic: [v1.6.9.7] Plugin function issues  (Read 3560 times)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
[v1.6.9.7] Plugin function issues
« on: January 31, 2018, 01:15:25 PM »
I'm not sure if it's something I'm doing wrong, but using "vaProxy.ParseTokens()" in the "VA_Init1" or "VA_Exit1" functions will throw an exception:

Quote
Plugin initialization exception: 'VoiceAttack.VoiceAttackInitProxyClass' does not contain a definition for 'ParseTokens'

Quote
Plugin exit exception (VoiceAttack Plugin Name): Exception has been thrown by the target of an invocation.
(I had to get this one from the log, as VoiceAttack's main window disappears)

I assume the function is only exposed to "VoiceAttack.VoiceAttackInvokeProxyClass", however this is not noted it the documentation(Though it would be handy if the function was available in those other contexts, too).



Checking the non variable-related functions, "ProxyVersion()" doesn't seem to work anywhere:
Quote
Plugin execution exception: Non-invocable member 'VoiceAttack.VoiceAttackProxyClass.ProxyVersion' cannot be used like a method.

However, this is because it's not a function(method), but a property.

The documentation appears to be erroneous, as it states
Quote from: VoiceAttackHelp.pdf page 171
ProxyVersion() – This will return a System.Version object to indicate the version of the proxy interface. This will help you determine whether or not the installed interface is compatible with your plugin.
System.Version v = vaProxy.ProxyVersion();

This is made more confusing as "VAVersion()"(which also returns a Version)*is*, as noted in the documentation, a function(method).



As a side note, when a plugin exception is thrown, the name of the plugin is not shown(neither by the initial "Plugin execution exception:" or the subsequent "UNABLE TO INVOKE PLUGIN DUE TO EXCEPTION:" messages).

Obviously I know which plugin I was tinkering with, but if a plugin fails outside of a development context, it may be useful to have the name in the log so it can easily be identified.



EDIT: All three issues are still present in v1.7.3

I corrected the manual excerpt for "ProxyVersion()" which erroneously contained that for "PluginPath()"(the latter actually is a method, and correctly listed as such).

EDIT#2: Exception message upon invocation has been modified to correctly wrap the plugin name in single quotes, though retains the period between it and "DUE TO" (for stylistic reasons?) in v1.8.3.24
« Last Edit: March 10, 2020, 01:32:42 AM by Pfeil »

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: [v1.6.9.7] Plugin function issues
« Reply #1 on: January 31, 2018, 01:32:56 PM »
I'll take a look at the scope of that function and see where it ended up.  vaProxy is subclassed behind the scenes to be able to handle each type of function its being called from.  Might need to be pushed up the tree one level.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: [v1.6.9.7] Plugin function issues
« Reply #2 on: April 27, 2019, 10:48:10 PM »
The reason why, 'ParseTokens' is not in the init or exit is because token parsing functionality in VA requires access to a command.  Init occurs when the plugin is loaded (prior to even a profile being loaded) and exit is when the app is closing.
I could add an init parse token that would only render things that don't require a command (tokens that do not take a variable).  Exit may be a little tricky since certain resources may not be available (I'd have to review every token to find out what that would be).

In regards to getting the name of the plugin producing an error, I think that's been done.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: [v1.6.9.7] Plugin function issues
« Reply #3 on: April 27, 2019, 11:16:52 PM »
In regards to getting the name of the plugin producing an error, I think that's been done.
When attempting to invoke a plugin that already threw an exception, yes:
Quote
UNABLE TO INVOKE PLUGIN, 'My VoiceAttack Plugin - v1.5.14+. DUE TO EXCEPTION: Exception of type 'System.Exception' was thrown.

However, not when the plugin initially throws an exception:
Quote
Plugin execution exception: Exception of type 'System.Exception' was thrown.



The reason why, 'ParseTokens' is not in the init or exit is because token parsing functionality in VA requires access to a command.
Apparently that's not limited to tokens, the new methods also have this issue.

E.G.
Code: [Select]
public static void VA_Init1(dynamic vaProxy)
{
vaProxy.WriteToLog(vaProxy.Command.Name());
}

Quote
Plugin initialization exception: Object reference not set to an instance of an object.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: [v1.6.9.7] Plugin function issues
« Reply #4 on: April 28, 2019, 04:47:46 PM »
Bah - scratch all that I said about the utility class.  The utility class is actually accessible from within init (which I missed).  I made some adjustments so that an empty command is used in places where a command is required and the call is not from a command.

I see where the init exception handler was not including the name.  This has been updated.


ProxyVersion documentation has been updated (not sure when, tho lol).

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: [v1.6.9.7] Plugin function issues
« Reply #5 on: May 09, 2019, 06:06:33 PM »
Testing with v1.7.5.8:

Just making sure: The change to allow ParseTokens() is only intended to apply to the member of the Utility class, not the legacy version in the root class?

I.E.
Code: [Select]
vaProxy.ParseTokens()
throws an exception,
Code: [Select]
vaProxy.Utility.ParseTokens()
does not.


Exceptions in VA_Init1() now write the plugin name to the log, as stated:
Quote
Plugin initialization exception [My VoiceAttack Plugin - v1.5.14+]: Exception of type 'System.Exception' was thrown.

However the initial exception in VA_Invoke1() does not:
Quote
Plugin execution exception: Exception of type 'System.Exception' was thrown.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: [v1.6.9.7] Plugin function issues
« Reply #6 on: March 04, 2020, 11:12:59 PM »
The plugin execution exception now includes the plugin name.  This will be in the next update!

Good eye on that.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: [v1.6.9.7] Plugin function issues
« Reply #7 on: March 07, 2020, 10:19:28 PM »
The initial exception looks good in v1.8.3.22, however I noticed the message for subsequent exceptions appears to have a typo:

Quote
UNABLE TO INVOKE PLUGIN, 'My VoiceAttack Plugin - v1.5.14+. DUE TO EXCEPTION: Exception of type 'System.Exception' was thrown.

Rather than the plugin name being wrapped in single quotes, there is an opening single quote, but where the closing single quote would be, there's a period instead.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: [v1.6.9.7] Plugin function issues
« Reply #8 on: March 07, 2020, 10:22:13 PM »
Got it!