-
Notifications
You must be signed in to change notification settings - Fork 17
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
feat: use ObjectId for object ids in MetasysClient #141
Conversation
4014fde
to
0f7f2b2
Compare
MetasysServicesExampleApp/FeaturesDemo/GetObjectIdentifierDemo.cs
Outdated
Show resolved
Hide resolved
c0b1775
to
b7c9429
Compare
b7c9429
to
b7e18fe
Compare
4ea75f2
to
fa54be9
Compare
@@ -282,26 +285,10 @@ public void TestGetObjectIdentifierBadRequestThrowsException() | |||
PrintMessage($"TestGetObjectIdentifierBadRequestThrowsException: {e.Message}"); | |||
} | |||
|
|||
[Test] |
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.
This test was removed because it represents a condition that can't happen any more. We can't fail parsing a guid since we no longer attempt to parse to guid.
[Test] | ||
public void TestGetObjectIdentifierNullResponseThrowsException() | ||
{ | ||
httpTest.RespondWith("null"); | ||
httpTest.RespondWithJson(JToken.Parse("null")); |
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.
To test for null we need a JSON null which looks like null
vs. a string with the word null which looks like "null"
. The previous version of this test was just encoding the word "null"
as a string.
It was a mistake that we started using Guid for object identifiers in this library. The Metasys REST API makes no guarantee that the ids it returns will be Guids. It has never documented them as such. This commit starts to transition us away from Using Guid - Introduce new ObjectId type which has implicit conversions to/from string and to/from Guid to aid the transition to the new methods - Modify all methods of MetasysClient and IMetasysClient that use Guid as an objectIdentifier to take an ObjectId instead. This is a non-breaking change (unless clients are using Reflection to find methods). - For MetasysClient and IMetasysClient methods that take an IEnumerable<Guid> we had to leave those methods. But we marked them obsolete, added new methods that take IEnumerable<ObjectId>. These new methods take their implementation from the old methods. The old methods delegate to the new methods so they are easy to delete in the future. - In tests and demo apps disabled warning related to obsolete methods (for now). - fix variant related classes to use ObjectId - fix BatchRequestParm - Fix ParseObjectIdentifier to stop using Guid and just return ObjectId. Remove a test case related to parsing Guid.
Like the previous commit this switches from Guid to ObjectId as the type for paramters that need an object identifer.
fa54be9
to
8c66502
Compare
8c66502
to
aebda38
Compare
5a5b63f
to
9a93671
Compare
9a93671
to
ecc1b3d
Compare
This will be slightly easier to review one commit at a time. Only the first one is large. But 90% of it is changing type from Guid to ObjectId or converting guid to/from objectid
It was a mistake that we started using
Guid
for object identifiers in this library. The Metasys REST API makes no guarantee that the ids it returns will be Guids. It has never documented them as such. (For example see Get an object and examine theobjectId
parameter.)This PR starts the transition away from using
Guid
Introduce new
ObjectId
type which has implicit conversions to/fromstring
and to/fromGuid
to aid the transition to the new methods. The new type was used (instead of just usingstring
) as I think it makes the APIs slightly easier to understand. But it also allowed us to create implicit conversions so that the changes could be made without introducing compile time breakages for clients.Modify all methods of
MetasysClient
andIMetasysClient
that useGuid
as an objectIdentifier to take anObjectId
instead. This is a non-breaking change due to the implicit conversion fromGuid
toObjectId
(unless clients are using Reflection to find methods).For
MetasysClient
andIMetasysClient
methods that take anIEnumerable<Guid>
we had to leave those methods. But we marked them obsolete, added new methods that takeIEnumerable<ObjectId>
. These new methods take their implementation from the old methods. The old methods delegate to the new methods so they are easy to delete in the future.Future work: There are many other interfaces/methods that identify objects by
Guid
. This PR will be updated with those as wellare being called just delegate to the new methods.
Note
Alarm, Audit and Activity guid identifiers will be left alone (for now). While those are also just documented as strings it just increases the scope of the change to be too large. So only Object identifiers are being targeted at this time. See #142 for the alarms and audits changes.