Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change ValueChangedEvent to a struct #6114

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions osu.Framework.Tests/Bindables/BindableBindingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,8 @@ public void TestEventArgs()

bindable2.BindTo(bindable1);

ValueChangedEvent<int> event1 = null;
ValueChangedEvent<int> event2 = null;
ValueChangedEvent<int> event1 = default;
ValueChangedEvent<int> event2 = default;

bindable1.BindValueChanged(e => event1 = e);
bindable2.BindValueChanged(e => event2 = e);
Expand Down
2 changes: 1 addition & 1 deletion osu.Framework/Audio/AdjustableAudioComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void RemoveAdjustment(AdjustableProperty type, IBindable<double> adjustBi

private bool invalidationPending;

internal void InvalidateState(ValueChangedEvent<double>? valueChangedEvent = null)
internal void InvalidateState(ValueChangedEvent<double> valueChangedEvent = default)
{
if (CanPerformInline)
OnStateChanged();
Expand Down
2 changes: 1 addition & 1 deletion osu.Framework/Bindables/AggregateBindable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void RemoveSource(IBindable<T> bindable)
private WeakRefPair findExistingPair(IBindable<T> bindable) =>
sourceMapping.FirstOrDefault(p => p.WeakReference.TryGetTarget(out var target) && target == bindable);

private void recalculateAggregate(ValueChangedEvent<T> obj = null)
private void recalculateAggregate(ValueChangedEvent<T> obj = default)
{
T calculated = initialValue;

Expand Down
2 changes: 1 addition & 1 deletion osu.Framework/Bindables/ValueChangedEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace osu.Framework.Bindables
/// An event fired when a value changes, providing the old and new value for reference.
/// </summary>
/// <typeparam name="T">The type of bindable.</typeparam>
public class ValueChangedEvent<T>
public readonly struct ValueChangedEvent<T>
{
/// <summary>
/// The old value.
Expand Down
Loading