Skip to content

Commit

Permalink
minor code quality improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jstedfast committed Nov 22, 2023
1 parent 8b42b15 commit 65ec713
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion MailKit/BodyPartCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public int IndexOf (Uri uri)
if (uri == null)
throw new ArgumentNullException (nameof (uri));

bool cid = uri.IsAbsoluteUri && uri.Scheme.ToLowerInvariant () == "cid";
bool cid = uri.IsAbsoluteUri && uri.Scheme.Equals ("cid", StringComparison.OrdinalIgnoreCase);

for (int index = 0; index < Count; index++) {
if (this[index] is not BodyPartBasic bodyPart)
Expand Down
4 changes: 2 additions & 2 deletions MailKit/IMailFolderStoreExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static partial class IMailFolderExtensions
{
#region Store Flags Extensions

static IStoreFlagsRequest GetStoreFlagsRequest (StoreAction action, bool silent, MessageFlags flags, HashSet<string> keywords = null, ulong? modseq = null)
static StoreFlagsRequest GetStoreFlagsRequest (StoreAction action, bool silent, MessageFlags flags, HashSet<string> keywords = null, ulong? modseq = null)
{
if (action != StoreAction.Set && flags == MessageFlags.None && (keywords == null || keywords.Count == 0))
throw new ArgumentException ("No flags were specified.", nameof (flags));
Expand Down Expand Up @@ -3623,7 +3623,7 @@ public static Task<IList<int>> SetFlagsAsync (this IMailFolder folder, IList<int

#region Store Labels Extensions

static IStoreLabelsRequest GetStoreLabelsRequest (StoreAction action, bool silent, IList<string> labels, ulong? modseq = null)
static StoreLabelsRequest GetStoreLabelsRequest (StoreAction action, bool silent, IList<string> labels, ulong? modseq = null)
{
if (labels == null)
throw new ArgumentNullException (nameof (labels));
Expand Down
6 changes: 3 additions & 3 deletions MailKit/MessageThreader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public int Index {
public IList<string> GMailLabels => null;
}

static IDictionary<string, ThreadableNode> CreateIdTable (IEnumerable<IMessageSummary> messages)
static Dictionary<string, ThreadableNode> CreateIdTable (IEnumerable<IMessageSummary> messages)
{
var ids = new Dictionary<string, ThreadableNode> (StringComparer.OrdinalIgnoreCase);

Expand Down Expand Up @@ -350,7 +350,7 @@ static void GetThreads (ThreadableNode root, IList<MessageThread> threads, IList
}
}

static IList<MessageThread> ThreadByReferences (IEnumerable<IMessageSummary> messages, IList<OrderBy> orderBy)
static List<MessageThread> ThreadByReferences (IEnumerable<IMessageSummary> messages, IList<OrderBy> orderBy)
{
var threads = new List<MessageThread> ();
var ids = CreateIdTable (messages);
Expand All @@ -364,7 +364,7 @@ static IList<MessageThread> ThreadByReferences (IEnumerable<IMessageSummary> mes
return threads;
}

static IList<MessageThread> ThreadBySubject (IEnumerable<IMessageSummary> messages, IList<OrderBy> orderBy)
static List<MessageThread> ThreadBySubject (IEnumerable<IMessageSummary> messages, IList<OrderBy> orderBy)
{
var threads = new List<MessageThread> ();
var root = new ThreadableNode (null);
Expand Down
4 changes: 2 additions & 2 deletions MailKit/Net/Imap/ImapEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3365,7 +3365,7 @@ ImapCommand QueueGetFolderCommand (string encodedName, CancellationToken cancell
return ic;
}

ImapFolder ProcessGetFolderResponse (ImapCommand ic, string path, string encodedName, out List<ImapFolder> list)
static ImapFolder ProcessGetFolderResponse (ImapCommand ic, string path, string encodedName, out List<ImapFolder> list)
{
ImapFolder folder;

Expand Down Expand Up @@ -3536,7 +3536,7 @@ ImapCommand QueueGetFoldersCommand (FolderNamespace @namespace, StatusItems item
return ic;
}

IList<IMailFolder> ToListOfIMailFolder (List<ImapFolder> list)
static IList<IMailFolder> ToListOfIMailFolder (List<ImapFolder> list)
{
var folders = new IMailFolder[list.Count];
for (int i = 0; i < folders.Length; i++)
Expand Down
4 changes: 2 additions & 2 deletions MailKit/Net/Imap/ImapFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3338,11 +3338,11 @@ public QuotaContext ()
QuotaRoots = new List<string> ();
}

public IList<string> QuotaRoots {
public List<string> QuotaRoots {
get; private set;
}

public IDictionary<string, Quota> Quotas {
public Dictionary<string, Quota> Quotas {
get; private set;
}
}
Expand Down
2 changes: 0 additions & 2 deletions MailKit/Net/Proxy/HttpProxyClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ namespace MailKit.Net.Proxy
/// </remarks>
public class HttpProxyClient : ProxyClient
{
const int BufferSize = 4096;

/// <summary>
/// Initializes a new instance of the <see cref="T:MailKit.Net.Proxy.HttpProxyClient"/> class.
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions MailKit/Net/Proxy/Socks4Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ static async Task<IPAddress> ResolveAsync (string host, CancellationToken cancel
{
cancellationToken.ThrowIfCancellationRequested ();

#if NET6_0_OR_GREATER
var ipAddresses = await Dns.GetHostAddressesAsync (host, cancellationToken).ConfigureAwait (false);
#else
var ipAddresses = await Dns.GetHostAddressesAsync (host).ConfigureAwait (false);
#endif

return Resolve (host, ipAddresses);
}
Expand Down
4 changes: 4 additions & 0 deletions MailKit/Net/SocketUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ public static async Task<Socket> ConnectAsync (string host, int port, IPEndPoint
{
cancellationToken.ThrowIfCancellationRequested ();

#if NET6_0_OR_GREATER
var ipAddresses = await Dns.GetHostAddressesAsync (host, cancellationToken).ConfigureAwait (false);
#else
var ipAddresses = await Dns.GetHostAddressesAsync (host).ConfigureAwait (false);
#endif

for (int i = 0; i < ipAddresses.Length; i++) {
cancellationToken.ThrowIfCancellationRequested ();
Expand Down

0 comments on commit 65ec713

Please sign in to comment.