-
Notifications
You must be signed in to change notification settings - Fork 495
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
Fix customer serializer being used for internal types #1105
Fix customer serializer being used for internal types #1105
Conversation
…removes the need for the ComosFeedResponseUtil class.
…er to test for internal types.
Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/FeedProcessorCore.cs
Show resolved
Hide resolved
...soft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Performance.Tests/Benchmarks/ItemBenchmark.cs
Show resolved
Hide resolved
...soft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Performance.Tests/Benchmarks/ItemBenchmark.cs
Show resolved
Hide resolved
operationType: 'Replace', | ||
resourceType: 'trigger' | ||
string conflictResponsePayload = @"{ ""Conflicts"":[{ | ||
""id"": ""Conflict1"", |
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.
Is the change to double escaping required? Why is that?
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.
I mean, I understand the validity concern, but did anything that that would make previous format not work?
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.
Single quotes is not valid JSON. It seems like newtonsoft will still convert it, but CosmosElements will not. The backend always send valid json with doube quotes.
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.
Yeah, this is also something that will happen with System.Text.Json and anyone passing invalid JSON
/// <summary> | ||
/// This is an interface to allow a custom serializer to be used by the CosmosClient | ||
/// </summary> | ||
internal class CosmosSerializerCore |
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.
Shouldn't it inherit from CosmosSerializer?
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.
No, I don't want the public contract restricting the internal type.
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.
Then you can create CosmosSerializerInternal that inherits from CosmosSerializer and inherit from that instead.
In reply to: 359071623 [](ancestors = 359071623)
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.
My only big question is, in all the internal scenarios where we are now passing CosmosSerializerCore instead of CosmosSerializer means that we won't be able to pass a mocked instance, right? Are we ok with that? Any gaps where we think we would mock the serializer?
Currently nothing is mocking the serializerCore so I didn't bother making the methods virtual. It's an internal class so we can modify it at any time without impacting users. This still support mocking the custom serializer and passing it in. |
this.ClientContext.ResponseFactory.CreateQueryFeedResponse<T>); | ||
(response) => this.ClientContext.ResponseFactory.CreateQueryFeedResponse<T>( | ||
responseMessage: response, | ||
resourceType: ResourceType.Database)); |
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 method is questionable right? Why do we make this generic when it always returns a database response that is schematized?
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.
It doesn't always return a DatabaseProperties. The user can specify a custom type.
Example query:
"Select t.id from t"
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.
Just grabbed your newly released 3.6.0 package. HURRRRRRRRRRRAY!!! Thank you :D :D |
Pull Request Template
Description
This change fixes a bug where the custom serializer is being used to convert several internal types. The custom serializer can not convert the internal types and causes exception.
To fix the issue:
Type of change
Please delete options that are not relevant.
Closes #1004, #871, #1106