コード例 #1
0
 public void PopulateFields(DetailsStore store)
 {
     FieldDetails = raw.Fields
                    .Select(field => new UnityFieldDetails(field, store))
                    .ToList()
                    .AsReadOnly();
 }
コード例 #2
0
        public UnityFieldDetails(FieldDefinition field, DetailsStore store)
        {
            PascalCaseName = Formatting.SnakeCaseToPascalCase(field.Name);
            CamelCaseName  = Formatting.PascalCaseToCamelCase(PascalCaseName);
            FieldNumber    = field.FieldId;

            IsBlittable = store.CheckBlittable(field);

            if (field.OptionType != null)
            {
                CanBeEmpty = true;
                fieldType  = new OptionFieldType(field.OptionType.InnerType, store);
            }
            else if (field.ListType != null)
            {
                CanBeEmpty = true;
                fieldType  = new ListFieldType(field.ListType.InnerType, store);
            }
            else if (field.MapType != null)
            {
                CanBeEmpty = true;
                fieldType  = new MapFieldType(field.MapType.KeyType, field.MapType.ValueType, store);
            }
            else
            {
                var singularType = field.SingularType.Type;
                fieldType = new SingularFieldType(singularType, store);
            }

            Raw = field;
        }
コード例 #3
0
        public UnityFieldDetails(FieldDefinition rawFieldDefinition, DetailsStore store) : base(rawFieldDefinition)
        {
            fieldNumber = rawFieldDefinition.FieldId;

            IsBlittable = store.CheckBlittable(rawFieldDefinition);

            if (rawFieldDefinition.OptionType != null)
            {
                CanBeEmpty = true;
                FieldType  = new OptionFieldType(rawFieldDefinition.OptionType.InnerType);
            }
            else if (rawFieldDefinition.ListType != null)
            {
                CanBeEmpty = true;
                FieldType  = new ListFieldType(rawFieldDefinition.ListType.InnerType);
            }
            else if (rawFieldDefinition.MapType != null)
            {
                CanBeEmpty = true;
                FieldType  = new MapFieldType(rawFieldDefinition.MapType.KeyType, rawFieldDefinition.MapType.ValueType);
            }
            else
            {
                FieldType = new SingularFieldType(rawFieldDefinition.SingularType.Type);
            }

            RawFieldDefinition = rawFieldDefinition;
        }
コード例 #4
0
 public void PopulateFields(DetailsStore store)
 {
     if (!string.IsNullOrEmpty(raw.DataDefinition))
     {
         FieldDetails = store.Types[raw.DataDefinition].FieldDetails;
     }
     else
     {
         FieldDetails = raw.Fields
                        .Select(field => new UnityFieldDetails(field, store))
                        .ToList()
                        .AsReadOnly();
     }
 }
コード例 #5
0
 public void PopulateFields(DetailsStore store)
 {
     Logger.Trace($"Populating field details for component {rawComponentDefinition.QualifiedName}.");
     if (!string.IsNullOrEmpty(rawComponentDefinition.DataDefinition))
     {
         FieldDetails = store.Types[rawComponentDefinition.DataDefinition].FieldDetails;
     }
     else
     {
         FieldDetails = rawComponentDefinition.Fields
                        .Select(field => new UnityFieldDetails(field, store))
                        .ToList()
                        .AsReadOnly();
     }
 }
コード例 #6
0
        private void PopulateChildren(DetailsStore store)
        {
            var children = store.GetNestedTypes(raw.QualifiedName);

            ChildTypes = store.Types
                         .Where(kv => children.Contains(kv.Key))
                         .Select(kv => kv.Value)
                         .ToList()
                         .AsReadOnly();

            ChildEnums = store.Enums
                         .Where(kv => children.Contains(kv.Key))
                         .Select(kv => kv.Value)
                         .ToList()
                         .AsReadOnly();
        }
コード例 #7
0
        private void PopulateChildren(DetailsStore store)
        {
            var children = store.GetNestedTypes(rawTypeDefinition.QualifiedName);

            Logger.Trace($"Populating child type details for type {rawTypeDefinition.QualifiedName}.");
            ChildTypes = store.Types
                         .Where(kv => children.Contains(kv.Key))
                         .Select(kv => kv.Value)
                         .ToList()
                         .AsReadOnly();

            Logger.Trace($"Populating child enum details for type {rawTypeDefinition.QualifiedName}.");
            ChildEnums = store.Enums
                         .Where(kv => children.Contains(kv.Key))
                         .Select(kv => kv.Value)
                         .ToList()
                         .AsReadOnly();
        }
