Skip to content

Commit 49d030b

Browse files
committed
Fix inconsistencies in BindCommand docs
1 parent a52ad2c commit 49d030b

4 files changed

Lines changed: 86 additions & 129 deletions

File tree

src/ReactiveUI/Bindings/Command/CommandBinder.cs

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,27 @@ static CommandBinder() => _binderImplementation = AppLocator.Current.GetService<
3232

3333
/// <summary>
3434
/// Binds a command from the view model to a control on the view, enabling the control to execute the command with a
35-
/// parameter when triggered.
35+
/// specified parameter when an event is raised.
3636
/// </summary>
37-
/// <remarks>This method uses reflection to dynamically observe events and properties on the control,
38-
/// which may be affected by trimming in some deployment scenarios. The binding remains active until the returned
39-
/// IReactiveBinding is disposed.</remarks>
40-
/// <typeparam name="TView">The type of the view implementing the IViewFor interface.</typeparam>
41-
/// <typeparam name="TViewModel">The type of the view model containing the command property.</typeparam>
42-
/// <typeparam name="TProp">The type of the command property, which must implement ICommand.</typeparam>
37+
/// <remarks>This method uses reflection to observe events and properties on the control, which may be
38+
/// affected by trimming in some deployment scenarios. The binding remains active until the returned
39+
/// IReactiveBinding is disposed. If the specified event does not exist on the control, an exception may be thrown
40+
/// at runtime.</remarks>
41+
/// <typeparam name="TView">The type of the view that implements the IViewFor interface.</typeparam>
42+
/// <typeparam name="TViewModel">The type of the view model containing the command to bind.</typeparam>
43+
/// <typeparam name="TProp">The type of the command property on the view model. Must implement ICommand.</typeparam>
4344
/// <typeparam name="TControl">The type of the control on the view to which the command will be bound.</typeparam>
44-
/// <typeparam name="TParam">The type of the parameter passed to the command when it is executed.</typeparam>
45-
/// <param name="view">The view instance to which the command will be bound. Cannot be null.</param>
46-
/// <param name="viewModel">The view model instance containing the command property. May be null if the view is not currently bound to a
47-
/// view model.</param>
45+
/// <typeparam name="TParam">The type of the parameter passed to the command when the event is raised.</typeparam>
46+
/// <param name="view">The view instance containing the control to which the command will be bound. Cannot be null.</param>
47+
/// <param name="viewModel">The view model instance containing the command to bind. Used for type inference.
48+
/// Can be null if the binding should be established without an initial view model.</param>
4849
/// <param name="propertyName">An expression identifying the command property on the view model to bind. Cannot be null.</param>
4950
/// <param name="controlName">An expression identifying the control on the view to which the command will be bound. Cannot be null.</param>
5051
/// <param name="withParameter">An observable that provides the parameter to pass to the command when it is executed. Cannot be null.</param>
51-
/// <param name="toEvent">The name of the event on the control that triggers the command. If null, a default event is used based on the
52-
/// control type.
52+
/// <param name="toEvent">The name of the event on the control that triggers the command execution. If null, a default event is used based
53+
/// on the control type.
5354
/// NOTE: If this parameter is used inside WhenActivated, it's important to dispose the binding when the view is deactivated.</param>
54-
/// <returns>An IReactiveBinding instance representing the active binding between the command and the control.</returns>
55+
/// <returns>An IReactiveBinding{TView, TProp} representing the established binding between the command and the control.</returns>
5556
[RequiresUnreferencedCode("Dynamic observation uses reflection over members that may be trimmed.")]
5657
public static IReactiveBinding<TView, TProp> BindCommand<
5758
TView,
@@ -79,25 +80,26 @@ public static IReactiveBinding<TView, TProp> BindCommand<
7980
}
8081

