Skip to content

Commit

Permalink
Remove usage of [Pure] from Immutable Collections
Browse files Browse the repository at this point in the history
  • Loading branch information
ericstj committed Apr 20, 2020
1 parent 287165d commit bdd4646
Show file tree
Hide file tree
Showing 35 changed files with 1 addition and 812 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@
<PropertyGroup>
<StrongNameKeyId>Microsoft</StrongNameKeyId>
<IsNETCoreApp>true</IsNETCoreApp>
<!-- Set CONTRACTS_FULL to preserve usage of Contracts attributes -->
<DefineConstants>$(DefineConstants),CONTRACTS_FULL</DefineConstants>
</PropertyGroup>
</Project>
</Project>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,16 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetsNetCoreApp)' == 'true'">
<ProjectReference Include="..\..\System.Collections\ref\System.Collections.csproj" />
<ProjectReference Include="..\..\System.Diagnostics.Contracts\ref\System.Diagnostics.Contracts.csproj" />
<ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" />
<ProjectReference Include="..\..\System.Runtime.InteropServices\ref\System.Runtime.InteropServices.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.0'">
<Reference Include="System.Runtime" />
<Reference Include="System.Collections" />
<Reference Include="System.Diagnostics.Contracts" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3'">
<Reference Include="System.Runtime" />
<Reference Include="System.Collections" />
<Reference Include="System.Diagnostics.Contracts" />
<Reference Include="System.Runtime.InteropServices" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3' or '$(TargetFramework)' == 'netstandard2.0'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;