コード例 #8
0
        private void PopulateFields(DetailsStore store)
        {
            Logger.Trace($"Populating field details for type {rawTypeDefinition.QualifiedName}.");
            FieldDetails = rawTypeDefinition.Fields
                           .Select(field => new UnityFieldDetails(field, store))
                           .Where(fieldDetail =>
            {
                var clashingChildEnums = ChildEnums
                                         .Where(childEnum =>
                {
                    // When field does not clash with child enum, return false
                    if (!fieldDetail.PascalCaseName.Equals(childEnum.Name))
                    {
                        return(false);
                    }

                    Logger.Error($"Error in type \"{Name}\". Field \"{fieldDetail.RawFieldDefinition.Name}\" clashes with child enum \"{childEnum.Name}\".");
                    return(true);
                });

                var clashingChildTypes = ChildTypes
                                         .Where(childType =>
                {
                    // When field does not clash with child type, return false
                    if (!fieldDetail.PascalCaseName.Equals(childType.Name))
                    {
                        return(false);
                    }

                    Logger.Error($"Error in type \"{Name}\". Field \"{fieldDetail.RawFieldDefinition.Name}\" clashes with child type \"{childType.CamelCaseName}\".");
                    return(true);
                });

                // Only return true if the field has no name clashes with child enums and types
                return(!clashingChildEnums.Any() && !clashingChildTypes.Any());
            })
                           .ToList()
                           .AsReadOnly();
        }
コード例 #9
0
        private void PopulateFields(DetailsStore store)
        {
            FieldDetails = raw.Fields
                           .Select(field => new UnityFieldDetails(field, store))
                           .Where(fieldDetail =>
            {
                var clashingChildEnums = ChildEnums
                                         .Where(childEnum =>
                {
                    // When field does not clash with child enum, return false
                    if (!fieldDetail.PascalCaseName.Equals(childEnum.TypeName))
                    {
                        return(false);
                    }

                    Console.Error.WriteLine($"Error in type \"{CapitalisedName}\". Field \"{fieldDetail.Raw.Name}\" clashes with child enum \"{childEnum.TypeName}\".");
                    return(true);
                });

                var clashingChildTypes = ChildTypes
                                         .Where(childType =>
                {
                    // When field does not clash with child type, return false
                    if (!fieldDetail.PascalCaseName.Equals(childType.CapitalisedName))
                    {
                        return(false);
                    }

                    Console.Error.WriteLine($"Error in type \"{CapitalisedName}\". Field \"{fieldDetail.Raw.Name}\" clashes with child type \"{childType.CamelCaseName}\".");
                    return(true);
                });

                // Only return true if the field has no name clashes with child enums and types
                return(!clashingChildEnums.Any() && !clashingChildTypes.Any());
            })
                           .ToList()
                           .AsReadOnly();
        }
コード例 #10
0
 public void Populate(DetailsStore store)
 {
     PopulateChildren(store);
     PopulateFields(store);
 }
コード例 #11
0
 public MapFieldType(TypeReference keyType, TypeReference valueType, DetailsStore store)
 {
     this.keyType   = new ContainedType(keyType);
     this.valueType = new ContainedType(valueType);
 }
コード例 #12
0
        public UnityComponentDetails(string package, ComponentDefinition componentDefinitionRaw, DetailsStore store)
        {
            Package       = package;
            ComponentName = componentDefinitionRaw.Name;
            ComponentId   = componentDefinitionRaw.ComponentId;
            IsBlittable   = store.BlittableSet.Contains(componentDefinitionRaw.QualifiedName);

            CommandDetails = componentDefinitionRaw.Commands
                             .Select(command => new UnityCommandDetails(command))
                             .Where(commandDetail =>
            {
                // Return true to keep commands that do not have a name clash with the component
                if (!commandDetail.CommandName.Equals(ComponentName))
                {
                    return(true);
                }

                Console.Error.WriteLine($"Error in component \"{ComponentName}\". Command \"{commandDetail.RawCommandName}\" clashes with component name.");
                return(false);
            })
                             .ToList()
                             .AsReadOnly();

            EventDetails = componentDefinitionRaw.Events
                           .Select(ev => new UnityEventDetails(ev))
                           .Where(eventDetail =>
            {
                // Return true to keep events that do not have a name clash with the component
                if (!eventDetail.EventName.Equals(ComponentName))
                {
                    return(true);
                }

                Console.Error.WriteLine($"Error in component \"{ComponentName}\". Event \"{eventDetail.RawEventName}\" clashes with component name.");
                return(false);
            })
                           .ToList()
                           .AsReadOnly();

            raw = componentDefinitionRaw;
        }
