Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions NetCord/Rest/ComponentProperties/ComponentSectionProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace NetCord.Rest;

[GenerateMethodsForProperties]
public partial class ComponentSectionProperties(IComponentSectionAccessoryComponentProperties accessory, IEnumerable<TextDisplayProperties> components) : IMessageComponentProperties, IComponentContainerComponentProperties, IComponentSectionProperties, IEnumerable<TextDisplayProperties>
public partial class ComponentSectionProperties(IComponentSectionAccessoryComponentProperties accessory, IEnumerable<IComponentSectionComponentProperties> components) : IMessageComponentProperties, IComponentContainerComponentProperties, IComponentSectionProperties, IEnumerable<IComponentSectionComponentProperties>
{
public ComponentSectionProperties(IComponentSectionAccessoryComponentProperties accessory) : this(accessory, [])
{
Expand All @@ -16,12 +16,12 @@ public ComponentSectionProperties(IComponentSectionAccessoryComponentProperties

public ComponentType ComponentType => ComponentType.Section;

public IEnumerable<TextDisplayProperties> Components { get; set; } = components;
public IEnumerable<IComponentSectionComponentProperties> Components { get; set; } = components;

public IComponentSectionAccessoryComponentProperties Accessory { get; set; } = accessory;

[EditorBrowsable(EditorBrowsableState.Never)]
public void Add(TextDisplayProperties component) => AddComponents(component);
public void Add(IComponentSectionComponentProperties component) => AddComponents(component);

private void WriteTo(Utf8JsonWriter writer)
{
Expand All @@ -38,14 +38,14 @@ void IJsonSerializable<IComponentContainerComponentProperties>.WriteTo(Utf8JsonW
WriteTo(writer);
}

IEnumerator<TextDisplayProperties> IEnumerable<TextDisplayProperties>.GetEnumerator() => Components.GetEnumerator();
IEnumerator<IComponentSectionComponentProperties> IEnumerable<IComponentSectionComponentProperties>.GetEnumerator() => Components.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable)Components).GetEnumerator();
}

internal interface IComponentSectionProperties : IComponentProperties
{
[JsonPropertyName("components")]
public IEnumerable<TextDisplayProperties> Components { get; }
public IEnumerable<IComponentSectionComponentProperties> Components { get; }

[JsonPropertyName("accessory")]
public IComponentSectionAccessoryComponentProperties Accessory { get; }
Expand Down
7 changes: 6 additions & 1 deletion NetCord/Rest/ComponentProperties/TextDisplayProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace NetCord.Rest;

[GenerateMethodsForProperties]
public partial class TextDisplayProperties(string content) : IMessageComponentProperties, IModalComponentProperties, IComponentContainerComponentProperties
public partial class TextDisplayProperties(string content) : IMessageComponentProperties, IModalComponentProperties, IComponentContainerComponentProperties, IComponentSectionComponentProperties
{
/// <summary>
/// Unique identifier for the component. Auto populated through increment if not provided.
Expand Down Expand Up @@ -38,4 +38,9 @@ void IJsonSerializable<IComponentContainerComponentProperties>.WriteTo(Utf8JsonW
{
WriteTo(writer);
}

void IJsonSerializable<IComponentSectionComponentProperties>.WriteTo(Utf8JsonWriter writer)
{
WriteTo(writer);
}
}