I’ve just noticed something peculiar yesterday when uninstalling my own extension. I happened to have the Ruby Console open and the following message popped up:
Extension returned wrong type for method mark_as_uninstalled
I’ve checked the docs and couldn’t find anything. Any ideas on how to suppress that message?
(1) Did you override the mark_as_uninstalled() method in your extension instance ?
It is an internal housekeeping method that should never be called directly by extensions nor overridden.
BTW, The method always should return true as its single statement is:
@has_been_uninstalled = true
(2) What is the your value of $VERBOSE ? If set to true you will get many more warnings in the console.
The default value is false I believe. Extensions should only ever change this global var’s value temporarily.
Setting to nil will suppress all warnings.
But be warned, (pun intended,) some of the internal API warnings have no way to switch them off.
The "extensions.rb" file is located in %ProgramFiles%/SketchUp/SketchUp 2022/Tools can be opened manually and read. Do not change it as all the contents of the "Tools" subfolder have been signed as is.
You cannot prevent it. The decision to output it to IO is made in the SketchUp core.
And, as you say, it occurs for all extensions, so suppressing it for one and not all would do no real good.
I tested and the warning appears regardless of the value of $VERBOSE.
(Normally setting to nil suppresses all such warnings.)
A user will only see it if they happen to have the Console open whilst managing their extensions. Most will not.
Update on this. After some testing I determined that the Extension Manager core expects a NULL result from the mark_as_uninstalled() callback. So in a subclass override for the callback, if the last line is return nil, the core is happy and does not spit out the frivolous type error message.
For all extensions the "Tools/extensions.rb" would need to be updated by Trimble (or the EM core.)
Developers (who are not subclassing SketchupExtension,) could modify their SketchupExtension objects individually by defining a singleton method override in the registrar file to prevent the frivolous message in older SketchUp versions.
This will only work for extensions with such an override:
# After creating the SketchupExtension object referenced as EXTENSION:
EXTENSION.define_singleton_method(:mark_as_uninstalled) { super; nil }