Skip to content

Do not serialize familyId to remain compatible with ObjC API #1183

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

Closed
wants to merge 1 commit into from

Conversation

bgavrilMS
Copy link
Member

No description provided.

@@ -79,7 +79,12 @@ internal override JObject ToJObject()

json[StorageJsonKeys.Environment] = Environment;
json[StorageJsonKeys.ClientId] = ClientId;
json[StorageJsonKeys.FamilyId] = FamilyId;

// Workaround: MSAL-ObjC has a problem with
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we link to the github issue in their repo? do we have one?

Copy link
Collaborator

@jennyf19 jennyf19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we have to. lgtm

@henrik-me
Copy link
Contributor

Not convinced this is what we should be doing. Also not sure we have done enough testing to ensure this is a good approach.

Copy link
Contributor

@henrik-me henrik-me left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕐

@bgavrilMS
Copy link
Member Author

Semantically the 2 pieces of JSON below are identical:

{}

and

{ 
"family_id": null
}

When we rehydrate the cache, family_id will be null in both cases.

I haven't tested if the cache remains valid with an ObjC app and to see if the scenario encountered still works, was hoping @jennyf19 can help.

I can look at generalizing this fix but I haven't found an easy way to say "ignore nulls"

@jennyf19
Copy link
Collaborator

I'll help anyway possible w/testing, but the more i think about it, the more i don't like this "workaround". especially w/the other null values that we discussed (and henrik brought up in the email).


In reply to: 497392892 [](ancestors = 497392892)

json[StorageJsonKeys.FamilyId] = FamilyId;

// Workaround: MSAL-ObjC has a problem with
if (!String.IsNullOrEmpty(FamilyId))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: lowercase string for type here

@@ -85,7 +85,10 @@ internal override JObject ToJObject()
{
var json = base.ToJObject();

json[StorageJsonKeys.FamilyId] = FamilyId;
if (!string.IsNullOrEmpty(FamilyId))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to follow this pattern, we should make a method to take the key and the value and do the nullcheck and only set if valid. will keep these easily to one line and we can call that method on any of the optional fields.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, will do. I was looking if it's possible to do it via newtonsoft configuration. I don't think it's possibble because we're at such a low level down the stack.

@henrik-me
Copy link
Contributor

henrik-me commented Jun 3, 2019

can't we use some thing like a general serializer setting to prevent null values to even be written? Like what Mark pointed out?
https://stackoverflow.com/questions/6507889/how-to-ignore-a-property-in-class-if-null-using-json-net

@MarkZuber
Copy link
Contributor

I think #1189 fixes this consistently for not serializing null values at all. should we close this one out and use 1189 as the fix for this?

@bgavrilMS
Copy link
Member Author

Sure, no problem. I had a look at the suggestion Henrik made, but I think we're using an API that is too low level to be affected by those attributes.

@bgavrilMS bgavrilMS closed this Jun 6, 2019
@bgavrilMS bgavrilMS deleted the bogavril/jsonnull branch March 30, 2020 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants