-
-
Notifications
You must be signed in to change notification settings - Fork 954
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
[Editor] Collection support in abstract properties #2120
base: master
Are you sure you want to change the base?
Conversation
@Eideren It's not trivial 😅. Allow me a few days to take the time to review it. If I understand correctly, the issue is for a new type inheriting from a collection type? If so, can't composition be used instead of inheritance? |
It work with unique inheritance (eg : https://github.com/Nicogo1705/Stride.BepuPhysics/blob/master/Stride.BepuPhysics/Definitions/ListOfColliders.cs ) But as soon as you add an interface (eg : class MyClass : List< Entity >, IMyInterface ) make the collection "readonly" inside editor (we cannot add new items). but it should be like in the screen from Eideren that fix that issue. See https://discord.com/channels/500285081265635328/1183088711810945157/1198297089151619273 for more informations. |
My question is more: why are we using inheritance instead of composition. [DataContract]
class CompoundColliders : ICollider
{
public List<ColliderBase> Colliders { get; set; }
public int SomeOtherProperty { get; set; }
} Quantum is built towards composition, so instead of fighting it and possibly introducing non-critical bugs or regression, it would be better to adapt to it. Inheriting a collection is a code smell for me, even outside Stride context. |
Ho, that's actually how i fixed it until this PR get merged. You will have to wait for Eideren answer then. |
Kind of but it goes a bit further than that: class MyClass
{
// Users cannot add or remove items from this list
public AnyTypeOrInterfaceThatCanHoldAList MyField = new List<float>();
// or this one
public Object MyField2 = new MyCustomListType();
// but they can swap the value of those fields to one of a different type somehow
}
class MyCustomListType : IList<float>{}
Yes, the end goal of that collection is to implement
I do agree with you if this was for a project using the engine, we shouldn't create hacks that have the potential to break the engine. But here we do have the ability to fix those issues, granted it might not be as easy, but we really shouldn't dictate how users should build their API. I think it makes sense that the editor has the same feature set as the serialization system, and our serialization system and dotnet coverage is a big help in converting users of unity over to our engine; tons of users were relieved when they could use properties in the engine for example. |
PR Details
Collection stored into properties of a non-collection type do not allow for adding and removing from said collection, this PR fixes that and ensures the feature can co-exist with the abstract setter.
Excerpt from bepu:
Related Issue
None reported afaict.
Types of changes
Checklist
Debugging quantum is such a shore, this PR doesn't even finish support for dictionaries or sets, I just don't have time to cover those as well.
@Kryptos-FR could you take a quick look to check that this nonsense is fine - that would be great.