Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fixing nullable annotations and warnings in Retry#716

Open
algirdasN wants to merge 2 commits intoFlaUI:masterfrom
algirdasN:retry-nullable-fix
Open

Fixing nullable annotations and warnings in Retry#716
algirdasN wants to merge 2 commits intoFlaUI:masterfrom
algirdasN:retry-nullable-fix

Conversation

@algirdasN
Copy link

Changes:

  • Added nullable annotations to Find methods.
    After nullable annotation where added to the project, these methods were left out. For delegate parameter on single element Find it makes sense to accept Func that returns a nullable value, because all find methods now return nullable results. For return value it also makes sense because the RetryResult.Result will be null if retry fails to find the element/-s. I also think that the method for locating multiple elements should return an empty array when none are found but changing that would be a breaking change at this point.
  • Added nullable annotation to defaultOnTimeout parameter in While method.
    This was to align this with other methods that accept a default value. Also removed redundant type parameter on one of this method's call.
  • Changed how WhileEmpty method checks for an empty IEnumerable.
    Calling GetEnumerator() on each iteration without disposing it might cause issues if the IEnumerable that are backed by unmanaged resources. While vast majority of uses is likely with in-memory collection, I think it is still worth fixing this. Any iterator in essence does the same GetEnumerator().MoveNext() call but disposes of the enumerator afterwards. Cast iterator is required to get the generic version of IEnumerable which is expected by Any(). It also should be possible to remove the null check here, the compiler would warn of possible null reference but I bet that this is used by someone somewhere so I am not comfortable breaking it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant