Skip to content

Commit

Permalink
Add CollectionBuilder attribute to some immutable collection interfac…
Browse files Browse the repository at this point in the history
…es (#89459)
  • Loading branch information
stephentoub authored Aug 9, 2023
1 parent e7a9930 commit a67d5f1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
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")]
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))]
public interface IImmutableStack<T> : IEnumerable<T>
{
/// <summary>
Expand Down

0 comments on commit a67d5f1

Please sign in to comment.