daluu / sharprobotremoteserver

Moved my project here due to Google Code's demise
http://code.google.com/p/sharprobotremoteserver
0 stars 1 forks source link

get_keyword_names returns additional unexpected keywords #5

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Call get_keyword_names method of remote server loaded with some remote 
library, for example the example remote library.
2. Observe the returned list of keywords. For the example library, compare 
results of this .NET implementation against the Python one.

What is the expected output? What do you see instead?

Should just get the list of defined keywords and no more.

This may inadvertently cause problems with keyword collision conflicts if some 
of the unexpected keywords conflict with another library.

Original issue reported on code.google.com by manga...@gmail.com on 1 Mar 2011 at 7:36

GoogleCodeExporter commented 9 years ago
Not a big deal for two reasons:

* Except for developers/users who debug/test the remote server using XML-RPC, 
most Robot Framework users won't notice this bug.

* The unexpected keywords are typically system default methods for generic 
objects like ToString(), Equals(), etc. These don't follow the Robot Framework 
keyword naming convention of keyword_name(), and are rather KeywordName(), so 
very unlikely there would be a keyword collision.

Original comment by manga...@gmail.com on 1 Mar 2011 at 7:38

GoogleCodeExporter commented 9 years ago
Fix would be to figure out way to filter out the unexpected keywords.

Best way may be to use somethng like

Type.GetMethods(BindingFlags.Public | BindingFlags.Static);

but that didn't seem to work rather filtering out all keywords. Need to figure 
out exact filters to use. Or manually store/track a dictionary of keyword names 
that one should filter out and manually do the filtering after get_keyword_name 
is called but before result is sent back to Robot Framework.

Original comment by manga...@gmail.com on 1 Mar 2011 at 7:40

GoogleCodeExporter commented 9 years ago
Another exception would be documenting library with libdoc.py, workaround for 
that is to manually remove the unneeded keyword entries in the documentation.

Original comment by manga...@gmail.com on 3 Jun 2011 at 6:17

GoogleCodeExporter commented 9 years ago
I think you want the loop to ignore methods inherited from object and also 
include instance methods. Something like this:

const BindingFlags flags = BindingFlags.Public | BindingFlags.Static | 
BindingFlags.Instance;
foreach (MethodInfo mi in classType.GetType().GetMethods(flags))
{
    if (mi.DeclaringType != typeof(object))
        keyword_names[i++] = mi.Name;
}

Original comment by kormb...@gmail.com on 27 Dec 2012 at 7:29

GoogleCodeExporter commented 9 years ago
Thanks Kevin, I'll give that a try sometime.

Original comment by manga...@gmail.com on 27 Dec 2012 at 9:52