Add [NotNull] annotation and explanation to ImapClient.Inbox#1996
Closed
campbell-reid-displayr wants to merge 1 commit intojstedfast:masterfrom
Closed
Add [NotNull] annotation and explanation to ImapClient.Inbox#1996campbell-reid-displayr wants to merge 1 commit intojstedfast:masterfrom
campbell-reid-displayr wants to merge 1 commit intojstedfast:masterfrom
Conversation
The property is typed as IMailFolder? to match the nullable underlying ImapEngine.Inbox field, but it never returns null in practice — it throws ServiceNotAuthenticatedException before reaching engine.Inbox, and QuerySpecialFolders() guarantees engine.Inbox is non-null before Authenticate() returns. The [NotNull] attribute surfaces this guarantee to the compiler for callers using the concrete type. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
b3ee18c to
094f7c3
Compare
Owner
|
The problem is that it can return null in several situations:
|
Owner
|
Ah, looks like I wrote a workaround for the second situation |
Owner
|
Ok, I guess we can... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ImapClient.Inboxis typed asIMailFolder?to match the nullableImapEngine.Inboxfield, but the property never actually returnsnullin practice[NotNull]so the compiler can surface this guarantee to callers using the concreteImapClienttype, eliminating spurious null warningsWhy it never returns null
CheckAuthenticated()throwsServiceNotAuthenticatedExceptionbeforeengine.Inboxis ever reached if the client is unauthenticatedAuthenticate()callsOnAuthenticated()→QuerySpecialFolders()synchronously before returning, which always assignsengine.Inbox— creating a placeholder folder if the server never reported one (ImapEngine.cs#L3762-L3768)engine.Inboxis never reassignednullafter that pointTest plan
ImapClient.Inboxdirectly no longer receive a nullable warning from the compiler🤖 Generated with Claude Code