Beispiel #1
0
        private void ValidateObjectField(
            ITypeInitializationContext context,
            InterfaceField first)
        {
            if (Fields.TryGetField(first.Name, out ObjectField field))
            {
                if (!field.Type.IsEqualTo(first.Type))
                {
                    context.ReportError(new SchemaError(
                                            "The return type of the interface field " +
                                            $"{first.Name} does not match the field declared " +
                                            $"by object type {Name}.",
                                            this));
                }

                if (!ArgumentsAreEqual(field.Arguments, first.Arguments))
                {
                    context.ReportError(new SchemaError(
                                            $"Object type {Name} does not implement " +
                                            $"all arguments of field {first.Name} " +
                                            $"from interface {first.DeclaringType.Name}.",
                                            this));
                }
            }
            else
            {
                context.ReportError(new SchemaError(
                                        $"Object type {Name} does not implement the " +
                                        $"field {first.Name} " +
                                        $"from interface {first.DeclaringType.Name}.",
                                        this));
            }
        }
Beispiel #2
0
        private void ValidateField(
            ITypeInitializationContext context,
            IGrouping <string, InterfaceField> interfaceField)
        {
            InterfaceField first = interfaceField.First();

            if (ValidateInterfaceFieldGroup(context, first, interfaceField))
            {
                ValidateObjectField(context, first);
            }
        }
Beispiel #3
0
        private bool ValidateInterfaceFieldGroup(
            ITypeInitializationContext context,
            InterfaceField first,
            IGrouping <string, InterfaceField> interfaceField)
        {
            if (interfaceField.Count() == 1)
            {
                return(true);
            }

            foreach (InterfaceField field in interfaceField)
            {
                if (!field.Type.IsEqualTo(first.Type))
                {
                    context.ReportError(new SchemaError(
                                            "The return type of the interface field " +
                                            $"{first.Name} from interface " +
                                            $"{first.DeclaringType.Name} and " +
                                            $"{field.DeclaringType.Name} do not match " +
                                            $"and are implemented by object type {Name}.",
                                            this));
                    return(false);
                }

                if (!ArgumentsAreEqual(field.Arguments, first.Arguments))
                {
                    context.ReportError(new SchemaError(
                                            $"The arguments of the interface field {first.Name} " +
                                            $"from interface {first.DeclaringType.Name} and " +
                                            $"{field.DeclaringType.Name} do not match " +
                                            $"and are implemented by object type {Name}.",
                                            this));
                    return(false);
                }
            }

            return(true);
        }