Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Include Debug.Fail with GlobalLog.Assert in Net Mail. #12749

Merged
merged 1 commit into from
Oct 19, 2016

Conversation

Priya91
Copy link
Contributor

@Priya91 Priya91 commented Oct 18, 2016

fixes #12674

cc @CIPop

@@ -205,9 +206,14 @@ internal void EndGetConnection(IAsyncResult result)
throw new ArgumentNullException(nameof(recipients));
}

if (GlobalLog.IsEnabled && recipients.Count > 0)
if (recipients.Count <= 0)
Copy link
Member

@stephentoub stephentoub Oct 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this was a bug? It's now asserting in the opposite condition. Regardless, this seems like a strange assert. Presumably _recipients is provided/populated by the dev? Are we validating that it's not empty prior to this call? If this is coming from user input, we should not be asserting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is populated by _recipients, and we do throw in SmtpClient, if no recipient information was given. Will remove these asserts.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the code diverge from Desktop? I would expect to see this assert when running our tests in CHK mode.

@@ -257,10 +263,16 @@ internal MailWriter EndSendMail(IAsyncResult result)
throw new ArgumentNullException(nameof(recipients));
}

if (GlobalLog.IsEnabled && recipients.Count > 0)
if (recipients.Count <= 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

GlobalLog.Assert("SmtpTransport::BeginSendMail()|recepients.Count <= 0");
}

Debug.Fail("SmtpTransport::BeginSendMail()|recepients.Count <= 0");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Search and replace: recepients => recipients

@Priya91 Priya91 merged commit 4db64b2 into dotnet:master Oct 19, 2016
@Priya91 Priya91 deleted the netmail branch October 19, 2016 18:09
@@ -205,11 +205,6 @@ internal void EndGetConnection(IAsyncResult result)
throw new ArgumentNullException(nameof(recipients));
}

if (GlobalLog.IsEnabled && recipients.Count > 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why were these removed and how did the code work before (looks like this will always fail in the normal case)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even without the inversion (should have been recipients.Count == 0), this is not something we should be asserting for. This is user-provided data. If we want to fail on such input, it should be with an exception in both debug and release; a debug assert doesn't do us any good.

@karelz karelz modified the milestone: 1.2.0 Dec 3, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Include Debug.Fail with GlobalLog.Assert in Net Mail.

Commit migrated from dotnet/corefx@4db64b2
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SmtpClient ported code is missing DEBUG assert statements
6 participants