Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array properties throw an error when trying to add new items #7090

Open
Fortune117 opened this issue Dec 1, 2024 · 2 comments
Open

Array properties throw an error when trying to add new items #7090

Fortune117 opened this issue Dec 1, 2024 · 2 comments

Comments

@Fortune117
Copy link

Describe the bug

I have a very simple resource set up:

[GameResource("Face Connection", "fconn", "A connection from a submodule face.", Icon = "join_left")]
public class TestResource : GameResource
{
	public ConnectionData[] Connections { get; set; } = Array.Empty<ConnectionData>();
}

public class ConnectionData
{
	private int Number { get; set; }
}

This appears correctly in the editor but hitting the + button throws this error:

Collection was of a fixed size.
System.NotSupportedException: Collection was of a fixed size.
   at System.Array.System.Collections.IList.Insert(Int32 index, Object value)
   at Sandbox.SerializedList.Insert(Int32 index, Object value) in C:\build\_work\sbox\sbox\engine\Sandbox.System\SerializedObject\SerializedList.cs:line 80
   at Sandbox.SerializedList.Add(Object value) in C:\build\_work\sbox\sbox\engine\Sandbox.System\SerializedObject\SerializedList.cs:line 63
   at Editor.ListControlWidget.AddEntry() in C:\My Stuff\Steam\steamapps\common\sbox\addons\tools\Code\Widgets\ControlWidgets\ListControlWidget.cs:line 83
   at Editor.Widget.OnMouseClick(MouseEvent e) in C:\build\_work\sbox\sbox\engine\Sandbox.Tools\Qt\Widget.Events.cs:line 103
   at Editor.IconButton.OnMouseClick(MouseEvent e) in C:\build\_work\sbox\sbox\engine\Sandbox.Tools\Widgets\IconButton.cs:line 64
   at Editor.Widget.OnMouseReleased(MouseEvent e) in C:\build\_work\sbox\sbox\engine\Sandbox.Tools\Qt\Widget.Events.cs:line 75
   at Managed.SourceTools.Exports.Editor_Widget_InternalMouseReleaseEvent(UInt32 self, IntPtr e) in C:\build\_work\sbox\sbox\engine\Sandbox.Tools\Interop.Tools.cs:line 22633

To Reproduce

  1. Open the test repo
  2. Try adding a new element to the array in the resource
  3. Error

Expected behavior

Should work as expected!

Media/Files

bug_repo.zip

Additional context

No response

@MrBrax
Copy link

MrBrax commented Dec 1, 2024

is there a reason to not use a list here?

@Fortune117
Copy link
Author

is there a reason to not use a list here?

A list would work instead, but the bug is about arrays.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: To triage
Development

No branches or pull requests

2 participants