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
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ public static bool TryGetInfo(
token.ThrowIfCancellationRequested();

using ImmutableArrayBuilder<string> propertyChangedNames = ImmutableArrayBuilder<string>.Rent();
using ImmutableArrayBuilder<string> propertyChangingNames = ImmutableArrayBuilder<string>.Rent();
using ImmutableArrayBuilder<string> notifiedCommandNames = ImmutableArrayBuilder<string>.Rent();
using ImmutableArrayBuilder<AttributeInfo> forwardedAttributes = ImmutableArrayBuilder<AttributeInfo>.Rent();

Expand All @@ -131,12 +130,6 @@ public static bool TryGetInfo(

token.ThrowIfCancellationRequested();

// Track the property changing event for the property, if the type supports it
if (shouldInvokeOnPropertyChanging)
{
propertyChangingNames.Add(propertyName);
}

// The current property is always notified
propertyChangedNames.Add(propertyName);

Expand Down Expand Up @@ -296,12 +289,24 @@ public static bool TryGetInfo(

token.ThrowIfCancellationRequested();

// Prepare the effective property changing/changed names. For the property changing names,
// there are two possible cases: if the mode is disabled, then there are no names to report
// at all. If the mode is enabled, then the list is just the same as for property changed.
ImmutableArray<string> effectivePropertyChangedNames = propertyChangedNames.ToImmutable();
ImmutableArray<string> effectivePropertyChangingNames = shouldInvokeOnPropertyChanging switch
{
true => effectivePropertyChangedNames,
false => ImmutableArray<string>.Empty
};

token.ThrowIfCancellationRequested();

propertyInfo = new PropertyInfo(
typeNameWithNullabilityAnnotations,
fieldName,
propertyName,
propertyChangingNames.ToImmutable(),
propertyChangedNames.ToImmutable(),
effectivePropertyChangingNames,
effectivePropertyChangedNames,
notifiedCommandNames.ToImmutable(),
notifyRecipients,
notifyDataErrorInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,14 @@ namespace CommunityToolkit.Mvvm.ComponentModel;
/// get => name;
/// set
/// {
/// if (SetProperty(ref name, value))
/// if (!EqualityComparer&lt;string&gt;.Default.Equals(name, value))
/// {
/// OnPropertyChanging(nameof(Name));
/// OnPropertyChanged(nameof(FullName));
///
/// name = value;
///
/// OnPropertyChanged(nameof(Name));
/// OnPropertyChanged(nameof(FullName));
/// }
/// }
Expand All @@ -58,8 +64,14 @@ namespace CommunityToolkit.Mvvm.ComponentModel;
/// get => surname;
/// set
/// {
/// if (SetProperty(ref surname, value))
/// if (!EqualityComparer&lt;string&gt;.Default.Equals(name, value))
/// {
/// OnPropertyChanging(nameof(Surname));
/// OnPropertyChanged(nameof(FullName));
///
/// surname = value;
///
/// OnPropertyChanged(nameof(Surname));
/// OnPropertyChanged(nameof(FullName));
/// }
/// }
Expand Down
Loading