mirror of
https://github.com/CommunityToolkit/dotnet.git
synced 2026-10-26 01:53:02 +08:00
Minor code tweaks
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user