From 562c505a8295e8fcd69d41bdfabbef1f26cb4966 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 20 Nov 2020 14:26:24 +0100 Subject: [PATCH] Minor code tweaks --- Microsoft.Toolkit.Mvvm/ComponentModel/ObservableObject.cs | 4 ++-- .../ComponentModel/ObservableValidator.cs | 2 +- Microsoft.Toolkit.Mvvm/Messaging/IMessengerExtensions.cs | 6 +++--- Microsoft.Toolkit.Mvvm/Messaging/WeakReferenceMessenger.cs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Microsoft.Toolkit.Mvvm/ComponentModel/ObservableObject.cs b/Microsoft.Toolkit.Mvvm/ComponentModel/ObservableObject.cs index d8f9c052..c7e4f053 100644 --- a/Microsoft.Toolkit.Mvvm/ComponentModel/ObservableObject.cs +++ b/Microsoft.Toolkit.Mvvm/ComponentModel/ObservableObject.cs @@ -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); } /// @@ -401,7 +401,7 @@ namespace Microsoft.Toolkit.Mvvm.ComponentModel /// protected bool SetPropertyAndNotifyOnCompletion(ref TaskNotifier? taskNotifier, Task? newValue, [CallerMemberName] string? propertyName = null) { - return SetPropertyAndNotifyOnCompletion(taskNotifier ??= new(), newValue, _ => { }, propertyName); + return SetPropertyAndNotifyOnCompletion(taskNotifier ??= new(), newValue, static _ => { }, propertyName); } /// diff --git a/Microsoft.Toolkit.Mvvm/ComponentModel/ObservableValidator.cs b/Microsoft.Toolkit.Mvvm/ComponentModel/ObservableValidator.cs index 8408d3d7..76f5ade5 100644 --- a/Microsoft.Toolkit.Mvvm/ComponentModel/ObservableValidator.cs +++ b/Microsoft.Toolkit.Mvvm/ComponentModel/ObservableValidator.cs @@ -338,7 +338,7 @@ namespace Microsoft.Toolkit.Mvvm.ComponentModel [MethodImpl(MethodImplOptions.NoInlining)] IEnumerable GetAllErrors() { - return this.errors.Values.SelectMany(errors => errors); + return this.errors.Values.SelectMany(static errors => errors); } return GetAllErrors(); diff --git a/Microsoft.Toolkit.Mvvm/Messaging/IMessengerExtensions.cs b/Microsoft.Toolkit.Mvvm/Messaging/IMessengerExtensions.cs index 5eb1d327..f4804582 100644 --- a/Microsoft.Toolkit.Mvvm/Messaging/IMessengerExtensions.cs +++ b/Microsoft.Toolkit.Mvvm/Messaging/IMessengerExtensions.cs @@ -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[] registrationActions = DiscoveredRecipients.RegistrationMethods.GetValue( recipient.GetType(), - t => LoadRegistrationMethodsForType(t)); + static t => LoadRegistrationMethodsForType(t)); foreach (Action registrationAction in registrationActions) { @@ -157,7 +157,7 @@ namespace Microsoft.Toolkit.Mvvm.Messaging public static void Register(this IMessenger messenger, IRecipient recipient) where TMessage : class { - messenger.Register, TMessage, Unit>(recipient, default, (r, m) => r.Receive(m)); + messenger.Register, TMessage, Unit>(recipient, default, static (r, m) => r.Receive(m)); } /// @@ -174,7 +174,7 @@ namespace Microsoft.Toolkit.Mvvm.Messaging where TMessage : class where TToken : IEquatable { - messenger.Register, TMessage, TToken>(recipient, token, (r, m) => r.Receive(m)); + messenger.Register, TMessage, TToken>(recipient, token, static (r, m) => r.Receive(m)); } /// diff --git a/Microsoft.Toolkit.Mvvm/Messaging/WeakReferenceMessenger.cs b/Microsoft.Toolkit.Mvvm/Messaging/WeakReferenceMessenger.cs index e8bc3890..b3f15157 100644 --- a/Microsoft.Toolkit.Mvvm/Messaging/WeakReferenceMessenger.cs +++ b/Microsoft.Toolkit.Mvvm/Messaging/WeakReferenceMessenger.cs @@ -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>(mapping.GetValue(recipient, _ => new DictionarySlim())); + var map = Unsafe.As>(mapping.GetValue(recipient, static _ => new DictionarySlim())); // Add the new registration entry ref object? registeredHandler = ref map.GetOrAddValueRef(token);