dotnet / dotnet/winforms

Support `ICollection<string>` on `Clipboard.SetFileDropList`

Open
#5,896 4 comments 0 reactions 0 assignees View on GitHub
api-suggestion area-Clipboard
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
20h 23m
Merged PRs (30d)
103

Description

**Is your feature request related to a problem? Please describe.**
I'd like to use a `Collection` as a parameter for `Clipboard.SetFileDropList`, since I'd like to avoid creating new `StringCollection`s and copying entries.

**Describe the solution you'd like and alternatives you've considered**

Relevant part of the code:
https://github.com/dotnet/winforms/blob/81774abbcbb885fe906f1c0f813e8175eef8705c/src/System.Windows.Forms/src/System/Windows/Forms/Clipboard.cs#L359-L392

It currently only accepts a `System.Collections.Specialized.StringCollection`.
Maybe a `System.Collections.Generic.ICollection`, `IList` or even `IReadOnlyList` would work better for most of the cases.

By introducing an additional overload, this would be possible:
```csharp
void SetData(IList files) {
StringCollection paths = new StringCollection();
foreach (var path in files) {
paths.Add(path);
}
Clipboard.SetFileDropList(paths);
}

// With proposed addition:
void SetData(IList paths) {
// No copy of list needed
Clipboard.SetFileDropList(paths);
}
```

**Will this feature affect UI controls?**
No.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.