public TypeInfo(
     ITypeDiscoveryContext context,
     IComplexOutputTypeDefinition definition)
 {
     Context    = context;
     Definition = definition;
 }
示例#2
0
        public static void Complete(
            ICompletionContext context,
            IComplexOutputTypeDefinition definition,
            Type clrType,
            ICollection <InterfaceType> interfaces,
            ITypeSystemObject interfaceOrObject,
            ISyntaxNode?node)
        {
            if (clrType != typeof(object))
            {
                TryInferInterfaceUsageFromClrType(context, clrType, interfaces);
            }

            if (definition.KnownClrTypes.Count > 0)
            {
                definition.KnownClrTypes.Remove(typeof(object));

                foreach (Type type in definition.KnownClrTypes.Distinct())
                {
                    TryInferInterfaceUsageFromClrType(context, type, interfaces);
                }
            }

            foreach (ITypeReference interfaceRef in definition.Interfaces)
            {
                if (!context.TryGetType(interfaceRef, out InterfaceType type))
                {
                    // TODO : resources
                    context.ReportError(SchemaErrorBuilder.New()
                                        .SetMessage("COULD NOT RESOLVE INTERFACE")
                                        .SetCode(ErrorCodes.Schema.MissingType)
                                        .SetTypeSystemObject(interfaceOrObject)
                                        .AddSyntaxNode(node)
                                        .Build());
                }

                if (!interfaces.Contains(type))
                {
                    interfaces.Add(type);
                }
            }
        }
        public static void Complete(
            ITypeCompletionContext context,
            IComplexOutputTypeDefinition definition,
            Type clrType,
            ICollection <InterfaceType> interfaces,
            ITypeSystemObject interfaceOrObject,
            ISyntaxNode?node)
        {
            if (clrType != typeof(object))
            {
                TryInferInterfaceUsageFromClrType(context, clrType, interfaces);
            }

            if (definition.KnownClrTypes.Count > 0)
            {
                definition.KnownClrTypes.Remove(typeof(object));

                foreach (Type type in definition.KnownClrTypes.Distinct())
                {
                    TryInferInterfaceUsageFromClrType(context, type, interfaces);
                }
            }

            foreach (ITypeReference interfaceRef in definition.Interfaces)
            {
                if (!context.TryGetType(interfaceRef, out InterfaceType type))
                {
                    context.ReportError(
                        CompleteInterfacesHelper_UnableToResolveInterface(
                            interfaceOrObject, node));
                }

                if (!interfaces.Contains(type))
                {
                    interfaces.Add(type);
                }
            }
        }
示例#4
0
        public static void CompleteInterfaces(
            ITypeCompletionContext context,
            IComplexOutputTypeDefinition definition,
            Type clrType,
            ICollection <InterfaceType> interfaces,
            ITypeSystemObject interfaceOrObject,
            ISyntaxNode?node)
        {
            foreach (ITypeReference interfaceRef in definition.Interfaces)
            {
                if (!context.TryGetType(interfaceRef, out InterfaceType type))
                {
                    context.ReportError(
                        CompleteInterfacesHelper_UnableToResolveInterface(
                            interfaceOrObject, node));
                }

                if (!interfaces.Contains(type))
                {
                    interfaces.Add(type);
                }
            }
        }