2.0alpha1-netstandard2.0_vs_2.0alpha2-netstandard2.0.apilist.diff
--- Smdn.Net.MessageAccessProtocols-2.0alpha1-netstandard2.0.apilist.cs	2019-03-23 14:49:39.000000000 +0900
+++ Smdn.Net.MessageAccessProtocols-2.0alpha2-netstandard2.0.apilist.cs	2019-03-23 14:49:41.000000000 +0900
@@ -1,219 +1,233 @@
-// Smdn.Net.MessageAccessProtocols-2.0alpha1 (netstandard2.0)
+// Smdn.Net.MessageAccessProtocols-2.0alpha2 (netstandard2.0)
 //   Name: Smdn.Net.MessageAccessProtocols
 //   TargetFramework: .NETStandard,Version=v2.0
 //   AssemblyVersion: 2.0.0.0
-//   InformationalVersion: 2.0alpha1 (netstandard2.0)
+//   InformationalVersion: 2.0alpha2 (netstandard2.0)
 
 using System;
 using System.Collections;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.IO;
 using System.Net;
 using System.Net.Security;
-using System.Net.Sockets;
 using System.Security.Authentication;
 using System.Security.Cryptography.X509Certificates;
+using System.Threading;
+using System.Threading.Tasks;
 using Smdn.IO.Streams.LineOriented;
 using Smdn.Net.Connection;
-using Smdn.Net.MessageAccessProtocols;
 using Smdn.Net.MessageAccessProtocols.Diagnostics;
