Skip to content

Commit 09ed2f2

Browse files
committed
Minor code tweaks
1 parent 905307f commit 09ed2f2

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

Microsoft.Toolkit.Mvvm/ComponentModel/ObservableObject.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ protected bool SetPropertyAndNotifyOnCompletion(ref TaskNotifier? taskNotifier,
340340
// instance. This will result in no further allocations after the first time this method is called for a given
341341
// generic type. We only pay the cost of the virtual call to the delegate, but this is not performance critical
342342
// code and that overhead would still be much lower than the rest of the method anyway, so that's fine.
343-
return SetPropertyAndNotifyOnCompletion(taskNotifier ??= new(), newValue, _ => { }, propertyName);
343+
return SetPropertyAndNotifyOnCompletion(taskNotifier ??= new(), newValue, static _ => { }, propertyName);
344344
}
345345

346346
/// <summary>
@@ -401,7 +401,7 @@ protected bool SetPropertyAndNotifyOnCompletion(ref TaskNotifier? taskNotifier,
401401
/// </remarks>
402402
protected bool SetPropertyAndNotifyOnCompletion<T>(ref TaskNotifier<T>? taskNotifier, Task<T>? newValue, [CallerMemberName] string? propertyName = null)
403403
{
404-
return SetPropertyAndNotifyOnCompletion(taskNotifier ??= new(), newValue, _ => { }, propertyName);
404+
return SetPropertyAndNotifyOnCompletion(taskNotifier ??= new(), newValue, static _ => { }, propertyName);
405405
}
406406

407407
/// <summary>

Microsoft.Toolkit.Mvvm/ComponentModel/ObservableValidator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ public IEnumerable<ValidationResult> GetErrors(string? propertyName)
338338
[MethodImpl(MethodImplOptions.NoInlining)]
339339
IEnumerable<ValidationResult> GetAllErrors()
340340
{
341-
return this.errors.Values.SelectMany(errors => errors);
341+
return this.errors.Values.SelectMany(static errors => errors);
342342
}
343343

344344
return GetAllErrors();

Microsoft.Toolkit.Mvvm/Messaging/IMessengerExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static Action<IMessenger, object, TToken> GetRegistrationAction(Type type, Metho
138138
// For more info on this, see the related issue at https://github.com/dotnet/roslyn/issues/5835.
139139
Action<IMessenger, object, TToken>[] registrationActions = DiscoveredRecipients<TToken>.RegistrationMethods.GetValue(
140140
recipient.GetType(),
141-
t => LoadRegistrationMethodsForType(t));
141+
static t => LoadRegistrationMethodsForType(t));
142142

143143
foreach (Action<IMessenger, object, TToken> registrationAction in registrationActions)
144144
{
@@ -157,7 +157,7 @@ static Action<IMessenger, object, TToken> GetRegistrationAction(Type type, Metho
157157
public static void Register<TMessage>(this IMessenger messenger, IRecipient<TMessage> recipient)
158158
where TMessage : class
159159
{
160-
messenger.Register<IRecipient<TMessage>, TMessage, Unit>(recipient, default, (r, m) => r.Receive(m));
160+
messenger.Register<IRecipient<TMessage>, TMessage, Unit>(recipient, default, static (r, m) => r.Receive(m));
161161
}
162162

163163
/// <summary>
@@ -174,7 +174,7 @@ public static void Register<TMessage, TToken>(this IMessenger messenger, IRecipi
174174
where TMessage : class
175175
where TToken : IEquatable<TToken>
176176
{
177-
messenger.Register<IRecipient<TMessage>, TMessage, TToken>(recipient, token, (r, m) => r.Receive(m));
177+
messenger.Register<IRecipient<TMessage>, TMessage, TToken>(recipient, token, static (r, m) => r.Receive(m));
178178
}
179179

180180
/// <summary>

Microsoft.Toolkit.Mvvm/Messaging/WeakReferenceMessenger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void Register<TRecipient, TMessage, TToken>(TRecipient recipient, TToken
8787
mapping ??= new RecipientsTable();
8888

8989
// Get or create the handlers dictionary for the target recipient
90-
var map = Unsafe.As<DictionarySlim<TToken, object>>(mapping.GetValue(recipient, _ => new DictionarySlim<TToken, object>()));
90+
var map = Unsafe.As<DictionarySlim<TToken, object>>(mapping.GetValue(recipient, static _ => new DictionarySlim<TToken, object>()));
9191

9292
// Add the new registration entry
9393
ref object? registeredHandler = ref map.GetOrAddValueRef(token);

0 commit comments

Comments
 (0)