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

Commit

Permalink
Include Debug.Fail with GlobalLog.Assert in Net Mail.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lakshmi Priya Sekar committed Oct 18, 2016
1 parent c5abd4a commit 26850f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
10 changes: 7 additions & 3 deletions src/System.Net.Mail/src/System/Net/Mail/SmtpConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,15 @@ private Authorization SetContextAndTryAuthenticate(ISmtpAuthenticationModule mod
// We may need to restore user thread token here
if (ReferenceEquals(credential, CredentialCache.DefaultNetworkCredentials))
{
// CONSIDER: Change to a real runtime check that throws InvalidOperationException to help catch customer race conditions.
#if DEBUG
if (GlobalLog.IsEnabled)
if (context != null && !context.IdentityRequested)
{
GlobalLog.AssertFormat(context == null || context.IdentityRequested, "SmtpConnection#{0}::SetContextAndTryAuthenticate|Authentication required when it wasn't expected. (Maybe Credentials was changed on another thread?)", LoggingHash.HashString(this));
if (GlobalLog.IsEnabled)
{
GlobalLog.AssertFormat("SmtpConnection#{0}::SetContextAndTryAuthenticate|Authentication required when it wasn't expected. (Maybe Credentials was changed on another thread?)", LoggingHash.HashString(this));
}

Debug.Fail("SmtpConnection#" + LoggingHash.HashString(this) + "::SetContextAndTryAuthenticate|Authentication required when it wasn't expected. (Maybe Credentials was changed on another thread?)");
}
#endif

Expand Down
9 changes: 0 additions & 9 deletions src/System.Net.Mail/src/System/Net/Mail/SmtpTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,6 @@ internal IAsyncResult BeginSendMail(MailAddress sender, MailAddressCollection re
throw new ArgumentNullException(nameof(recipients));
}

if (GlobalLog.IsEnabled && recipients.Count > 0)
{
GlobalLog.Assert("SmtpTransport::BeginSendMail()|recepients.Count <= 0");
}

SendMailAsyncResult result = new SendMailAsyncResult(_connection, sender, recipients,
allowUnicode, _connection.DSNEnabled ? deliveryNotify : null,
callback, state);
Expand Down Expand Up @@ -257,10 +252,6 @@ internal MailWriter SendMail(MailAddress sender, MailAddressCollection recipient
throw new ArgumentNullException(nameof(recipients));
}

if (GlobalLog.IsEnabled && recipients.Count > 0)
{
GlobalLog.Assert("SmtpTransport::SendMail()|recepients.Count <= 0");
}
MailCommand.Send(_connection, SmtpCommands.Mail, sender, allowUnicode);
_failedRecipientExceptions.Clear();

Expand Down

0 comments on commit 26850f1

Please sign in to comment.