Skip to content

Commit f6bdee0

Browse files
authored
Housekeeping - Update Spelling and minor code fixes (#3649)
<!-- Please be sure to read the [Contribute](https://github.com/reactiveui/reactiveui#contribute) section of the README --> **What kind of change does this PR introduce?** <!-- Bug fix, feature, docs update, ... --> Update **What is the current behavior?** <!-- You can also link to an open issue here. --> Code has spelling errors **What is the new behavior?** <!-- If this is a feature change --> Fixed ReactiveUI main project spelling **What might this PR break?** none expected **Please check if the PR fulfills these requirements** - [ ] Tests for the changes have been added (for bug fixes / features) - [ ] Docs have been added / updated (for bug fixes / features) **Other information**:
1 parent ba197d4 commit f6bdee0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+171
-259
lines changed

src/ReactiveUI.Fody.Helpers/ReactiveDependencyAttribute.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,17 @@ namespace ReactiveUI.Fody.Helpers;
1111
/// Attribute that marks a property as a Reactive Dependency.
1212
/// </summary>
1313
/// <seealso cref="System.Attribute" />
14+
/// <remarks>
15+
/// Initializes a new instance of the <see cref="ReactiveDependencyAttribute"/> class.
16+
/// </remarks>
17+
/// <param name="targetName">Name of the target.</param>
1418
[AttributeUsage(AttributeTargets.Property)]
15-
public sealed class ReactiveDependencyAttribute : Attribute
19+
public sealed class ReactiveDependencyAttribute(string targetName) : Attribute
1620
{
17-
/// <summary>
18-
/// Initializes a new instance of the <see cref="ReactiveDependencyAttribute"/> class.
19-
/// </summary>
20-
/// <param name="targetName">Name of the target.</param>
21-
public ReactiveDependencyAttribute(string targetName) => Target = targetName;
22-
2321
/// <summary>
2422
/// Gets the name of the backing property.
2523
/// </summary>
26-
public string Target { get; }
24+
public string Target { get; } = targetName;
2725

2826
/// <summary>
2927
/// Gets or sets the target property on the backing property.

src/ReactiveUI/Activation/ViewForMixins.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,14 @@ public static IDisposable WhenActivated(this IActivatableView item, Action<Compo
227227
},
228228
view);
229229

230-
private static IDisposable HandleViewActivation(Func<IEnumerable<IDisposable>> block, IObservable<bool> activation)
230+
private static CompositeDisposable HandleViewActivation(Func<IEnumerable<IDisposable>> block, IObservable<bool> activation)
231231
{
232232
var viewDisposable = new SerialDisposable();
233233

234234
return new CompositeDisposable(
235235
activation.Subscribe(activated =>
236236
{
237-
// NB: We need to make sure to respect ordering so that the cleanup
237+
// NB: We need to make sure to respect ordering so that the clean up
238238
// happens before we invoke block again
239239
viewDisposable.Disposable = Disposable.Empty;
240240
if (activated)
@@ -245,7 +245,7 @@ private static IDisposable HandleViewActivation(Func<IEnumerable<IDisposable>> b
245245
viewDisposable);
246246
}
247247

248-
private static IDisposable HandleViewModelActivation(IViewFor view, IObservable<bool> activation)
248+
private static CompositeDisposable HandleViewModelActivation(IViewFor view, IObservable<bool> activation)
249249
{
250250
var vmDisposable = new SerialDisposable();
251251
var viewVmDisposable = new SerialDisposable();
@@ -259,7 +259,7 @@ private static IDisposable HandleViewModelActivation(IViewFor view, IObservable<
259259
.Select(x => x as IActivatableViewModel)
260260
.Subscribe(x =>
261261
{
262-
// NB: We need to make sure to respect ordering so that the cleanup
262+
// NB: We need to make sure to respect ordering so that the clean up
263263
// happens before we activate again
264264
vmDisposable.Disposable = Disposable.Empty;
265265
if (x is not null)

src/ReactiveUI/Activation/ViewModelActivator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ public sealed class ViewModelActivator : IDisposable
4545
/// </summary>
4646
public ViewModelActivator()
4747
{
48-
_blocks = new List<Func<IEnumerable<IDisposable>>>();
49-
_activated = new Subject<Unit>();
50-
_deactivated = new Subject<Unit>();
48+
_blocks = new();
49+
_activated = new();
50+
_deactivated = new();
5151
}
5252

5353
/// <summary>
@@ -111,4 +111,4 @@ public void Dispose()
111111
/// </summary>
112112
/// <param name="block">The block to add.</param>
113113
internal void AddActivationBlock(Func<IEnumerable<IDisposable>> block) => _blocks.Add(block);
114-
}
114+
}

src/ReactiveUI/Bindings/Property/IPropertyBinderImplementation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,4 +226,4 @@ IDisposable BindTo<TValue, TTarget, TTValue>(
226226
object? conversionHint,
227227
IBindingTypeConverter? vmToViewConverterOverride = null)
228228
where TTarget : class;
229-
}
229+
}

src/ReactiveUI/Bindings/Property/PropertyBinderImplementation.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// The .NET Foundation licenses this file to you under the MIT license.
44
// See the LICENSE file in the project root for full license information.
55

6-
using System.Diagnostics.CodeAnalysis;
76
using System.Globalization;
87

98
namespace ReactiveUI;
@@ -257,10 +256,7 @@ public IDisposable BindTo<TValue, TTarget, TTValue>(
257256
}
258257

259258
var setter = _setMethodCache.Get((fromType, targetType));
260-
261-
#pragma warning disable IDE0031 // Use null propagation
262259
return setter is null ? null : setter.PerformSet;
263-
#pragma warning restore IDE0031 // Use null propagation
264260
}
265261

266262
private (IDisposable disposable, IObservable<TValue> value) BindToDirect<TTarget, TValue, TObs>(
@@ -332,7 +328,7 @@ private bool EvalBindingHooks<TViewModel, TView>(TViewModel? viewModel, TView vi
332328
})
333329
: (() => new IObservedChange<object, object?>[]
334330
{
335-
new ObservedChange<object, object?>(null!, null!, viewModel)
331+
new ObservedChange<object, object?>(null!, null, viewModel)
336332
});
337333

338334
var vFetcher = new Func<IObservedChange<object, object?>[]>(() =>
@@ -354,7 +350,6 @@ private bool EvalBindingHooks<TViewModel, TView>(TViewModel? viewModel, TView vi
354350
return shouldBind;
355351
}
356352

357-
[SuppressMessage("Roslynator", "RCS1176: Use var instead of explicit", Justification = "Required for generics")]
358353
private IReactiveBinding<TView, (object? view, bool isViewModel)> BindImpl<TViewModel, TView, TVMProp, TVProp, TDontCare>(
359354
TViewModel? viewModel,
360355
TView view,
@@ -466,4 +461,4 @@ signalViewUpdate is null ?
466461
BindingDirection.TwoWay,
467462
disposable);
468463
}
469-
}
464+
}

src/ReactiveUI/Bindings/Property/PropertyBindingMixins.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static PropertyBindingMixins()
7575

7676
/// <summary>
7777
/// Binds the specified view model property to the given view property, and
78-
/// provide a custom view update signaler to signal when the view property has been updated.
78+
/// provide a custom view update signaller to signal when the view property has been updated.
7979
/// </summary>
8080
/// <typeparam name="TViewModel">The type of the view model being bound.</typeparam>
8181
/// <typeparam name="TView">The type of the view being bound.</typeparam>
@@ -327,4 +327,4 @@ public static IDisposable BindTo<TValue, TTarget, TTValue>(
327327
IBindingTypeConverter? vmToViewConverterOverride = null)
328328
where TTarget : class =>
329329
_binderImplementation.BindTo(@this, target, property, conversionHint, vmToViewConverterOverride);
330-
}
330+
}

src/ReactiveUI/Bindings/Reactive/IReactiveBinding.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public interface IReactiveBinding<out TView, out TValue> : IDisposable
1717
where TView : IViewFor
1818
{
1919
/// <summary>
20-
/// Gets an expression representing the property on the viewmodel bound to the view.
20+
/// Gets an expression representing the property on the ViewModel bound to the view.
2121
/// This can be a child property, for example x.Foo.Bar.Baz in which case
2222
/// that will be the expression.
2323
/// </summary>
@@ -29,7 +29,7 @@ public interface IReactiveBinding<out TView, out TValue> : IDisposable
2929
TView View { get; }
3030

3131
/// <summary>
32-
/// Gets an expression representing the property on the view bound to the viewmodel.
32+
/// Gets an expression representing the property on the view bound to the ViewModel.
3333
/// This can be a child property, for example x.Foo.Bar.Baz in which case
3434
/// that will be the expression.
3535
/// </summary>
@@ -44,4 +44,4 @@ public interface IReactiveBinding<out TView, out TValue> : IDisposable
4444
/// Gets the direction of the binding.
4545
/// </summary>
4646
BindingDirection Direction { get; }
47-
}
47+
}

src/ReactiveUI/Bindings/Reactive/ReactiveBinding.cs

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,29 @@
55

66
namespace ReactiveUI;
77

8-
internal class ReactiveBinding<TView, TValue> : IReactiveBinding<TView, TValue>
8+
internal class ReactiveBinding<TView, TValue>(
9+
TView view,
10+
Expression viewExpression,
11+
Expression viewModelExpression,
12+
IObservable<TValue?> changed,
13+
BindingDirection direction,
14+
IDisposable bindingDisposable) : IReactiveBinding<TView, TValue>
915
where TView : IViewFor
1016
{
11-
private readonly IDisposable _bindingDisposable;
12-
13-
public ReactiveBinding(
14-
TView view,
15-
Expression viewExpression,
16-
Expression viewModelExpression,
17-
IObservable<TValue?> changed,
18-
BindingDirection direction,
19-
IDisposable bindingDisposable)
20-
{
21-
View = view;
22-
ViewExpression = viewExpression;
23-
ViewModelExpression = viewModelExpression;
24-
Direction = direction;
25-
Changed = changed;
26-
27-
_bindingDisposable = bindingDisposable;
28-
}
29-
3017
/// <inheritdoc />
31-
public Expression ViewModelExpression { get; }
18+
public Expression ViewModelExpression { get; } = viewModelExpression;
3219

3320
/// <inheritdoc />
34-
public TView View { get; }
21+
public TView View { get; } = view;
3522

3623
/// <inheritdoc />
37-
public Expression ViewExpression { get; }
24+
public Expression ViewExpression { get; } = viewExpression;
3825

3926
/// <inheritdoc />
40-
public IObservable<TValue?> Changed { get; }
27+
public IObservable<TValue?> Changed { get; } = changed;
4128

4229
/// <inheritdoc />
43-
public BindingDirection Direction { get; }
30+
public BindingDirection Direction { get; } = direction;
4431

4532
/// <inheritdoc />
4633
public void Dispose()
@@ -57,7 +44,7 @@ protected virtual void Dispose(bool isDisposing)
5744
{
5845
if (isDisposing)
5946
{
60-
_bindingDisposable.Dispose();
47+
bindingDisposable.Dispose();
6148
}
6249
}
63-
}
50+
}

src/ReactiveUI/Comparers/ChainedComparer.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,19 @@
55

66
namespace ReactiveUI;
77

8-
internal sealed class ChainedComparer<T> : IComparer<T>
8+
internal sealed class ChainedComparer<T>(IComparer<T>? parent, Comparison<T> comparison) : IComparer<T>
99
{
10-
private readonly IComparer<T>? _parent;
11-
private readonly Comparison<T> _inner;
12-
13-
public ChainedComparer(IComparer<T>? parent, Comparison<T> comparison)
14-
{
15-
_parent = parent;
16-
_inner = comparison;
17-
}
1810

1911
/// <inheritdoc />
2012
public int Compare(T? x, T? y)
2113
{
22-
var parentResult = _parent?.Compare(x!, y!) ?? 0;
14+
var parentResult = parent?.Compare(x!, y!) ?? 0;
2315

2416
if (x is null && y is null)
2517
{
2618
return 0;
2719
}
2820

29-
return parentResult != 0 ? parentResult : _inner(x!, y!);
21+
return parentResult != 0 ? parentResult : comparison(x!, y!);
3022
}
31-
}
23+
}

src/ReactiveUI/Expression/ExpressionRewriter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected override Expression VisitUnary(UnaryExpression node)
101101
protected override Expression VisitMethodCall(MethodCallExpression node)
102102
{
103103
// Rewrite a method call to an indexer as an index expression
104-
if (node.Arguments.Any(e => !(e is ConstantExpression)) || !node.Method.IsSpecialName)
104+
if (node.Arguments.Any(e => e is not ConstantExpression) || !node.Method.IsSpecialName)
105105
{
106106
throw new NotSupportedException("Index expressions are only supported with constants.");
107107
}
@@ -120,11 +120,11 @@ protected override Expression VisitMethodCall(MethodCallExpression node)
120120

121121
protected override Expression VisitIndex(IndexExpression node)
122122
{
123-
if (node.Arguments.Any(e => !(e is ConstantExpression)))
123+
if (node.Arguments.Any(e => e is not ConstantExpression))
124124
{
125125
throw new NotSupportedException("Index expressions are only supported with constants.");
126126
}
127127

128128
return base.VisitIndex(node);
129129
}
130-
}
130+
}

