Minor code tweaks

This commit is contained in:
Sergio Pedri
2021-02-13 00:16:27 +01:00
parent 451111ff82
commit 562c505a82
4 changed files with 7 additions and 7 deletions
@@ -340,7 +340,7 @@ namespace Microsoft.Toolkit.Mvvm.ComponentModel
// instance. This will result in no further allocations after the first time this method is called for a given
// generic type. We only pay the cost of the virtual call to the delegate, but this is not performance critical
// code and that overhead would still be much lower than the rest of the method anyway, so that's fine.
return SetPropertyAndNotifyOnCompletion(taskNotifier ??= new(), newValue, _ => { }, propertyName);
return SetPropertyAndNotifyOnCompletion(taskNotifier ??= new(), newValue, static _ => { }, propertyName);
}
/// <summary>
@@ -401,7 +401,7 @@ namespace Microsoft.Toolkit.Mvvm.ComponentModel
/// </remarks>
protected bool SetPropertyAndNotifyOnCompletion<T>(ref TaskNotifier<T>? taskNotifier, Task<T>? newValue, [CallerMemberName] string? propertyName = null)
{
return SetPropertyAndNotifyOnCompletion(taskNotifier ??= new(), newValue, _ => { }, propertyName);
return SetPropertyAndNotifyOnCompletion(taskNotifier ??= new(), newValue, static _ => { }, propertyName);
}
/// <summary>
@@ -338,7 +338,7 @@ namespace Microsoft.Toolkit.Mvvm.ComponentModel
[MethodImpl(MethodImplOptions.NoInlining)]
IEnumerable<ValidationResult> GetAllErrors()
{
return this.errors.Values.SelectMany(errors => errors);
return this.errors.Values.SelectMany(static errors => errors);
}
return GetAllErrors();
@@ -138,7 +138,7 @@ namespace Microsoft.Toolkit.Mvvm.Messaging
// For more info on this, see the related issue at https://github.com/dotnet/roslyn/issues/5835.
Action<IMessenger, object, TToken>[] registrationActions = DiscoveredRecipients<TToken>.RegistrationMethods.GetValue(
recipient.GetType(),
t => LoadRegistrationMethodsForType(t));
static t => LoadRegistrationMethodsForType(t));
foreach (Action<IMessenger, object, TToken> registrationAction in registrationActions)
{
@@ -157,7 +157,7 @@ namespace Microsoft.Toolkit.Mvvm.Messaging
public static void Register<TMessage>(this IMessenger messenger, IRecipient<TMessage> recipient)
where TMessage : class
{
messenger.Register<IRecipient<TMessage>, TMessage, Unit>(recipient, default, (r, m) => r.Receive(m));
messenger.Register<IRecipient<TMessage>, TMessage, Unit>(recipient, default, static (r, m) => r.Receive(m));
}
/// <summary>
@@ -174,7 +174,7 @@ namespace Microsoft.Toolkit.Mvvm.Messaging
where TMessage : class
where TToken : IEquatable<TToken>
{
messenger.Register<IRecipient<TMessage>, TMessage, TToken>(recipient, token, (r, m) => r.Receive(m));
messenger.Register<IRecipient<TMessage>, TMessage, TToken>(recipient, token, static (r, m) => r.Receive(m));
}
/// <summary>
@@ -87,7 +87,7 @@ namespace Microsoft.Toolkit.Mvvm.Messaging
mapping ??= new RecipientsTable();
// Get or create the handlers dictionary for the target recipient
var map = Unsafe.As<DictionarySlim<TToken, object>>(mapping.GetValue(recipient, _ => new DictionarySlim<TToken, object>()));
var map = Unsafe.As<DictionarySlim<TToken, object>>(mapping.GetValue(recipient, static _ => new DictionarySlim<TToken, object>()));
// Add the new registration entry
ref object? registeredHandler = ref map.GetOrAddValueRef(token);