Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CollectionBuilder attribute to some immutable collection interfaces #89459

Merged
merged 1 commit into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public partial interface IImmutableDictionary<TKey, TValue> : System.Collections
System.Collections.Immutable.IImmutableDictionary<TKey, TValue> SetItems(System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, TValue>> items);
bool TryGetKey(TKey equalKey, out TKey actualKey);
}
[System.Runtime.CompilerServices.CollectionBuilderAttribute(typeof(System.Collections.Immutable.ImmutableList), "Create")]
stephentoub marked this conversation as resolved.
Show resolved Hide resolved
public partial interface IImmutableList<T> : System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IReadOnlyCollection<T>, System.Collections.Generic.IReadOnlyList<T>, System.Collections.IEnumerable
{
System.Collections.Immutable.IImmutableList<T> Add(T value);
Expand All @@ -148,6 +149,7 @@ public partial interface IImmutableList<T> : System.Collections.Generic.IEnumera
System.Collections.Immutable.IImmutableList<T> Replace(T oldValue, T newValue, System.Collections.Generic.IEqualityComparer<T>? equalityComparer);
System.Collections.Immutable.IImmutableList<T> SetItem(int index, T value);
}
[System.Runtime.CompilerServices.CollectionBuilderAttribute(typeof(System.Collections.Immutable.ImmutableQueue), "Create")]
public partial interface IImmutableQueue<T> : System.Collections.Generic.IEnumerable<T>, System.Collections.IEnumerable
{
bool IsEmpty { get; }
Expand All @@ -156,6 +158,7 @@ public partial interface IImmutableQueue<T> : System.Collections.Generic.IEnumer
System.Collections.Immutable.IImmutableQueue<T> Enqueue(T value);
T Peek();
}
[System.Runtime.CompilerServices.CollectionBuilderAttribute(typeof(System.Collections.Immutable.ImmutableHashSet), "Create")]
public partial interface IImmutableSet<T> : System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IReadOnlyCollection<T>, System.Collections.IEnumerable
{
System.Collections.Immutable.IImmutableSet<T> Add(T value);
Expand All @@ -174,6 +177,7 @@ public partial interface IImmutableSet<T> : System.Collections.Generic.IEnumerab
bool TryGetValue(T equalValue, out T actualValue);
System.Collections.Immutable.IImmutableSet<T> Union(System.Collections.Generic.IEnumerable<T> other);
}
[System.Runtime.CompilerServices.CollectionBuilderAttribute(typeof(System.Collections.Immutable.ImmutableStack), "Create")]
public partial interface IImmutableStack<T> : System.Collections.Generic.IEnumerable<T>, System.Collections.IEnumerable
{
bool IsEmpty { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

namespace System.Collections.Immutable
{
Expand All @@ -14,6 +14,7 @@ namespace System.Collections.Immutable
/// Mutations on this list generate new lists. Incremental changes to a list share as much memory as possible with the prior versions of a list,
/// while allowing garbage collection to clean up any unique list data that is no longer being referenced.
/// </remarks>
[CollectionBuilder(typeof(ImmutableList), nameof(ImmutableList.Create))]
public interface IImmutableList<T> : IReadOnlyList<T>
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

namespace System.Collections.Immutable
{
/// <summary>
/// An immutable queue.
/// </summary>
/// <typeparam name="T">The type of elements in the queue.</typeparam>
[CollectionBuilder(typeof(ImmutableQueue), nameof(ImmutableQueue.Create))]
public interface IImmutableQueue<T> : IEnumerable<T>
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

namespace System.Collections.Immutable
{
Expand All @@ -14,6 +14,7 @@ namespace System.Collections.Immutable
/// Mutations on this set generate new sets. Incremental changes to a set share as much memory as possible with the prior versions of a set,
/// while allowing garbage collection to clean up any unique set data that is no longer being referenced.
/// </remarks>
[CollectionBuilder(typeof(ImmutableHashSet), nameof(ImmutableHashSet.Create))]
public interface IImmutableSet<T> : IReadOnlyCollection<T>
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

namespace System.Collections.Immutable
{
/// <summary>
/// An immutable stack.
/// </summary>
/// <typeparam name="T">The type of elements stored in the stack.</typeparam>
[CollectionBuilder(typeof(ImmutableStack), nameof(ImmutableStack.Create))]
stephentoub marked this conversation as resolved.
Show resolved Hide resolved
public interface IImmutableStack<T> : IEnumerable<T>
{
/// <summary>
Expand Down