dotnet / dotnet/msbuild

Implement a way to merge one item into another

Open
#2,317 2 comments 6 reactions 0 assignees View on GitHub
Area: Language triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

Given item types A and B, there should be an easy way in MSBuild to merge B into A.

Possible ways to do merging:
1. Metadata merging
1. Additive: Apply the metadata from the elements of B[B∩A] to the elements A[B∩A]
2. Overwrite: Overwrite the metadata from the elements of B[B∩A] to the elements A[B∩A]
2. Item merging:
1. Intersection: Merge (additive or overwrite) the metadata from the elements of B[B∩A] to the elements A[B∩A]
2. Union: Merge (additive or overwrite) the metadata from the elements of B[B∩A] to the elements A[B∩A], and insert the elements B\A into A

Probably the most useful merging is intersection item merging with additive metadata. Possible syntax implementations for only this type of merging:
- reuse the current Update operation. If the Update query is an item reference, and there is no metadata defined, do merging instead.
```xml
// applies all the metadata from Bar into Foo
// applies only metadata named "Tar" from Bar into Foo
// applies all metadata except "Tar" from Bar into Foo
```

The drawback is that MSBuild currently treats `` as a noop (i.e. for all items in Foo that match in Bar, do nothing), so we'll break the existing noop behaviour. Since it's a pretty benign behaviour, it probably doesn't happen too often.

- add a new `Merge` operation
```xml
// applies all the metadata from Bar into Foo
// applies only metadata named "Tar" from Bar into Foo
// applies all metadata except "Tar" from Bar into Foo
```

The advantages of `Merge`:
- it disambiguates behaviour by item operations. This way each operation does something consistent (Update single metadata via a matching query Vs Merging all metadata of one item type into another item type).
- it allows extensibility to the other merging types via configuration attributes (e.g. ``)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.