namespace System.Collections.Immutable
{
Expand All @@ -18,7 +17,6 @@ public interface IImmutableDictionary<TKey, TValue> : IReadOnlyDictionary<TKey,
/// <summary>
/// Gets an empty dictionary with equivalent ordering and key/value comparison rules.
/// </summary>
[Pure]
IImmutableDictionary<TKey, TValue> Clear();

/// <summary>
Expand All @@ -31,7 +29,6 @@ public interface IImmutableDictionary<TKey, TValue> : IReadOnlyDictionary<TKey,
/// <remarks>
/// If the given key-value pair are already in the dictionary, the existing instance is returned.
/// </remarks>
[Pure]
IImmutableDictionary<TKey, TValue> Add(TKey key, TValue value);

/// <summary>
Expand All @@ -40,7 +37,6 @@ public interface IImmutableDictionary<TKey, TValue> : IReadOnlyDictionary<TKey,
/// <param name="pairs">The pairs.</param>
/// <returns>The new dictionary containing the additional key-value pairs.</returns>
/// <exception cref="ArgumentException">Thrown when one of the given keys already exists in the dictionary but has a different value.</exception>
[Pure]
IImmutableDictionary<TKey, TValue> AddRange(IEnumerable<KeyValuePair<TKey, TValue>> pairs);

/// <summary>
Expand All @@ -53,31 +49,27 @@ public interface IImmutableDictionary<TKey, TValue> : IReadOnlyDictionary<TKey,
/// If the given key-value pair are already in the dictionary, the existing instance is returned.
/// If the key already exists but with a different value, a new instance with the overwritten value will be returned.
/// </remarks>
[Pure]
IImmutableDictionary<TKey, TValue> SetItem(TKey key, TValue value);

/// <summary>
/// Applies a given set of key=value pairs to an immutable dictionary, replacing any conflicting keys in the resulting dictionary.
/// </summary>
/// <param name="items">The key=value pairs to set on the dictionary. Any keys that conflict with existing keys will overwrite the previous values.</param>
/// <returns>An immutable dictionary.</returns>
[Pure]
IImmutableDictionary<TKey, TValue> SetItems(IEnumerable<KeyValuePair<TKey, TValue>> items);

/// <summary>
/// Removes the specified keys from the dictionary with their associated values.
/// </summary>
/// <param name="keys">The keys to remove.</param>
/// <returns>A new dictionary with those keys removed; or this instance if those keys are not in the dictionary.</returns>
[Pure]
IImmutableDictionary<TKey, TValue> RemoveRange(IEnumerable<TKey> keys);

/// <summary>
/// Removes the specified key from the dictionary with its associated value.
/// </summary>
/// <param name="key">The key to remove.</param>
/// <returns>A new dictionary with the matching entry removed; or this instance if the key is not in the dictionary.</returns>
[Pure]
IImmutableDictionary<TKey, TValue> Remove(TKey key);

/// <summary>
Expand All @@ -87,7 +79,6 @@ public interface IImmutableDictionary<TKey, TValue> : IReadOnlyDictionary<TKey,
/// <returns>
/// <c>true</c> if this dictionary contains the key-value pair; otherwise, <c>false</c>.
/// </returns>
[Pure]
bool Contains(KeyValuePair<TKey, TValue> pair);

/// <summary>
Expand All @@ -102,7 +93,6 @@ public interface IImmutableDictionary<TKey, TValue> : IReadOnlyDictionary<TKey,
/// the canonical value, or a value that has more complete data than the value you currently have,
/// although their comparer functions indicate they are equal.
/// </remarks>
[Pure]
bool TryGetKey(TKey equalKey, out TKey actualKey);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;

namespace System.Collections.Immutable
{
Expand All @@ -21,7 +20,6 @@ public interface IImmutableList<T> : IReadOnlyList<T>
/// <summary>
/// Gets an empty list that retains the same sort semantics that this instance has.
/// </summary>
[Pure]
IImmutableList<T> Clear();

/// <summary>
Expand Down Expand Up @@ -49,7 +47,6 @@ public interface IImmutableList<T> : IReadOnlyList<T>
/// elements in the <see cref="ImmutableList{T}"/> that starts at index and
/// contains count number of elements, if found; otherwise, -1.
/// </returns>
[Pure]
int IndexOf(T item, int index, int count, IEqualityComparer<T>? equalityComparer);

/// <summary>
Expand All @@ -73,23 +70,20 @@ public interface IImmutableList<T> : IReadOnlyList<T>
/// in the <see cref="ImmutableList{T}"/> that contains <paramref name="count"/> number of elements
/// and ends at <paramref name="index"/>, if found; otherwise, -1.
/// </returns>
[Pure]
int LastIndexOf(T item, int index, int count, IEqualityComparer<T>? equalityComparer);

/// <summary>
/// Adds the specified value to this list.
/// </summary>
/// <param name="value">The value to add.</param>
/// <returns>A new list with the element added.</returns>
[Pure]
IImmutableList<T> Add(T value);

/// <summary>
/// Adds the specified values to this list.
/// </summary>
/// <param name="items">The values to add.</param>
/// <returns>A new list with the elements added.</returns>
[Pure]
IImmutableList<T> AddRange(IEnumerable<T> items);

/// <summary>
Expand All @@ -98,7 +92,6 @@ public interface IImmutableList<T> : IReadOnlyList<T>
/// <param name="index">The index at which to insert the value.</param>
/// <param name="element">The element to insert.</param>
/// <returns>The new immutable list.</returns>
[Pure]
IImmutableList<T> Insert(int index, T element);

/// <summary>
Expand All @@ -107,7 +100,6 @@ public interface IImmutableList<T> : IReadOnlyList<T>
/// <param name="index">The index at which to insert the value.</param>
/// <param name="items">The elements to insert.</param>
/// <returns>The new immutable list.</returns>
[Pure]
IImmutableList<T> InsertRange(int index, IEnumerable<T> items);

/// <summary>
Expand All @@ -119,7 +111,6 @@ public interface IImmutableList<T> : IReadOnlyList<T>
/// If <c>null</c>, <see cref="EqualityComparer{T}.Default"/> is used.
/// </param>
/// <returns>A new list with the element removed, or this list if the element is not in this list.</returns>
[Pure]
IImmutableList<T> Remove(T value, IEqualityComparer<T>? equalityComparer);

/// <summary>
Expand All @@ -133,7 +124,6 @@ public interface IImmutableList<T> : IReadOnlyList<T>
/// <returns>
/// The new list.
/// </returns>
[Pure]
IImmutableList<T> RemoveAll(Predicate<T> match);

/// <summary>
Expand All @@ -147,7 +137,6 @@ public interface IImmutableList<T> : IReadOnlyList<T>
/// <returns>
/// A new list with the elements removed.
/// </returns>
[Pure]
IImmutableList<T> RemoveRange(IEnumerable<T> items, IEqualityComparer<T>? equalityComparer);

/// <summary>
Expand All @@ -158,15 +147,13 @@ public interface IImmutableList<T> : IReadOnlyList<T>
/// <returns>
/// A new list with the elements removed.
/// </returns>
[Pure]
IImmutableList<T> RemoveRange(int index, int count);

/// <summary>
/// Removes the element at the specified index.
/// </summary>
/// <param name="index">The index.</param>
/// <returns>A new list with the elements removed.</returns>
[Pure]
IImmutableList<T> RemoveAt(int index);

/// <summary>
Expand All @@ -175,7 +162,6 @@ public interface IImmutableList<T> : IReadOnlyList<T>
/// <param name="index">The position in the list of the element to replace.</param>
/// <param name="value">The element to replace the old element with.</param>
/// <returns>The new list -- even if the value being replaced is equal to the new value for that position.</returns>
[Pure]
IImmutableList<T> SetItem(int index, T value);

/// <summary>
Expand All @@ -189,7 +175,6 @@ public interface IImmutableList<T> : IReadOnlyList<T>
/// </param>
/// <returns>The new list -- even if the value being replaced is equal to the new value for that position.</returns>
/// <exception cref="ArgumentException">Thrown when the old value does not exist in the list.</exception>
[Pure]
IImmutableList<T> Replace(T oldValue, T newValue, IEqualityComparer<T>? equalityComparer);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;

namespace System.Collections.Immutable
{
Expand All @@ -20,13 +19,11 @@ public interface IImmutableQueue<T> : IEnumerable<T>
/// <value>
/// <c>true</c> if this queue is empty; otherwise, <c>false</c>.
/// </value>
[Pure]
bool IsEmpty { get; }

/// <summary>
/// Gets an empty queue.
/// </summary>
[Pure]
IImmutableQueue<T> Clear();

/// <summary>
Expand All @@ -36,7 +33,6 @@ public interface IImmutableQueue<T> : IEnumerable<T>
/// The element at the front of the queue.
/// </returns>
/// <exception cref="InvalidOperationException">Thrown when the queue is empty.</exception>
[Pure]
T Peek();

/// <summary>
Expand All @@ -46,15 +42,13 @@ public interface IImmutableQueue<T> : IEnumerable<T>
/// <returns>
/// The new queue.
/// </returns>
[Pure]
IImmutableQueue<T> Enqueue(T value);

/// <summary>
/// Returns a queue that is missing the front element.
/// </summary>
/// <returns>A queue; never <c>null</c>.</returns>
/// <exception cref="InvalidOperationException">Thrown when the queue is empty.</exception>
[Pure]
IImmutableQueue<T> Dequeue();
}
}
Loading

0 comments on commit bdd4646

Please sign in to comment.