-
Notifications
You must be signed in to change notification settings - Fork 292
SDK fixes including CP-53003 #6210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,9 +28,6 @@ | |
*/ | ||
|
||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
|
||
|
||
namespace XenAPI | ||
{ | ||
|
@@ -63,8 +60,7 @@ namespace XenAPI | |
{ | ||
try | ||
{ | ||
return (API_Version)Enum.Parse(typeof(API_Version), | ||
string.Format("API_{0}_{1}", major, minor)); | ||
return (API_Version)Enum.Parse(typeof(API_Version), $"API_{major}_{minor}"); | ||
} | ||
catch (ArgumentException) | ||
{ | ||
|
@@ -82,30 +78,14 @@ namespace XenAPI | |
{ | ||
string[] tokens = version.Split('.'); | ||
int major, minor; | ||
if (tokens.Length == 2 && int.TryParse(tokens[0], out major) && int.TryParse(tokens[1], out minor)) | ||
if (tokens.Length == 2 && | ||
int.TryParse(tokens[0], out major) && | ||
int.TryParse(tokens[1], out minor)) | ||
{ | ||
return GetAPIVersion(major, minor); | ||
} | ||
} | ||
return API_Version.UNKNOWN; | ||
} | ||
|
||
/// <summary> | ||
/// Return a positive number if the given session's API version is greater than the given | ||
/// API_version, negative if it is less, and 0 if they are equal. | ||
/// </summary> | ||
internal static int APIVersionCompare(Session session, API_Version v) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why remove those functions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These methods are not visible outside the library because they are internal. Inside the library they are not used, which means they are not needed. |
||
{ | ||
return (int)session.APIVersion - (int)v; | ||
} | ||
|
||
/// <summary> | ||
/// Return true if the given session's API version is greater than or equal to the given | ||
/// API_version. | ||
/// </summary> | ||
internal static bool APIVersionMeets(Session session, API_Version v) | ||
{ | ||
return APIVersionCompare(session, v) >= 0; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems the default value is already "JsonRpcVersion.v1", do we need re-setting here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theoretically someone could create the session object, change the JsonRpcVersion, and then call
login_with_password
which calls this method. In reality it's highly unlikely someone would do that, but I put the code there to be defensive.