From ef38eb662f1ee14bd1787e7395fa892594a9fb09 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Fri, 2 Oct 2020 11:54:10 +0200 Subject: [PATCH 01/16] [wasm][net] System.Net.Mail should not throw PNSE for full assembly. --- .../System.Net.Mail/Directory.Build.props | 3 +- .../src/System.Net.Mail.csproj | 72 ++++---- .../src/System/Net/Mail/SmtpClient.Browser.cs | 159 ++++++++++++++++++ .../Net/Mail/SmtpFailedRecipientException.cs | 3 + 4 files changed, 202 insertions(+), 35 deletions(-) create mode 100644 src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs diff --git a/src/libraries/System.Net.Mail/Directory.Build.props b/src/libraries/System.Net.Mail/Directory.Build.props index 4784967b7f86a..5a1a0f181caaa 100644 --- a/src/libraries/System.Net.Mail/Directory.Build.props +++ b/src/libraries/System.Net.Mail/Directory.Build.props @@ -3,6 +3,5 @@ Open true - browser - \ No newline at end of file + diff --git a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj index 0bc8b1c63c460..f743121833bd7 100644 --- a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj +++ b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj @@ -5,10 +5,7 @@ enable - - SR.SystemNetMail_PlatformNotSupported - - + @@ -43,42 +40,23 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + - + - + throw new PlatformNotSupportedException(); + set => throw new PlatformNotSupportedException(); + } + + public int Port + { + get => throw new PlatformNotSupportedException(); + set => throw new PlatformNotSupportedException(); + } + + public bool UseDefaultCredentials + { + get => throw new PlatformNotSupportedException(); + set => throw new PlatformNotSupportedException(); + } + + public ICredentialsByHost? Credentials + { + get => throw new PlatformNotSupportedException(); + set => throw new PlatformNotSupportedException(); + } + + public int Timeout + { + get => throw new PlatformNotSupportedException(); + set => throw new PlatformNotSupportedException(); + } + + public ServicePoint ServicePoint + { + get => throw new PlatformNotSupportedException(); + } + + public SmtpDeliveryMethod DeliveryMethod + { + get => throw new PlatformNotSupportedException(); + set => throw new PlatformNotSupportedException(); + } + + public SmtpDeliveryFormat DeliveryFormat + { + get => throw new PlatformNotSupportedException(); + set => throw new PlatformNotSupportedException(); + } + + public string? PickupDirectoryLocation + { + get => throw new PlatformNotSupportedException(); + set => throw new PlatformNotSupportedException(); + } + + /// + /// Set to true if we need SSL + /// + public bool EnableSsl + { + get => throw new PlatformNotSupportedException(); + set => throw new PlatformNotSupportedException(); + } + + /// + /// Certificates used by the client for establishing an SSL connection with the server. + /// + public X509CertificateCollection ClientCertificates => throw new PlatformNotSupportedException(); + + public string? TargetName + { + get => throw new PlatformNotSupportedException(); + set => throw new PlatformNotSupportedException(); + } + + private bool ServerSupportsEai => throw new PlatformNotSupportedException(); + + public void Send(string from, string recipients, string? subject, string? body) => throw new PlatformNotSupportedException(); + + public void Send(MailMessage message) => throw new PlatformNotSupportedException(); + + public void SendAsync(string from, string recipients, string? subject, string? body, object? userToken) => throw new PlatformNotSupportedException(); + + public void SendAsync(MailMessage message, object? userToken) => throw new PlatformNotSupportedException(); + + public void SendAsyncCancel() => throw new PlatformNotSupportedException(); + + //************* Task-based async public methods ************************* + public Task SendMailAsync(string from, string recipients, string? subject, string? body) => throw new PlatformNotSupportedException(); + + public Task SendMailAsync(MailMessage message) => throw new PlatformNotSupportedException(); + + public Task SendMailAsync(string from, string recipients, string? subject, string? body, CancellationToken cancellationToken) => throw new PlatformNotSupportedException(); + + public Task SendMailAsync(MailMessage message, CancellationToken cancellationToken) => throw new PlatformNotSupportedException(); + + protected void OnSendCompleted(AsyncCompletedEventArgs e) => throw new PlatformNotSupportedException(); + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { } + } +} diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpFailedRecipientException.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpFailedRecipientException.cs index 6919990791abf..f3a5d300f0cc9 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpFailedRecipientException.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpFailedRecipientException.cs @@ -12,7 +12,10 @@ namespace System.Net.Mail public class SmtpFailedRecipientException : SmtpException, ISerializable { private readonly string? _failedRecipient; + +#pragma warning disable CS0649 // Browser - never assigned to internal bool fatal; +#pragma warning restore CS0649 public SmtpFailedRecipientException() : base() { } From 3ad3cf2d0a6f8de712678009679c301781bed33c Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Fri, 2 Oct 2020 13:25:20 +0200 Subject: [PATCH 02/16] Address review comment. Remove comment line --- .../System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs index 1f8e863426fc7..5f8b2fc49ebee 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs @@ -47,7 +47,6 @@ public SmtpClient(string? host, int port) private void Initialize() { - //_transport = new SmtpTransport(); throw new PlatformNotSupportedException(); } From 0a256afb660eb89ed444e49605543f263fa51525 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Fri, 2 Oct 2020 13:27:35 +0200 Subject: [PATCH 03/16] Address review comments. Remove redundant defs --- src/libraries/System.Net.Mail/src/System.Net.Mail.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj index f743121833bd7..c1df92d987cba 100644 --- a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj +++ b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj @@ -135,7 +135,7 @@ - + - + Date: Fri, 2 Oct 2020 14:17:29 +0200 Subject: [PATCH 04/16] Activate tests on CI - SmtpClient relevant tests are not supported --- .../System.Net.Mail/tests/Functional/AssemblyInfo.cs | 1 - src/libraries/System.Net.Mail/tests/Functional/LoggingTest.cs | 1 + .../System.Net.Mail/tests/Functional/MailMessageTest.cs | 1 + .../tests/Functional/SmtpClientCredentialsTest.cs | 3 ++- .../System.Net.Mail/tests/Functional/SmtpClientTest.cs | 1 + .../tests/Functional/System.Net.Mail.Functional.Tests.csproj | 4 +--- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libraries/System.Net.Mail/tests/Functional/AssemblyInfo.cs b/src/libraries/System.Net.Mail/tests/Functional/AssemblyInfo.cs index 4f5a0ace5deef..54c8a4d926e5c 100644 --- a/src/libraries/System.Net.Mail/tests/Functional/AssemblyInfo.cs +++ b/src/libraries/System.Net.Mail/tests/Functional/AssemblyInfo.cs @@ -4,4 +4,3 @@ using Xunit; [assembly: ActiveIssue("https://github.com/dotnet/runtime/issues/34690", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] -[assembly: SkipOnMono("System.Net.Mail is not supported on wasm", TestPlatforms.Browser)] diff --git a/src/libraries/System.Net.Mail/tests/Functional/LoggingTest.cs b/src/libraries/System.Net.Mail/tests/Functional/LoggingTest.cs index 65c9d1c10abe0..34f29d5b65032 100644 --- a/src/libraries/System.Net.Mail/tests/Functional/LoggingTest.cs +++ b/src/libraries/System.Net.Mail/tests/Functional/LoggingTest.cs @@ -9,6 +9,7 @@ namespace System.Net.Mail.Tests { + [PlatformSpecific(~TestPlatforms.Browser)] // SmtpClient is not supported on Browser public class LoggingTest { [Fact] diff --git a/src/libraries/System.Net.Mail/tests/Functional/MailMessageTest.cs b/src/libraries/System.Net.Mail/tests/Functional/MailMessageTest.cs index 8b6382bb64ef3..9bbb6218ec8fa 100644 --- a/src/libraries/System.Net.Mail/tests/Functional/MailMessageTest.cs +++ b/src/libraries/System.Net.Mail/tests/Functional/MailMessageTest.cs @@ -146,6 +146,7 @@ public void SubjectAndEncodingTest() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] // not passing yet with Value cannot be null. public void SentSpecialLengthMailAttachment_Base64Decode_Success() { // The special length follows pattern: (3N - 1) * 0x4400 + 1 diff --git a/src/libraries/System.Net.Mail/tests/Functional/SmtpClientCredentialsTest.cs b/src/libraries/System.Net.Mail/tests/Functional/SmtpClientCredentialsTest.cs index 824717a0d9c78..64d884412b8fd 100644 --- a/src/libraries/System.Net.Mail/tests/Functional/SmtpClientCredentialsTest.cs +++ b/src/libraries/System.Net.Mail/tests/Functional/SmtpClientCredentialsTest.cs @@ -11,10 +11,11 @@ namespace System.Net.Mail.Functional.Tests { + [PlatformSpecific(~TestPlatforms.Browser)] // SmtpClient is not supported on Browser public class SmtpClientCredentialsTest { private readonly string UserName = "user"; - private readonly string Password = Guid.NewGuid().ToString(); + private readonly string Password = Guid.NewGuid().ToString(); [Fact] public void Credentials_Unset_Null() diff --git a/src/libraries/System.Net.Mail/tests/Functional/SmtpClientTest.cs b/src/libraries/System.Net.Mail/tests/Functional/SmtpClientTest.cs index 3d55574f0cab3..9519ff7529f41 100644 --- a/src/libraries/System.Net.Mail/tests/Functional/SmtpClientTest.cs +++ b/src/libraries/System.Net.Mail/tests/Functional/SmtpClientTest.cs @@ -19,6 +19,7 @@ namespace System.Net.Mail.Tests { + [PlatformSpecific(~TestPlatforms.Browser)] // SmtpClient is not supported on Browser public class SmtpClientTest : FileCleanupTestBase { private SmtpClient _smtp; diff --git a/src/libraries/System.Net.Mail/tests/Functional/System.Net.Mail.Functional.Tests.csproj b/src/libraries/System.Net.Mail/tests/Functional/System.Net.Mail.Functional.Tests.csproj index 83bb83a34f4d2..7519783c1cbaf 100644 --- a/src/libraries/System.Net.Mail/tests/Functional/System.Net.Mail.Functional.Tests.csproj +++ b/src/libraries/System.Net.Mail/tests/Functional/System.Net.Mail.Functional.Tests.csproj @@ -2,8 +2,6 @@ true $(NetCoreAppCurrent) - - true @@ -31,4 +29,4 @@ - \ No newline at end of file + From 62999df946b931c8caec7f5c474cf24194511367 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Mon, 5 Oct 2020 07:25:49 +0200 Subject: [PATCH 05/16] Add `[UnsupportedOSPlatform("browser")]` to SmtpClient --- src/libraries/System.Net.Mail/ref/System.Net.Mail.cs | 1 + .../System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs | 2 ++ src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs | 2 ++ 3 files changed, 5 insertions(+) diff --git a/src/libraries/System.Net.Mail/ref/System.Net.Mail.cs b/src/libraries/System.Net.Mail/ref/System.Net.Mail.cs index e59605eb60f29..5826634dd14a9 100644 --- a/src/libraries/System.Net.Mail/ref/System.Net.Mail.cs +++ b/src/libraries/System.Net.Mail/ref/System.Net.Mail.cs @@ -165,6 +165,7 @@ public enum MailPriority High = 2, } public delegate void SendCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e); + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public partial class SmtpClient : System.IDisposable { public SmtpClient() { } diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs index 5f8b2fc49ebee..9a9485a7ad0ca 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs @@ -3,6 +3,7 @@ using System; using System.ComponentModel; +using System.Runtime.Versioning; using System.Security.Cryptography.X509Certificates; using System.Threading; using System.Threading.Tasks; @@ -25,6 +26,7 @@ public enum SmtpDeliveryFormat International = 1, // SMTPUTF8 - Email Address Internationalization (EAI) } + [UnsupportedOSPlatform("browser")] public class SmtpClient : IDisposable { #pragma warning disable CS0067 // Field is not used diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs index 9e87770828eba..cceff5d15fa1e 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs @@ -6,6 +6,7 @@ using System.Globalization; using System.IO; using System.Net.NetworkInformation; +using System.Runtime.Versioning; using System.Security; using System.Security.Authentication; using System.Security.Cryptography.X509Certificates; @@ -31,6 +32,7 @@ public enum SmtpDeliveryFormat International = 1, // SMTPUTF8 - Email Address Internationalization (EAI) } + [UnsupportedOSPlatform("browser")] public class SmtpClient : IDisposable { private string? _host; From 14e90dcd97531b14eb6ad61c549e828e9c1358a8 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Mon, 5 Oct 2020 08:14:39 +0200 Subject: [PATCH 06/16] Add back System.Net.Mail Unit tests --- .../tests/Unit/AssemblyInfo.cs | 2 - .../EhloParseExtensionsTest.cs | 1 + .../Unit/System.Net.Mail.Unit.Tests.csproj | 48 ++++++++++--------- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/libraries/System.Net.Mail/tests/Unit/AssemblyInfo.cs b/src/libraries/System.Net.Mail/tests/Unit/AssemblyInfo.cs index 2991b965dfe9d..fa6166bae3e4a 100644 --- a/src/libraries/System.Net.Mail/tests/Unit/AssemblyInfo.cs +++ b/src/libraries/System.Net.Mail/tests/Unit/AssemblyInfo.cs @@ -2,5 +2,3 @@ // The .NET Foundation licenses this file to you under the MIT license. using Xunit; - -[assembly: SkipOnMono("System.Net.Mail is not supported on wasm", TestPlatforms.Browser)] diff --git a/src/libraries/System.Net.Mail/tests/Unit/SmtpConnectionTests/EhloParseExtensionsTest.cs b/src/libraries/System.Net.Mail/tests/Unit/SmtpConnectionTests/EhloParseExtensionsTest.cs index fa4333b952e4d..f0c3f437c180d 100644 --- a/src/libraries/System.Net.Mail/tests/Unit/SmtpConnectionTests/EhloParseExtensionsTest.cs +++ b/src/libraries/System.Net.Mail/tests/Unit/SmtpConnectionTests/EhloParseExtensionsTest.cs @@ -5,6 +5,7 @@ namespace System.Net.Mail.Tests { + [PlatformSpecific(~TestPlatforms.Browser)] // SmtpClient is not supported on Browser public class EhloParseExtensionsTest { private SmtpConnection _smtpConnection; diff --git a/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj b/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj index 79709820e29b9..85aeaab14285a 100644 --- a/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj +++ b/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj @@ -2,7 +2,7 @@ true ../../src/Resources/Strings.resx - $(NetCoreAppCurrent)-Windows_NT;$(NetCoreAppCurrent)-Unix + $(NetCoreAppCurrent)-Windows_NT;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser annotations @@ -19,7 +19,7 @@ - + @@ -36,16 +36,8 @@ Link="ProductionCode\MailAddress.cs" /> - - - - - - - - - + - - + + + + + + + + + + + + + + From 74b6bbb99b6fb65cba571fdc26a1a8567b6a25b8 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Mon, 5 Oct 2020 08:17:45 +0200 Subject: [PATCH 07/16] Remove redundant $(TargetsBrowser) from ItemGroup --- .../tests/Unit/System.Net.Mail.Unit.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj b/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj index 85aeaab14285a..80a2f6775dc07 100644 --- a/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj +++ b/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj @@ -148,7 +148,7 @@ Link="Common\System\HexConverter.cs" /> - + Date: Tue, 6 Oct 2020 07:17:10 +0200 Subject: [PATCH 08/16] Add `[UnsupportedOSPlatform("browser")]` to SmtpClient methods and properties - It does not hurt to have this. --- .../System.Net.Mail/ref/System.Net.Mail.cs | 28 ++++++++++++++++++ .../src/System/Net/Mail/SmtpClient.Browser.cs | 29 +++++++++++++++++++ .../src/System/Net/Mail/SmtpClient.cs | 29 +++++++++++++++++++ 3 files changed, 86 insertions(+) diff --git a/src/libraries/System.Net.Mail/ref/System.Net.Mail.cs b/src/libraries/System.Net.Mail/ref/System.Net.Mail.cs index 5826634dd14a9..63576c2e76b4f 100644 --- a/src/libraries/System.Net.Mail/ref/System.Net.Mail.cs +++ b/src/libraries/System.Net.Mail/ref/System.Net.Mail.cs @@ -168,34 +168,62 @@ public enum MailPriority [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public partial class SmtpClient : System.IDisposable { + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public SmtpClient() { } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public SmtpClient(string? host) { } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public SmtpClient(string? host, int port) { } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.Security.Cryptography.X509Certificates.X509CertificateCollection ClientCertificates { get { throw null; } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.Net.ICredentialsByHost? Credentials { get { throw null; } set { } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.Net.Mail.SmtpDeliveryFormat DeliveryFormat { get { throw null; } set { } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.Net.Mail.SmtpDeliveryMethod DeliveryMethod { get { throw null; } set { } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public bool EnableSsl { get { throw null; } set { } } [System.Diagnostics.CodeAnalysis.DisallowNullAttribute] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public string? Host { get { throw null; } set { } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public string? PickupDirectoryLocation { get { throw null; } set { } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public int Port { get { throw null; } set { } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.Net.ServicePoint ServicePoint { get { throw null; } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public string? TargetName { get { throw null; } set { } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public int Timeout { get { throw null; } set { } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public bool UseDefaultCredentials { get { throw null; } set { } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public event System.Net.Mail.SendCompletedEventHandler? SendCompleted { add { } remove { } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public void Dispose() { } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] protected virtual void Dispose(bool disposing) { } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] protected void OnSendCompleted(System.ComponentModel.AsyncCompletedEventArgs e) { } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public void Send(System.Net.Mail.MailMessage message) { } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public void Send(string from, string recipients, string? subject, string? body) { } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public void SendAsync(System.Net.Mail.MailMessage message, object? userToken) { } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public void SendAsync(string from, string recipients, string? subject, string? body, object? userToken) { } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public void SendAsyncCancel() { } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.Threading.Tasks.Task SendMailAsync(System.Net.Mail.MailMessage message) { throw null; } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.Threading.Tasks.Task SendMailAsync(string from, string recipients, string? subject, string? body) { throw null; } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.Threading.Tasks.Task SendMailAsync(System.Net.Mail.MailMessage message, System.Threading.CancellationToken cancellationToken) { throw null; } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.Threading.Tasks.Task SendMailAsync(string from, string recipients, string? subject, string? body, System.Threading.CancellationToken cancellationToken) { throw null; } } public enum SmtpDeliveryFormat diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs index 9a9485a7ad0ca..05e3e2a274675 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs @@ -30,18 +30,22 @@ public enum SmtpDeliveryFormat public class SmtpClient : IDisposable { #pragma warning disable CS0067 // Field is not used + [UnsupportedOSPlatform("browser")] public event SendCompletedEventHandler? SendCompleted; #pragma warning restore CS0067 + [UnsupportedOSPlatform("browser")] public SmtpClient() { Initialize(); } + [UnsupportedOSPlatform("browser")] public SmtpClient(string? host) { Initialize(); } + [UnsupportedOSPlatform("browser")] public SmtpClient(string? host, int port) { Initialize(); @@ -52,53 +56,62 @@ private void Initialize() throw new PlatformNotSupportedException(); } + [UnsupportedOSPlatform("browser")] public string? Host { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } + [UnsupportedOSPlatform("browser")] public int Port { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } + [UnsupportedOSPlatform("browser")] public bool UseDefaultCredentials { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } + [UnsupportedOSPlatform("browser")] public ICredentialsByHost? Credentials { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } + [UnsupportedOSPlatform("browser")] public int Timeout { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } + [UnsupportedOSPlatform("browser")] public ServicePoint ServicePoint { get => throw new PlatformNotSupportedException(); } + [UnsupportedOSPlatform("browser")] public SmtpDeliveryMethod DeliveryMethod { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } + [UnsupportedOSPlatform("browser")] public SmtpDeliveryFormat DeliveryFormat { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } + [UnsupportedOSPlatform("browser")] public string? PickupDirectoryLocation { get => throw new PlatformNotSupportedException(); @@ -108,6 +121,7 @@ public string? PickupDirectoryLocation /// /// Set to true if we need SSL /// + [UnsupportedOSPlatform("browser")] public bool EnableSsl { get => throw new PlatformNotSupportedException(); @@ -117,43 +131,58 @@ public bool EnableSsl /// /// Certificates used by the client for establishing an SSL connection with the server. /// + [UnsupportedOSPlatform("browser")] public X509CertificateCollection ClientCertificates => throw new PlatformNotSupportedException(); + [UnsupportedOSPlatform("browser")] public string? TargetName { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } + [UnsupportedOSPlatform("browser")] private bool ServerSupportsEai => throw new PlatformNotSupportedException(); + [UnsupportedOSPlatform("browser")] public void Send(string from, string recipients, string? subject, string? body) => throw new PlatformNotSupportedException(); + [UnsupportedOSPlatform("browser")] public void Send(MailMessage message) => throw new PlatformNotSupportedException(); + [UnsupportedOSPlatform("browser")] public void SendAsync(string from, string recipients, string? subject, string? body, object? userToken) => throw new PlatformNotSupportedException(); + [UnsupportedOSPlatform("browser")] public void SendAsync(MailMessage message, object? userToken) => throw new PlatformNotSupportedException(); + [UnsupportedOSPlatform("browser")] public void SendAsyncCancel() => throw new PlatformNotSupportedException(); //************* Task-based async public methods ************************* + [UnsupportedOSPlatform("browser")] public Task SendMailAsync(string from, string recipients, string? subject, string? body) => throw new PlatformNotSupportedException(); + [UnsupportedOSPlatform("browser")] public Task SendMailAsync(MailMessage message) => throw new PlatformNotSupportedException(); + [UnsupportedOSPlatform("browser")] public Task SendMailAsync(string from, string recipients, string? subject, string? body, CancellationToken cancellationToken) => throw new PlatformNotSupportedException(); + [UnsupportedOSPlatform("browser")] public Task SendMailAsync(MailMessage message, CancellationToken cancellationToken) => throw new PlatformNotSupportedException(); + [UnsupportedOSPlatform("browser")] protected void OnSendCompleted(AsyncCompletedEventArgs e) => throw new PlatformNotSupportedException(); + [UnsupportedOSPlatform("browser")] public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } + [UnsupportedOSPlatform("browser")] protected virtual void Dispose(bool disposing) { } } diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs index cceff5d15fa1e..3640c49fd53f3 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs @@ -62,21 +62,26 @@ public class SmtpClient : IDisposable private SmtpFailedRecipientException? _failedRecipientException; // ports above this limit are invalid private const int MaxPortValue = 65535; + [UnsupportedOSPlatform("browser")] + public event SendCompletedEventHandler? SendCompleted; private bool _useDefaultCredentials; private ICredentialsByHost? _customCredentials; + [UnsupportedOSPlatform("browser")] public SmtpClient() { Initialize(); } + [UnsupportedOSPlatform("browser")] public SmtpClient(string? host) { _host = host; Initialize(); } + [UnsupportedOSPlatform("browser")] public SmtpClient(string? host, int port) { try @@ -155,6 +160,7 @@ private void Initialize() } [DisallowNull] + [UnsupportedOSPlatform("browser")] public string? Host { get @@ -188,6 +194,7 @@ public string? Host } } + [UnsupportedOSPlatform("browser")] public int Port { get @@ -214,6 +221,7 @@ public int Port } } + [UnsupportedOSPlatform("browser")] public bool UseDefaultCredentials { get @@ -232,6 +240,7 @@ public bool UseDefaultCredentials } } + [UnsupportedOSPlatform("browser")] public ICredentialsByHost? Credentials { get @@ -255,6 +264,7 @@ private void UpdateTransportCredentials() _transport.Credentials = _useDefaultCredentials ? CredentialCache.DefaultNetworkCredentials : _customCredentials; } + [UnsupportedOSPlatform("browser")] public int Timeout { get @@ -277,6 +287,7 @@ public int Timeout } } + [UnsupportedOSPlatform("browser")] public ServicePoint ServicePoint { get @@ -295,6 +306,7 @@ public ServicePoint ServicePoint } } + [UnsupportedOSPlatform("browser")] public SmtpDeliveryMethod DeliveryMethod { get @@ -307,6 +319,7 @@ public SmtpDeliveryMethod DeliveryMethod } } + [UnsupportedOSPlatform("browser")] public SmtpDeliveryFormat DeliveryFormat { get @@ -319,6 +332,7 @@ public SmtpDeliveryFormat DeliveryFormat } } + [UnsupportedOSPlatform("browser")] public string? PickupDirectoryLocation { get @@ -334,6 +348,7 @@ public string? PickupDirectoryLocation /// /// Set to true if we need SSL /// + [UnsupportedOSPlatform("browser")] public bool EnableSsl { get @@ -349,6 +364,7 @@ public bool EnableSsl /// /// Certificates used by the client for establishing an SSL connection with the server. /// + [UnsupportedOSPlatform("browser")] public X509CertificateCollection ClientCertificates { get @@ -357,6 +373,7 @@ public X509CertificateCollection ClientCertificates } } + [UnsupportedOSPlatform("browser")] public string? TargetName { get { return _targetName; } @@ -403,6 +420,7 @@ internal MailWriter GetFileMailWriter(string? pickupDirectory) return new MailWriter(fileStream, encodeForTransport: false); } + [UnsupportedOSPlatform("browser")] protected void OnSendCompleted(AsyncCompletedEventArgs e) { SendCompleted?.Invoke(this, e); @@ -413,6 +431,7 @@ private void SendCompletedWaitCallback(object? operationState) OnSendCompleted((AsyncCompletedEventArgs)operationState!); } + [UnsupportedOSPlatform("browser")] public void Send(string from, string recipients, string? subject, string? body) { if (_disposed) @@ -424,6 +443,7 @@ public void Send(string from, string recipients, string? subject, string? body) Send(mailMessage); } + [UnsupportedOSPlatform("browser")] public void Send(MailMessage message) { if (_disposed) @@ -567,6 +587,7 @@ e is AuthenticationException || } } + [UnsupportedOSPlatform("browser")] public void SendAsync(string from, string recipients, string? subject, string? body, object? userToken) { if (_disposed) @@ -576,6 +597,7 @@ public void SendAsync(string from, string recipients, string? subject, string? b SendAsync(new MailMessage(from, recipients, subject, body), userToken); } + [UnsupportedOSPlatform("browser")] public void SendAsync(MailMessage message, object? userToken) { if (_disposed) @@ -720,6 +742,7 @@ private bool IsSystemNetworkCredentialInCache(CredentialCache cache) return false; } + [UnsupportedOSPlatform("browser")] public void SendAsyncCancel() { if (_disposed) @@ -738,23 +761,27 @@ public void SendAsyncCancel() //************* Task-based async public methods ************************* + [UnsupportedOSPlatform("browser")] public Task SendMailAsync(string from, string recipients, string? subject, string? body) { var message = new MailMessage(from, recipients, subject, body); return SendMailAsync(message, cancellationToken: default); } + [UnsupportedOSPlatform("browser")] public Task SendMailAsync(MailMessage message) { return SendMailAsync(message, cancellationToken: default); } + [UnsupportedOSPlatform("browser")] public Task SendMailAsync(string from, string recipients, string? subject, string? body, CancellationToken cancellationToken) { var message = new MailMessage(from, recipients, subject, body); return SendMailAsync(message, cancellationToken); } + [UnsupportedOSPlatform("browser")] public Task SendMailAsync(MailMessage message, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) @@ -1019,12 +1046,14 @@ private void GetConnection() private void Abort() => _transport.Abort(); + [UnsupportedOSPlatform("browser")] public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } + [UnsupportedOSPlatform("browser")] protected virtual void Dispose(bool disposing) { if (disposing && !_disposed) From 26df263cb9a21462e8704f981be27ec5c72d3151 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Wed, 7 Oct 2020 05:19:44 +0200 Subject: [PATCH 09/16] Remove unnecessary Unsupported attribute at the method level --- .../System.Net.Mail/ref/System.Net.Mail.cs | 28 ------------------- .../src/System/Net/Mail/SmtpClient.Browser.cs | 4 --- .../src/System/Net/Mail/SmtpClient.cs | 5 ---- 3 files changed, 37 deletions(-) diff --git a/src/libraries/System.Net.Mail/ref/System.Net.Mail.cs b/src/libraries/System.Net.Mail/ref/System.Net.Mail.cs index 63576c2e76b4f..5826634dd14a9 100644 --- a/src/libraries/System.Net.Mail/ref/System.Net.Mail.cs +++ b/src/libraries/System.Net.Mail/ref/System.Net.Mail.cs @@ -168,62 +168,34 @@ public enum MailPriority [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public partial class SmtpClient : System.IDisposable { - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public SmtpClient() { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public SmtpClient(string? host) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public SmtpClient(string? host, int port) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.Security.Cryptography.X509Certificates.X509CertificateCollection ClientCertificates { get { throw null; } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.Net.ICredentialsByHost? Credentials { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.Net.Mail.SmtpDeliveryFormat DeliveryFormat { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.Net.Mail.SmtpDeliveryMethod DeliveryMethod { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public bool EnableSsl { get { throw null; } set { } } [System.Diagnostics.CodeAnalysis.DisallowNullAttribute] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public string? Host { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public string? PickupDirectoryLocation { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public int Port { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.Net.ServicePoint ServicePoint { get { throw null; } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public string? TargetName { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public int Timeout { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public bool UseDefaultCredentials { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public event System.Net.Mail.SendCompletedEventHandler? SendCompleted { add { } remove { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public void Dispose() { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] protected virtual void Dispose(bool disposing) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] protected void OnSendCompleted(System.ComponentModel.AsyncCompletedEventArgs e) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public void Send(System.Net.Mail.MailMessage message) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public void Send(string from, string recipients, string? subject, string? body) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public void SendAsync(System.Net.Mail.MailMessage message, object? userToken) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public void SendAsync(string from, string recipients, string? subject, string? body, object? userToken) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public void SendAsyncCancel() { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.Threading.Tasks.Task SendMailAsync(System.Net.Mail.MailMessage message) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.Threading.Tasks.Task SendMailAsync(string from, string recipients, string? subject, string? body) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.Threading.Tasks.Task SendMailAsync(System.Net.Mail.MailMessage message, System.Threading.CancellationToken cancellationToken) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.Threading.Tasks.Task SendMailAsync(string from, string recipients, string? subject, string? body, System.Threading.CancellationToken cancellationToken) { throw null; } } public enum SmtpDeliveryFormat diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs index 05e3e2a274675..0bd9e7e67042e 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs @@ -30,22 +30,18 @@ public enum SmtpDeliveryFormat public class SmtpClient : IDisposable { #pragma warning disable CS0067 // Field is not used - [UnsupportedOSPlatform("browser")] public event SendCompletedEventHandler? SendCompleted; #pragma warning restore CS0067 - [UnsupportedOSPlatform("browser")] public SmtpClient() { Initialize(); } - [UnsupportedOSPlatform("browser")] public SmtpClient(string? host) { Initialize(); } - [UnsupportedOSPlatform("browser")] public SmtpClient(string? host, int port) { Initialize(); diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs index 3640c49fd53f3..b81b84d0e5c0e 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs @@ -62,26 +62,21 @@ public class SmtpClient : IDisposable private SmtpFailedRecipientException? _failedRecipientException; // ports above this limit are invalid private const int MaxPortValue = 65535; - [UnsupportedOSPlatform("browser")] - public event SendCompletedEventHandler? SendCompleted; private bool _useDefaultCredentials; private ICredentialsByHost? _customCredentials; - [UnsupportedOSPlatform("browser")] public SmtpClient() { Initialize(); } - [UnsupportedOSPlatform("browser")] public SmtpClient(string? host) { _host = host; Initialize(); } - [UnsupportedOSPlatform("browser")] public SmtpClient(string? host, int port) { try From 528bf7da6b6beed8c7647588d1b56bdb9fdb9422 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Wed, 7 Oct 2020 05:46:18 +0200 Subject: [PATCH 10/16] Remove unnecessary Unsupported attribute at the method level --- .../src/System/Net/Mail/SmtpClient.Browser.cs | 25 ------------------- .../src/System/Net/Mail/SmtpClient.cs | 24 ------------------ 2 files changed, 49 deletions(-) diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs index 0bd9e7e67042e..9a9485a7ad0ca 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs @@ -52,62 +52,53 @@ private void Initialize() throw new PlatformNotSupportedException(); } - [UnsupportedOSPlatform("browser")] public string? Host { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } - [UnsupportedOSPlatform("browser")] public int Port { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } - [UnsupportedOSPlatform("browser")] public bool UseDefaultCredentials { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } - [UnsupportedOSPlatform("browser")] public ICredentialsByHost? Credentials { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } - [UnsupportedOSPlatform("browser")] public int Timeout { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } - [UnsupportedOSPlatform("browser")] public ServicePoint ServicePoint { get => throw new PlatformNotSupportedException(); } - [UnsupportedOSPlatform("browser")] public SmtpDeliveryMethod DeliveryMethod { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } - [UnsupportedOSPlatform("browser")] public SmtpDeliveryFormat DeliveryFormat { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } - [UnsupportedOSPlatform("browser")] public string? PickupDirectoryLocation { get => throw new PlatformNotSupportedException(); @@ -117,7 +108,6 @@ public string? PickupDirectoryLocation /// /// Set to true if we need SSL /// - [UnsupportedOSPlatform("browser")] public bool EnableSsl { get => throw new PlatformNotSupportedException(); @@ -127,58 +117,43 @@ public bool EnableSsl /// /// Certificates used by the client for establishing an SSL connection with the server. /// - [UnsupportedOSPlatform("browser")] public X509CertificateCollection ClientCertificates => throw new PlatformNotSupportedException(); - [UnsupportedOSPlatform("browser")] public string? TargetName { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } - [UnsupportedOSPlatform("browser")] private bool ServerSupportsEai => throw new PlatformNotSupportedException(); - [UnsupportedOSPlatform("browser")] public void Send(string from, string recipients, string? subject, string? body) => throw new PlatformNotSupportedException(); - [UnsupportedOSPlatform("browser")] public void Send(MailMessage message) => throw new PlatformNotSupportedException(); - [UnsupportedOSPlatform("browser")] public void SendAsync(string from, string recipients, string? subject, string? body, object? userToken) => throw new PlatformNotSupportedException(); - [UnsupportedOSPlatform("browser")] public void SendAsync(MailMessage message, object? userToken) => throw new PlatformNotSupportedException(); - [UnsupportedOSPlatform("browser")] public void SendAsyncCancel() => throw new PlatformNotSupportedException(); //************* Task-based async public methods ************************* - [UnsupportedOSPlatform("browser")] public Task SendMailAsync(string from, string recipients, string? subject, string? body) => throw new PlatformNotSupportedException(); - [UnsupportedOSPlatform("browser")] public Task SendMailAsync(MailMessage message) => throw new PlatformNotSupportedException(); - [UnsupportedOSPlatform("browser")] public Task SendMailAsync(string from, string recipients, string? subject, string? body, CancellationToken cancellationToken) => throw new PlatformNotSupportedException(); - [UnsupportedOSPlatform("browser")] public Task SendMailAsync(MailMessage message, CancellationToken cancellationToken) => throw new PlatformNotSupportedException(); - [UnsupportedOSPlatform("browser")] protected void OnSendCompleted(AsyncCompletedEventArgs e) => throw new PlatformNotSupportedException(); - [UnsupportedOSPlatform("browser")] public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } - [UnsupportedOSPlatform("browser")] protected virtual void Dispose(bool disposing) { } } diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs index b81b84d0e5c0e..cceff5d15fa1e 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs @@ -155,7 +155,6 @@ private void Initialize() } [DisallowNull] - [UnsupportedOSPlatform("browser")] public string? Host { get @@ -189,7 +188,6 @@ public string? Host } } - [UnsupportedOSPlatform("browser")] public int Port { get @@ -216,7 +214,6 @@ public int Port } } - [UnsupportedOSPlatform("browser")] public bool UseDefaultCredentials { get @@ -235,7 +232,6 @@ public bool UseDefaultCredentials } } - [UnsupportedOSPlatform("browser")] public ICredentialsByHost? Credentials { get @@ -259,7 +255,6 @@ private void UpdateTransportCredentials() _transport.Credentials = _useDefaultCredentials ? CredentialCache.DefaultNetworkCredentials : _customCredentials; } - [UnsupportedOSPlatform("browser")] public int Timeout { get @@ -282,7 +277,6 @@ public int Timeout } } - [UnsupportedOSPlatform("browser")] public ServicePoint ServicePoint { get @@ -301,7 +295,6 @@ public ServicePoint ServicePoint } } - [UnsupportedOSPlatform("browser")] public SmtpDeliveryMethod DeliveryMethod { get @@ -314,7 +307,6 @@ public SmtpDeliveryMethod DeliveryMethod } } - [UnsupportedOSPlatform("browser")] public SmtpDeliveryFormat DeliveryFormat { get @@ -327,7 +319,6 @@ public SmtpDeliveryFormat DeliveryFormat } } - [UnsupportedOSPlatform("browser")] public string? PickupDirectoryLocation { get @@ -343,7 +334,6 @@ public string? PickupDirectoryLocation /// /// Set to true if we need SSL /// - [UnsupportedOSPlatform("browser")] public bool EnableSsl { get @@ -359,7 +349,6 @@ public bool EnableSsl /// /// Certificates used by the client for establishing an SSL connection with the server. /// - [UnsupportedOSPlatform("browser")] public X509CertificateCollection ClientCertificates { get @@ -368,7 +357,6 @@ public X509CertificateCollection ClientCertificates } } - [UnsupportedOSPlatform("browser")] public string? TargetName { get { return _targetName; } @@ -415,7 +403,6 @@ internal MailWriter GetFileMailWriter(string? pickupDirectory) return new MailWriter(fileStream, encodeForTransport: false); } - [UnsupportedOSPlatform("browser")] protected void OnSendCompleted(AsyncCompletedEventArgs e) { SendCompleted?.Invoke(this, e); @@ -426,7 +413,6 @@ private void SendCompletedWaitCallback(object? operationState) OnSendCompleted((AsyncCompletedEventArgs)operationState!); } - [UnsupportedOSPlatform("browser")] public void Send(string from, string recipients, string? subject, string? body) { if (_disposed) @@ -438,7 +424,6 @@ public void Send(string from, string recipients, string? subject, string? body) Send(mailMessage); } - [UnsupportedOSPlatform("browser")] public void Send(MailMessage message) { if (_disposed) @@ -582,7 +567,6 @@ e is AuthenticationException || } } - [UnsupportedOSPlatform("browser")] public void SendAsync(string from, string recipients, string? subject, string? body, object? userToken) { if (_disposed) @@ -592,7 +576,6 @@ public void SendAsync(string from, string recipients, string? subject, string? b SendAsync(new MailMessage(from, recipients, subject, body), userToken); } - [UnsupportedOSPlatform("browser")] public void SendAsync(MailMessage message, object? userToken) { if (_disposed) @@ -737,7 +720,6 @@ private bool IsSystemNetworkCredentialInCache(CredentialCache cache) return false; } - [UnsupportedOSPlatform("browser")] public void SendAsyncCancel() { if (_disposed) @@ -756,27 +738,23 @@ public void SendAsyncCancel() //************* Task-based async public methods ************************* - [UnsupportedOSPlatform("browser")] public Task SendMailAsync(string from, string recipients, string? subject, string? body) { var message = new MailMessage(from, recipients, subject, body); return SendMailAsync(message, cancellationToken: default); } - [UnsupportedOSPlatform("browser")] public Task SendMailAsync(MailMessage message) { return SendMailAsync(message, cancellationToken: default); } - [UnsupportedOSPlatform("browser")] public Task SendMailAsync(string from, string recipients, string? subject, string? body, CancellationToken cancellationToken) { var message = new MailMessage(from, recipients, subject, body); return SendMailAsync(message, cancellationToken); } - [UnsupportedOSPlatform("browser")] public Task SendMailAsync(MailMessage message, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) @@ -1041,14 +1019,12 @@ private void GetConnection() private void Abort() => _transport.Abort(); - [UnsupportedOSPlatform("browser")] public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } - [UnsupportedOSPlatform("browser")] protected virtual void Dispose(bool disposing) { if (disposing && !_disposed) From 7e532dbd057f79a5bccd47fb082e590448bf9b5a Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Wed, 7 Oct 2020 14:43:02 +0200 Subject: [PATCH 11/16] Modify message on skipped test. --- src/libraries/System.Net.Mail/src/System.Net.Mail.csproj | 2 +- .../System.Net.Mail/tests/Functional/MailMessageTest.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj index c1df92d987cba..cad02d8a38a7f 100644 --- a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj +++ b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj @@ -46,7 +46,6 @@ - @@ -97,6 +96,7 @@ + diff --git a/src/libraries/System.Net.Mail/tests/Functional/MailMessageTest.cs b/src/libraries/System.Net.Mail/tests/Functional/MailMessageTest.cs index 9bbb6218ec8fa..1d7f0e236ef4e 100644 --- a/src/libraries/System.Net.Mail/tests/Functional/MailMessageTest.cs +++ b/src/libraries/System.Net.Mail/tests/Functional/MailMessageTest.cs @@ -146,7 +146,7 @@ public void SubjectAndEncodingTest() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] // not passing yet with Value cannot be null. + [PlatformSpecific(~TestPlatforms.Browser)] // Not passing as internal System.Net.Mail.MailWriter stripped from build public void SentSpecialLengthMailAttachment_Base64Decode_Success() { // The special length follows pattern: (3N - 1) * 0x4400 + 1 From 0e5d51f2084a1db3a64ab9fd4e13503604191a5b Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Thu, 8 Oct 2020 05:55:28 +0200 Subject: [PATCH 12/16] Address review comments and remove string resource --- src/libraries/System.Net.Mail/src/Resources/Strings.resx | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/libraries/System.Net.Mail/src/Resources/Strings.resx b/src/libraries/System.Net.Mail/src/Resources/Strings.resx index b04e8c6d8d1e2..a72e327927cce 100644 --- a/src/libraries/System.Net.Mail/src/Resources/Strings.resx +++ b/src/libraries/System.Net.Mail/src/Resources/Strings.resx @@ -334,7 +334,4 @@ IIS delivery is not supported. - - System.Net.Mail is not supported on this platform. - From aeff320f7d1040b7aca986c7d748025c13270a01 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Thu, 8 Oct 2020 05:57:10 +0200 Subject: [PATCH 13/16] Remove redundant AssemblyInfo per review comment --- src/libraries/System.Net.Mail/tests/Unit/AssemblyInfo.cs | 4 ---- .../tests/Unit/System.Net.Mail.Unit.Tests.csproj | 1 - 2 files changed, 5 deletions(-) delete mode 100644 src/libraries/System.Net.Mail/tests/Unit/AssemblyInfo.cs diff --git a/src/libraries/System.Net.Mail/tests/Unit/AssemblyInfo.cs b/src/libraries/System.Net.Mail/tests/Unit/AssemblyInfo.cs deleted file mode 100644 index fa6166bae3e4a..0000000000000 --- a/src/libraries/System.Net.Mail/tests/Unit/AssemblyInfo.cs +++ /dev/null @@ -1,4 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Xunit; diff --git a/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj b/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj index 80a2f6775dc07..9d4ade5c5e302 100644 --- a/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj +++ b/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj @@ -6,7 +6,6 @@ annotations - From ec6d9d8fc719c2691a92accde23719216c6a5f37 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Fri, 9 Oct 2020 05:53:50 +0200 Subject: [PATCH 14/16] Remove condition attribute --- .../tests/Unit/System.Net.Mail.Unit.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj b/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj index 9d4ade5c5e302..9aacdfaf22f1b 100644 --- a/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj +++ b/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj @@ -18,7 +18,7 @@ - + From 54d10688fab2f13bb5ca701843ffd673cee3c2b7 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Fri, 9 Oct 2020 05:58:59 +0200 Subject: [PATCH 15/16] Attribute is needed --- .../tests/Unit/System.Net.Mail.Unit.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj b/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj index 9aacdfaf22f1b..9d4ade5c5e302 100644 --- a/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj +++ b/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj @@ -18,7 +18,7 @@ - + From 87d1a619668119eaa74346496e8c5c797db7891f Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Fri, 9 Oct 2020 09:41:05 +0200 Subject: [PATCH 16/16] Fix build issues --- .../tests/Unit/System.Net.Mail.Unit.Tests.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj b/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj index 9d4ade5c5e302..06a2e27ed6424 100644 --- a/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj +++ b/src/libraries/System.Net.Mail/tests/Unit/System.Net.Mail.Unit.Tests.csproj @@ -164,6 +164,10 @@ Link="Common\Interop\Unix\System.Net.Security.Native\Interop.NetSecurityNative.IsNtlmInstalled.cs" /> + + - -