Skip to content

Commit 49501a1

Browse files
committed
Initialize MailFolder.FirstUnread to -1 to indicate unknown
Also improved documentation. Fixes issue #1898
1 parent b2c7f42 commit 49501a1

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

MailKit/IMailFolder.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,16 +290,19 @@ public interface IMailFolder : IEnumerable<MimeMessage>
290290
/// <para>Gets the size of the folder in bytes.</para>
291291
/// <note type="note">If the value is not set, then the size is unspecified.</note>
292292
/// </remarks>
293-
/// <value>The size.</value>
293+
/// <value>The size of the folder, in bytes.</value>
294294
ulong? Size { get; }
295295

296296
/// <summary>
297297
/// Get the index of the first unread message in the folder.
298298
/// </summary>
299299
/// <remarks>
300-
/// This value will only be set after the folder has been opened.
300+
/// <para>Gets the index of the first unread message in the folder.</para>
301+
/// <note type="note"><para>This value will only be set after the folder has been opened.</para>
302+
/// <para>A value of <c>-1</c> indicates that there are no unread messages in the folder or that the server
303+
/// has not provided the index of the first unread message.</para></note>
301304
/// </remarks>
302-
/// <value>The index of the first unread message.</value>
305+
/// <value>The index of the first unread message or <c>-1</c> if there are no unread messages in the folder.</value>
303306
int FirstUnread { get; }
304307

305308
/// <summary>
@@ -343,7 +346,7 @@ public interface IMailFolder : IEnumerable<MimeMessage>
343346
/// Get the threading algorithms supported by the folder.
344347
/// </summary>
345348
/// <remarks>
346-
/// Get the threading algorithms supported by the folder.
349+
/// Gets the threading algorithms supported by the folder.
347350
/// </remarks>
348351
/// <value>The supported threading algorithms.</value>
349352
HashSet<ThreadingAlgorithm> ThreadingAlgorithms { get; }

MailKit/MailFolder.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public abstract class MailFolder : IMailFolder
6969
/// </remarks>
7070
protected MailFolder ()
7171
{
72+
FirstUnread = -1;
7273
}
7374

7475
/// <summary>
@@ -373,7 +374,7 @@ public uint? AppendLimit {
373374
/// <para>Gets the size of the folder in bytes.</para>
374375
/// <note type="note">If the value is not set, then the size is unspecified.</note>
375376
/// </remarks>
376-
/// <value>The size.</value>
377+
/// <value>The size of the folder, in bytes.</value>
377378
public ulong? Size {
378379
get; protected set;
379380
}
@@ -382,9 +383,12 @@ public ulong? Size {
382383
/// Get the index of the first unread message in the folder.
383384
/// </summary>
384385
/// <remarks>
385-
/// This value will only be set after the folder has been opened.
386+
/// <para>Gets the index of the first unread message in the folder.</para>
387+
/// <note type="note"><para>This value will only be set after the folder has been opened.</para>
388+
/// <para>A value of <c>-1</c> indicates that there are no unread messages in the folder or that the server
389+
/// has not provided the index of the first unread message.</para></note>
386390
/// </remarks>
387-
/// <value>The index of the first unread message.</value>
391+
/// <value>The index of the first unread message or <c>-1</c> if there are no unread messages in the folder.</value>
388392
public int FirstUnread {
389393
get; protected set;
390394
}
@@ -404,15 +408,15 @@ public int Unread {
404408
}
405409

406410
/// <summary>
407-
/// Get the number of recently added messages in the folder.
411+
/// Get the number of recently delivered messages in the folder.
408412
/// </summary>
409413
/// <remarks>
410414
/// <para>Gets the number of recently delivered messages in the folder.</para>
411415
/// <note type="note">This value will only be set after calling
412416
/// <see cref="Status(StatusItems, System.Threading.CancellationToken)"/>
413417
/// with <see cref="StatusItems.Recent"/> or by opening the folder.</note>
414418
/// </remarks>
415-
/// <value>The number of recently added messages.</value>
419+
/// <value>The number of recently delivered messages.</value>
416420
public int Recent {
417421
get; protected set;
418422
}
@@ -438,7 +442,7 @@ public int Count {
438442
/// Get the threading algorithms supported by the folder.
439443
/// </summary>
440444
/// <remarks>
441-
/// Get the threading algorithms supported by the folder.
445+
/// Gets the threading algorithms supported by the folder.
442446
/// </remarks>
443447
/// <value>The supported threading algorithms.</value>
444448
public abstract HashSet<ThreadingAlgorithm> ThreadingAlgorithms { get; }
@@ -9377,6 +9381,7 @@ internal protected virtual void OnClosed ()
93779381
PermanentFlags = MessageFlags.None;
93789382
AcceptedFlags = MessageFlags.None;
93799383
Access = FolderAccess.None;
9384+
FirstUnread = -1;
93809385

93819386
AnnotationAccess = AnnotationAccess.None;
93829387
AnnotationScopes = AnnotationScope.None;

0 commit comments

Comments
 (0)