Skip to content

Commit 3e61aeb

Browse files
committed
Remove [Pure] attribute usages
1 parent 88f2a07 commit 3e61aeb

File tree

69 files changed

+0
-298
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+0
-298
lines changed

CommunityToolkit.Common/Collections/ObservableGroupedCollectionExtensions.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
using System;
66
using System.Collections.Generic;
7-
using System.Diagnostics.Contracts;
87
using System.Linq;
98
using System.Runtime.CompilerServices;
109

@@ -24,7 +23,6 @@ public static class ObservableGroupedCollectionExtensions
2423
/// <param name="key">The key of the group to query.</param>
2524
/// <returns>The first group matching <paramref name="key"/>.</returns>
2625
/// <exception cref="InvalidOperationException">The target group does not exist.</exception>
27-
[Pure]
2826
public static ObservableGroup<TKey, TValue> First<TKey, TValue>(this ObservableGroupedCollection<TKey, TValue> source, TKey key)
2927
where TKey : notnull
3028
{
@@ -51,7 +49,6 @@ static void ThrowArgumentExceptionForKeyNotFound()
5149
/// <param name="source">The source <see cref="ObservableGroupedCollection{TKey, TValue}"/> instance.</param>
5250
/// <param name="key">The key of the group to query.</param>
5351
/// <returns>The first group matching <paramref name="key"/> or null.</returns>
54-
[Pure]
5552
public static ObservableGroup<TKey, TValue>? FirstOrDefault<TKey, TValue>(this ObservableGroupedCollection<TKey, TValue> source, TKey key)
5653
where TKey : notnull
5754
{
@@ -89,7 +86,6 @@ static void ThrowArgumentExceptionForKeyNotFound()
8986
/// <returns>The element.</returns>
9087
/// <exception cref="InvalidOperationException">The target group does not exist.</exception>
9188
/// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is less than zero or <paramref name="index"/> is greater than the group elements' count.</exception>
92-
[Pure]
9389
public static TValue ElementAt<TKey, TValue>(
9490
this ObservableGroupedCollection<TKey, TValue> source,
9591
TKey key,
@@ -106,7 +102,6 @@ public static TValue ElementAt<TKey, TValue>(
106102
/// <param name="key">The key of the group to query.</param>
107103
/// <param name="index">The index of the item from the targeted group.</param>
108104
/// <returns>The element or default(TValue) if it does not exist.</returns>
109-
[Pure]
110105
public static TValue? ElementAtOrDefault<TKey, TValue>(
111106
this ObservableGroupedCollection<TKey, TValue> source,
112107
TKey key,

CommunityToolkit.Common/Extensions/TaskExtensions.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
using System.Diagnostics.Contracts;
65
using System.Reflection;
76
using System.Runtime.CompilerServices;
87
using System.Threading.Tasks;
@@ -24,7 +23,6 @@ public static class TaskExtensions
2423
/// and uses reflection to access the <see cref="Task{TResult}.Result"/> property and boxes the result if it's
2524
/// a value type, which adds overhead. It should only be used when using generics is not possible.
2625
/// </remarks>
27-
[Pure]
2826
[MethodImpl(MethodImplOptions.AggressiveInlining)]
2927
public static object? GetResultOrDefault(this Task task)
3028
{
@@ -66,7 +64,6 @@ public static class TaskExtensions
6664
/// <param name="task">The input <see cref="Task{TResult}"/> instance to get the result for.</param>
6765
/// <returns>The result of <paramref name="task"/> if completed successfully, or <see langword="default"/> otherwise.</returns>
6866
/// <remarks>This method does not block if <paramref name="task"/> has not completed yet.</remarks>
69-
[Pure]
7067
[MethodImpl(MethodImplOptions.AggressiveInlining)]
7168
public static T? GetResultOrDefault<T>(this Task<T?> task)
7269
{

CommunityToolkit.Diagnostics/Extensions/TypeExtensions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
using System;
66
using System.Collections.Generic;
7-
using System.Diagnostics.Contracts;
87
using System.Linq;
98
using System.Runtime.CompilerServices;
109

@@ -48,7 +47,6 @@ public static class TypeExtensions
4847
/// </summary>
4948
/// <param name="type">The input type.</param>
5049
/// <returns>The string representation of <paramref name="type"/>.</returns>
51-
[Pure]
5250
public static string ToTypeString(this Type type)
5351
{
5452
// Local function to create the formatted string for a given type

CommunityToolkit.Diagnostics/Extensions/ValueTypeExtensions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System;
6-
using System.Diagnostics.Contracts;
76
using System.Runtime.CompilerServices;
87
using System.Runtime.InteropServices;
98

@@ -42,7 +41,6 @@ public static class ValueTypeExtensions
4241
/// Console.WriteLine((-1).ToHexString()); // "0xFFFFFFFF"
4342
/// </code>
4443
/// </remarks>
45-
[Pure]
4644
[SkipLocalsInit]
4745
public static unsafe string ToHexString<T>(this T value)
4846
where T : unmanaged

CommunityToolkit.Diagnostics/Guard.Comparable.Generic.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System;
6-
using System.Diagnostics.Contracts;
76
using System.Runtime.CompilerServices;
87

98
namespace CommunityToolkit.Diagnostics;
@@ -191,7 +190,6 @@ public static unsafe void IsBitwiseEqualTo<T>(T value, T target, [CallerArgument
191190
}
192191

193192
// Compares 64 bits of data from two given memory locations for bitwise equality
194-
[Pure]
195193
[MethodImpl(MethodImplOptions.AggressiveInlining)]
196194
private static unsafe bool Bit64Compare(ref ulong left, ref ulong right)
197195
{

CommunityToolkit.Diagnostics/Internals/Guard.ThrowHelper.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
using System;
66
using System.Diagnostics.CodeAnalysis;
7-
using System.Diagnostics.Contracts;
87

98
namespace CommunityToolkit.Diagnostics;
109

@@ -23,7 +22,6 @@ private static partial class ThrowHelper
2322
/// </summary>
2423
/// <param name="obj">The input <see cref="object"/> to format.</param>
2524
/// <returns>A formatted representation of <paramref name="obj"/> to display in error messages.</returns>
26-
[Pure]
2725
private static string AssertString(object? obj)
2826
{
2927
return obj switch

CommunityToolkit.HighPerformance/Box{T}.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System;
66
using System.Diagnostics;
77
using System.Diagnostics.CodeAnalysis;
8-
using System.Diagnostics.Contracts;
98
using System.Runtime.CompilerServices;
109

1110
namespace CommunityToolkit.HighPerformance;
@@ -69,7 +68,6 @@ private Box()
6968
/// </summary>
7069
/// <param name="obj">The input <see cref="object"/> instance, representing a boxed <typeparamref name="T"/> value.</param>
7170
/// <returns>A <see cref="Box{T}"/> reference pointing to <paramref name="obj"/>.</returns>
72-
[Pure]
7371
[MethodImpl(MethodImplOptions.AggressiveInlining)]
7472
public static Box<T> GetFrom(object obj)
7573
{
@@ -90,7 +88,6 @@ public static Box<T> GetFrom(object obj)
9088
/// This method doesn't check the actual type of <paramref name="obj"/>, so it is responsibility of the caller
9189
/// to ensure it actually represents a boxed <typeparamref name="T"/> value and not some other instance.
9290
/// </remarks>
93-
[Pure]
9491
[MethodImpl(MethodImplOptions.AggressiveInlining)]
9592
public static Box<T> DangerousGetFrom(object obj)
9693
{
@@ -197,7 +194,6 @@ public static class BoxExtensions
197194
/// <typeparam name="T">The type of reference to retrieve.</typeparam>
198195
/// <param name="box">The input <see cref="Box{T}"/> instance.</param>
199196
/// <returns>A <typeparamref name="T"/> reference to the boxed value within <paramref name="box"/>.</returns>
200-
[Pure]
201197
[MethodImpl(MethodImplOptions.AggressiveInlining)]
202198
public static ref T GetReference<T>(this Box<T> box)
203199
where T : struct

CommunityToolkit.HighPerformance/Buffers/ArrayPoolBufferWriter{T}.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System;
66
using System.Buffers;
77
using System.Diagnostics;
8-
using System.Diagnostics.Contracts;
98
using System.Runtime.CompilerServices;
109
using System.Runtime.InteropServices;
1110
using CommunityToolkit.HighPerformance.Buffers.Views;
@@ -320,7 +319,6 @@ public void Dispose()
320319
}
321320

322321
/// <inheritdoc/>
323-
[Pure]
324322
public override string ToString()
325323
{
326324
// See comments in MemoryOwner<T> about this

CommunityToolkit.HighPerformance/Buffers/MemoryBufferWriter{T}.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System;
66
using System.Buffers;
77
using System.Diagnostics;
8-
using System.Diagnostics.Contracts;
98
using System.Runtime.CompilerServices;
109
using CommunityToolkit.HighPerformance.Buffers.Views;
1110

@@ -144,7 +143,6 @@ private void ValidateSizeHint(int sizeHint)
144143
}
145144

146145
/// <inheritdoc/>
147-
[Pure]
148146
public override string ToString()
149147
{
150148
// See comments in MemoryOwner<T> about this

CommunityToolkit.HighPerformance/Buffers/MemoryOwner{T}.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System;
66
using System.Buffers;
77
using System.Diagnostics;
8-
using System.Diagnostics.Contracts;
98
using System.Runtime.CompilerServices;
109
#if NETCOREAPP3_1_OR_GREATER
1110
using System.Runtime.InteropServices;
@@ -86,7 +85,6 @@ private MemoryOwner(int start, int length, ArrayPool<T> pool, T[] array)
8685
/// <summary>
8786
/// Gets an empty <see cref="MemoryOwner{T}"/> instance.
8887
/// </summary>
89-
[Pure]
9088
public static MemoryOwner<T> Empty
9189
{
9290
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -100,7 +98,6 @@ public static MemoryOwner<T> Empty
10098
/// <returns>A <see cref="MemoryOwner{T}"/> instance of the requested length.</returns>
10199
/// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="size"/> is not valid.</exception>
102100
/// <remarks>This method is just a proxy for the <see langword="private"/> constructor, for clarity.</remarks>
103-
[Pure]
104101
[MethodImpl(MethodImplOptions.AggressiveInlining)]
105102
public static MemoryOwner<T> Allocate(int size) => new(size, ArrayPool<T>.Shared, AllocationMode.Default);
106103

@@ -112,7 +109,6 @@ public static MemoryOwner<T> Empty
112109
/// <returns>A <see cref="MemoryOwner{T}"/> instance of the requested length.</returns>
113110
/// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="size"/> is not valid.</exception>
114111
/// <remarks>This method is just a proxy for the <see langword="private"/> constructor, for clarity.</remarks>
115-
[Pure]
116112
[MethodImpl(MethodImplOptions.AggressiveInlining)]
117113
public static MemoryOwner<T> Allocate(int size, ArrayPool<T> pool) => new(size, pool, AllocationMode.Default);
118114

@@ -124,7 +120,6 @@ public static MemoryOwner<T> Empty
124120
/// <returns>A <see cref="MemoryOwner{T}"/> instance of the requested length.</returns>
125121
/// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="size"/> is not valid.</exception>
126122
/// <remarks>This method is just a proxy for the <see langword="private"/> constructor, for clarity.</remarks>
127-
[Pure]
128123
[MethodImpl(MethodImplOptions.AggressiveInlining)]
129124
public static MemoryOwner<T> Allocate(int size, AllocationMode mode) => new(size, ArrayPool<T>.Shared, mode);
130125

@@ -137,7 +132,6 @@ public static MemoryOwner<T> Empty
137132
/// <returns>A <see cref="MemoryOwner{T}"/> instance of the requested length.</returns>
138133
/// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="size"/> is not valid.</exception>
139134
/// <remarks>This method is just a proxy for the <see langword="private"/> constructor, for clarity.</remarks>
140-
[Pure]
141135
[MethodImpl(MethodImplOptions.AggressiveInlining)]
142136
public static MemoryOwner<T> Allocate(int size, ArrayPool<T> pool, AllocationMode mode) => new(size, pool, mode);
143137

@@ -211,7 +205,6 @@ public Span<T> Span
211205
/// the buffer itself has been disposed or not. This check should not be removed, and it's also
212206
/// the reason why the method to get a reference at a specified offset is not present.
213207
/// </remarks>
214-
[Pure]
215208
[MethodImpl(MethodImplOptions.AggressiveInlining)]
216209
public ref T DangerousGetReference()
217210
{
@@ -236,7 +229,6 @@ public ref T DangerousGetReference()
236229
/// not used after the current <see cref="MemoryOwner{T}"/> instance is disposed. Doing so is considered undefined behavior,
237230
/// as the same array might be in use within another <see cref="MemoryOwner{T}"/> instance.
238231
/// </remarks>
239-
[Pure]
240232
[MethodImpl(MethodImplOptions.AggressiveInlining)]
241233
public ArraySegment<T> DangerousGetArray()
242234
{
@@ -311,7 +303,6 @@ public void Dispose()
311303
}
312304

313305
/// <inheritdoc/>
314-
[Pure]
315306
public override string ToString()
316307
{
317308
// Normally we would throw if the array has been disposed,

0 commit comments

Comments
 (0)