[Feature Request]: Add property to `ProjectRootElement` for convenient access to `<Sdk>` elements
- Dominant language
- C#
- Stars
- 5.5k
- Forks
- 1.5k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 133
Description
### Summary
Project files can contain `` elements (modeled by `ProjectSdkElement`).
For parity with other project contents, there should be a property to access only those elements (e.g. `SdkReferences`).
### Background and Motivation
There are already properties for accessing the `Sdk` attribute, all properties, all imports and all items.
However, while `Sdk` elements appear in `Children`, they have no dedicated convenience accessor of their own.
### Proposed Feature
```cs
///
/// Get a read-only collection of the SDK references.
///
public ICollection Sdks => new ReadOnlyCollection(Children.OfType());
```
(name could also be `SdkElements` for better distinction from `Sdk`; there is also `ChooseElements`)
(using `Children` and not `AllChildren` because I assume these elements are only valid at the top level)
A nice-to-have additional property (`SdkReferences`) or method (`GetSdkReferences()`) would be one that gathers all SDK references in a project, from all sources:
- `Sdk` attribute on the project
- `Sdk` elements
- `Import` elements that specify an SDK
(That would make it easy for something like Dependabot to check whether a particular project references an SDK package for which an update is available.)
### Alternative Designs
_No response_
Contributor guide
No contributing guide indexed for this repository
Research direction
Locate ProjectRootElement and compare its existing convenience properties with the ProjectSdkElement model and Children collection. Add a read-only accessor for the direct SDK elements, resolve the proposed naming choice, and consider the stated broader SDK-reference aggregation only if the scope is confirmed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100