8182
/// <summary>
82-
/// Binds a command from the view model to a control on the view, enabling the control to execute the specified
83-
/// command when triggered.
83+
/// Binds a command from the view model to a control on the view, enabling the control to execute the command with a
84+
/// specified parameter when an event is raised.
8485
/// </summary>
85-
/// <remarks>This method uses reflection to observe events and properties on the control and may be
86-
/// affected by trimming in environments that remove unused members. The binding enables the control to execute the
87-
/// command when the specified event is raised, and automatically manages the enabled state of the control based on
88-
/// the command's CanExecute state.</remarks>
89-
/// <typeparam name="TView">The type of the view implementing the IViewFor interface.</typeparam>
90-
/// <typeparam name="TViewModel">The type of the view model containing the command property.</typeparam>
91-
/// <typeparam name="TProp">The type of the command property to bind, implementing ICommand.</typeparam>
86+
/// <remarks>This method uses reflection to observe events and properties on the control, which may be
87+
/// affected by trimming in some deployment scenarios. The binding remains active until the returned
88+
/// IReactiveBinding is disposed. If the specified event does not exist on the control, an exception may be thrown
89+
/// at runtime.</remarks>
90+
/// <typeparam name="TView">The type of the view that implements the IViewFor interface.</typeparam>
91+
/// <typeparam name="TViewModel">The type of the view model containing the command to bind.</typeparam>
92+
/// <typeparam name="TProp">The type of the command property on the view model. Must implement ICommand.</typeparam>
9293
/// <typeparam name="TControl">The type of the control on the view to which the command will be bound.</typeparam>
93-
/// <param name="view">The view instance to which the control belongs. Cannot be null.</param>
94-
/// <param name="viewModel">The view model instance containing the command property. Can be null if the view's ViewModel property is used.</param>
94+
/// <param name="view">The view instance containing the control to which the command will be bound. Cannot be null.</param>
95+
/// <param name="viewModel">The view model instance containing the command to bind. Used for type inference.
96+
/// Can be null if the binding should be established without an initial view model.</param>
9597
/// <param name="propertyName">An expression identifying the command property on the view model to bind. Cannot be null.</param>
96-
/// <param name="controlName">An expression identifying the control on the view to bind the command to. Cannot be null.</param>
97-
/// <param name="toEvent">The name of the event on the control that triggers the command. If null, a default event is used based on the
98-
/// control type.
98+
/// <param name="controlName">An expression identifying the control on the view to which the command will be bound. Cannot be null.</param>
99+
/// <param name="toEvent">The name of the event on the control that triggers the command execution. If null, a default event is used based
100+
/// on the control type.
99101
/// NOTE: If this parameter is used inside WhenActivated, it's important to dispose the binding when the view is deactivated.</param>
100-
/// <returns>An object representing the binding between the command and the control, which can be disposed to unbind.</returns>
102+
/// <returns>An IReactiveBinding{TView, TProp} representing the established binding between the command and the control.</returns>
101103
[RequiresUnreferencedCode("Dynamic observation uses reflection over members that may be trimmed.")]
102104
public static IReactiveBinding<TView, TProp> BindCommand<
103105
TView,
@@ -123,19 +125,20 @@ public static IReactiveBinding<TView, TProp> BindCommand<
123125

124126
/// <summary>
125127
/// Binds a command from the view model to a control on the view, enabling the control to execute the command with a
126-
/// specified parameter when triggered.
128+
/// specified parameter when an event is raised.
127129
/// </summary>
128-
/// <remarks>This method uses reflection to observe events and properties on the control and view model,
129-
/// which may be affected by trimming in some deployment scenarios. The binding remains active until the returned
130-
/// IReactiveBinding is disposed.</remarks>
131-
/// <typeparam name="TView">The type of the view implementing the IViewFor interface.</typeparam>
132-
/// <typeparam name="TViewModel">The type of the view model containing the command property.</typeparam>
133-
/// <typeparam name="TProp">The type of the command property, typically implementing ICommand.</typeparam>
130+
/// <remarks>This method uses reflection to observe events and properties on the control, which may be
131+
/// affected by trimming in some deployment scenarios. The binding remains active until the returned
132+
/// IReactiveBinding is disposed. If the specified event does not exist on the control, an exception may be thrown
133+
/// at runtime.</remarks>
134+
/// <typeparam name="TView">The type of the view that implements the IViewFor interface.</typeparam>
135+
/// <typeparam name="TViewModel">The type of the view model containing the command to bind.</typeparam>
136+
/// <typeparam name="TProp">The type of the command property on the view model. Must implement ICommand.</typeparam>
134137
/// <typeparam name="TControl">The type of the control on the view to which the command will be bound.</typeparam>
135-
/// <typeparam name="TParam">The type of the parameter passed to the command when it is executed.</typeparam>
136-
/// <param name="view">The view instance containing the control to bind the command to. Cannot be null.</param>
137-
/// <param name="viewModel">The view model instance containing the command property. May be null if the view is not currently bound to a
138-
/// view model.</param>
138+
/// <typeparam name="TParam">The type of the parameter passed to the command when the event is raised.</typeparam>
139+
/// <param name="view">The view instance containing the control to which the command will be bound. Cannot be null.</param>
140+
/// <param name="viewModel">The view model instance containing the command to bind. Used for type inference.
141+
/// Can be null if the binding should be established without an initial view model.</param>
139142
/// <param name="propertyName">An expression identifying the command property on the view model to bind. Cannot be null.</param>
140143
/// <param name="controlName">An expression identifying the control on the view to which the command will be bound. Cannot be null.</param>
141144
/// <param name="withParameter">An expression specifying the parameter to pass to the command when it is executed. Cannot be null.</param>

