public override IEnumerable Compare()

in openapi-diff/src/modeler/AutoRest.Swagger/Model/SwaggerObject.cs [94:181]


        public override IEnumerable<ComparisonMessage> Compare(
            ComparisonContext<ServiceDefinition> context,
            T previous
        )
        {

            var prior = previous;

            if (prior == null)
            {
                throw new ArgumentNullException("priorVersion");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            base.Compare(context, previous);

            var thisModelName = this.XmsClientName ?? Reference ?? "";
            var priorModelName = previous.XmsClientName ?? previous.Reference ?? "";
            if (!thisModelName.Equals(priorModelName))
            {
                context.LogBreakingChange(ComparisonMessages.ReferenceRedirection);
            }

            if (IsRequired != prior.IsRequired)
            {
                if (context.Direction != DataDirection.Response)
                {
                    if (IsRequired && !prior.IsRequired)
                    {
                        context.LogBreakingChange(ComparisonMessages.RequiredStatusChange, prior.IsRequired, IsRequired);
                    }
                    else
                    {
                        context.LogInfo(ComparisonMessages.RequiredStatusChange, prior.IsRequired, IsRequired);
                    }
                }
            }

            // Are the types the same?

            if ((Type.HasValue && prior.Type.HasValue && prior.Type.Value != Type.Value))
            {
                context.LogError(ComparisonMessages.TypeChanged,
                    Type.HasValue ? Type.Value.ToString().ToLower() : "",
                    prior.Type.HasValue ? prior.Type.Value.ToString().ToLower() : "");
            }
            var isObject = Type.HasValue && Type.Value == DataType.Object && (this is Schema) ? (this as Schema).Properties != null : false;
            if (prior.Type.HasValue != Type.HasValue) {
                if (!prior.Type.HasValue && Type.HasValue && isObject)
                {
                    context.LogInfo(ComparisonMessages.TypeChanged,
                   Type.HasValue ? Type.Value.ToString().ToLower() : "",
                   prior.Type.HasValue ? prior.Type.Value.ToString().ToLower() : "");
                }
                else {
                    context.LogError(ComparisonMessages.TypeChanged,
                   Type.HasValue ? Type.Value.ToString().ToLower() : "",
                   prior.Type.HasValue ? prior.Type.Value.ToString().ToLower() : "");
                }
            }

            // What about the formats?

            CompareFormats(context, prior);

            CompareItems(context, prior);

            if ((Default != null || prior.Default != null) && !JToken.DeepEquals(Default,prior.Default))
            {
                context.LogBreakingChange(ComparisonMessages.DefaultValueChanged);
            }

            if (Type.HasValue && Type.Value == DataType.Array && prior.CollectionFormat != CollectionFormat)
            {
                context.LogBreakingChange(ComparisonMessages.ArrayCollectionFormatChanged);
            }

            CompareConstraints(context, prior);

            CompareProperties(context, prior);

            CompareEnums(context, prior);

            return context.Messages;
        }