Skip to content

[GameStudio] FIX for #1913 - Make "Add Component" button functional with multiple entities selected#3089

Open
luca-domenichini wants to merge 3 commits intostride3d:masterfrom
luca-domenichini:master
Open

[GameStudio] FIX for #1913 - Make "Add Component" button functional with multiple entities selected#3089
luca-domenichini wants to merge 3 commits intostride3d:masterfrom
luca-domenichini:master

Conversation

@luca-domenichini
Copy link

@luca-domenichini luca-domenichini commented Mar 11, 2026

PR Details

This PR fixes a bug not allowing users to add components to multple entities at once. The popup for component addition was not showing.

Related Issue

#1913

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have built and run the editor to try this change out.

@luca-domenichini
Copy link
Author

@dotnet-policy-service agree

@luca-domenichini
Copy link
Author

question for maintainers (tagging a random one @VaclavElias)

I changed a public facing method public static object CombineProperty(IEnumerable<object> properties) into public static IEnumerable<TAbstractNodeEntry> CombineProperty<TAbstractNodeEntry>(IEnumerable<object> properties), so technically this is a breaking change.

I am open to do the following, as maintainers prefer:

  • add original method back plus a [Obsolete] attribute explaining why it's a bad idea to use it
  • leave all as it is and marking this PR as "breaking change"
  • anything else?

@Ethereal77
Copy link
Contributor

I'm not a mantainer, but imho (talking from my understanding, I have not checked if this makes sense):

  • If the new method operates over several properties, maybe a good idea would be to name it CombineProperties, then make CombineProperty a special case that just does what it did before (or calls the old CombineProperty and returns just the first, and mark it as [Obsolete].
  • Change all the calls to the old CombineProperty to the new CombineProperties.

Does this make sense?

@luca-domenichini
Copy link
Author

  • If the new method operates over several properties, maybe a good idea would be to name it CombineProperties, then make CombineProperty a special case that just does what it did before (or calls the old CombineProperty and returns just the first, and mark it as [Obsolete].

Actually, it already was CombineProperty despite the fact it returned an IEnumerable.
Definetely, CombineProperties would be better.
I could just add [Obsolete] to old method, but I would like to hear from maintainers if that is really needed, since I already changed all calls to the new method, so the old one is to be dropped ASAP.
I am wondering if removing that method would break someone using it outside of Stride GameStudio, since it belongs to Stride.Assets.Core.Editor project.

  • Change all the calls to the old CombineProperty to the new CombineProperties.

Yes, done 👍.

In the meanwhile, let me refactor with your suggestions..

@Ethereal77
Copy link
Contributor

From a very quick search across all the repo, that method is only used in AbstractNodeEntryData.cs and EntityHierarchyData.cs. Usually, for public APIs, obsoleting is the preferred way, but as this is only used in presentation/editor-related assemblies, let's ask @Kryptos-FR

…ed old CombineProperty non generic method marked as Obsolete
@luca-domenichini luca-domenichini marked this pull request as ready for review March 13, 2026 16:39
Copilot AI review requested due to automatic review settings March 13, 2026 16:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes GameStudio multi-selection behavior so the “Add Component” popup works when multiple entities are selected by ensuring combined attached-property values keep the correct generic type for WPF bindings.

Changes:

  • Introduces a generic CombineProperties<TAbstractNodeEntry> combiner to preserve the concrete entry type when combining attached properties.
  • Switches entity component “available types”/“type groups” attached-property keys to use the generic combiner.
  • Keeps the previous non-generic combiner as [Obsolete] for backward compatibility.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
sources/editor/Stride.Core.Assets.Editor/Quantum/NodePresenters/Keys/AbstractNodeEntryData.cs Adds a generic property combiner to avoid WPF binding type-coercion issues when combining attached properties.
sources/editor/Stride.Assets.Presentation/NodePresenters/Keys/EntityHierarchyData.cs Uses the generic combiner for component type/type-group attached properties so multi-selection keeps the expected types.
Comments suppressed due to low confidence (1)

sources/editor/Stride.Core.Assets.Editor/Quantum/NodePresenters/Keys/AbstractNodeEntryData.cs:21

  • result is initialized to a new HashSet<AbstractNodeEntry>() and then immediately overwritten with hashSets[0]. Removing the unused allocation will make the code clearer and avoid an extra allocation.
            var result = new HashSet<AbstractNodeEntry>();
            var hashSets = new List<HashSet<AbstractNodeEntry>>();
            hashSets.AddRange(properties.Cast<IEnumerable<AbstractNodeEntry>>().Select(x => new HashSet<AbstractNodeEntry>(x)));
            result = hashSets[0];

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +36 to +38
/// <param name="properties"></param>
/// <typeparam name="TAbstractNodeEntry"></typeparam>
/// <returns></returns>
Comment on lines +15 to 17
[Obsolete("Use the generic version of CombineProperties instead, which allows to specify the type of the properties to combine. This method is kept for backward compatibility, but it is recommended to use the generic version instead.")]
public static object CombineProperty(IEnumerable<object> properties)
{
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants