1818using System ;
1919using System . Collections . Generic ;
2020using System . ComponentModel ;
21+ using System . Diagnostics . CodeAnalysis ;
2122using System . Runtime . CompilerServices ;
2223using System . Threading . Tasks ;
2324
@@ -84,7 +85,7 @@ protected void OnPropertyChanging([CallerMemberName] string? propertyName = null
8485 /// The <see cref="PropertyChanging"/> and <see cref="PropertyChanged"/> events are not raised
8586 /// if the current and new value for the target property are the same.
8687 /// </remarks>
87- protected bool SetProperty < T > ( ref T field , T newValue , [ CallerMemberName ] string ? propertyName = null )
88+ protected bool SetProperty < T > ( [ NotNullIfNotNull ( "newValue" ) ] ref T field , T newValue , [ CallerMemberName ] string ? propertyName = null )
8889 {
8990 // We duplicate the code here instead of calling the overload because we can't
9091 // guarantee that the invoked SetProperty<T> will be inlined, and we need the JIT
@@ -120,7 +121,7 @@ protected bool SetProperty<T>(ref T field, T newValue, [CallerMemberName] string
120121 /// <param name="comparer">The <see cref="IEqualityComparer{T}"/> instance to use to compare the input values.</param>
121122 /// <param name="propertyName">(optional) The name of the property that changed.</param>
122123 /// <returns><see langword="true"/> if the property was changed, <see langword="false"/> otherwise.</returns>
123- protected bool SetProperty < T > ( ref T field , T newValue , IEqualityComparer < T > comparer , [ CallerMemberName ] string ? propertyName = null )
124+ protected bool SetProperty < T > ( [ NotNullIfNotNull ( "newValue" ) ] ref T field , T newValue , IEqualityComparer < T > comparer , [ CallerMemberName ] string ? propertyName = null )
124125 {
125126 if ( comparer . Equals ( field , newValue ) )
126127 {
@@ -340,7 +341,7 @@ protected bool SetProperty<TModel, T>(T oldValue, T newValue, IEqualityComparer<
340341 /// indicates that the new value being assigned to <paramref name="taskNotifier"/> is different than the previous one,
341342 /// and it does not mean the new <see cref="Task"/> instance passed as argument is in any particular state.
342343 /// </remarks>
343- protected bool SetPropertyAndNotifyOnCompletion ( ref TaskNotifier ? taskNotifier , Task ? newValue , [ CallerMemberName ] string ? propertyName = null )
344+ protected bool SetPropertyAndNotifyOnCompletion ( [ NotNull ] ref TaskNotifier ? taskNotifier , Task ? newValue , [ CallerMemberName ] string ? propertyName = null )
344345 {
345346 // We invoke the overload with a callback here to avoid code duplication, and simply pass an empty callback.
346347 // The lambda expression here is transformed by the C# compiler into an empty closure class with a
@@ -368,7 +369,7 @@ protected bool SetPropertyAndNotifyOnCompletion(ref TaskNotifier? taskNotifier,
368369 /// The <see cref="PropertyChanging"/> and <see cref="PropertyChanged"/> events are not raised
369370 /// if the current and new value for the target property are the same.
370371 /// </remarks>
371- protected bool SetPropertyAndNotifyOnCompletion ( ref TaskNotifier ? taskNotifier , Task ? newValue , Action < Task ? > callback , [ CallerMemberName ] string ? propertyName = null )
372+ protected bool SetPropertyAndNotifyOnCompletion ( [ NotNull ] ref TaskNotifier ? taskNotifier , Task ? newValue , Action < Task ? > callback , [ CallerMemberName ] string ? propertyName = null )
372373 {
373374 return SetPropertyAndNotifyOnCompletion ( taskNotifier ??= new ( ) , newValue , callback , propertyName ) ;
374375 }
@@ -407,7 +408,7 @@ protected bool SetPropertyAndNotifyOnCompletion(ref TaskNotifier? taskNotifier,
407408 /// indicates that the new value being assigned to <paramref name="taskNotifier"/> is different than the previous one,
408409 /// and it does not mean the new <see cref="Task{TResult}"/> instance passed as argument is in any particular state.
409410 /// </remarks>
410- protected bool SetPropertyAndNotifyOnCompletion < T > ( ref TaskNotifier < T > ? taskNotifier , Task < T > ? newValue , [ CallerMemberName ] string ? propertyName = null )
411+ protected bool SetPropertyAndNotifyOnCompletion < T > ( [ NotNull ] ref TaskNotifier < T > ? taskNotifier , Task < T > ? newValue , [ CallerMemberName ] string ? propertyName = null )
411412 {
412413 return SetPropertyAndNotifyOnCompletion ( taskNotifier ??= new ( ) , newValue , static _ => { } , propertyName ) ;
413414 }
@@ -430,7 +431,7 @@ protected bool SetPropertyAndNotifyOnCompletion<T>(ref TaskNotifier<T>? taskNoti
430431 /// The <see cref="PropertyChanging"/> and <see cref="PropertyChanged"/> events are not raised
431432 /// if the current and new value for the target property are the same.
432433 /// </remarks>
433- protected bool SetPropertyAndNotifyOnCompletion < T > ( ref TaskNotifier < T > ? taskNotifier , Task < T > ? newValue , Action < Task < T > ? > callback , [ CallerMemberName ] string ? propertyName = null )
434+ protected bool SetPropertyAndNotifyOnCompletion < T > ( [ NotNull ] ref TaskNotifier < T > ? taskNotifier , Task < T > ? newValue , Action < Task < T > ? > callback , [ CallerMemberName ] string ? propertyName = null )
434435 {
435436 return SetPropertyAndNotifyOnCompletion ( taskNotifier ??= new ( ) , newValue , callback , propertyName ) ;
436437 }
0 commit comments