Einhugur Plugin and Rect class issue

see <https://xojo.com/issue/59696>

@Björn Eiríksson
please see the feedback case.

The TypeLib overwrites this Rect() Constructor: Rect.Constructor(X As Double, Y As Double, Width As Double, Height As Double)
https://documentation.xojo.com/api/graphics/rect.html#rect-constructor(x_as_double-_y_as_double-_width_as_double-_height_as_double)

TypeLib has it’s own rect constructors one of them is overwriting the native Xojo Rect constructor
which is causing issues.

This plugin is why we prefixed the Rect, Size, and Point classes with REALbasic way back when. It seems with API2, that wasn’t a priority.

Am a little confused by reading the feedback case.

You were trying to construct the Xojo Rect ? And got the help text from the Einhugur Rect which caused confusion on Width vs Right ?

Or the other way around ? Or something else ?

And yes Rect is very old and does predate the Xojo’s own Rect, even if I have wanted to change it then its not easy task as it was used internally in so many plugins. (which is getting little now though).

Short test on this:

Dim r As Rect = New Rect(10, 10, 100, 100)

If r IsA REALbasic.Rect Then
MessageBox “Is Xojo Rect”
Else
MessageBox “Is Rect from plugin”
End If

In this case the Rect will come from Plugin but hovering over the Rect in first line will incorrectly say its REALbasic.Rect.

Dim r As REALbasic.Rect = New REALbasic.Rect(10, 10, 100, 100)

If r IsA REALbasic.Rect Then
MessageBox “Is Xojo Rect”
Else
MessageBox “Is Rect from plugin”
End If

In this case it will come from Xojo.

Try the example project, the Rect class (api2) is names the same ad the einhugur class. Since the einhugur plugin is required for other parts of the einhugur plugins these constructors became useless.

There are probably more naming conflicts to be found sooner or later.

[quote=483037:@Björn Eiríksson]Short test on this:

Dim r As Rect = New Rect(10, 10, 100, 100)

If r IsA REALbasic.Rect Then
MessageBox “Is Xojo Rect”
Else
MessageBox “Is Rect from plugin”
End If

In this case the Rect will come from Plugin but hovering over the Rect in first line will incorrectly say its REALbasic.Rect.

Dim r As REALbasic.Rect = New REALbasic.Rect(10, 10, 100, 100)

If r IsA REALbasic.Rect Then
MessageBox “Is Xojo Rect”
Else
MessageBox “Is Rect from plugin”
End If

In this case it will come from Xojo.[/quote]

Hovering over says realbasic.rect is probably another bug.

Note we are not trying to use REALBasic.Rect but the API 2.0 Rect class:

https://documentation.xojo.com/api/graphics/rect.html

I think the issue here is Xojo creates new classes, that’s fine but it seems to allow the plugins to silently overwrite whatever Xojo provides. This should NOT be happening, extending is ok but overwriting silently is causing such really hard to find issues

[quote=483028:@Björn Eiríksson]Am a little confused by reading the feedback case.

You were trying to construct the Xojo Rect ? And got the help text from the Einhugur Rect which caused confusion on Width vs Right ?

Or the other way around ? Or something else ?
[/quote]

I was simply using the Xojo’s API 2.0 Rect() class:


// Xojo's native rect class constructor: x, y, width, height
Dim r As New Rect(25, 50, 100, 200)
// Einhugur rect class constructor: x, y, bottom, right

// The debugger should show:

// r.x = 25
// r.y = 50
// r.width = 75 ?!?
// r.height = 150 ?!?

// The wrong (expected) values are being set, since it's using the plugin's constructor instead of xojo's constructor. 

This is because the plugin has it’s own constructor that’s not assinging the X, Y, W, H but the X, Y, Bottom, Right …
And the xojo compiler is selecting the plugin’s constructor instead of the Xojo native constructor.

Even if it where old or new, XOJO’s class and Einhugur plugins class is NAMED the same.
This is causing serious unexpected issues !
Einhugur plugins have issues with: Point, Rect maybe even more classes.

