Skip to content
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
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent

# Modifier preferences
dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning
# Modifier preferences (set to silent until https://github.com/dotnet/roslyn/issues/52904 is resolved)
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent

# Code block preferences
dotnet_style_allow_multiple_blank_lines_experimental = false:warning
Expand Down
14 changes: 7 additions & 7 deletions CommunityToolkit.Common/Deferred/DeferredEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ public class DeferredEventArgs : EventArgs
/// </summary>
public static new DeferredEventArgs Empty => new();

private readonly object _eventDeferralLock = new();
private readonly object eventDeferralLock = new();

private EventDeferral? _eventDeferral;
private EventDeferral? eventDeferral;

/// <summary>
/// Returns an <see cref="EventDeferral"/> which can be completed when deferred event is ready to continue.
/// </summary>
/// <returns><see cref="EventDeferral"/> instance.</returns>
public EventDeferral GetDeferral()
{
lock (_eventDeferralLock)
lock (this.eventDeferralLock)
{
return _eventDeferral ??= new EventDeferral();
return this.eventDeferral ??= new EventDeferral();
}
}

Expand All @@ -45,11 +45,11 @@ public EventDeferral GetDeferral()
[Obsolete("This is an internal only method to be used by EventHandler extension classes, public callers should call GetDeferral() instead.")]
public EventDeferral? GetCurrentDeferralAndReset()
{
lock (_eventDeferralLock)
lock (this.eventDeferralLock)
{
EventDeferral? eventDeferral = _eventDeferral;
EventDeferral? eventDeferral = this.eventDeferral;

_eventDeferral = null;
this.eventDeferral = null;

return eventDeferral;
}
Expand Down
10 changes: 5 additions & 5 deletions CommunityToolkit.Common/Deferred/EventDeferral.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ namespace CommunityToolkit.Common.Deferred;
/// </summary>
public class EventDeferral : IDisposable
{
//// TODO: If/when .NET 6 is base, we can upgrade to non-generic version
private readonly TaskCompletionSource<object?> _taskCompletionSource = new();
// TODO: If/when .NET 6 is base, we can upgrade to non-generic version
private readonly TaskCompletionSource<object?> taskCompletionSource = new();

internal EventDeferral()
{
Expand All @@ -26,7 +26,7 @@ internal EventDeferral()
/// <summary>
/// Call when finished with the Deferral.
/// </summary>
public void Complete() => _taskCompletionSource.TrySetResult(null);
public void Complete() => this.taskCompletionSource.TrySetResult(null);

/// <summary>
/// Waits for the <see cref="EventDeferral"/> to be completed by the event handler.
Expand All @@ -38,9 +38,9 @@ internal EventDeferral()
[Obsolete("This is an internal only method to be used by EventHandler extension classes, public callers should call GetDeferral() instead on the DeferredEventArgs.")]
public async Task WaitForCompletion(CancellationToken cancellationToken)
{
using (cancellationToken.Register(() => _taskCompletionSource.TrySetCanceled()))
using (cancellationToken.Register(() => this.taskCompletionSource.TrySetCanceled()))
{
_ = await _taskCompletionSource.Task;
_ = await this.taskCompletionSource.Task;
}
}

Expand Down
4 changes: 2 additions & 2 deletions CommunityToolkit.HighPerformance/Buffers/SpanOwner{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public Span<T> Span
get
{
#if NETCOREAPP3_1_OR_GREATER
ref T r0 = ref array!.DangerousGetReference();
ref T r0 = ref this.array!.DangerousGetReference();

return MemoryMarshal.CreateSpan(ref r0, this.length);
#else
Expand Down Expand Up @@ -174,7 +174,7 @@ public ref T DangerousGetReference()
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ArraySegment<T> DangerousGetArray()
{
return new(array!, 0, this.length);
return new(this.array!, 0, this.length);
}

/// <summary>
Expand Down
11 changes: 6 additions & 5 deletions CommunityToolkit.HighPerformance/Enumerables/RefEnumerable{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public readonly ref struct RefEnumerable<T>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal RefEnumerable(ref T reference, int length, int step)
{
Span = MemoryMarshal.CreateSpan(ref reference, length);
Step = step;
this.Span = MemoryMarshal.CreateSpan(ref reference, length);
this.Step = step;
}

/// <summary>
Expand Down Expand Up @@ -94,10 +94,11 @@ public static RefEnumerable<T> DangerousCreate(ref T value, int length, int step
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal RefEnumerable(object? instance, IntPtr offset, int length, int step)
{
Instance = instance;
Offset = offset;
this.Instance = instance;
this.Offset = offset;
this.Step = step;

Length = length;
Step = step;
}
#endif

Expand Down
8 changes: 4 additions & 4 deletions CommunityToolkit.HighPerformance/NullableRef{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public readonly ref struct NullableRef<T>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public NullableRef(ref T value)
{
Span = MemoryMarshal.CreateSpan(ref value, 1);
this.Span = MemoryMarshal.CreateSpan(ref value, 1);
}

/// <summary>
Expand All @@ -42,7 +42,7 @@ public NullableRef(ref T value)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private NullableRef(Span<T> span)
{
Span = span;
this.Span = span;
}

/// <summary>
Expand All @@ -69,7 +69,7 @@ public unsafe bool HasValue
// also account for the byte endianness of the current system),
// and then reinterpret that value to a bool flag.
// This results in a single movzx instruction on x86-64.
byte length = unchecked((byte)Span.Length);
byte length = unchecked((byte)this.Span.Length);

return *(bool*)&length;
}
Expand All @@ -89,7 +89,7 @@ public ref T Value
ThrowInvalidOperationException();
}

return ref MemoryMarshal.GetReference(Span);
return ref MemoryMarshal.GetReference(this.Span);
}
}

Expand Down
4 changes: 2 additions & 2 deletions CommunityToolkit.HighPerformance/ReadOnlyRef{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ReadOnlyRef(in T value)
{
ref T r0 = ref Unsafe.AsRef(value);

Span = MemoryMarshal.CreateReadOnlySpan(ref r0, 1);
this.Span = MemoryMarshal.CreateReadOnlySpan(ref r0, 1);
}

/// <summary>
Expand All @@ -56,7 +56,7 @@ public unsafe ReadOnlyRef(void* pointer)
public ref readonly T Value
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => ref MemoryMarshal.GetReference(Span);
get => ref MemoryMarshal.GetReference(this.Span);
}

/// <summary>
Expand Down
10 changes: 5 additions & 5 deletions CommunityToolkit.HighPerformance/Ref{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public readonly ref struct Ref<T>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Ref(ref T value)
{
Span = MemoryMarshal.CreateSpan(ref value, 1);
this.Span = MemoryMarshal.CreateSpan(ref value, 1);
}

/// <summary>
Expand All @@ -54,7 +54,7 @@ public unsafe Ref(void* pointer)
public ref T Value
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => ref MemoryMarshal.GetReference(Span);
get => ref MemoryMarshal.GetReference(this.Span);
}
#else
/// <summary>
Expand All @@ -80,8 +80,8 @@ public ref T Value
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Ref(object owner, ref T value)
{
Owner = owner;
Offset = ObjectMarshal.DangerousGetObjectDataByteOffset(owner, ref value);
this.Owner = owner;
this.Offset = ObjectMarshal.DangerousGetObjectDataByteOffset(owner, ref value);
}

/// <summary>
Expand All @@ -90,7 +90,7 @@ public Ref(object owner, ref T value)
public ref T Value
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => ref ObjectMarshal.DangerousGetObjectDataReferenceAt<T>(Owner, Offset);
get => ref ObjectMarshal.DangerousGetObjectDataReferenceAt<T>(this.Owner, this.Offset);
}
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@ public sealed override int Read(Span<byte> buffer)
{
MemoryStream.ValidateDisposed(this.disposed);

int
bytesAvailable = this.source.Length - this.position,
bytesCopied = Math.Min(bytesAvailable, buffer.Length);
int bytesAvailable = this.source.Length - this.position;
int bytesCopied = Math.Min(bytesAvailable, buffer.Length);

Span<byte> source = this.source.Span.Slice(this.position, bytesCopied);

Expand Down
26 changes: 13 additions & 13 deletions CommunityToolkit.Mvvm.SourceGenerators/Helpers/HashCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,32 +410,32 @@ private static uint MixFinal(uint hash)
private void Add(int value)
{
uint val = (uint)value;
uint previousLength = length++;
uint previousLength = this.length++;
uint position = previousLength % 4;

if (position == 0)
{
queue1 = val;
this.queue1 = val;
}
else if (position == 1)
{
queue2 = val;
this.queue2 = val;
}
else if (position == 2)
{
queue3 = val;
this.queue3 = val;
}
else
{
if (previousLength == 3)
{
Initialize(out v1, out v2, out v3, out v4);
Initialize(out this.v1, out this.v2, out this.v3, out this.v4);
}

v1 = Round(v1, queue1);
v2 = Round(v2, queue2);
v3 = Round(v3, queue3);
v4 = Round(v4, val);
this.v1 = Round(this.v1, this.queue1);
this.v2 = Round(this.v2, this.queue2);
this.v3 = Round(this.v3, this.queue3);
this.v4 = Round(this.v4, val);
}
}

Expand All @@ -447,21 +447,21 @@ public int ToHashCode()
{
uint length = this.length;
uint position = length % 4;
uint hash = length < 4 ? MixEmptyState() : MixState(v1, v2, v3, v4);
uint hash = length < 4 ? MixEmptyState() : MixState(this.v1, this.v2, this.v3, this.v4);

hash += length * 4;

if (position > 0)
{
hash = QueueRound(hash, queue1);
hash = QueueRound(hash, this.queue1);

if (position > 1)
{
hash = QueueRound(hash, queue2);
hash = QueueRound(hash, this.queue2);

if (position > 2)
{
hash = QueueRound(hash, queue3);
hash = QueueRound(hash, this.queue3);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public Awaiter(Task task)
public bool IsCompleted
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => taskAwaiter.IsCompleted;
get => this.taskAwaiter.IsCompleted;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static void Register(Action<object> callback, object target)
}
else
{
handle.Free();
this.handle.Free();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ private sealed class Container
private readonly ConditionalWeakTable2<TKey, TValue> parent;

/// <summary>
/// <c>_buckets[hashcode &amp; (_buckets.Length - 1)]</c> contains index of the first entry in bucket (-1 if empty).
/// <c>buckets[hashcode &amp; (buckets.Length - 1)]</c> contains index of the first entry in bucket (-1 if empty).
/// </summary>
private int[] buckets;

Expand All @@ -317,7 +317,7 @@ private sealed class Container
private Entry[] entries;

/// <summary>
/// <c>_firstFreeEntry &lt; _entries.Length => table</c> has capacity, entries grow from the bottom of the table.
/// <c>firstFreeEntry &lt; entries.Length => table</c> has capacity, entries grow from the bottom of the table.
/// </summary>
private int firstFreeEntry;

Expand Down Expand Up @@ -410,7 +410,7 @@ internal void CreateEntryNoResize(TKey key, TValue value)
}

/// <summary>
/// Worker for finding a key/value pair. Must hold _lock.
/// Worker for finding a key/value pair. Must hold lock.
/// </summary>
internal bool TryGetValueWorker(TKey key, [MaybeNullWhen(false)] out TValue value)
{
Expand All @@ -423,7 +423,7 @@ internal bool TryGetValueWorker(TKey key, [MaybeNullWhen(false)] out TValue valu

/// <summary>
/// Returns -1 if not found (if key expires during FindEntry, this can be treated as "not found.").
/// Must hold _lock, or be prepared to retry the search while holding _lock.
/// Must hold lock, or be prepared to retry the search while holding lock.
/// </summary>
/// <remarks>This method requires <paramref name="value"/> to be on the stack to be properly tracked.</remarks>
internal int FindEntry(TKey key, out object? value)
Expand Down Expand Up @@ -463,7 +463,7 @@ internal bool TryGetEntry(int index, [NotNullWhen(true)] out TKey? key, [MaybeNu
{
if (index < this.entries.Length)
{
// object? oKey = _entries[index].depHnd.UnsafeGetTargetAndDependent(out object? oValue);
// object? oKey = entries[index].depHnd.UnsafeGetTargetAndDependent(out object? oValue);
(object? oKey, object? oValue) = this.entries[index].depHnd.TargetAndDependent;

// Ensure we don't get finalized while accessing DependentHandle
Expand Down Expand Up @@ -522,10 +522,10 @@ private void RemoveIndex(int entryIndex)
}

/// <summary>
/// Resize, and scrub expired keys off bucket lists. Must hold _lock.
/// Resize, and scrub expired keys off bucket lists. Must hold <see cref="lockObject"/>.
/// </summary>
/// <remarks>
/// _firstEntry is less than _entries.Length on exit, that is, the table has at least one free entry.
/// <see cref="firstFreeEntry"/> is less than <c>entries.Length</c> on exit, that is, the table has at least one free entry.
/// </remarks>
internal Container Resize()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public bool MoveNext()
{
LinkedListNode<WeakReference<TKey>>? node;

if (!isFirstMoveNextPending)
if (!this.isFirstMoveNextPending)
{
node = this.node!.Next;
}
Expand Down
Loading