public void PopulateFields(DetailsStore store) { FieldDetails = raw.Fields .Select(field => new UnityFieldDetails(field, store)) .ToList() .AsReadOnly(); }
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; }
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; }
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(); } }
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(); } }
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(); }
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(); }
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(); }
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(); }
public void Populate(DetailsStore store) { PopulateChildren(store); PopulateFields(store); }
public MapFieldType(TypeReference keyType, TypeReference valueType, DetailsStore store) { this.keyType = new ContainedType(keyType); this.valueType = new ContainedType(valueType); }
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; }
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; }
public OptionFieldType(TypeReference innerType, DetailsStore store) { containedType = new ContainedType(innerType); }
public SingularFieldType(TypeReference innerType, DetailsStore store) { containedType = new ContainedType(innerType); }
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; }
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; }