[Feature Request]: Add property to `ProjectRootElement` for convenient access to `<Sdk>` elements
#9,546 建立於 2023年12月14日
描述
Summary
Project files can contain <Sdk> 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
/// <summary>
/// Get a read-only collection of the SDK references.
/// </summary>
public ICollection<ProjectSdkElement> Sdks => new ReadOnlyCollection<ProjectSdkElement>(Children.OfType<ProjectSdkElement>());
(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:
Sdkattribute on the projectSdkelementsImportelements 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