77using System ;
88using System . Collections . Generic ;
99using System . ComponentModel ;
10+ using System . Diagnostics . CodeAnalysis ;
1011using System . Runtime . CompilerServices ;
1112using System . Threading . Tasks ;
1213
@@ -50,7 +51,7 @@ protected void OnPropertyChanged([CallerMemberName] string? propertyName = null)
5051 /// <remarks>
5152 /// The <see cref="PropertyChanged"/> event is not raised if the current and new value for the target property are the same.
5253 /// </remarks>
53- protected bool SetProperty < T > ( ref T field , T newValue , [ CallerMemberName ] string ? propertyName = null )
54+ protected bool SetProperty < T > ( [ NotNullIfNotNull ( "newValue" ) ] ref T field , T newValue , [ CallerMemberName ] string ? propertyName = null )
5455 {
5556 if ( EqualityComparer < T > . Default . Equals ( field , newValue ) )
5657 {
@@ -75,7 +76,7 @@ protected bool SetProperty<T>(ref T field, T newValue, [CallerMemberName] string
7576 /// <param name="comparer">The <see cref="IEqualityComparer{T}"/> instance to use to compare the input values.</param>
7677 /// <param name="propertyName">(optional) The name of the property that changed.</param>
7778 /// <returns><see langword="true"/> if the property was changed, <see langword="false"/> otherwise.</returns>
78- protected bool SetProperty < T > ( ref T field , T newValue , IEqualityComparer < T > comparer , [ CallerMemberName ] string ? propertyName = null )
79+ protected bool SetProperty < T > ( [ NotNullIfNotNull ( "newValue" ) ] ref T field , T newValue , IEqualityComparer < T > comparer , [ CallerMemberName ] string ? propertyName = null )
7980 {
8081 if ( comparer . Equals ( field , newValue ) )
8182 {
@@ -280,7 +281,7 @@ protected bool SetProperty<TModel, T>(T oldValue, T newValue, IEqualityComparer<
280281 /// <paramref name="taskNotifier"/> is different than the previous one, and it does not mean the new
281282 /// <see cref="Task"/> instance passed as argument is in any particular state.
282283 /// </remarks>
283- protected bool SetPropertyAndNotifyOnCompletion ( ref TaskNotifier ? taskNotifier , Task ? newValue , [ CallerMemberName ] string ? propertyName = null )
284+ protected bool SetPropertyAndNotifyOnCompletion ( [ NotNull ] ref TaskNotifier ? taskNotifier , Task ? newValue , [ CallerMemberName ] string ? propertyName = null )
284285 {
285286 return SetPropertyAndNotifyOnCompletion ( taskNotifier ??= new ( ) , newValue , static _ => { } , propertyName ) ;
286287 }
@@ -300,7 +301,7 @@ protected bool SetPropertyAndNotifyOnCompletion(ref TaskNotifier? taskNotifier,
300301 /// <remarks>
301302 /// The <see cref="PropertyChanged"/> event is not raised if the current and new value for the target property are the same.
302303 /// </remarks>
303- protected bool SetPropertyAndNotifyOnCompletion ( ref TaskNotifier ? taskNotifier , Task ? newValue , Action < Task ? > callback , [ CallerMemberName ] string ? propertyName = null )
304+ protected bool SetPropertyAndNotifyOnCompletion ( [ NotNull ] ref TaskNotifier ? taskNotifier , Task ? newValue , Action < Task ? > callback , [ CallerMemberName ] string ? propertyName = null )
304305 {
305306 return SetPropertyAndNotifyOnCompletion ( taskNotifier ??= new ( ) , newValue , callback , propertyName ) ;
306307 }
@@ -338,7 +339,7 @@ protected bool SetPropertyAndNotifyOnCompletion(ref TaskNotifier? taskNotifier,
338339 /// <paramref name="taskNotifier"/> is different than the previous one, and it does not mean the new
339340 /// <see cref="Task{TResult}"/> instance passed as argument is in any particular state.
340341 /// </remarks>
341- protected bool SetPropertyAndNotifyOnCompletion < T > ( ref TaskNotifier < T > ? taskNotifier , Task < T > ? newValue , [ CallerMemberName ] string ? propertyName = null )
342+ protected bool SetPropertyAndNotifyOnCompletion < T > ( [ NotNull ] ref TaskNotifier < T > ? taskNotifier , Task < T > ? newValue , [ CallerMemberName ] string ? propertyName = null )
342343 {
343344 return SetPropertyAndNotifyOnCompletion ( taskNotifier ??= new ( ) , newValue , static _ => { } , propertyName ) ;
344345 }
@@ -359,7 +360,7 @@ protected bool SetPropertyAndNotifyOnCompletion<T>(ref TaskNotifier<T>? taskNoti
359360 /// <remarks>
360361 /// The <see cref="PropertyChanged"/> event is not raised if the current and new value for the target property are the same.
361362 /// </remarks>
362- protected bool SetPropertyAndNotifyOnCompletion < T > ( ref TaskNotifier < T > ? taskNotifier , Task < T > ? newValue , Action < Task < T > ? > callback , [ CallerMemberName ] string ? propertyName = null )
363+ protected bool SetPropertyAndNotifyOnCompletion < T > ( [ NotNull ] ref TaskNotifier < T > ? taskNotifier , Task < T > ? newValue , Action < Task < T > ? > callback , [ CallerMemberName ] string ? propertyName = null )
363364 {
364365 return SetPropertyAndNotifyOnCompletion ( taskNotifier ??= new ( ) , newValue , callback , propertyName ) ;
365366 }
0 commit comments