Пример #1
0
        public void Merge_Should_Merge_HandlersAndPrependExtensionHandlers()
        {
            // arrange
            var firstFieldHandler     = new QueryableDefaultSortFieldHandler();
            var extensionFieldHandler = new MockFieldHandler();
            var convention            = new MockProvider(x => x.AddFieldHandler(firstFieldHandler));
            var extension             = new MockProviderExtensions(
                x => x.AddFieldHandler(extensionFieldHandler));
            var context = new ConventionContext(
                "Scope",
                new ServiceCollection().BuildServiceProvider(),
                DescriptorContext.Create());

            convention.Initialize(context);
            extension.Initialize(context);

            // act
            extension.Merge(context, convention);

            // assert
            Assert.NotNull(convention.DefinitionAccessor);
            Assert.Collection(
                convention.DefinitionAccessor !.Handlers,
                x => Assert.Equal(extensionFieldHandler, x.HandlerInstance),
                x => Assert.Equal(firstFieldHandler, x.HandlerInstance));
        }
Пример #2
0
        public Schema Create()
        {
            IServiceProvider services      = _services ?? new EmptyServiceProvider();
            IBindingLookup   bindingLookup =
                _bindingCompiler.Compile(DescriptorContext.Create(services));

            var types = new List <ITypeReference>(_types);

            if (_documents.Count > 0)
            {
                types.AddRange(ParseDocuments(services, bindingLookup));
            }

            var lazy = new LazySchema();

            TypeInitializer initializer =
                InitializeTypes(services, bindingLookup, types, () => lazy.Schema);

            SchemaDefinition definition = CreateSchemaDefinition(initializer);

            if (definition.QueryType == null && _options.StrictValidation)
            {
                // TODO : Resources
                throw new SchemaException(
                          SchemaErrorBuilder.New()
                          .SetMessage("No QUERY TYPE")
                          .Build());
            }

            var schema = new Schema(definition);

            lazy.Schema = schema;
            return(schema);
        }
        public void Merge_Should_DeepMerge_Configurations()
        {
            // arrange
            var convention = new MockFilterConvention(
                x => x.Configure <ComparableOperationFilterInput <int> >(d => d.Name("Foo")));
            var extension = new FilterConventionExtension(
                x => x.Configure <ComparableOperationFilterInput <int> >(d => d.Name("Bar")));
            var context = new ConventionContext(
                "Scope",
                new ServiceCollection().BuildServiceProvider(),
                DescriptorContext.Create());

            convention.Initialize(context);
            extension.Initialize(context);

            // act
            extension.Merge(context, convention);

            // assert
            Assert.NotNull(convention.DefinitionAccessor);
            List <ConfigureFilterInputType> configuration =
                Assert.Single(convention.DefinitionAccessor !.Configurations.Values) !;

            Assert.Equal(2, configuration.Count);
        }
Пример #4
0
    public void Merge_Should_Merge_ProviderExtensions()
    {
        // arrange
        var provider1  = new MockProviderExtensions();
        var convention = new MockProjectionConvention(x => x.AddProviderExtension(provider1));
        var provider2  = new MockProviderExtensions();
        var extension  =
            new ProjectionConventionExtension(x => x.AddProviderExtension(provider2));
        var context = new ConventionContext(
            "Scope",
            new ServiceCollection().BuildServiceProvider(),
            DescriptorContext.Create());

        convention.Initialize(context);
        extension.Initialize(context);

        // act
        extension.Merge(context, convention);

        // assert
        Assert.NotNull(convention.DefinitionAccessor);
        Assert.Collection(
            convention.DefinitionAccessor !.ProviderExtensions,
            x => Assert.Equal(provider1, x),
            x => Assert.Equal(provider2, x));
    }
