-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow collection expressions for 'System.Collections.ObjectModel' col…
…lection types (#111093) * #110161 Allow collection expressions for 'System.Collections.ObjectModel' collection types #110161 * Code review Enhance ReadOnlyCollection with documentation and updates The `EditorBrowsable` attribute is replaced with a `SuppressMessage` attribute to clarify the intended usage of these methods. Additionally, the condition for checking if input values are empty is updated from `values.Length <= 0` to `values.IsEmpty` for improved readability and performance. * Remove unused namespace from ReadOnlyCollection.cs Eliminated the `using System.ComponentModel;` directive, reducing dependencies and potentially simplifying the code structure. * Remove suppression attributes from collection methods The `CreateCollection<T>` method in the `ReadOnlyCollection` class had its suppression attribute removed, addressing a style warning related to collection initialization while maintaining its functionality. Similarly, the `CreateSet<T>` method in the `ReadOnlySet` class also had its suppression attribute removed, preserving its original functionality. * Refactor `(HashSet<T>)[.. values]` to manual loop * Marked CreateCollection and CreateSet methods in ReadOnlyCollection with the `[EditorBrowsable(EditorBrowsableState.Never)]` attribute to hide them from IntelliSense. * Apply suggestions from code review * Refactor ReadOnlyCollection and ReadOnlySet APIs Updated method names in ReadOnlyCollection and ReadOnlySet from CreateCollection and CreateSet to Create for clarity and consistency. Removed the CreateSet method from ReadOnlyCollection to streamline functionality. Adjusted documentation comments for improved clarity. Updated CollectionBuilder attributes to reflect the new method names, ensuring proper linkage for collection creation. * Updated the `CollectionBuilder` attribute to reference `ReadOnlySet` instead of `ReadOnlyCollection`, reflecting a change in the collection type used in the `ReadOnlySet` class. * Code Style * Rename methods in ReadOnlyCollection and ReadOnlySet Updated `ReadOnlyCollection` to rename `Create` to `CreateCollection` and introduced `CreateSet` for creating `ReadOnlySet` instances from spans. Adjusted `CollectionBuilder` attributes accordingly and removed the static `ReadOnlySet` class, integrating its functionality into the main class. Updated the `ReadOnlyCollection` partial class in `System.Runtime.cs` to maintain API consistency. --------- Co-authored-by: Eirik Tsarpalis <[email protected]>
- Loading branch information
1 parent
71db8b2
commit 22e39f9
Showing
5 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters