diff --git a/src/ReactiveUI.Fody.Helpers/ReactiveDependencyAttribute.cs b/src/ReactiveUI.Fody.Helpers/ReactiveDependencyAttribute.cs index 9a6d94459e..371a353f0e 100644 --- a/src/ReactiveUI.Fody.Helpers/ReactiveDependencyAttribute.cs +++ b/src/ReactiveUI.Fody.Helpers/ReactiveDependencyAttribute.cs @@ -11,19 +11,17 @@ namespace ReactiveUI.Fody.Helpers; /// Attribute that marks a property as a Reactive Dependency. /// /// +/// +/// Initializes a new instance of the class. +/// +/// Name of the target. [AttributeUsage(AttributeTargets.Property)] -public sealed class ReactiveDependencyAttribute : Attribute +public sealed class ReactiveDependencyAttribute(string targetName) : Attribute { - /// - /// Initializes a new instance of the class. - /// - /// Name of the target. - public ReactiveDependencyAttribute(string targetName) => Target = targetName; - /// /// Gets the name of the backing property. /// - public string Target { get; } + public string Target { get; } = targetName; /// /// Gets or sets the target property on the backing property. diff --git a/src/ReactiveUI/Activation/ViewForMixins.cs b/src/ReactiveUI/Activation/ViewForMixins.cs index 06b0b57671..4822effc42 100644 --- a/src/ReactiveUI/Activation/ViewForMixins.cs +++ b/src/ReactiveUI/Activation/ViewForMixins.cs @@ -227,14 +227,14 @@ public static IDisposable WhenActivated(this IActivatableView item, Action> block, IObservable activation) + private static CompositeDisposable HandleViewActivation(Func> block, IObservable activation) { var viewDisposable = new SerialDisposable(); return new CompositeDisposable( activation.Subscribe(activated => { - // NB: We need to make sure to respect ordering so that the cleanup + // NB: We need to make sure to respect ordering so that the clean up // happens before we invoke block again viewDisposable.Disposable = Disposable.Empty; if (activated) @@ -245,7 +245,7 @@ private static IDisposable HandleViewActivation(Func> b viewDisposable); } - private static IDisposable HandleViewModelActivation(IViewFor view, IObservable activation) + private static CompositeDisposable HandleViewModelActivation(IViewFor view, IObservable activation) { var vmDisposable = new SerialDisposable(); var viewVmDisposable = new SerialDisposable(); @@ -259,7 +259,7 @@ private static IDisposable HandleViewModelActivation(IViewFor view, IObservable< .Select(x => x as IActivatableViewModel) .Subscribe(x => { - // NB: We need to make sure to respect ordering so that the cleanup + // NB: We need to make sure to respect ordering so that the clean up // happens before we activate again vmDisposable.Disposable = Disposable.Empty; if (x is not null) diff --git a/src/ReactiveUI/Activation/ViewModelActivator.cs b/src/ReactiveUI/Activation/ViewModelActivator.cs index a56c14a796..79a5e4f333 100644 --- a/src/ReactiveUI/Activation/ViewModelActivator.cs +++ b/src/ReactiveUI/Activation/ViewModelActivator.cs @@ -45,9 +45,9 @@ public sealed class ViewModelActivator : IDisposable /// public ViewModelActivator() { - _blocks = new List>>(); - _activated = new Subject(); - _deactivated = new Subject(); + _blocks = new(); + _activated = new(); + _deactivated = new(); } /// @@ -111,4 +111,4 @@ public void Dispose() /// /// The block to add. internal void AddActivationBlock(Func> block) => _blocks.Add(block); -} \ No newline at end of file +} diff --git a/src/ReactiveUI/Bindings/Property/IPropertyBinderImplementation.cs b/src/ReactiveUI/Bindings/Property/IPropertyBinderImplementation.cs index 130245309e..fd740954e2 100644 --- a/src/ReactiveUI/Bindings/Property/IPropertyBinderImplementation.cs +++ b/src/ReactiveUI/Bindings/Property/IPropertyBinderImplementation.cs @@ -226,4 +226,4 @@ IDisposable BindTo( object? conversionHint, IBindingTypeConverter? vmToViewConverterOverride = null) where TTarget : class; -} \ No newline at end of file +} diff --git a/src/ReactiveUI/Bindings/Property/PropertyBinderImplementation.cs b/src/ReactiveUI/Bindings/Property/PropertyBinderImplementation.cs index 553e49d3b1..af4d781c16 100644 --- a/src/ReactiveUI/Bindings/Property/PropertyBinderImplementation.cs +++ b/src/ReactiveUI/Bindings/Property/PropertyBinderImplementation.cs @@ -3,7 +3,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Diagnostics.CodeAnalysis; using System.Globalization; namespace ReactiveUI; @@ -257,10 +256,7 @@ public IDisposable BindTo( } var setter = _setMethodCache.Get((fromType, targetType)); - -#pragma warning disable IDE0031 // Use null propagation return setter is null ? null : setter.PerformSet; -#pragma warning restore IDE0031 // Use null propagation } private (IDisposable disposable, IObservable value) BindToDirect( @@ -332,7 +328,7 @@ private bool EvalBindingHooks(TViewModel? viewModel, TView vi }) : (() => new IObservedChange[] { - new ObservedChange(null!, null!, viewModel) + new ObservedChange(null!, null, viewModel) }); var vFetcher = new Func[]>(() => @@ -354,7 +350,6 @@ private bool EvalBindingHooks(TViewModel? viewModel, TView vi return shouldBind; } - [SuppressMessage("Roslynator", "RCS1176: Use var instead of explicit", Justification = "Required for generics")] private IReactiveBinding BindImpl( TViewModel? viewModel, TView view, @@ -466,4 +461,4 @@ signalViewUpdate is null ? BindingDirection.TwoWay, disposable); } -} \ No newline at end of file +} diff --git a/src/ReactiveUI/Bindings/Property/PropertyBindingMixins.cs b/src/ReactiveUI/Bindings/Property/PropertyBindingMixins.cs index 82862b7db0..5dee02e855 100644 --- a/src/ReactiveUI/Bindings/Property/PropertyBindingMixins.cs +++ b/src/ReactiveUI/Bindings/Property/PropertyBindingMixins.cs @@ -75,7 +75,7 @@ static PropertyBindingMixins() /// /// Binds the specified view model property to the given view property, and - /// provide a custom view update signaler to signal when the view property has been updated. + /// provide a custom view update signaller to signal when the view property has been updated. /// /// The type of the view model being bound. /// The type of the view being bound. @@ -327,4 +327,4 @@ public static IDisposable BindTo( IBindingTypeConverter? vmToViewConverterOverride = null) where TTarget : class => _binderImplementation.BindTo(@this, target, property, conversionHint, vmToViewConverterOverride); -} \ No newline at end of file +} diff --git a/src/ReactiveUI/Bindings/Reactive/IReactiveBinding.cs b/src/ReactiveUI/Bindings/Reactive/IReactiveBinding.cs index ed6679e504..a25029daae 100644 --- a/src/ReactiveUI/Bindings/Reactive/IReactiveBinding.cs +++ b/src/ReactiveUI/Bindings/Reactive/IReactiveBinding.cs @@ -17,7 +17,7 @@ public interface IReactiveBinding : IDisposable where TView : IViewFor { /// - /// Gets an expression representing the property on the viewmodel bound to the view. + /// Gets an expression representing the property on the ViewModel bound to the view. /// This can be a child property, for example x.Foo.Bar.Baz in which case /// that will be the expression. /// @@ -29,7 +29,7 @@ public interface IReactiveBinding : IDisposable TView View { get; } /// - /// Gets an expression representing the property on the view bound to the viewmodel. + /// Gets an expression representing the property on the view bound to the ViewModel. /// This can be a child property, for example x.Foo.Bar.Baz in which case /// that will be the expression. /// @@ -44,4 +44,4 @@ public interface IReactiveBinding : IDisposable /// Gets the direction of the binding. /// BindingDirection Direction { get; } -} \ No newline at end of file +} diff --git a/src/ReactiveUI/Bindings/Reactive/ReactiveBinding.cs b/src/ReactiveUI/Bindings/Reactive/ReactiveBinding.cs index cd4e06aea9..154e01b5c3 100644 --- a/src/ReactiveUI/Bindings/Reactive/ReactiveBinding.cs +++ b/src/ReactiveUI/Bindings/Reactive/ReactiveBinding.cs @@ -5,42 +5,29 @@ namespace ReactiveUI; -internal class ReactiveBinding : IReactiveBinding +internal class ReactiveBinding( + TView view, + Expression viewExpression, + Expression viewModelExpression, + IObservable changed, + BindingDirection direction, + IDisposable bindingDisposable) : IReactiveBinding where TView : IViewFor { - private readonly IDisposable _bindingDisposable; - - public ReactiveBinding( - TView view, - Expression viewExpression, - Expression viewModelExpression, - IObservable changed, - BindingDirection direction, - IDisposable bindingDisposable) - { - View = view; - ViewExpression = viewExpression; - ViewModelExpression = viewModelExpression; - Direction = direction; - Changed = changed; - - _bindingDisposable = bindingDisposable; - } - /// - public Expression ViewModelExpression { get; } + public Expression ViewModelExpression { get; } = viewModelExpression; /// - public TView View { get; } + public TView View { get; } = view; /// - public Expression ViewExpression { get; } + public Expression ViewExpression { get; } = viewExpression; /// - public IObservable Changed { get; } + public IObservable Changed { get; } = changed; /// - public BindingDirection Direction { get; } + public BindingDirection Direction { get; } = direction; /// public void Dispose() @@ -57,7 +44,7 @@ protected virtual void Dispose(bool isDisposing) { if (isDisposing) { - _bindingDisposable.Dispose(); + bindingDisposable.Dispose(); } } -} \ No newline at end of file +} diff --git a/src/ReactiveUI/Comparers/ChainedComparer.cs b/src/ReactiveUI/Comparers/ChainedComparer.cs index 2f280cd059..f01478a7e2 100644 --- a/src/ReactiveUI/Comparers/ChainedComparer.cs +++ b/src/ReactiveUI/Comparers/ChainedComparer.cs @@ -5,27 +5,19 @@ namespace ReactiveUI; -internal sealed class ChainedComparer : IComparer +internal sealed class ChainedComparer(IComparer? parent, Comparison comparison) : IComparer { - private readonly IComparer? _parent; - private readonly Comparison _inner; - - public ChainedComparer(IComparer? parent, Comparison comparison) - { - _parent = parent; - _inner = comparison; - } /// public int Compare(T? x, T? y) { - var parentResult = _parent?.Compare(x!, y!) ?? 0; + var parentResult = parent?.Compare(x!, y!) ?? 0; if (x is null && y is null) { return 0; } - return parentResult != 0 ? parentResult : _inner(x!, y!); + return parentResult != 0 ? parentResult : comparison(x!, y!); } -} \ No newline at end of file +} diff --git a/src/ReactiveUI/Expression/ExpressionRewriter.cs b/src/ReactiveUI/Expression/ExpressionRewriter.cs index 1043b7f5c6..d0a95cbe7a 100644 --- a/src/ReactiveUI/Expression/ExpressionRewriter.cs +++ b/src/ReactiveUI/Expression/ExpressionRewriter.cs @@ -101,7 +101,7 @@ protected override Expression VisitUnary(UnaryExpression node) protected override Expression VisitMethodCall(MethodCallExpression node) { // Rewrite a method call to an indexer as an index expression - if (node.Arguments.Any(e => !(e is ConstantExpression)) || !node.Method.IsSpecialName) + if (node.Arguments.Any(e => e is not ConstantExpression) || !node.Method.IsSpecialName) { throw new NotSupportedException("Index expressions are only supported with constants."); } @@ -120,11 +120,11 @@ protected override Expression VisitMethodCall(MethodCallExpression node) protected override Expression VisitIndex(IndexExpression node) { - if (node.Arguments.Any(e => !(e is ConstantExpression))) + if (node.Arguments.Any(e => e is not ConstantExpression)) { throw new NotSupportedException("Index expressions are only supported with constants."); } return base.VisitIndex(node); } -} \ No newline at end of file +} diff --git a/src/ReactiveUI/Expression/Reflection.cs b/src/ReactiveUI/Expression/Reflection.cs index 07e79978cb..40f243ed8a 100644 --- a/src/ReactiveUI/Expression/Reflection.cs +++ b/src/ReactiveUI/Expression/Reflection.cs @@ -327,7 +327,7 @@ public static bool TrySetValueToPropertyChain(object? target, IEnumerabl /// Gets the appropriate EventArgs derived object for the specified event name for a Type. /// /// The type of object to find the event on. - /// The mame of the event. + /// The name of the event. /// The Type of the EventArgs to use. /// If there is no event matching the name on the target type. public static Type GetEventArgsTypeForEvent(Type type, string? eventName) // TODO: Create Test @@ -398,4 +398,4 @@ internal static IObservable ViewModelWhenAnyValue(TVi .Where(x => x is not null) .Select(x => ((TViewModel?)x).WhenAnyDynamic(expression, y => y.Value)) .Switch()!; -} \ No newline at end of file +} diff --git a/src/ReactiveUI/Interfaces/ICreatesObservableForProperty.cs b/src/ReactiveUI/Interfaces/ICreatesObservableForProperty.cs index 8015885f0b..918c1fb1eb 100644 --- a/src/ReactiveUI/Interfaces/ICreatesObservableForProperty.cs +++ b/src/ReactiveUI/Interfaces/ICreatesObservableForProperty.cs @@ -45,4 +45,4 @@ public interface ICreatesObservableForProperty : IEnableLogger /// property on the object changes. If this cannot be done for a /// specified value of beforeChanged, return Observable.Never. IObservable> GetNotificationForProperty(object sender, Expression expression, string propertyName, bool beforeChanged = false, bool suppressWarnings = false); -} \ No newline at end of file +} diff --git a/src/ReactiveUI/Interfaces/ObservedChange.cs b/src/ReactiveUI/Interfaces/ObservedChange.cs index 70ca7078ea..b80ea91cf4 100644 --- a/src/ReactiveUI/Interfaces/ObservedChange.cs +++ b/src/ReactiveUI/Interfaces/ObservedChange.cs @@ -10,27 +10,20 @@ namespace ReactiveUI; /// /// The sender type. /// The value type. -public class ObservedChange : IObservedChange +/// +/// Initializes a new instance of the class. +/// +/// The sender. +/// Expression describing the member. +/// The value. +public class ObservedChange(TSender sender, Expression? expression, TValue value) : IObservedChange { - /// - /// Initializes a new instance of the class. - /// - /// The sender. - /// Expression describing the member. - /// The value. - public ObservedChange(TSender sender, Expression? expression, TValue value) - { - Sender = sender; - Expression = expression; - Value = value; - } - /// - public TSender Sender { get; } + public TSender Sender { get; } = sender; /// - public Expression? Expression { get; } + public Expression? Expression { get; } = expression; /// - public TValue Value { get; } -} \ No newline at end of file + public TValue Value { get; } = value; +} diff --git a/src/ReactiveUI/Interfaces/ReactivePropertyChangedEventArgs.cs b/src/ReactiveUI/Interfaces/ReactivePropertyChangedEventArgs.cs index c8b0287138..c9635d0334 100644 --- a/src/ReactiveUI/Interfaces/ReactivePropertyChangedEventArgs.cs +++ b/src/ReactiveUI/Interfaces/ReactivePropertyChangedEventArgs.cs @@ -3,8 +3,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.ComponentModel; - namespace ReactiveUI; /// @@ -12,20 +10,16 @@ namespace ReactiveUI; /// Expands on the PropertyChangedEventArgs to add the Sender. /// /// The sender type. -public class ReactivePropertyChangedEventArgs : PropertyChangedEventArgs, IReactivePropertyChangedEventArgs +/// +/// Initializes a new instance of the class. +/// +/// The sender. +/// Name of the property. +public class ReactivePropertyChangedEventArgs(TSender sender, string propertyName) : PropertyChangedEventArgs(propertyName), IReactivePropertyChangedEventArgs { - /// - /// Initializes a new instance of the class. - /// - /// The sender. - /// Name of the property. - public ReactivePropertyChangedEventArgs(TSender sender, string propertyName) - : base(propertyName) => - Sender = sender; - /// /// Gets the sender which triggered the property changed event. /// /// - public TSender Sender { get; } -} \ No newline at end of file + public TSender Sender { get; } = sender; +} diff --git a/src/ReactiveUI/Interfaces/ReactivePropertyChangingEventArgs.cs b/src/ReactiveUI/Interfaces/ReactivePropertyChangingEventArgs.cs index 71566647dd..da55d94375 100644 --- a/src/ReactiveUI/Interfaces/ReactivePropertyChangingEventArgs.cs +++ b/src/ReactiveUI/Interfaces/ReactivePropertyChangingEventArgs.cs @@ -3,28 +3,22 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.ComponentModel; - namespace ReactiveUI; /// /// Event arguments for when a property is changing. /// /// The sender type. -public class ReactivePropertyChangingEventArgs : PropertyChangingEventArgs, IReactivePropertyChangedEventArgs +/// +/// Initializes a new instance of the class. +/// +/// The sender. +/// Name of the property. +public class ReactivePropertyChangingEventArgs(TSender sender, string? propertyName) : PropertyChangingEventArgs(propertyName), IReactivePropertyChangedEventArgs { - /// - /// Initializes a new instance of the class. - /// - /// The sender. - /// Name of the property. - public ReactivePropertyChangingEventArgs(TSender sender, string? propertyName) - : base(propertyName) => - Sender = sender; - /// /// Gets the sender which triggered the Reactive property changed event. /// /// - public TSender Sender { get; } -} \ No newline at end of file + public TSender Sender { get; } = sender; +} diff --git a/src/ReactiveUI/Legacy/CollectionDebugView.cs b/src/ReactiveUI/Legacy/CollectionDebugView.cs index 07e2067dab..dc99a2e11c 100644 --- a/src/ReactiveUI/Legacy/CollectionDebugView.cs +++ b/src/ReactiveUI/Legacy/CollectionDebugView.cs @@ -7,11 +7,9 @@ namespace ReactiveUI.Legacy; -internal sealed class CollectionDebugView +internal sealed class CollectionDebugView(ICollection collection) { - private readonly ICollection _collection; - - public CollectionDebugView(ICollection collection) => _collection = collection ?? throw new ArgumentNullException(nameof(collection), "collection is null."); + private readonly ICollection _collection = collection ?? throw new ArgumentNullException(nameof(collection), "collection is null."); [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] public T[] Items @@ -23,4 +21,4 @@ public T[] Items return array; } } -} \ No newline at end of file +} diff --git a/src/ReactiveUI/Legacy/RefcountDisposeWrapper.cs b/src/ReactiveUI/Legacy/RefcountDisposeWrapper.cs index 62a78c31a7..ae18d13b48 100644 --- a/src/ReactiveUI/Legacy/RefcountDisposeWrapper.cs +++ b/src/ReactiveUI/Legacy/RefcountDisposeWrapper.cs @@ -5,13 +5,11 @@ namespace ReactiveUI.Legacy; -internal sealed class RefcountDisposeWrapper +internal sealed class RefcountDisposeWrapper(IDisposable inner) { - private IDisposable? _inner; + private IDisposable? _inner = inner; private int _refCount = 1; - public RefcountDisposeWrapper(IDisposable inner) => _inner = inner; - public void AddRef() => Interlocked.Increment(ref _refCount); public void Release() @@ -22,4 +20,4 @@ public void Release() inner?.Dispose(); } } -} \ No newline at end of file +} diff --git a/src/ReactiveUI/Mixins/AutoPersistHelper.cs b/src/ReactiveUI/Mixins/AutoPersistHelper.cs index ca9832d6c1..b873ffb332 100644 --- a/src/ReactiveUI/Mixins/AutoPersistHelper.cs +++ b/src/ReactiveUI/Mixins/AutoPersistHelper.cs @@ -31,7 +31,7 @@ public static class AutoPersistHelper /// /// AutoPersist allows you to automatically call a method when an object /// has changed, throttling on a certain interval. Note that this object - /// must mark its persistable properties via the [DataMember] attribute. + /// must mark its persistent properties via the [DataMember] attribute. /// Changes to properties not marked with DataMember will not trigger the /// object to be saved. /// @@ -54,7 +54,7 @@ public static IDisposable AutoPersist(this T @this, Func /// /// AutoPersist allows you to automatically call a method when an object /// has changed, throttling on a certain interval. Note that this object - /// must mark its persistable properties via the [DataMember] attribute. + /// must mark its persistent properties via the [DataMember] attribute. /// Changes to properties not marked with DataMember will not trigger the /// object to be saved. /// diff --git a/src/ReactiveUI/Mixins/ReactiveNotifyPropertyChangedMixin.cs b/src/ReactiveUI/Mixins/ReactiveNotifyPropertyChangedMixin.cs index 87141065ce..225400e2c8 100644 --- a/src/ReactiveUI/Mixins/ReactiveNotifyPropertyChangedMixin.cs +++ b/src/ReactiveUI/Mixins/ReactiveNotifyPropertyChangedMixin.cs @@ -147,7 +147,7 @@ public static IObservable> SubscribeToExpressio { // ensure cast to TValue will succeed, throw useful exception otherwise var val = x.GetValue(); - if (val is not null && !(val is TValue)) + if (val is not null && val is not TValue) { throw new InvalidCastException($"Unable to cast from {val.GetType()} to {typeof(TValue)}."); } @@ -161,7 +161,7 @@ public static IObservable> SubscribeToExpressio private static IObservable> NestedObservedChanges(Expression expression, IObservedChange sourceChange, bool beforeChange, bool suppressWarnings) { // Make sure a change at a root node propagates events down - var kicker = new ObservedChange(sourceChange.Value!, expression, default); + var kicker = new ObservedChange(sourceChange.Value, expression, default); // Handle null values in the chain if (sourceChange.Value is null) diff --git a/src/ReactiveUI/ObservableForProperty/INPCObservableForProperty.cs b/src/ReactiveUI/ObservableForProperty/INPCObservableForProperty.cs index 53c7f59d23..154a5a1933 100644 --- a/src/ReactiveUI/ObservableForProperty/INPCObservableForProperty.cs +++ b/src/ReactiveUI/ObservableForProperty/INPCObservableForProperty.cs @@ -43,12 +43,12 @@ public int GetAffinityForObject(Type type, string propertyName, bool beforeChang { return obs.Where(x => string.IsNullOrEmpty(x) || x?.Equals(propertyName + "[]", StringComparison.InvariantCulture) == true) - .Select(_ => new ObservedChange(sender, expression, default!)); + .Select(_ => new ObservedChange(sender, expression, default)); } return obs.Where(x => string.IsNullOrEmpty(x) || x?.Equals(propertyName, StringComparison.InvariantCulture) == true) - .Select(_ => new ObservedChange(sender, expression, default!)); + .Select(_ => new ObservedChange(sender, expression, default)); } else if (sender is INotifyPropertyChanged after) { @@ -65,16 +65,16 @@ public int GetAffinityForObject(Type type, string propertyName, bool beforeChang { return obs.Where(x => string.IsNullOrEmpty(x) || x?.Equals(propertyName + "[]", StringComparison.InvariantCulture) == true) - .Select(_ => new ObservedChange(sender, expression, default!)); + .Select(_ => new ObservedChange(sender, expression, default)); } return obs.Where(x => string.IsNullOrEmpty(x) || x?.Equals(propertyName, StringComparison.InvariantCulture) == true) - .Select(_ => new ObservedChange(sender, expression, default!)); + .Select(_ => new ObservedChange(sender, expression, default)); } else { return Observable>.Never; } } -} \ No newline at end of file +} diff --git a/src/ReactiveUI/ObservableForProperty/IROObservableForProperty.cs b/src/ReactiveUI/ObservableForProperty/IROObservableForProperty.cs index ab3d11b30b..5612524da4 100644 --- a/src/ReactiveUI/ObservableForProperty/IROObservableForProperty.cs +++ b/src/ReactiveUI/ObservableForProperty/IROObservableForProperty.cs @@ -43,20 +43,20 @@ public int GetAffinityForObject(Type type, string propertyName, bool beforeChang if (expression.NodeType == ExpressionType.Index) { return obs.Where(x => x.PropertyName?.Equals(propertyName + "[]", StringComparison.InvariantCulture) == true) - .Select(_ => new ObservedChange(sender, expression, default!)); + .Select(_ => new ObservedChange(sender, expression, default)); } return obs.Where(x => x.PropertyName?.Equals(propertyName, StringComparison.InvariantCulture) == true) - .Select(_ => new ObservedChange(sender, expression, default!)); + .Select(_ => new ObservedChange(sender, expression, default)); } if (expression.NodeType == ExpressionType.Index) { return obs.Where(x => x.PropertyName?.Equals(propertyName + "[]", StringComparison.InvariantCulture) == true) - .Select(_ => new ObservedChange(sender, expression, default!)); + .Select(_ => new ObservedChange(sender, expression, default)); } return obs.Where(x => x.PropertyName?.Equals(propertyName, StringComparison.InvariantCulture) == true) - .Select(_ => new ObservedChange(sender, expression, default!)); + .Select(_ => new ObservedChange(sender, expression, default)); } -} \ No newline at end of file +} diff --git a/src/ReactiveUI/ObservableForProperty/ObservableAsPropertyHelper.cs b/src/ReactiveUI/ObservableForProperty/ObservableAsPropertyHelper.cs index ab30604e35..370bbe8364 100644 --- a/src/ReactiveUI/ObservableForProperty/ObservableAsPropertyHelper.cs +++ b/src/ReactiveUI/ObservableForProperty/ObservableAsPropertyHelper.cs @@ -211,7 +211,7 @@ public T Value /// /// Constructs a "default" ObservableAsPropertyHelper object. This is /// useful for when you will initialize the OAPH later, but don't want - /// bindings to access a null OAPH at startup. + /// bindings to access a null OAPH at start up. /// /// /// The initial (and only) value of the property. @@ -232,4 +232,4 @@ public void Dispose() // TODO: Create Test _disposable?.Dispose(); _disposable = null!; } -} \ No newline at end of file +} diff --git a/src/ReactiveUI/ObservableForProperty/POCOObservableForProperty.cs b/src/ReactiveUI/ObservableForProperty/POCOObservableForProperty.cs index c9f9cf7fd9..387daf3a8b 100644 --- a/src/ReactiveUI/ObservableForProperty/POCOObservableForProperty.cs +++ b/src/ReactiveUI/ObservableForProperty/POCOObservableForProperty.cs @@ -14,7 +14,7 @@ namespace ReactiveUI; /// public class POCOObservableForProperty : ICreatesObservableForProperty { - private static readonly IDictionary<(Type, string), bool> _hasWarned = new ConcurrentDictionary<(Type, string), bool>(); + private static readonly ConcurrentDictionary<(Type, string), bool> _hasWarned = new(); /// public int GetAffinityForObject(Type type, string propertyName, bool beforeChanged = false) => 1; @@ -37,4 +37,4 @@ public class POCOObservableForProperty : ICreatesObservableForProperty return Observable.Return(new ObservedChange(sender, expression, default), RxApp.MainThreadScheduler) .Concat(Observable>.Never); } -} \ No newline at end of file +} diff --git a/src/ReactiveUI/Platforms/android/AutoSuspendHelper.cs b/src/ReactiveUI/Platforms/android/AutoSuspendHelper.cs index 65d9f80d91..143300ce75 100644 --- a/src/ReactiveUI/Platforms/android/AutoSuspendHelper.cs +++ b/src/ReactiveUI/Platforms/android/AutoSuspendHelper.cs @@ -48,7 +48,7 @@ public AutoSuspendHelper(Application hostApplication) // TODO: Create Test } /// - /// Gets a subject to indicate whether the application has untimely dismised. + /// Gets a subject to indicate whether the application has untimely dismissed. /// public static Subject UntimelyDemise { get; } = new(); @@ -60,7 +60,7 @@ public AutoSuspendHelper(Application hostApplication) // TODO: Create Test /// public void Dispose() { - // Do not change this code. Put cleanup code in Dispose(bool disposing) above. + // Do not change this code. Put clean up code in Dispose(bool disposing) above. Dispose(true); GC.SuppressFinalize(this); } @@ -87,15 +87,11 @@ protected virtual void Dispose(bool disposing) _disposedValue = true; } - private class ObservableLifecycle : Java.Lang.Object, Application.IActivityLifecycleCallbacks + private class ObservableLifecycle(AutoSuspendHelper @this) : Java.Lang.Object, Application.IActivityLifecycleCallbacks { - private readonly AutoSuspendHelper _this; + public void OnActivityCreated(Activity? activity, Bundle? savedInstanceState) => @this._onCreate.OnNext(savedInstanceState); - public ObservableLifecycle(AutoSuspendHelper @this) => _this = @this; - - public void OnActivityCreated(Activity? activity, Bundle? savedInstanceState) => _this._onCreate.OnNext(savedInstanceState); - - public void OnActivityResumed(Activity? activity) => _this._onRestart.OnNext(Unit.Default); + public void OnActivityResumed(Activity? activity) => @this._onRestart.OnNext(Unit.Default); public void OnActivitySaveInstanceState(Activity? activity, Bundle? outState) { @@ -103,10 +99,10 @@ public void OnActivitySaveInstanceState(Activity? activity, Bundle? outState) // we can tell the difference between created from scratch and resume. outState?.PutString("___dummy_value_please_create_a_bundle", "VeryYes"); - _this._onSaveInstanceState.OnNext(outState); + @this._onSaveInstanceState.OnNext(outState); } - public void OnActivityPaused(Activity? activity) => _this._onPause.OnNext(Unit.Default); + public void OnActivityPaused(Activity? activity) => @this._onPause.OnNext(Unit.Default); public void OnActivityDestroyed(Activity? activity) { diff --git a/src/ReactiveUI/Platforms/android/ControlFetcherMixin.cs b/src/ReactiveUI/Platforms/android/ControlFetcherMixin.cs index f28608d094..83be04dfaf 100644 --- a/src/ReactiveUI/Platforms/android/ControlFetcherMixin.cs +++ b/src/ReactiveUI/Platforms/android/ControlFetcherMixin.cs @@ -13,7 +13,7 @@ namespace ReactiveUI; /// -/// ControlFetcherMixin helps you automatically wire-up Activities and +/// Control Fetcher Mix-in helps you automatically wire-up Activities and /// Fragments via property names, similar to Butter Knife, as well as allows /// you to fetch controls manually. /// diff --git a/src/ReactiveUI/Platforms/android/LayoutViewHost.cs b/src/ReactiveUI/Platforms/android/LayoutViewHost.cs index 61e5617481..91eea7ff36 100644 --- a/src/ReactiveUI/Platforms/android/LayoutViewHost.cs +++ b/src/ReactiveUI/Platforms/android/LayoutViewHost.cs @@ -30,7 +30,7 @@ protected LayoutViewHost() /// The layout identifier. /// The parent. /// if set to true [attach to root]. - /// if set to true [perform automatic wireup]. + /// if set to true [perform automatic wire-up]. protected LayoutViewHost(Context ctx, int layoutId, ViewGroup parent, bool attachToRoot = false, bool performAutoWireup = true) { var inflater = LayoutInflater.FromContext(ctx); diff --git a/src/ReactiveUI/Platforms/android/ObjectExtension.cs b/src/ReactiveUI/Platforms/android/ObjectExtension.cs index 9cb6a4e729..400a977592 100644 --- a/src/ReactiveUI/Platforms/android/ObjectExtension.cs +++ b/src/ReactiveUI/Platforms/android/ObjectExtension.cs @@ -16,7 +16,7 @@ public static TObject ToNetObject(this Object value) return default!; } - if (!(value is JavaHolder)) + if (value is not JavaHolder) { throw new InvalidOperationException("Unable to convert to .NET object. Only Java.Lang.Object created with .ToJavaObject() can be converted."); } diff --git a/src/ReactiveUI/Platforms/android/ReactiveViewHost.cs b/src/ReactiveUI/Platforms/android/ReactiveViewHost.cs index 38c05cea20..6e10ca0b92 100644 --- a/src/ReactiveUI/Platforms/android/ReactiveViewHost.cs +++ b/src/ReactiveUI/Platforms/android/ReactiveViewHost.cs @@ -38,7 +38,7 @@ public abstract class ReactiveViewHost : LayoutViewHost, IViewForThe layout identifier. /// The parent. /// if set to true [attach to root]. - /// if set to true [perform automatic wireup]. + /// if set to true [perform automatic wire-up]. protected ReactiveViewHost(Context ctx, int layoutId, ViewGroup parent, bool attachToRoot = false, bool performAutoWireup = true) : base(ctx, layoutId, parent, attachToRoot, performAutoWireup) => SetupRxObj(); diff --git a/src/ReactiveUI/Platforms/android/SharedPreferencesExtensions.cs b/src/ReactiveUI/Platforms/android/SharedPreferencesExtensions.cs index 6e111002f4..8a0dbb0440 100644 --- a/src/ReactiveUI/Platforms/android/SharedPreferencesExtensions.cs +++ b/src/ReactiveUI/Platforms/android/SharedPreferencesExtensions.cs @@ -28,14 +28,10 @@ public static class SharedPreferencesExtensions /// /// Private implementation of ISharedPreferencesOnSharedPreferenceChangeListener. /// - private class OnSharedPreferenceChangeListener - : Java.Lang.Object, + private class OnSharedPreferenceChangeListener(IObserver observer) + : Java.Lang.Object, ISharedPreferencesOnSharedPreferenceChangeListener { - private readonly IObserver _observer; - - public OnSharedPreferenceChangeListener(IObserver observer) => _observer = observer; - - void ISharedPreferencesOnSharedPreferenceChangeListener.OnSharedPreferenceChanged(ISharedPreferences? sharedPreferences, string? key) => _observer.OnNext(key); + void ISharedPreferencesOnSharedPreferenceChangeListener.OnSharedPreferenceChanged(ISharedPreferences? sharedPreferences, string? key) => observer.OnNext(key); } } diff --git a/src/ReactiveUI/Platforms/android/UsbManagerExtensions.cs b/src/ReactiveUI/Platforms/android/UsbManagerExtensions.cs index c9a2912cd5..62d7b32ffa 100644 --- a/src/ReactiveUI/Platforms/android/UsbManagerExtensions.cs +++ b/src/ReactiveUI/Platforms/android/UsbManagerExtensions.cs @@ -61,18 +61,9 @@ public static IObservable PermissionRequested(this UsbManager manager, Con /// /// Private implementation of BroadcastReceiver to handle device permission requests. /// - private class UsbDevicePermissionReceiver - : BroadcastReceiver + private class UsbDevicePermissionReceiver(IObserver observer, UsbDevice device) + : BroadcastReceiver { - private readonly IObserver _observer; - private readonly UsbDevice _device; - - public UsbDevicePermissionReceiver(IObserver observer, UsbDevice device) - { - _observer = observer; - _device = device; - } - #if NET7_0_OR_GREATER [ObsoletedOSPlatform("android33.0")] #elif MONOANDROID13_0 @@ -87,14 +78,14 @@ public override void OnReceive(Context? context, Intent? intent) } var extraDevice = intent.GetParcelableExtra(UsbManager.ExtraDevice) as UsbDevice; - if (_device.DeviceName != extraDevice?.DeviceName) + if (device.DeviceName != extraDevice?.DeviceName) { return; } var permissionGranted = intent.GetBooleanExtra(UsbManager.ExtraPermissionGranted, false); - _observer.OnNext(permissionGranted); - _observer.OnCompleted(); + observer.OnNext(permissionGranted); + observer.OnCompleted(); } } @@ -105,18 +96,9 @@ public override void OnReceive(Context? context, Intent? intent) /// /// Private implementation of BroadcastReceiver to handle accessory permission requests. /// - private class UsbAccessoryPermissionReceiver - : BroadcastReceiver + private class UsbAccessoryPermissionReceiver(IObserver observer, UsbAccessory accessory) + : BroadcastReceiver { - private readonly IObserver _observer; - private readonly UsbAccessory _accessory; - - public UsbAccessoryPermissionReceiver(IObserver observer, UsbAccessory accessory) - { - _observer = observer; - _accessory = accessory; - } - #if NET7_0_OR_GREATER [ObsoletedOSPlatform("android33.0")] #elif MONOANDROID13_0 @@ -130,14 +112,14 @@ public override void OnReceive(Context? context, Intent? intent) return; } - if (_accessory.Manufacturer != extraAccessory.Manufacturer || _accessory.Model != extraAccessory.Model) + if (accessory.Manufacturer != extraAccessory.Manufacturer || accessory.Model != extraAccessory.Model) { return; } var permissionGranted = intent.GetBooleanExtra(UsbManager.ExtraPermissionGranted, false); - _observer.OnNext(permissionGranted); - _observer.OnCompleted(); + observer.OnNext(permissionGranted); + observer.OnCompleted(); } #if MONOANDROID13_0 diff --git a/src/ReactiveUI/Platforms/android/ViewCommandExtensions.cs b/src/ReactiveUI/Platforms/android/ViewCommandExtensions.cs index a2d8a44257..31d49be224 100644 --- a/src/ReactiveUI/Platforms/android/ViewCommandExtensions.cs +++ b/src/ReactiveUI/Platforms/android/ViewCommandExtensions.cs @@ -42,10 +42,7 @@ public static IDisposable BindToTarget(this ICommand command, View control) // T command.Execute(null); }); - var cech = new EventHandler((o, e) => - { - control.Enabled = command.CanExecute(null); - }); + var cech = new EventHandler((o, e) => control.Enabled = command.CanExecute(null)); command.CanExecuteChanged += cech; control.Click += ev; diff --git a/src/ReactiveUI/Platforms/apple-common/AppSupportJsonSuspensionDriver.cs b/src/ReactiveUI/Platforms/apple-common/AppSupportJsonSuspensionDriver.cs index 654edcd5c8..7d2e91f6ec 100644 --- a/src/ReactiveUI/Platforms/apple-common/AppSupportJsonSuspensionDriver.cs +++ b/src/ReactiveUI/Platforms/apple-common/AppSupportJsonSuspensionDriver.cs @@ -76,10 +76,8 @@ public IObservable InvalidateState() private static string CreateAppDirectory(NSSearchPathDirectory targetDir, string subDir = "Data") { - NSError err; - var fm = new NSFileManager(); - var url = fm.GetUrl(targetDir, NSSearchPathDomain.All, null, true, out err); + var url = fm.GetUrl(targetDir, NSSearchPathDomain.All, null, true, out var err); var ret = Path.Combine(url.RelativePath!, NSBundle.MainBundle.BundleIdentifier, subDir); if (!Directory.Exists(ret)) { diff --git a/src/ReactiveUI/Platforms/apple-common/BlockObserveValueDelegate.cs b/src/ReactiveUI/Platforms/apple-common/BlockObserveValueDelegate.cs index 6b0a121364..a2b96b3f7f 100644 --- a/src/ReactiveUI/Platforms/apple-common/BlockObserveValueDelegate.cs +++ b/src/ReactiveUI/Platforms/apple-common/BlockObserveValueDelegate.cs @@ -7,11 +7,7 @@ namespace ReactiveUI; -internal class BlockObserveValueDelegate : NSObject +internal class BlockObserveValueDelegate(Action block) : NSObject { - private readonly Action _block; - - public BlockObserveValueDelegate(Action block) => _block = block; - - public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context) => _block(keyPath, ofObject, change); + public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context) => block(keyPath, ofObject, change); } diff --git a/src/ReactiveUI/Platforms/apple-common/ObservableForPropertyBase.cs b/src/ReactiveUI/Platforms/apple-common/ObservableForPropertyBase.cs index 546bfaca16..edc7e06983 100644 --- a/src/ReactiveUI/Platforms/apple-common/ObservableForPropertyBase.cs +++ b/src/ReactiveUI/Platforms/apple-common/ObservableForPropertyBase.cs @@ -141,7 +141,7 @@ protected void Register(Type type, string property, int affinity, Func(); + typeProperties = new(); _config[type] = typeProperties; } diff --git a/src/ReactiveUI/Platforms/apple-common/ReactiveImageView.cs b/src/ReactiveUI/Platforms/apple-common/ReactiveImageView.cs index 43fb837e92..35b7a4b8a7 100644 --- a/src/ReactiveUI/Platforms/apple-common/ReactiveImageView.cs +++ b/src/ReactiveUI/Platforms/apple-common/ReactiveImageView.cs @@ -66,7 +66,7 @@ protected ReactiveImageView(NSObjectFlag t) /// Initializes a new instance of the class. /// /// The image. - /// The higlighted image. + /// The highlighted image. protected ReactiveImageView(NSImage image, NSImage highlightedImage) : base(image, highlightedImage) { diff --git a/src/ReactiveUI/Platforms/apple-common/ViewModelViewHost.cs b/src/ReactiveUI/Platforms/apple-common/ViewModelViewHost.cs index e7f27ecd17..6781215be4 100644 --- a/src/ReactiveUI/Platforms/apple-common/ViewModelViewHost.cs +++ b/src/ReactiveUI/Platforms/apple-common/ViewModelViewHost.cs @@ -205,7 +205,7 @@ private void Initialize() #pragma warning restore RCS1221 // Use pattern matching instead of combination of 'as' operator and null check. if (viewController is null) { - //// TODO: As viewController = NULL at this point this excetion will never show the FullName, find fixed text to replace this with. + //// TODO: As viewController = NULL at this point this execution will never show the FullName, find fixed text to replace this with. throw new Exception($"Resolved view type '{viewController?.GetType().FullName}' is not a '{typeof(NSViewController).FullName}'."); } diff --git a/src/ReactiveUI/Platforms/ios/LinkerOverrides.cs b/src/ReactiveUI/Platforms/ios/LinkerOverrides.cs index c2be0c5958..f2743e09ae 100644 --- a/src/ReactiveUI/Platforms/ios/LinkerOverrides.cs +++ b/src/ReactiveUI/Platforms/ios/LinkerOverrides.cs @@ -16,7 +16,7 @@ internal class LinkerOverrides [System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Used by linker.")] public void KeepMe() { - // UIButon + // UIButton var btn = new UIButton(); var title = btn.Title(UIControlState.Disabled); btn.SetTitle("foo", UIControlState.Disabled); diff --git a/src/ReactiveUI/Platforms/mac/AutoSuspendHelper.cs b/src/ReactiveUI/Platforms/mac/AutoSuspendHelper.cs index 5e87197fc7..a548b60563 100644 --- a/src/ReactiveUI/Platforms/mac/AutoSuspendHelper.cs +++ b/src/ReactiveUI/Platforms/mac/AutoSuspendHelper.cs @@ -67,26 +67,26 @@ public NSApplicationTerminateReply ApplicationShouldTerminate(NSApplication send } /// - /// Dids the finish launching. + /// Did finish launching. /// /// The notification. #pragma warning disable RCS1163 // Unused parameter. public void DidFinishLaunching(NSNotification notification) => _isResuming.OnNext(Unit.Default); /// - /// Dids the resign active. + /// Did resign active. /// /// The notification. public void DidResignActive(NSNotification notification) => _shouldPersistState.OnNext(Disposable.Empty); /// - /// Dids the become active. + /// Did become active. /// /// The notification. public void DidBecomeActive(NSNotification notification) => _isUnpausing.OnNext(Unit.Default); /// - /// Dids the hide. + /// Did hide. /// /// The notification. public void DidHide(NSNotification notification) => _shouldPersistState.OnNext(Disposable.Empty); diff --git a/src/ReactiveUI/Platforms/uikit-common/ReactiveTableViewSource.cs b/src/ReactiveUI/Platforms/uikit-common/ReactiveTableViewSource.cs index b7a58bcd1d..9364675f19 100644 --- a/src/ReactiveUI/Platforms/uikit-common/ReactiveTableViewSource.cs +++ b/src/ReactiveUI/Platforms/uikit-common/ReactiveTableViewSource.cs @@ -173,7 +173,7 @@ public override UITableViewCell GetCell(UITableView tableView, NSIndexPath index /// public override nint RowsInSection(UITableView tableview, nint section) { - // iOS may call this method even when we have no sections, but only if we've overridden + // iOS may call this method even when we have no sections, but only if we've overriden // EstimatedHeight(UITableView, NSIndexPath) in our UITableViewSource if (section >= _commonSource.NumberOfSections()) { @@ -214,7 +214,7 @@ public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexP /// public override nfloat GetHeightForHeader(UITableView tableView, nint section) { - // iOS may call this method even when we have no sections, but only if we've overridden + // iOS may call this method even when we have no sections, but only if we've overriden // EstimatedHeight(UITableView, NSIndexPath) in our UITableViewSource if (section >= _commonSource.NumberOfSections()) { @@ -230,7 +230,7 @@ public override nfloat GetHeightForHeader(UITableView tableView, nint section) /// public override nfloat GetHeightForFooter(UITableView tableView, nint section) { - // iOS may call this method even when we have no sections, but only if we've overridden + // iOS may call this method even when we have no sections, but only if we've overriden // EstimatedHeight(UITableView, NSIndexPath) in our UITableViewSource if (section >= _commonSource.NumberOfSections()) { diff --git a/src/ReactiveUI/ReactiveCommand/IReactiveCommand.cs b/src/ReactiveUI/ReactiveCommand/IReactiveCommand.cs index ee4bfefc1e..70558ee4b7 100644 --- a/src/ReactiveUI/ReactiveCommand/IReactiveCommand.cs +++ b/src/ReactiveUI/ReactiveCommand/IReactiveCommand.cs @@ -16,6 +16,9 @@ public interface IReactiveCommand : IDisposable, IHandleObservableErrors /// /// Gets an observable whose value indicates whether the command is currently executing. /// + /// + /// The is executing. + /// /// /// This observable can be particularly useful for updating UI, such as showing an activity indicator whilst a command /// is executing. @@ -25,6 +28,9 @@ public interface IReactiveCommand : IDisposable, IHandleObservableErrors /// /// Gets an observable whose value indicates whether the command can currently execute. /// + /// + /// The can execute. + /// /// /// The value provided by this observable is governed both by any canExecute observable provided during /// command creation, as well as the current execution status of the command. A command that is currently executing @@ -57,6 +63,10 @@ public interface IReactiveCommand : IObservable /// /// Gets an observable that, when subscribed, executes this command. /// + /// The parameter to pass into command execution. + /// + /// An observable that will tick the single result value if and when it becomes available. + /// /// /// /// Invoking this method will return a cold (lazy) observable that, when subscribed, will execute the logic @@ -64,7 +74,7 @@ public interface IReactiveCommand : IObservable /// happen if you call Execute and neglect to subscribe (directly or indirectly) to the returned observable. /// /// - /// If no parameter value is provided, a default value of type will be passed into + /// If no parameter value is provided, a default value of type will be passed into /// the execution logic. /// /// @@ -73,20 +83,17 @@ public interface IReactiveCommand : IObservable /// /// /// In those cases where execution fails, there will be no result value. Instead, the failure will tick through the - /// observable. + /// observable. /// /// - /// - /// The parameter to pass into command execution. - /// - /// - /// An observable that will tick the single result value if and when it becomes available. - /// IObservable Execute(TParam parameter); /// /// Gets an observable that, when subscribed, executes this command. /// + /// + /// An observable that will tick the single result value if and when it becomes available. + /// /// /// /// Invoking this method will return a cold (lazy) observable that, when subscribed, will execute the logic @@ -94,7 +101,7 @@ public interface IReactiveCommand : IObservable /// happen if you call Execute and neglect to subscribe (directly or indirectly) to the returned observable. /// /// - /// If no parameter value is provided, a default value of type will be passed into + /// If no parameter value is provided, a default value of type will be passed into /// the execution logic. /// /// @@ -103,11 +110,8 @@ public interface IReactiveCommand : IObservable /// /// /// In those cases where execution fails, there will be no result value. Instead, the failure will tick through the - /// observable. + /// observable. /// /// - /// - /// An observable that will tick the single result value if and when it becomes available. - /// IObservable Execute(); -} \ No newline at end of file +} diff --git a/src/ReactiveUI/ReactiveCommand/ReactiveCommand.cs b/src/ReactiveUI/ReactiveCommand/ReactiveCommand.cs index 543d9e714d..db3180c943 100644 --- a/src/ReactiveUI/ReactiveCommand/ReactiveCommand.cs +++ b/src/ReactiveUI/ReactiveCommand/ReactiveCommand.cs @@ -3,8 +3,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Diagnostics.CodeAnalysis; - namespace ReactiveUI; /// diff --git a/src/ReactiveUI/Routing/NotAWeakReference.cs b/src/ReactiveUI/Routing/NotAWeakReference.cs index 5f7cfcdeae..78a6711989 100644 --- a/src/ReactiveUI/Routing/NotAWeakReference.cs +++ b/src/ReactiveUI/Routing/NotAWeakReference.cs @@ -7,12 +7,10 @@ namespace ReactiveUI; -internal class NotAWeakReference +internal class NotAWeakReference(object target) { - public NotAWeakReference(object target) => Target = target; - - public object Target { get; } + public object Target { get; } = target; [SuppressMessage("Microsoft.Maintainability", "CA1822", Justification = "Keep existing API.")] public bool IsAlive => true; -} \ No newline at end of file +} diff --git a/src/ReactiveUI/Routing/RoutableViewModelMixin.cs b/src/ReactiveUI/Routing/RoutableViewModelMixin.cs index 29a7e4b750..ca55355aba 100644 --- a/src/ReactiveUI/Routing/RoutableViewModelMixin.cs +++ b/src/ReactiveUI/Routing/RoutableViewModelMixin.cs @@ -65,7 +65,7 @@ public static IDisposable WhenNavigatedTo(this IRoutableViewModel item, Func /// - /// The viewmodel to watch for navigation changes. + /// The ViewModel to watch for navigation changes. /// An IObservable{Unit} that signals when the ViewModel has /// been added or brought to the top of the navigation stack. The /// observable completes when the ViewModel is no longer a part of the @@ -100,7 +100,7 @@ public static IObservable WhenNavigatedToObservable(this IRoutableViewMode /// and resubscribe each time it is reused. /// /// - /// /// The viewmodel to watch for navigation changes. + /// /// The ViewModel to watch for navigation changes. /// An IObservable{Unit} that signals when the ViewModel is no /// longer the topmost ViewModel in the navigation stack. The observable /// completes when the ViewModel is no longer a part of the navigation @@ -128,4 +128,4 @@ private static bool WasItemRemoved(IChangeSet changeSet, IRo .Any( change => change.Reason == ListChangeReason.Clear || (_navigationStackRemovalOperations.Contains(change.Reason) && change.Item.Current == item)); -} \ No newline at end of file +} diff --git a/src/ReactiveUI/Routing/RoutingState.cs b/src/ReactiveUI/Routing/RoutingState.cs index 3092a0e430..3e366cd537 100644 --- a/src/ReactiveUI/Routing/RoutingState.cs +++ b/src/ReactiveUI/Routing/RoutingState.cs @@ -34,7 +34,7 @@ public class RoutingState : ReactiveObject public RoutingState(IScheduler? scheduler = null) { _scheduler = scheduler ?? RxApp.MainThreadScheduler; - NavigationStack = new ObservableCollection(); + NavigationStack = new(); SetupRx(); } diff --git a/src/ReactiveUI/Suspension/SuspensionHostExtensions.cs b/src/ReactiveUI/Suspension/SuspensionHostExtensions.cs index 01662c299a..9990da0154 100644 --- a/src/ReactiveUI/Suspension/SuspensionHostExtensions.cs +++ b/src/ReactiveUI/Suspension/SuspensionHostExtensions.cs @@ -16,7 +16,7 @@ public static class SuspensionHostExtensions private static Func>? ensureLoadAppStateFunc; /// - /// Supsension driver reference field to prevent introducing breaking change. + /// Suspension driver reference field to prevent introducing breaking change. /// private static ISuspensionDriver? suspensionDriver; diff --git a/src/ReactiveUI/View/ViewContractAttribute.cs b/src/ReactiveUI/View/ViewContractAttribute.cs index 0e7a8b994e..c66e518e98 100644 --- a/src/ReactiveUI/View/ViewContractAttribute.cs +++ b/src/ReactiveUI/View/ViewContractAttribute.cs @@ -11,19 +11,17 @@ namespace ReactiveUI; /// View, you can select between different Views for a single ViewModel /// instance. /// +/// +/// Initializes a new instance of the class. +/// Constructs the ViewContractAttribute with a specific contract value. +/// +/// The value of the contract for view +/// resolution. [AttributeUsage(AttributeTargets.Class)] -public sealed class ViewContractAttribute : Attribute +public sealed class ViewContractAttribute(string contract) : Attribute { - /// - /// Initializes a new instance of the class. - /// Constructs the ViewContractAttribute with a specific contract value. - /// - /// The value of the contract for view - /// resolution. - public ViewContractAttribute(string contract) => Contract = contract; - /// /// Gets the contract to use when resolving the view in the Splat Dependency Injection engine. /// - public string Contract { get; } -} \ No newline at end of file + public string Contract { get; } = contract; +}