src/ReactiveUI/Bindings/Command/CommandBinderImplementation.cs

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,7 @@ namespace ReactiveUI;
2525
/// </remarks>
2626
public class CommandBinderImplementation : ICommandBinderImplementation
2727
{
28-
/// <summary>
29-
/// Binds a command from the view model to a control on the view, enabling the control to execute the command with
30-
/// an optional parameter when triggered by a specified event.
31-
/// </summary>
32-
/// <remarks>This method uses reflection to observe properties and events, which may be affected by
33-
/// trimming in some deployment scenarios. The binding is one-way, from the view model command to the view control.
34-
/// If the specified event is not found on the control, an exception may be thrown at runtime.</remarks>
35-
/// <typeparam name="TView">The type of the view implementing the IViewFor interface.</typeparam>
36-
/// <typeparam name="TViewModel">The type of the view model containing the command property.</typeparam>
37-
/// <typeparam name="TProp">The type of the command property to bind, implementing ICommand.</typeparam>
38-
/// <typeparam name="TControl">The type of the control on the view to which the command will be bound.</typeparam>
39-
/// <typeparam name="TParam">The type of the parameter passed to the command when it is executed.</typeparam>
40-
/// <param name="viewModel">The view model instance containing the command to bind. Can be null if the binding should be established without
41-
/// an initial view model.</param>
42-
/// <param name="view">The view instance containing the control to which the command will be bound. Cannot be null.</param>
43-
/// <param name="vmProperty">An expression specifying the command property on the view model to bind. Cannot be null.</param>
44-
/// <param name="controlProperty">An expression specifying the control on the view to which the command will be bound. Cannot be null.</param>
45-
/// <param name="withParameter">An expression specifying the parameter to pass to the command when it is executed. Can be null if the command
46-
/// does not require a parameter.</param>
47-
/// <param name="toEvent">The name of the event on the control that triggers the command execution. If null, a default event is used based
48-
/// on the control type.</param>
49-
/// <returns>An IReactiveBinding{TView, TProp} representing the established command binding. Disposing the returned object
50-
/// will remove the binding.</returns>
28+
/// <inheritdoc />
5129
[RequiresUnreferencedCode("Dynamic observation uses reflection over members that may be trimmed.")]
5230
public IReactiveBinding<TView, TProp> BindCommand<
5331
TView,
@@ -93,31 +71,7 @@ public IReactiveBinding<TView, TProp> BindCommand<
9371
bindingDisposable);
9472
}
9573

96-
/// <summary>
97-
/// Binds a command from the view model to a control on the view, enabling the control to execute the command with
98-
/// an optional parameter stream and event trigger.
99-
/// </summary>
100-
/// <remarks>This method uses reflection to observe and bind to members, which may be affected by trimming
101-
/// in some environments. The binding is one-way, from the view model command to the view control. If the control or
102-
/// command property is not found, the binding will not be established. The method is suitable for scenarios where
103-
/// commands need to be dynamically bound to controls with support for parameter streams and custom event
104-
/// triggers.</remarks>
105-
/// <typeparam name="TView">The type of the view implementing the IViewFor interface.</typeparam>
106-
/// <typeparam name="TViewModel">The type of the view model containing the command property.</typeparam>
107-
/// <typeparam name="TProp">The type of the command property, which must implement ICommand.</typeparam>
108-
/// <typeparam name="TControl">The type of the control on the view to which the command will be bound.</typeparam>
109-
/// <typeparam name="TParam">The type of the parameter passed to the command when it is executed.</typeparam>
110-
/// <param name="viewModel">The view model instance containing the command to bind. Can be null if the view model is not available at
111-
/// binding time.</param>
112-
/// <param name="view">The view instance containing the control to which the command will be bound.</param>
113-
/// <param name="vmProperty">An expression specifying the command property on the view model to bind.</param>
114-
/// <param name="controlProperty">An expression specifying the control on the view that will trigger the command.</param>
115-
/// <param name="withParameter">An observable sequence providing the parameter to pass to the command when it is executed. The latest value is
116-
/// used for each command invocation.</param>
117-
/// <param name="toEvent">The name of the event on the control that triggers the command. If null, a default event is used based on the
118-
/// control type.</param>
119-
/// <returns>An IReactiveBinding{TView, TProp} representing the established binding between the command and the control.
120-
/// Disposing the binding will remove the command association.</returns>
74+
/// <inheritdoc />
12175
[RequiresUnreferencedCode("Dynamic observation uses reflection over members that may be trimmed.")]
12276
public IReactiveBinding<TView, TProp> BindCommand<
12377
TView,

0 commit comments

Comments
 (0)