+using Smdn.Net.MessageAccessProtocols.Strings;
 
 namespace Smdn.IO.Streams {
   public class InterruptStream : Stream {
     public InterruptStream(Stream innerStream) {}
 
     public override bool CanRead { get; }
     public override bool CanSeek { get; }
     public override bool CanTimeout { get; }
     public override bool CanWrite { get; }
     public Stream InnerStream { get; }
     public override long Length { get; }
     public override long Position { get; set; }
 
     public override void Close() {}
     public override void Flush() {}
     protected virtual int OnRead(byte[] buffer, int offset, int count) {}
     protected virtual void OnReading(byte[] buffer, int offset, int count, out bool abortRead) {}
     protected virtual void OnWriting(byte[] buffer, int offset, int count, out bool abortWrite) {}
     protected virtual void OnWritten(byte[] buffer, int offset, int count) {}
     public override int Read(byte[] buffer, int offset, int count) {}
     public override long Seek(long offset, SeekOrigin origin) {}
     public override void SetLength(long @value) {}
     public override void Write(byte[] buffer, int offset, int count) {}
   }
 }
 
 namespace Smdn.IO.Streams.LineOriented {
   public sealed class LineOrientedBufferedStream : StrictLineOrientedStream {
     public LineOrientedBufferedStream(Stream stream) {}
 
     public override bool CanSeek { get; }
     public override long Length { get; }
     public override long Position { get; set; }
 
     protected override void Dispose(bool disposing) {}
     public override void Flush() {}
     public override long Seek(long offset, SeekOrigin origin) {}
     public override void SetLength(long @value) {}
     public override void Write(byte[] src, int offset, int count) {}
     public void Write(Stream sourceStream) {}
     public void WriteToCrLf(byte[] src) {}
   }
 }
 
 namespace Smdn.Net {
   public static class ICredentialsByHostExtensions {
-    public static NetworkCredential LookupCredential(this ICredentialsByHost credentials, IConnectionInfo connection, string username, IStringEnum authenticationMechanism) {}
+    public static NetworkCredential LookupCredential(this ICredentialsByHost credentials, IConnectionInfo connection, string username, string authenticationMechanism) {}
     public static NetworkCredential LookupCredential(this ICredentialsByHost credentials, string host, int port, string username, string authenticationMechanism) {}
   }
 }
 
 namespace Smdn.Net.Connection {
-  public delegate Stream UpgradeConnectionStreamCallback(ConnectionBase connection, Stream baseStream);
+  public delegate Task<IPAddress> ResolveHostAddressCallback(string hostname, CancellationToken cancellationToken);
+  public delegate Task<Stream> UpgradeConnectionStreamCallback(ConnectionBase connection, Stream baseStream, CancellationToken cancellationToken);
 
   public interface IConnectionInfo {
     string Host { get; }
     int Port { get; }
   }
 
   public abstract class ConnectionBase :
     IConnectionInfo,
     IDisposable
   {
-    protected ConnectionBase(TraceSource traceSource) {}
+    protected ConnectionBase() {}
 
     public string Host { get; }
     public int Id { get; }
     public bool IsConnected { get; }
-    public bool IsSecureConnection { get; protected set; }
+    public bool IsSecureConnection { get; }
     public bool IsSecurePortConnection { get; }
     public IPEndPoint LocalEndPoint { get; }
     public int Port { get; }
-    protected virtual Stream RawStream { get; }
     public int ReceiveTimeout { get; set; }
     public IPEndPoint RemoteEndPoint { get; }
     public int SendTimeout { get; set; }
-    protected Socket Socket { get; }
     public static SslProtocols SslProtocolsDefault { get; }
-    protected LineOrientedBufferedStream Stream { get; }
+    protected Stream Stream { get; }
+    internal protected virtual TraceSource TraceSource { get; }
 
-    protected void CheckConnected() {}
     public void Close() {}
-    protected virtual void Connect(string host, int port, int millisecondsTimeout, UpgradeConnectionStreamCallback createAuthenticatedStream) {}
-    protected virtual LineOrientedBufferedStream CreateBufferedStream(Stream stream) {}
-    public static Stream CreateClientSslStream(ConnectionBase connection, Stream baseStream, X509Certificate2Collection clientCertificates, SslProtocols enabledSslProtocols, RemoteCertificateValidationCallback serverCertificateValidationCallback, LocalCertificateSelectionCallback clientCertificateSelectionCallback) {}
-    protected abstract Exception CreateConnectException(string message, Exception innerException);
-    protected abstract Exception CreateUpgradeStreamException(string message, Exception innerException);
+    public void Connect(string hostname, int port, ResolveHostAddressCallback resolveHostAddress = null, UpgradeConnectionStreamCallback createAuthenticatedStream = null, CancellationToken cancellationToken = default) {}
+    public Task ConnectAsync(string hostname, int port, ResolveHostAddressCallback resolveHostAddress = null, UpgradeConnectionStreamCallback createAuthenticatedStream = null, CancellationToken cancellationToken = default) {}
+    public static Task<Stream> CreateClientSslStreamAsync(ConnectionBase connection, Stream baseStream, X509Certificate2Collection clientCertificates, SslProtocols enabledSslProtocols, RemoteCertificateValidationCallback serverCertificateValidationCallback, LocalCertificateSelectionCallback clientCertificateSelectionCallback, CancellationToken cancellationToken) {}
+    protected virtual Exception CreateConnectException(string message, Exception baseException) {}
+    protected virtual Exception CreateUpgradeConnectionException(string message, Exception baseException) {}
+    protected virtual Exception CreateUpgradeToSecureConnectionException(string message, Exception baseException) {}
     protected virtual void Dispose(bool disposing) {}
     ~ConnectionBase() {}
+    protected virtual int GetDefaultPort(bool asSecurePortConnection) {}
+    protected virtual void OnConnectionStreamChanged(Stream stream) {}
     void IDisposable.Dispose() {}
+    protected void ThrowIfNotConnected() {}
     public override string ToString() {}
-    public virtual void UpgradeStream(UpgradeConnectionStreamCallback upgradeStream) {}
-  }
-}
-
-namespace Smdn.Net.MessageAccessProtocols {
-  public interface IReadOnlyStringSet<TStringEnum> : IReadOnlyCollection<TStringEnum> where TStringEnum : IStringEnum {
-    bool Contains(TStringEnum item);
-    bool Contains(string item);
-    bool IsProperSubsetOf(IEnumerable<TStringEnum> other);
-    bool IsProperSupersetOf(IEnumerable<TStringEnum> other);
-    bool IsSubsetOf(IEnumerable<TStringEnum> other);
-    bool IsSupersetOf(IEnumerable<TStringEnum> other);
-    bool Overlaps(IEnumerable<TStringEnum> other);
-    bool SetEquals(IEnumerable<TStringEnum> other);
-    bool TryGetValue(string @value, out TStringEnum item);
-  }
-
-  public interface IStringEnum :
-    IEquatable<IStringEnum>,
-    IEquatable<string>
-  {
-    string Value { get; }
-  }
-
-  public class StringEnumSet<TStringEnum> :
-    IReadOnlyStringSet<TStringEnum>,
-    ISet<TStringEnum>
-    where TStringEnum : class, IStringEnum
-  {
-    public StringEnumSet() {}
-    public StringEnumSet(IEnumerable<TStringEnum> items) {}
-    public StringEnumSet(IEnumerable<TStringEnum> items, IEqualityComparer<string> comparer) {}
-    public StringEnumSet(bool isReadOnly) {}
-    public StringEnumSet(bool isReadOnly, IEnumerable<TStringEnum> items, IEqualityComparer<string> comparer) {}
-    public StringEnumSet(bool isReadOnly, IEqualityComparer<string> comparer) {}
-
-    public int Count { get; }
-    public bool IsReadOnly { get; }
-
-    public bool Add(TStringEnum item) {}
-    public void AddRange(IEnumerable<TStringEnum> items) {}
-    public void Clear() {}
-    public bool Contains(TStringEnum item) {}
-    public bool Contains(string @value) {}
-    public void CopyTo(TStringEnum[] array, int arrayIndex) {}
-    public void ExceptWith(IEnumerable<TStringEnum> other) {}
-    public IEnumerator<TStringEnum> GetEnumerator() {}
-    public void IntersectWith(IEnumerable<TStringEnum> other) {}
-    public bool IsProperSubsetOf(IEnumerable<TStringEnum> other) {}
-    public bool IsProperSupersetOf(IEnumerable<TStringEnum> other) {}
-    public bool IsSubsetOf(IEnumerable<TStringEnum> other) {}
-    public bool IsSupersetOf(IEnumerable<TStringEnum> other) {}
-    public bool Overlaps(IEnumerable<TStringEnum> other) {}
-    public bool Remove(TStringEnum item) {}
-    public int RemoveWhere(Predicate<TStringEnum> match) {}
-    public bool SetEquals(IEnumerable<TStringEnum> other) {}
-    public void SymmetricExceptWith(IEnumerable<TStringEnum> other) {}
-    void ICollection<TStringEnum>.Add(TStringEnum item) {}
-    IEnumerator IEnumerable.GetEnumerator() {}
-    public TStringEnum[] ToArray() {}
-    public override string ToString() {}
-    public string[] ToStringArray() {}
-    public bool TryGetValue(string @value, out TStringEnum item) {}
-    public void UnionWith(IEnumerable<TStringEnum> other) {}
-  }
-
-  public static class StringEnumUtils {
-    public static IEnumerable<TStringEnum> GetDefinedConstants<TStringEnum>() where TStringEnum : class, IStringEnum {}
+    public Task UpgradeConnectionAsync(UpgradeConnectionStreamCallback upgradeStream, CancellationToken cancellationToken = default) {}
+    public Task UpgradeToSecureConnectionAsync(UpgradeConnectionStreamCallback upgradeStream, CancellationToken cancellationToken = default) {}
   }
 }
 
 namespace Smdn.Net.MessageAccessProtocols.Diagnostics {
   public sealed class ExceptionTraceData : TraceDataBase {
     public Exception Exception { get; }
 
     public override string ToString() {}
   }
 
   public sealed class MessageTraceData : TraceDataBase {
     public string Message { get; }
 
     public override string ToString() {}
   }
 
   public sealed class ReceiveTraceData : TraceDataBase {
     public ArraySegment<byte> Data { get; }
     public IPEndPoint LocalEndPoint { get; }
     public IPEndPoint RemoteEndPoint { get; }
 
     public override string ToString() {}
   }
 
   public sealed class SendTraceData : TraceDataBase {
     public ArraySegment<byte> Data { get; }
     public IPEndPoint LocalEndPoint { get; }
     public IPEndPoint RemoteEndPoint { get; }
 
     public override string ToString() {}
   }
 
   public abstract class TraceDataBase {
     internal protected TraceDataBase(int connectionId) {}
 
     public int ConnectionId { get; }
     public DateTime DateTime { get; }
   }
 }
 