Пример #5
0
        public void Register_ClrType_InferSchemaTypes()
        {
            // arrange
            var typeInterceptor = new AggregateTypeInterceptor();

            typeInterceptor.SetInterceptors(new[] { new IntrospectionTypeInterceptor() });
            IDescriptorContext context = DescriptorContext.Create(
                typeInterceptor: typeInterceptor);
            var typeRegistry = new TypeRegistry(context.TypeInterceptor);

            var typeInitializer = new TypeInitializer(
                context,
                typeRegistry,
                new List <ITypeReference>
            {
                context.TypeInspector.GetTypeRef(typeof(Foo), TypeContext.Output)
            },
                null,
                t =>
            {
                return(t switch
                {
                    ObjectType <Foo> => RootTypeKind.Query,
                    _ => RootTypeKind.None
                });
            });
Пример #6
0
        public void Merge_Should_DeepMerge_EnumConfigurations()
        {
            // arrange
            var convention = new MockSortConvention(
                x => x.ConfigureEnum <DefaultSortEnumType>(d => d.Name("Foo")));
            var extension = new SortConventionExtension(
                x => x.ConfigureEnum <DefaultSortEnumType>(d => d.Name("Foo")));
            var context = new ConventionContext(
                "Scope",
                new ServiceCollection().BuildServiceProvider(),
                DescriptorContext.Create());

            convention.Initialize(context);
            extension.Initialize(context);

            // act
            extension.Merge(context, convention);

            // assert
            Assert.NotNull(convention.DefinitionAccessor);
            List <ConfigureSortEnumType> configuration =
                Assert.Single(convention.DefinitionAccessor !.EnumConfigurations.Values) !;

            Assert.Equal(2, configuration.Count);
        }
Пример #7
0
        public void Register_ClrType_InferSchemaTypes()
        {
            // arrange
            var initialTypes = new List <ITypeReference>();

            initialTypes.Add(new ClrTypeReference(
                                 typeof(Foo),
                                 TypeContext.Output));

            var serviceProvider = new EmptyServiceProvider();

            var typeRegistrar = new TypeRegistrar(
                serviceProvider,
                DescriptorContext.Create(),
                initialTypes,
                new Dictionary <string, object>());

            // act
            typeRegistrar.Complete();

            // assert
            typeRegistrar.Registerd
            .Select(t => t.Value.Type)
            .OfType <IHasClrType>()
            .ToDictionary(
                t => t.GetType().GetTypeName(),
                t => t.ClrType.GetTypeName())
            .MatchSnapshot(new SnapshotNameExtension("registered"));

            typeRegistrar.ClrTypes.ToDictionary(
                t => t.Key.ToString(),
                t => t.Value.ToString())
            .MatchSnapshot(new SnapshotNameExtension("clr"));
        }
        public void Initializer_SchemaOptions_Are_Null()
        {
            // arrange
            IDescriptorContext context = DescriptorContext.Create(
                typeInterceptor: new AggregateTypeInterceptor(new IntrospectionTypeInterceptor()));
            var typeRegistry = new TypeRegistry();

            var typeInitializer = new TypeInitializer(
                context,
                typeRegistry,
                new List <ITypeReference>
            {
                context.TypeInspector.GetTypeRef(typeof(Foo), TypeContext.Output)
            },
                new List <Type>(),
                null !,
                t => t is ObjectType <Foo>,
                t => t is FooType);

            // act
            void Action() => typeInitializer.Initialize(() => null, null !);

            // assert
            Assert.Throws <ArgumentNullException>(Action);
        }
Пример #9
0
            private static DescriptorContext CreateContext(
                SchemaBuilder builder,
                LazySchema lazySchema)
            {
                IServiceProvider services = builder._services ?? new EmptyServiceProvider();
                var schemaInterceptors    = new List <ISchemaInterceptor>();
                var typeInterceptors      = new List <ITypeInitializationInterceptor>();

                InitializeInterceptors(services, builder._schemaInterceptors, schemaInterceptors);
                InitializeInterceptors(services, builder._typeInterceptors, typeInterceptors);

                var schemaInterceptor = new AggregateSchemaInterceptor(schemaInterceptors);
                var typeInterceptor   = new AggregateTypeInterceptor(typeInterceptors);

                DescriptorContext context = DescriptorContext.Create(
                    builder._options,
                    services,
                    builder._conventions,
                    builder._contextData,
                    lazySchema,
                    schemaInterceptor,
                    typeInterceptor);

                schemaInterceptor.OnBeforeCreate(context, builder);

                return(context);
            }
Пример #10
0
        public void Register_SchemaType_ClrTypeExists_NoSystemTypes()
        {
            // arrange
            var context      = DescriptorContext.Create();
            var typeRegistry = new TypeRegistry();
            var typeLookup   = new TypeLookup(context.TypeInspector, typeRegistry);

            var typeDiscoverer = new TypeDiscoverer(
                context,
                typeRegistry,
                typeLookup,
                new HashSet <ITypeReference>
            {
                _typeInspector.GetTypeRef(typeof(FooType), TypeContext.Output)
            },
                new AggregateTypeInterceptor(),
                false);

            // act
            IReadOnlyList <ISchemaError> errors = typeDiscoverer.DiscoverTypes();

            // assert
            Assert.Empty(errors);

            new
            {
                registered = typeRegistry.Types
                             .Select(t => new
                {
                    type        = t.Type.GetType().GetTypeName(),
                    runtimeType = t.Type is IHasRuntimeType hr
                            ? hr.RuntimeType.GetTypeName()
                            : null,
                    references = t.References.Select(t => t.ToString()).ToList()
                }).ToList(),
Пример #11
0
 public FilterFieldCollectionExtensionTest()
 {
     _property          = x => x.Bar;
     _propertyInfo      = (PropertyInfo)_property.ExtractMember();
     _descriptorContext = DescriptorContext.Create();
     _filterConvention  = new FilterConvention();
 }
Пример #12
0
        public void Initializer_SchemaOptions_Are_Null()
        {
            // arrange
            var initialTypes = new List <ITypeReference>();

            initialTypes.Add(new ClrTypeReference(
                                 typeof(Foo),
                                 TypeContext.Output));

            var serviceProvider = new EmptyServiceProvider();

            var typeInitializer = new TypeInitializer(
                serviceProvider,
                DescriptorContext.Create(),
                new Dictionary <string, object>(),
                initialTypes,
                new List <Type>(),
                new AggregateTypeInitializationInterceptor(),
                null,
                t => t is ObjectType <Foo>);

            // act
            Action action =
                () => typeInitializer.Initialize(() => null, null);

            // assert
            Assert.Throws <ArgumentNullException>(action);
        }
Пример #13
0
        protected override UnionTypeDefinition CreateDefinition(IInitializationContext context)
        {
            var descriptor = UnionTypeDescriptor.New(
                DescriptorContext.Create(context.Services),
                typeof(T));

            _configure(descriptor);
            return(descriptor.CreateDefinition());
        }
Пример #14
0
        protected override EnumTypeDefinition CreateDefinition(
            IInitializationContext context)
        {
            var descriptor = EnumTypeDescriptor.New <T>(
                DescriptorContext.Create(context.Services));

            _configure(descriptor);
            return(descriptor.CreateDefinition());
        }
Пример #15
0
        protected override ObjectTypeDefinition CreateDefinition(
            IInitializationContext context)
        {
            var descriptor = ObjectTypeDescriptor.New(
                DescriptorContext.Create(context.Services),
                GetType());

            _configure(descriptor);
            return(descriptor.CreateDefinition());
        }
Пример #16
0
        protected override DirectiveTypeDefinition CreateDefinition(
            IInitializationContext context)
        {
            var descriptor =
                DirectiveTypeDescriptor.New <TDirective>(
                    DescriptorContext.Create(context.Services));

            _conf(descriptor);
            return(descriptor.CreateDefinition());
        }
Пример #17
0
        public Schema Create()
        {
            IServiceProvider  services          = _services ?? new EmptyServiceProvider();
            DescriptorContext descriptorContext =
                DescriptorContext.Create(_options, services);

            IBindingLookup bindingLookup =
                _bindingCompiler.Compile(descriptorContext);

            var types = new List <ITypeReference>(_types);

            if (_documents.Count > 0)
            {
                types.AddRange(ParseDocuments(services, bindingLookup));
            }

            if (_schema == null)
            {
                types.Add(new SchemaTypeReference(new Schema()));
            }
            else
            {
                types.Add(_schema);
            }

            var lazy = new LazySchema();

            TypeInitializer initializer =
                InitializeTypes(
                    services,
                    descriptorContext,
                    bindingLookup,
                    types,
                    () => lazy.Schema);

            SchemaTypesDefinition definition =
                CreateSchemaDefinition(initializer);

            if (definition.QueryType == null && _options.StrictValidation)
            {
                throw new SchemaException(
                          SchemaErrorBuilder.New()
                          .SetMessage(TypeResources.SchemaBuilder_NoQueryType)
                          .Build());
            }

            Schema schema = initializer.Types.Values
                            .Select(t => t.Type)
                            .OfType <Schema>()
                            .First();

            schema.CompleteSchema(definition);
            lazy.Schema = schema;
            return(schema);
        }
Пример #18
0
        public void Ignore_ExpressionIsNull_ArgumentNullException()
        {
            // arrange
            var descriptor = InterfaceTypeDescriptor.New<IFoo>(DescriptorContext.Create());

            // act
            void Action() => descriptor.Ignore(null);

            // assert
            Assert.Throws<ArgumentNullException>(Action);
        }
        public Schema Create()
        {
            IServiceProvider services = _services ?? new EmptyServiceProvider();

            var descriptorContext = DescriptorContext.Create(
                _options,
                services,
                CreateConventions(services),
                _contextData);

            foreach (Action <IDescriptorContext> action in _onBeforeCreate)
            {
                action(descriptorContext);
            }

            IBindingLookup bindingLookup =
                _bindingCompiler.Compile(descriptorContext);

            IReadOnlyCollection <ITypeReference> types =
                GetTypeReferences(services, bindingLookup);

            var lazy = new LazySchema();

            TypeInitializer initializer =
                CreateTypeInitializer(
                    services,
                    descriptorContext,
                    bindingLookup,
                    types);

            DiscoveredTypes discoveredTypes = initializer.Initialize(() => lazy.Schema, _options);

            SchemaTypesDefinition definition = CreateSchemaDefinition(initializer, discoveredTypes);

            if (definition.QueryType == null && _options.StrictValidation)
            {
                throw new SchemaException(
                          SchemaErrorBuilder.New()
                          .SetMessage(TypeResources.SchemaBuilder_NoQueryType)
                          .Build());
            }

            Schema schema = discoveredTypes.Types
                            .Select(t => t.Type)
                            .OfType <Schema>()
                            .First();

            schema.CompleteSchema(definition);
            lazy.Schema = schema;
            TypeInspector.Default.Clear();
            return(schema);
        }
Пример #20
0
 private void AddRelayNodeField(
     ICompletionContext context,
     ICollection <ObjectField> fields)
 {
     if (context.IsQueryType.HasValue &&
         context.IsQueryType.Value &&
         context.ContextData.ContainsKey(
             RelayConstants.IsRelaySupportEnabled))
     {
         fields.Add(new NodeField(
                        DescriptorContext.Create(context.Services)));
     }
 }
Пример #21
0
        public void Ignore_ExpressionIsNull_ArgumentNullException()
        {
            // arrange
            InterfaceTypeDescriptor <IFoo> descriptor =
                InterfaceTypeDescriptor.New <IFoo>(DescriptorContext.Create());

            // act
            Action action = () =>
                            InterfaceTypeDescriptorExtensions
                            .Ignore(descriptor, null);

            // assert
            Assert.Throws <ArgumentNullException>(action);
        }
Пример #22
0
        private void AddIntrospectionFields(
            ICompletionContext context,
            ICollection <ObjectField> fields)
        {
            IDescriptorContext descriptorContext =
                DescriptorContext.Create(context.Services);

            if (context.IsQueryType.HasValue && context.IsQueryType.Value)
            {
                fields.Add(new __SchemaField(descriptorContext));
                fields.Add(new __TypeField(descriptorContext));
            }

            fields.Add(new __TypeNameField(descriptorContext));
        }
Пример #23
0
        public void Ignore_ExpressionIsNull_ArgumentNullException()
        {
            // arrange
            DirectiveTypeDescriptor <CustomDirective2> descriptor =
                DirectiveTypeDescriptor.New <CustomDirective2>(
                    DescriptorContext.Create());

            // act
            Action action = () =>
                            DirectiveTypeDescriptorExtensions
                            .Ignore(descriptor, null);

            // assert
            Assert.Throws <ArgumentNullException>(action);
        }
Пример #24
0
        public void Register_ClrType_InferSchemaTypes()
        {
            // arrange
            var initialTypes = new List <ITypeReference>();

            initialTypes.Add(TypeReference.Create(
                                 typeof(Foo),
                                 TypeContext.Output));

            var serviceProvider = new EmptyServiceProvider();

            var typeInitializer = new TypeInitializer(
                serviceProvider,
                DescriptorContext.Create(),
                initialTypes,
                new List <Type>(),
                new AggregateTypeInitializationInterceptor(),
                null,
                t => t is ObjectType <Foo>);

            // act
            typeInitializer.Initialize(() => null, new SchemaOptions());

            // assert
            bool exists = typeInitializer.DiscoveredTypes.TryGetType(
                TypeReference.Create(
                    typeof(ObjectType <Foo>),
                    TypeContext.Output),
                out RegisteredType type);

            Assert.True(exists);
            Dictionary <string, string> fooType =
                Assert.IsType <ObjectType <Foo> >(type.Type).Fields.ToDictionary(
                    t => t.Name.ToString(),
                    t => TypeVisualizer.Visualize(t.Type));

            exists = typeInitializer.DiscoveredTypes.TryGetType(
                TypeReference.Create(typeof(ObjectType <Bar>), TypeContext.Output),
                out type);

            Assert.True(exists);
            Dictionary <string, string> barType =
                Assert.IsType <ObjectType <Bar> >(type.Type).Fields.ToDictionary(
                    t => t.Name.ToString(),
                    t => TypeVisualizer.Visualize(t.Type));

            new { fooType, barType }.MatchSnapshot();
        }
Пример #25
0
        private void RegisterExternalResolvers()
        {
            if (_externalResolverTypes.Count == 0)
            {
                return;
            }

            IDescriptorContext descriptorContext =
                DescriptorContext.Create(_services);

            Dictionary <NameString, ObjectType> types =
                _types.Select(t => t.Value.Type)
                .OfType <ObjectType>()
                .ToDictionary(t => t.Name);

            foreach (Type type in _externalResolverTypes)
            {
                GraphQLResolverOfAttribute attribute =
                    type.GetCustomAttribute <GraphQLResolverOfAttribute>();

                if (attribute.TypeNames != null)
                {
                    foreach (string typeName in attribute.TypeNames)
                    {
                        if (types.TryGetValue(typeName,
                                              out ObjectType objectType))
                        {
                            AddResolvers(descriptorContext, objectType, type);
                        }
                    }
                }

                if (attribute.Types != null)
                {
                    foreach (Type sourceType in attribute.Types
                             .Where(t => !BaseTypes.IsNonGenericBaseType(t)))
                    {
                        ObjectType objectType = types.Values
                                                .FirstOrDefault(t => t.GetType() == sourceType);
                        if (objectType != null)
                        {
                            AddResolvers(descriptorContext, objectType, type);
                        }
                    }
                }
            }
        }
Пример #26
0
        public void Register_ClrType_InferSchemaTypes()
        {
            // arrange
            var initialTypes = new List <ITypeReference>();

            initialTypes.Add(new ClrTypeReference(
                                 typeof(Foo),
                                 TypeContext.Output));

            var serviceProvider = new EmptyServiceProvider();

            var typeInitializer = new TypeInitializer(
                serviceProvider,
                DescriptorContext.Create(),
                initialTypes,
                new List <Type>(),
                new Dictionary <string, object>(),
                null,
                t => t is ObjectType <Foo>);

            // act
            typeInitializer.Initialize(() => null, new SchemaOptions());

            // assert
            bool exists = typeInitializer.Types.TryGetValue(
                new ClrTypeReference(
                    typeof(ObjectType <Foo>),
                    TypeContext.Output),
                out RegisteredType type);

            Assert.True(exists);
            Assert.IsType <ObjectType <Foo> >(type.Type).Fields.ToDictionary(
                t => t.Name.ToString(),
                t => TypeVisualizer.Visualize(t.Type))
            .MatchSnapshot(new SnapshotNameExtension("FooType"));

            exists = typeInitializer.Types.TryGetValue(
                new ClrTypeReference(typeof(ObjectType <Bar>), TypeContext.Output),
                out type);

            Assert.True(exists);
            Assert.IsType <ObjectType <Bar> >(type.Type).Fields.ToDictionary(
                t => t.Name.ToString(),
                t => TypeVisualizer.Visualize(t.Type))
            .MatchSnapshot(new SnapshotNameExtension("BarType"));
        }
Пример #27
0
        public void Register_SchemaType_ClrTypeExists()
        {
            // arrange
            var typeInterceptor = new AggregateTypeInterceptor();

            typeInterceptor.SetInterceptors(new[] { new IntrospectionTypeInterceptor() });
            IDescriptorContext context = DescriptorContext.Create(
                typeInterceptor: typeInterceptor);
            var typeRegistry = new TypeRegistry(context.TypeInterceptor);

            var typeInitializer = new TypeInitializer(
                context,
                typeRegistry,
                new List <ITypeReference>
            {
                context.TypeInspector.GetTypeRef(typeof(FooType), TypeContext.Output)
            },
                null,
                t => t is FooType ? RootTypeKind.Query : RootTypeKind.None);

            // act
            typeInitializer.Initialize(() => null, new SchemaOptions());

            // assert
            var exists = typeRegistry.TryGetType(
                context.TypeInspector.GetTypeRef(typeof(FooType), TypeContext.Output),
                out RegisteredType type);

            Assert.True(exists);
            var fooType =
                Assert.IsType <FooType>(type.Type).Fields.ToDictionary(
                    t => t.Name.ToString(),
                    t => t.Type.Print());

            exists = typeRegistry.TryGetType(
                context.TypeInspector.GetTypeRef(typeof(BarType), TypeContext.Output),
                out type);

            Assert.True(exists);
            var barType =
                Assert.IsType <BarType>(type.Type).Fields.ToDictionary(
                    t => t.Name.ToString(),
                    t => t.Type.Print());

            new { fooType, barType }.MatchSnapshot();
        }
Пример #28
0
        public Schema Create()
        {
            IServiceProvider services = _services
                                        ?? new EmptyServiceProvider();

            var descriptorContext = DescriptorContext.Create(
                _options,
                services,
                CreateConventions(services));

            IBindingLookup bindingLookup =
                _bindingCompiler.Compile(descriptorContext);

            IReadOnlyCollection <ITypeReference> types =
                GetTypeReferences(services, bindingLookup);

            var lazy = new LazySchema();

            TypeInitializer initializer =
                InitializeTypes(
                    services,
                    descriptorContext,
                    bindingLookup,
                    types,
                    () => lazy.Schema);

            SchemaTypesDefinition definition =
                CreateSchemaDefinition(initializer);

            if (definition.QueryType == null && _options.StrictValidation)
            {
                throw new SchemaException(
                          SchemaErrorBuilder.New()
                          .SetMessage(TypeResources.SchemaBuilder_NoQueryType)
                          .Build());
            }

            Schema schema = initializer.Types.Values
                            .Select(t => t.Type)
                            .OfType <Schema>()
                            .First();

            schema.CompleteSchema(definition);
            lazy.Schema = schema;
            return(schema);
        }
        public void Register_ClrType_InferSchemaTypes()
        {
            // arrange
            IDescriptorContext context = DescriptorContext.Create(
                typeInterceptor: new AggregateTypeInterceptor(new IntrospectionTypeInterceptor()));
            var typeRegistry = new TypeRegistry();

            var typeInitializer = new TypeInitializer(
                context,
                typeRegistry,
                new List <ITypeReference>
            {
                context.TypeInspector.GetTypeRef(typeof(Foo), TypeContext.Output)
            },
                new List <Type>(),
                null,
                t => t is ObjectType <Foo>,
                t => t is FooType);

            // act
            typeInitializer.Initialize(() => null, new SchemaOptions());

            // assert
            var exists = typeRegistry.TryGetType(
                context.TypeInspector.GetTypeRef(typeof(ObjectType <Foo>), TypeContext.Output),
                out RegisteredType type);

            Assert.True(exists);
            var fooType =
                Assert.IsType <ObjectType <Foo> >(type.Type).Fields.ToDictionary(
                    t => t.Name.ToString(),
                    t => t.Type.Print());

            exists = typeRegistry.TryGetType(
                context.TypeInspector.GetTypeRef(typeof(ObjectType <Bar>), TypeContext.Output),
                out type);

            Assert.True(exists);
            var barType =
                Assert.IsType <ObjectType <Bar> >(type.Type).Fields.ToDictionary(
                    t => t.Name.ToString(),
                    t => t.Type.Print());

            new { fooType, barType }.MatchSnapshot();
        }
            private static DescriptorContext CreateContext(
                SchemaBuilder builder,
                LazySchema lazySchema)
            {
                DescriptorContext context = DescriptorContext.Create(
                    builder._options,
                    builder._services ?? new EmptyServiceProvider(),
                    builder._conventions,
                    builder._contextData,
                    lazySchema);

                foreach (Action <IDescriptorContext> action in builder._onBeforeCreate)
                {
                    action(context);
                }

                return(context);
            }