With mbs we never had naming conflicts, as they use well… [classname]MBS

The way I see it, Xojo has handed you two options:

  1. Get to work converting all your plugins to use the built-in classes.
  2. Rename your classes and make your customers switch over. Considering Xojo’s class name and identical (yet different meaning) constructor, this would lead to non-obvious issues for your customers.

Xojo has decided they own the global Rect, Size, and Point classes. So you have to find a way to adapt for your customer’s sake.

We did that years ago and added MBS on the end of the class names.

[quote=483045:@Thom McGrath]The way I see it, Xojo has handed you two options:

  1. Get to work converting all your plugins to use the built-in classes.
  2. Rename your classes and make your customers switch over. Considering Xojo’s class name and identical (yet different meaning) constructor, this would lead to non-obvious issues for your customers.

Xojo has decided they own the global Rect, Size, and Point classes. So you have to find a way to adapt for your customer’s sake.[/quote]

I mark this as the answer and hope @Björn Eiríksson is willing to change things. For now it seems a minor issue as i’ve found the cause, we’ll see how many other people will get some issues from this. At least we know what we can look for.

It seems that Xojo Inc has lost too must institutional knowledge as to why things were done as they originally were, which means issues like this are likely to keep happening.

IMO the Einhugur Plugin set is the best value (%/type of functionality that I use vs price) for people like me . If this results in some of those plugins being discontinued, it will not improve my view of Xojo Inc’s focus on existing customers.

-Karen

If they changed LimitText to MaximumCharactersAllowed, and in this case, Rect stands for Rectangular Area, why not use RectangularArea or Rectangle? I don’t see Rect as other more verbose API 2.0 things.

You have workaround for now, you prefix it with REALbasic, like REALbasic.Rect (Its why they put the prefix there in the first place so you have the option to prefix if there Is conflict).

For the sake of auto complete please prefix if you go this route. This is my one complaint about MBS.

No you’re missing the point. In API 2 there is a new Rect class in the global namespace.

This is why API 2 is a farce. You are absolutely right. I guess we need API 3 to correct this.

You means you want MBS to change 65,000 plugin function names? Nah please don’t.

@Björn Eiríksson for now i’ll use “plugin pro” to change, but the major project will NOT be converted since it used alot of rects.
Perhaps you forgot that xojo is already using these classes here and on many more places:
https://documentation.xojo.com/api/deprecated/window.html#window-bounds As Rect
Note the plugins also use Point, and maybe even move of the same names (conflicts).
Alot of serious issues will come from this.

No, my comment was for Björn to consider.

[quote=483087:@Thom McGrath]No you’re missing the point. In API 2 there is a new Rect class in the global namespace.

This is why API 2 is a farce. You are absolutely right. I guess we need API 3 to correct this.[/quote]

Ah so when doing REALbasic.Rect then that’s API1 rect I guess.

Thanks for clarifying, since I have been a bit confused in this thread. And had not connected why it was causing issues right now.

I do not have capability to update all at once which is basically the only tricky part. But many things have slowly been changed internally to just use Xojo rect (which by it self might be Hazard as well given the info you told me just now). But I suppose the way to go would be to just do the change and see what brakes and then slowly weed down whatever issues come.

[quote=483095:@Björn Eiríksson]Ah so when doing REALbasic.Rect then that’s API1 rect I guess.

Thanks for clarifying, since I have been a bit confused in this thread. And had not connected why it was causing issues right now.

I do not have capability to update all at once which is basically the only tricky part. But many things have slowly been changed internally to just use Xojo rect (which by it self might be Hazard as well given the info you told me just now). But I suppose the way to go would be to just do the change and see what brakes and then slowly weed down whatever issues come.[/quote]
Yeah it’s going to be a mess. Like I said, this stuff is why we avoided using global Rect in the first place.

I personally believe that all plugins should be forced into namespaces. They shouldn’t be allowed in the global space. But that will absolutely never happen at this point.