+namespace Smdn.Net.MessageAccessProtocols.Strings {
+  public interface IReadOnlyStringSet<TTypedString> : IReadOnlyCollection<TTypedString> {
+    bool Contains(TTypedString item);
+    bool Contains(string item);
+    bool IsProperSubsetOf(IEnumerable<TTypedString> other);
+    bool IsProperSupersetOf(IEnumerable<TTypedString> other);
+    bool IsSubsetOf(IEnumerable<TTypedString> other);
+    bool IsSupersetOf(IEnumerable<TTypedString> other);
+    bool Overlaps(IEnumerable<TTypedString> other);
+    bool SetEquals(IEnumerable<TTypedString> other);
+    bool TryGetValue(string @value, out TTypedString item);
+  }
+
+  public abstract class TypedStringEqualityComparerBase : IEqualityComparer<string> {
+    public abstract bool Equals(string x, string y);
+    public abstract int GetHashCode(string obj);
+  }
+
+  public abstract class TypedStringEqualityComparer<TTypedString> :
+    TypedStringEqualityComparerBase,
+    IEqualityComparer<TTypedString>
+  {
+    protected TypedStringEqualityComparer() {}
+
+    public bool Equals(TTypedString x, TTypedString y) {}
+    public bool Equals(TTypedString x, string y) {}
+    public int GetHashCode(TTypedString obj) {}
+    internal protected abstract string GetStringExpressionOf(TTypedString typedString);
+  }
+
+  public class TypedStringSet<TTypedString> :
+    IReadOnlyStringSet<TTypedString>,
+    ISet<TTypedString>
+  {
+    public TypedStringSet() {}
+    public TypedStringSet(IEnumerable<TTypedString> collection, TypedStringEqualityComparer<TTypedString> comparer, bool asReadOnly = false) {}
+    public TypedStringSet(IEnumerable<TTypedString> collection, bool asReadOnly = false) {}
+    public TypedStringSet(TypedStringEqualityComparer<TTypedString> comparer) {}
+    public TypedStringSet(int capacity) {}
+    public TypedStringSet(int capacity, TypedStringEqualityComparer<TTypedString> comparer) {}
+
+    public TypedStringEqualityComparer<TTypedString> Comparer { get; }
+    public int Count { get; }
+    public bool IsReadOnly { get; }
+
+    public bool Add(TTypedString item) {}
+    public void AddRange(IEnumerable<TTypedString> items) {}
+    public void Clear() {}
+    public bool Contains(TTypedString item) {}
+    public bool Contains(string @value) {}
+    public void CopyTo(TTypedString[] array, int arrayIndex) {}
+    public void ExceptWith(IEnumerable<TTypedString> other) {}
+    public IEnumerator<TTypedString> GetEnumerator() {}
+    public void IntersectWith(IEnumerable<TTypedString> other) {}
+    public bool IsProperSubsetOf(IEnumerable<TTypedString> other) {}
+    public bool IsProperSupersetOf(IEnumerable<TTypedString> other) {}
+    public bool IsSubsetOf(IEnumerable<TTypedString> other) {}
+    public bool IsSupersetOf(IEnumerable<TTypedString> other) {}
+    public bool Overlaps(IEnumerable<TTypedString> other) {}
+    public bool Remove(TTypedString item) {}
+    public int RemoveWhere(Predicate<TTypedString> match) {}
+    public bool SetEquals(IEnumerable<TTypedString> other) {}
+    public void SymmetricExceptWith(IEnumerable<TTypedString> other) {}
+    void ICollection<TTypedString>.Add(TTypedString item) {}
+    IEnumerator IEnumerable.GetEnumerator() {}
+    public TTypedString[] ToArray() {}
+    public override string ToString() {}
+    public bool TryGetValue(string @value, out TTypedString item) {}
+    public void UnionWith(IEnumerable<TTypedString> other) {}
+  }
+
+  public static class TypedStringUtils {
+    public static IEnumerable<TTypedString> GetDefinedConstants<TTypedString>() {}
+  }
+}
+