Exemplo n.º 1
0
        public void MarksComponentsAsBlittableAccordingToReferencedTypes()
        {
            var processedSchemaFiles = new UnitySchemaProcessor(new[]
            {
                new SchemaFileRaw
                {
                    completePath    = fakeFileName,
                    enumDefinitions = new EnumDefinitionRaw[0],
                    typeDefinitions = new[]
                    {
                        new TypeDefinitionRaw
                        {
                            qualifiedName    = "usertypewithint32",
                            enumDefinitions  = new EnumDefinitionRaw[0],
                            fieldDefinitions = new[]
                            {
                                new FieldDefinitionRaw
                                {
                                    singularType = new TypeReferenceRaw
                                    {
                                        builtInType = "int32"
                                    }
                                }
                            }
                        },
                        new TypeDefinitionRaw
                        {
                            qualifiedName    = "usertypewithstring",
                            enumDefinitions  = new EnumDefinitionRaw[0],
                            fieldDefinitions = new[]
                            {
                                new FieldDefinitionRaw
                                {
                                    singularType = new TypeReferenceRaw
                                    {
                                        builtInType = "string"
                                    }
                                }
                            }
                        }
                    },
                    componentDefinitions = new[]
                    {
                        new ComponentDefinitionRaw
                        {
                            name           = "component-with-int",
                            dataDefinition = new TypeReferenceRaw
                            {
                                userType = "usertypewithint32"
                            }
                        },
                        new ComponentDefinitionRaw
                        {
                            name           = "component-with-string",
                            dataDefinition = new TypeReferenceRaw
                            {
                                userType = "usertypewithstring"
                            }
                        }
                    }
                }
            }).ProcessedSchemaFiles;

            BlittableFlagger.SetBlittableFlags(processedSchemaFiles);

            Assert.IsTrue(
                processedSchemaFiles.First().ComponentDefinitions
                .Find(definition => definition.Name == "component-with-int").IsBlittable,
                "Components with int types should be blittable");
            Assert.IsFalse(
                processedSchemaFiles.First().ComponentDefinitions
                .Find(definition => definition.Name == "component-with-string").IsBlittable,
                "Components with string types should not be blittable");
        }
Exemplo n.º 2
0
        private void BuildTestProcessedSchemaFiles()
        {
            var processedSchemaFiles = new UnitySchemaProcessor(new[]
            {
                new SchemaFileRaw
                {
                    completePath    = fakeFileName,
                    enumDefinitions = new EnumDefinitionRaw[0],
                    typeDefinitions = new[]
                    {
                        new TypeDefinitionRaw
                        {
                            qualifiedName    = "usertypewithint32",
                            enumDefinitions  = new EnumDefinitionRaw[0],
                            fieldDefinitions = new[]
                            {
                                new FieldDefinitionRaw
                                {
                                    singularType = new TypeReferenceRaw
                                    {
                                        builtInType = "int32"
                                    }
                                }
                            }
                        },
                        new TypeDefinitionRaw
                        {
                            qualifiedName    = "usertypewithstring",
                            enumDefinitions  = new EnumDefinitionRaw[0],
                            fieldDefinitions = new[]
                            {
                                new FieldDefinitionRaw
                                {
                                    singularType = new TypeReferenceRaw
                                    {
                                        builtInType = "string"
                                    }
                                }
                            }
                        }
                    },
                    componentDefinitions = new[]
                    {
                        new ComponentDefinitionRaw
                        {
                            name           = "component-with-int",
                            dataDefinition = new TypeReferenceRaw
                            {
                                userType = "usertypewithint32"
                            }
                        },
                        new ComponentDefinitionRaw
                        {
                            name           = "component-with-string",
                            dataDefinition = new TypeReferenceRaw
                            {
                                userType = "usertypewithstring"
                            }
                        }
                    }
                }
            }).ProcessedSchemaFiles;

            BlittableFlagger.SetBlittableFlags(processedSchemaFiles);

            BlittableComponentDefinition = processedSchemaFiles.First().ComponentDefinitions
                                           .Find(definition => definition.Name == "component-with-int");
            NonBlittableComponentDefinition = processedSchemaFiles.First().ComponentDefinitions
                                              .Find(definition => definition.Name == "component-with-string");

            BlittableFieldDefinition = BlittableComponentDefinition.DataDefinition.typeDefinition.FieldDefinitions
                                       .First();
            NonBlittableFieldDefinition = NonBlittableComponentDefinition.DataDefinition.typeDefinition.FieldDefinitions
                                          .First();
        }