コード例 #13
0
        public UnityComponentDetails(string package, ComponentDefinition componentDefinitionRaw, DetailsStore store)
        {
            Package       = package;
            ComponentName = componentDefinitionRaw.Name;
            ComponentId   = componentDefinitionRaw.ComponentId;
            IsBlittable   = store.BlittableSet.Contains(componentDefinitionRaw.QualifiedName);

            CommandDetails = componentDefinitionRaw.Commands
                             .Select(command => new UnityCommandDetails(command))
                             .ToList()
                             .AsReadOnly();

            EventDetails = componentDefinitionRaw.Events
                           .Select(ev => new UnityEventDetails(ev))
                           .ToList()
                           .AsReadOnly();

            raw = componentDefinitionRaw;
        }
コード例 #14
0
 public OptionFieldType(TypeReference innerType, DetailsStore store)
 {
     containedType = new ContainedType(innerType);
 }
コード例 #15
0
 public SingularFieldType(TypeReference innerType, DetailsStore store)
 {
     containedType = new ContainedType(innerType);
 }
コード例 #16
0
        public UnityComponentDetails(string package, ComponentDefinition rawComponentDefinition, DetailsStore store)
            : base(package, rawComponentDefinition)
        {
            ComponentId = rawComponentDefinition.ComponentId;

            IsBlittable = store.BlittableSet.Contains(rawComponentDefinition.QualifiedName);

            Logger.Trace($"Populating command details for component {rawComponentDefinition.QualifiedName}.");
            CommandDetails = rawComponentDefinition.Commands
                             .Select(command => new UnityCommandDetails(command))
                             .Where(commandDetail =>
            {
                // Return true to keep commands that do not have a name clash with the component
                if (!commandDetail.PascalCaseName.Equals(Name))
                {
                    return(true);
                }

                Logger.Error($"Error in component \"{Name}\". Command \"{commandDetail.PascalCaseName}\" clashes with component name.");
                return(false);
            })
                             .ToList()
                             .AsReadOnly();

            Logger.Trace($"Populating event details for component {rawComponentDefinition.QualifiedName}.");
            EventDetails = rawComponentDefinition.Events
                           .Select(ev => new UnityEventDetails(ev))
                           .Where(eventDetail =>
            {
                // Return true to keep events that do not have a name clash with the component
                if (!eventDetail.PascalCaseName.Equals(Name))
                {
                    return(true);
                }

                Logger.Error($"Error in component \"{Name}\". Event \"{eventDetail.PascalCaseName}\" clashes with component name.");
                return(false);
            })
                           .ToList()
                           .AsReadOnly();

            var annotations = new Dictionary <string, List <Annotation> >();

            foreach (var annotation in rawComponentDefinition.Annotations)
            {
                if (!annotations.TryGetValue(annotation.TypeValue.Type, out var list))
                {
                    list = new List <Annotation>();
                    annotations[annotation.TypeValue.Type] = list;
                }

                list.Add(annotation);
            }

            Annotations = annotations;

            this.rawComponentDefinition = rawComponentDefinition;
        }
コード例 #17
0
        public UnityComponentDetails(string package, ComponentDefinition rawComponentDefinition, DetailsStore store)
            : base(package, rawComponentDefinition)
        {
            ComponentId = rawComponentDefinition.ComponentId;

            IsBlittable = store.BlittableSet.Contains(rawComponentDefinition.QualifiedName);

            Logger.Trace($"Populating command details for component {rawComponentDefinition.QualifiedName}.");
            CommandDetails = rawComponentDefinition.Commands
                .Select(command => new UnityCommandDetails(command))
                .Where(commandDetail =>
                {
                    // Return true to keep commands that do not have a name clash with the component
                    if (!commandDetail.PascalCaseName.Equals(Name))
                    {
                        return true;
                    }

                    Logger.Error($"Error in component \"{Name}\". Command \"{commandDetail.PascalCaseName}\" clashes with component name.");
                    return false;
                })
                .ToList()
                .AsReadOnly();

            Logger.Trace($"Populating event details for component {rawComponentDefinition.QualifiedName}.");
            EventDetails = rawComponentDefinition.Events
                .Select(ev => new UnityEventDetails(ev))
                .Where(eventDetail =>
                {
                    // Return true to keep events that do not have a name clash with the component
                    if (!eventDetail.PascalCaseName.Equals(Name))
                    {
                        return true;
                    }

                    Logger.Error($"Error in component \"{Name}\". Event \"{eventDetail.PascalCaseName}\" clashes with component name.");
                    return false;
                })
                .ToList()
                .AsReadOnly();

            this.rawComponentDefinition = rawComponentDefinition;
        }