-
Notifications
You must be signed in to change notification settings - Fork 55
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
fixes the jsonconfig conflicts #241
base: dev
Are you sure you want to change the base?
Conversation
/// <summary> | ||
/// JsonConvert Options | ||
/// </summary> | ||
public static class JsonConvertOptions |
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.
JsonConvertOptions [](start = 24, length = 18)
Instead of this, can you create a static instance of JsonSerializer?
JsonSerializer.Create Method
Creates a new JsonSerializer instance. The JsonSerializer will not use default settings from DefaultSettings.
https://www.newtonsoft.com/json/help/html/M_Newtonsoft_Json_JsonSerializer_Create.htm #Closed
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.
Yep, though you're creating a custom JsonSerializerSettings obj to be able to use the JsonConvert.SerializeObject function.
I just checked another Azure library, they wrapped the entire json settings into a class, resulting pretty much the same I think...
We cannot create a non-default variant of the JsonConvert unfortunately. We could go for the webjob's implementation although we have to add the ContractResolver property otherwise I'm still conflicting with the snake case my code uses. (because they use JsonSerializer.CreateDefault it reuses the default AND the custom settings of the lib) Looking forward to your opinion on this :)
Another thing I realized. We should not break existing leases. This change should only help on the new leases and clients with existing leases should continue working w/o a need to set the options. Have you tested this kind of scenario with your change? |
I'm not 100% sure if i follow you... I have this change working now for some days and it's operating fine :) This change involves that the encapsulated settings of the library stay the same whatever the user defined to their default settings. As Azure works fine with CamelCasing i think this is sufficient. |
I just want to make sure the change doesn't introduce a breaking change for the existing leases. We can assume it won't break but we cannot know for that real before giving a test. Here is a basic scenario:
|
/// Get the JsonConvert formatting options. so it's not conflicting / dependent upon the user's code. | ||
/// </summary> | ||
/// <returns></returns> | ||
public static JsonSerializerSettings GetOptions() |
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.
JsonSerializerSettings [](start = 22, length = 22)
Allow custom settings as well. Like getter/setter, allow clients to customize their casing. If not set, return the default.
Did a small experiment. This is what most people have now due to DefaultContractResolver. This is what client generates after the change. We should keep the DefaultContractResolver as default and provide an API to customize settings. What do you think? |
We can skip this Formatting = Formatting.Indented, to resolve the (\r\n). I think we should make it optional indeed. However maybe give them some options? camelcase and the default? and throw an exception when people enable other resolvers. Options depend on what the EH backend interface can cope with. |
The entire settings should be optional. It will be up to developer how to customize serialization. Please look at the PartitionManagerOptions. I believe we can provide settings there. |
Added default config options for json serializers so it's not conflicting with the user's default project settings.
issue is over here: #169