/// <summary> /// Verifies that in case of collection types, the item type is valid. /// </summary> /// <param name="expectedTypeReference">The expected type reference.</param> /// <param name="payloadType">The payload type.</param> /// <remarks> /// This method verifies that item type is not a derived complex type, we want to explicitly disallow that case for possible future enablement. /// </remarks> private static void VerifyCollectionComplexItemType(IEdmTypeReference expectedTypeReference, IEdmType payloadType) { Debug.Assert(expectedTypeReference != null, "expectedTypeReference != null"); Debug.Assert(payloadType != null, "payloadType != null"); Debug.Assert(expectedTypeReference.IsNonEntityODataCollectionTypeKind(), "This method only works on atomic collections."); Debug.Assert(payloadType.IsNonEntityODataCollectionTypeKind(), "This method only works on atomic collections."); IEdmCollectionTypeReference collectionTypeReference = ValidationUtils.ValidateCollectionType(expectedTypeReference); IEdmTypeReference expectedItemTypeReference = collectionTypeReference.GetCollectionItemType(); if (expectedItemTypeReference != null && expectedItemTypeReference.IsODataComplexTypeKind()) { IEdmCollectionTypeReference payloadCollectionTypeReference = ValidationUtils.ValidateCollectionType(payloadType.ToTypeReference()); IEdmTypeReference payloadItemTypeReference = payloadCollectionTypeReference.GetCollectionItemType(); if (payloadItemTypeReference != null && payloadItemTypeReference.IsODataComplexTypeKind()) { // Note that this method is called from both strict and lax code paths, so we must not fail if the types are not related. // The strict caller will fail if the types are not equal after this method returns. We use this method there to only get // a more specific error message if the derived complex types are used. VerifyComplexType(expectedItemTypeReference, payloadItemTypeReference.Definition, /* failIfNotRelated */ false); } } }