Background and motivation
Hi there folks.
We have repeated one condition 2 times, first in the constructor then in the body of set accessor.
the constructor wants a value for capacity , and then we can override that in the object initialization.

API Proposal
public sealed class BoundedChannelOptions : ChannelOptions
{
/// <summary>The behavior incurred by write operations when the channel is full.</summary>
private BoundedChannelFullMode _mode = BoundedChannelFullMode.Wait;
/// <summary>Initializes the options.</summary>
/// <param name="capacity">The maximum number of items the bounded channel may store.</param>
public BoundedChannelOptions(int capacity)
{
if (capacity < 1)
{
throw new ArgumentOutOfRangeException(nameof(capacity));
}
Capacity = capacity;
}
/// <summary>Gets or sets the maximum number of items the bounded channel may store.</summary>
public int Capacity { get; }
/// <summary>Gets or sets the behavior incurred by write operations when the channel is full.</summary>
public BoundedChannelFullMode FullMode
{
get => _mode;
set
{
switch (value)
{
case BoundedChannelFullMode.Wait:
case BoundedChannelFullMode.DropNewest:
case BoundedChannelFullMode.DropOldest:
case BoundedChannelFullMode.DropWrite:
_mode = value;
break;
default:
throw new ArgumentOutOfRangeException(nameof(value));
}
}
}
}
API Usage
We won't have capacity property in object initialization

Alternative Designs
No response
Risks
No response
Background and motivation
Hi there folks.
We have repeated one condition 2 times, first in the constructor then in the body of set accessor.
runtime/src/libraries/System.Threading.Channels/src/System/Threading/Channels/ChannelOptions.cs
Line 54 in 57bfe47
runtime/src/libraries/System.Threading.Channels/src/System/Threading/Channels/ChannelOptions.cs
Line 68 in 57bfe47
the constructor wants a value for capacity , and then we can override that in the object initialization.

API Proposal
API Usage
We won't have capacity property in object initialization

Alternative Designs
No response
Risks
No response