diff --git a/Microsoft.SystemForCrossDomainIdentityManagement/Protocol/Core2EnterpriseUserExtensions.cs b/Microsoft.SystemForCrossDomainIdentityManagement/Protocol/Core2EnterpriseUserExtensions.cs index 69cdaab5..935e776c 100644 --- a/Microsoft.SystemForCrossDomainIdentityManagement/Protocol/Core2EnterpriseUserExtensions.cs +++ b/Microsoft.SystemForCrossDomainIdentityManagement/Protocol/Core2EnterpriseUserExtensions.cs @@ -488,12 +488,13 @@ private static void PatchAddresses(this Core2EnterpriseUser user, PatchOperation if ( - string.IsNullOrWhiteSpace(address.Country) + address == null || + (string.IsNullOrWhiteSpace(address.Country) && string.IsNullOrWhiteSpace(address.Locality) && string.IsNullOrWhiteSpace(address.PostalCode) && string.IsNullOrWhiteSpace(address.Region) && string.IsNullOrWhiteSpace(address.StreetAddress) - && string.IsNullOrWhiteSpace(address.Formatted) + && string.IsNullOrWhiteSpace(address.Formatted)) ) { if (addressExisting != null) @@ -951,19 +952,23 @@ private static void PatchPhoneNumbers(this Core2EnterpriseUser user, PatchOperat }; } - string value = operation.Value?.Single().Value; - if - ( - value != null - && OperationName.Remove == operation.Name - && string.Equals(value, phoneNumber.Value, StringComparison.OrdinalIgnoreCase) - ) + if (phoneNumber != null) { - value = null; + string value = operation.Value?.Single().Value; + if + ( + value != null + && OperationName.Remove == operation.Name + && string.Equals(value, phoneNumber.Value, StringComparison.OrdinalIgnoreCase) + ) + { + value = null; + } + + phoneNumber.Value = value; } - phoneNumber.Value = value; - if (string.IsNullOrWhiteSpace(phoneNumber.Value)) + if (phoneNumber == null || string.IsNullOrWhiteSpace(phoneNumber.Value)) { if (phoneNumberExisting != null) { diff --git a/Microsoft.SystemForCrossDomainIdentityManagement/Schemas/TrustedJsonFactory.cs b/Microsoft.SystemForCrossDomainIdentityManagement/Schemas/TrustedJsonFactory.cs index 6f879798..2593d085 100644 --- a/Microsoft.SystemForCrossDomainIdentityManagement/Schemas/TrustedJsonFactory.cs +++ b/Microsoft.SystemForCrossDomainIdentityManagement/Schemas/TrustedJsonFactory.cs @@ -12,8 +12,7 @@ public class TrustedJsonFactory : JsonFactory public override Dictionary Create(string json) { Dictionary result = - (Dictionary)JsonConvert.DeserializeObject( - json); + JsonConvert.DeserializeObject>(json); return result; }