public ValueStructFieldModel( int offset, string name, string visibility, string type, string accessor, IEnumerable <string>?documentation, ValueStructSchemaModel parent, IFlatSharpAttributes attributes) { this.Offset = offset; this.Name = name; this.Visibility = visibility; this.TypeName = type; this.Accessor = accessor; this.Documentation = documentation; new FlatSharpAttributeValidator(FlatBufferSchemaElementType.ValueStructField, $"{parent.Name}.{name}").Validate(attributes); }
public ValueStructVectorModel( string type, string name, List <string> properties, ValueStructSchemaModel parent, IEnumerable <string>?documentation, IFlatSharpAttributes attributes) { this.Name = name; this.TypeName = type; this.Name = name; this.Properties = properties; this.Attributes = attributes; this.Documentation = documentation; new FlatSharpAttributeValidator(FlatBufferSchemaElementType.ValueStructField, $"{parent.Name}.{name}") { UnsafeStructVectorValidator = _ => AttributeValidationResult.Valid, }.Validate(attributes); }
public void Validate(IFlatSharpAttributes attributes) { void RegisterError(string key, AttributeValidationResult result, object value) { if (!result.IsValid) { ErrorContext.Current.RegisterError(result.ToString(this.ElementType, key, value?.ToString() ?? string.Empty)); } } if (attributes.NonVirtual is not null) { RegisterError(MetadataKeys.NonVirtualProperty, this.NonVirtualValidator(attributes.NonVirtual.Value), attributes.NonVirtual.Value); } if (attributes.DeserializationOption is not null) { RegisterError(MetadataKeys.SerializerKind, this.DeserializationOptionValidator(attributes.DeserializationOption.Value), attributes.DeserializationOption.Value); } if (attributes.SortedVector is not null) { RegisterError(MetadataKeys.SortedVector, this.SortedVectorValidator(attributes.SortedVector.Value), attributes.SortedVector.Value); } if (attributes.SharedString is not null) { RegisterError(MetadataKeys.SharedString, this.SharedStringValidator(attributes.SharedString.Value), attributes.SharedString.Value); } if (attributes.DefaultCtorKind is not null) { RegisterError(MetadataKeys.DefaultConstructorKind, this.DefaultConstructorValidator(attributes.DefaultCtorKind.Value), attributes.DefaultCtorKind.Value); } if (attributes.SetterKind is not null) { RegisterError(MetadataKeys.Setter, this.SetterKindValidator(attributes.SetterKind.Value), attributes.SetterKind.Value); } if (attributes.ForceWrite is not null) { RegisterError(MetadataKeys.ForceWrite, this.ForceWriteValidator(attributes.ForceWrite.Value), attributes.ForceWrite.Value); } if (attributes.UnsafeStructVector is not null) { RegisterError(MetadataKeys.UnsafeValueStructVector, this.UnsafeStructVectorValidator(attributes.UnsafeStructVector.Value), attributes.UnsafeStructVector.Value); } if (attributes.MemoryMarshalBehavior is not null) { RegisterError(MetadataKeys.MemoryMarshalBehavior, this.MemoryMarshalValidator(attributes.MemoryMarshalBehavior.Value), attributes.MemoryMarshalBehavior.Value); } if (attributes.VectorKind is not null) { RegisterError(MetadataKeys.VectorKind, this.VectorTypeValidator(attributes.VectorKind.Value), attributes.VectorKind.Value); } if (attributes.WriteThrough is not null) { RegisterError(MetadataKeys.WriteThrough, this.WriteThroughValidator(attributes.WriteThrough.Value), attributes.WriteThrough.Value); } if (attributes.RpcInterface is not null) { RegisterError(MetadataKeys.RpcInterface, this.RpcInterfaceValidator(attributes.RpcInterface.Value), attributes.RpcInterface.Value); } if (attributes.StreamingType is not null) { RegisterError(MetadataKeys.Streaming, this.StreamingTypeValidator(attributes.StreamingType.Value), attributes.StreamingType.Value); } }