src/ReactiveUI/Expression/Reflection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public static bool TrySetValueToPropertyChain<TValue>(object? target, IEnumerabl
327327
/// Gets the appropriate EventArgs derived object for the specified event name for a Type.
328328
/// </summary>
329329
/// <param name="type">The type of object to find the event on.</param>
330-
/// <param name="eventName">The mame of the event.</param>
330+
/// <param name="eventName">The name of the event.</param>
331331
/// <returns>The Type of the EventArgs to use.</returns>
332332
/// <exception cref="Exception">If there is no event matching the name on the target type.</exception>
333333
public static Type GetEventArgsTypeForEvent(Type type, string? eventName) // TODO: Create Test
@@ -398,4 +398,4 @@ internal static IObservable<object> ViewModelWhenAnyValue<TView, TViewModel>(TVi
398398
.Where(x => x is not null)
399399
.Select(x => ((TViewModel?)x).WhenAnyDynamic(expression, y => y.Value))
400400
.Switch()!;
401-
}
401+
}

src/ReactiveUI/Interfaces/ICreatesObservableForProperty.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ public interface ICreatesObservableForProperty : IEnableLogger
4545
/// property on the object changes. If this cannot be done for a
4646
/// specified value of beforeChanged, return Observable.Never.</returns>
4747
IObservable<IObservedChange<object?, object?>> GetNotificationForProperty(object sender, Expression expression, string propertyName, bool beforeChanged = false, bool suppressWarnings = false);
48-
}
48+
}

src/ReactiveUI/Interfaces/ObservedChange.cs

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,20 @@ namespace ReactiveUI;
1010
/// </summary>
1111
/// <typeparam name="TSender">The sender type.</typeparam>
1212
/// <typeparam name="TValue">The value type.</typeparam>
13-
public class ObservedChange<TSender, TValue> : IObservedChange<TSender, TValue>
13+
/// <remarks>
14+
/// Initializes a new instance of the <see cref="ObservedChange{TSender, TValue}"/> class.
15+
/// </remarks>
16+
/// <param name="sender">The sender.</param>
17+
/// <param name="expression">Expression describing the member.</param>
18+
/// <param name="value">The value.</param>
19+
public class ObservedChange<TSender, TValue>(TSender sender, Expression? expression, TValue value) : IObservedChange<TSender, TValue>
1420
{
15-
/// <summary>
16-
/// Initializes a new instance of the <see cref="ObservedChange{TSender, TValue}"/> class.
17-
/// </summary>
18-
/// <param name="sender">The sender.</param>
19-
/// <param name="expression">Expression describing the member.</param>
20-
/// <param name="value">The value.</param>
21-
public ObservedChange(TSender sender, Expression? expression, TValue value)
22-
{
23-
Sender = sender;
24-
Expression = expression;
25-
Value = value;
26-
}
27-
2821
/// <inheritdoc/>
29-
public TSender Sender { get; }
22+
public TSender Sender { get; } = sender;
3023

3124
/// <inheritdoc/>
32-
public Expression? Expression { get; }
25+
public Expression? Expression { get; } = expression;
3326

3427
/// <inheritdoc/>
35-
public TValue Value { get; }
36-
}
28+
public TValue Value { get; } = value;
29+
}

src/ReactiveUI/Interfaces/ReactivePropertyChangedEventArgs.cs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,23 @@
33
// The .NET Foundation licenses this file to you under the MIT license.
44
// See the LICENSE file in the project root for full license information.
55

6-
using System.ComponentModel;
7-
86
namespace ReactiveUI;
97

108
/// <summary>
119
/// Event arguments for when a property has changed.
1210
/// Expands on the PropertyChangedEventArgs to add the Sender.
1311
/// </summary>
1412
/// <typeparam name="TSender">The sender type.</typeparam>
15-
public class ReactivePropertyChangedEventArgs<TSender> : PropertyChangedEventArgs, IReactivePropertyChangedEventArgs<TSender>
13+
/// <remarks>
14+
/// Initializes a new instance of the <see cref="ReactivePropertyChangedEventArgs{TSender}"/> class.
15+
/// </remarks>
16+
/// <param name="sender">The sender.</param>
17+
/// <param name="propertyName">Name of the property.</param>
18+
public class ReactivePropertyChangedEventArgs<TSender>(TSender sender, string propertyName) : PropertyChangedEventArgs(propertyName), IReactivePropertyChangedEventArgs<TSender>
1619
{
17-
/// <summary>
18-
/// Initializes a new instance of the <see cref="ReactivePropertyChangedEventArgs{TSender}"/> class.
19-
/// </summary>
20-
/// <param name="sender">The sender.</param>
21-
/// <param name="propertyName">Name of the property.</param>
22-
public ReactivePropertyChangedEventArgs(TSender sender, string propertyName)
23-
: base(propertyName) =>
24-
Sender = sender;
25-
2620
/// <summary>
2721
/// Gets the sender which triggered the property changed event.
2822
/// </summary>
2923
/// <inheritdoc/>
30-
public TSender Sender { get; }
31-
}
24+
public TSender Sender { get; } = sender;
25+
}

0 commit comments

Comments
 (0)