Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/OpenNetty/OpenNettyAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public OpenNettyAddress(OpenNettyAddressType type, string value, ImmutableArray<
/// <summary>
/// Gets the additional parameters associated with the address, if applicable.
/// </summary>
public ImmutableArray<string> Parameters { get; }
public ImmutableArray<string> Parameters { get; } = [];

/// <summary>
/// Gets the type associated with the address.
Expand Down
2 changes: 1 addition & 1 deletion src/OpenNetty/OpenNettyCategory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public OpenNettyCategory(string value, ImmutableArray<string> parameters)
/// <summary>
/// Gets the additional parameters associated with the category, if applicable.
/// </summary>
public ImmutableArray<string> Parameters { get; }
public ImmutableArray<string> Parameters { get; } = [];

/// <inheritdoc/>
public bool Equals(OpenNettyCategory other)
Expand Down
2 changes: 1 addition & 1 deletion src/OpenNetty/OpenNettyCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public OpenNettyCommand(OpenNettyCategory category, string value, ImmutableArray
/// <summary>
/// Gets the additional parameters associated with the command, if applicable.
/// </summary>
public ImmutableArray<string> Parameters { get; }
public ImmutableArray<string> Parameters { get; } = [];

/// <inheritdoc/>
public bool Equals(OpenNettyCommand other)
Expand Down
6 changes: 3 additions & 3 deletions src/OpenNetty/OpenNettyCoordinator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ await _events.PublishAsync(new SwitchStateReportedEventArgs(endpoint,
// imprecise results that are inconsistent with the brightness level retrieved using a
// "DIMMER LEVEL SPEED" or "DIMMER STATUS" DIMENSION REQUEST frame (e.g when setting the
// brightness to 30%, a F418U2 SCS dimmer correctly reports the "130" value when using
// a DIMENSION REQUEST but returns "5" (50%) when using a STATUS REQUEST. To avoid that,
// a DIMENSION REQUEST but returns "5" (50%) when using a STATUS REQUEST). To avoid that,
// a specialized event handler is responsible for monitoring ON% BUS COMMAND frames and
// retrieving the exact brightness level using a "DIMMER LEVEL SPEED" DIMENSION REQUEST.
if (endpoint.HasCapability(OpenNettyCapabilities.BasicDimmingState) &&
Expand Down Expand Up @@ -1550,7 +1550,7 @@ await _events.PublishAsync(new SwitchStateReportedEventArgs(endpoint,
// results that are inconsistent with the brightness level retrieved using a "DIMMER LEVEL SPEED"
// or "DIMMER STATUS" DIMENSION REQUEST frame (e.g when setting the brightness to 30%, a F418U2 SCS
// dimmer correctly reports the "130" value when using a DIMENSION REQUEST but returns "5" (50%)
// when using a STATUS REQUEST. To avoid that, this event handler monitors all the ON% BUS COMMAND
// when using a STATUS REQUEST). To avoid that, this event handler monitors all the ON% BUS COMMAND
// frames and retrieves the exact brightness level using a "DIMMER LEVEL SPEED" DIMENSION REQUEST.
OpenNettyNotifications.MessageReceived {
Session.Type: OpenNettySessionType.Event,
Expand All @@ -1570,7 +1570,7 @@ await _events.PublishAsync(new SwitchStateReportedEventArgs(endpoint,
command == OpenNettyCommands.Lighting.On100
=> AsyncObservable.Return<(OpenNettyNotification Notification, OpenNettyMessage Message)>((notification, message)),

// Note: some Nitoo devices (like the 067210, 067212 and 067214 dimmers) offer preset buttons that allow
// Note: some Nitoo devices (like the 67210, 67212 and 67214 dimmers) offer preset buttons that allow
// setting the brightness to a fixed value configured by the user directly on the device. When pressed,
// the dimmer moves to the specified level and emits a SCENARIO ACTION frame but doesn't specify the
// actual value, that must be retrieved separately using a DIMENSION REQUEST to determine the exact level.
Expand Down
2 changes: 1 addition & 1 deletion src/OpenNetty/OpenNettyDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public sealed class OpenNettyDevice : IEquatable<OpenNettyDevice>
/// <summary>
/// Gets or sets the units associated with the device, if applicable.
/// </summary>
public ImmutableArray<OpenNettyUnit> Units { get; init; }
public ImmutableArray<OpenNettyUnit> Units { get; init; } = [];

/// <summary>
/// Resolves the specified boolean setting from the settings.
Expand Down
2 changes: 1 addition & 1 deletion src/OpenNetty/OpenNettyDimension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public OpenNettyDimension(OpenNettyCategory category, string value, ImmutableArr
/// <summary>
/// Gets the additional parameters associated with the dimension, if applicable.
/// </summary>
public ImmutableArray<string> Parameters { get; }
public ImmutableArray<string> Parameters { get; } = [];

/// <inheritdoc/>
public bool Equals(OpenNettyDimension other)
Expand Down
2 changes: 1 addition & 1 deletion src/OpenNetty/OpenNettyField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public OpenNettyField(params IEnumerable<OpenNettyParameter> parameters)
/// <summary>
/// Gets the raw parameters included in the field.
/// </summary>
public ImmutableArray<OpenNettyParameter> Parameters { get; }
public ImmutableArray<OpenNettyParameter> Parameters { get; } = [];

/// <summary>
/// Represents an empty field.
Expand Down
2 changes: 1 addition & 1 deletion src/OpenNetty/OpenNettyFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public OpenNettyFrame(params IEnumerable<OpenNettyField> fields)
/// <summary>
/// Gets the raw fields included in the current frame.
/// </summary>
public ImmutableArray<OpenNettyField> Fields { get; }
public ImmutableArray<OpenNettyField> Fields { get; } = [];

/// <summary>
/// Parses an OpenNetty frame from the specified <paramref name="value"/>.
Expand Down
2 changes: 1 addition & 1 deletion src/OpenNetty/OpenNettyModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ public sealed record class UnitDescription
/// <summary>
/// Gets or sets the values.
/// </summary>
public ImmutableArray<string> Values { get; init; }
public ImmutableArray<string> Values { get; init; } = [];

/// <summary>
/// Creates a new instance of the <see cref="UnitDescription"/> class using the specified unit description.
Expand Down
14 changes: 7 additions & 7 deletions src/OpenNetty/OpenNettySession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,18 @@ public async ValueTask SendAsync(
throw new InvalidOperationException(SR.GetResourceString(SR.ID0010));
}

var address = message.Address;

if (options.HasFlag(OpenNettyTransmissionOptions.RequireActionValidation))
{
if (message.Protocol is not OpenNettyProtocol.Nitoo)
{
throw new InvalidOperationException(SR.GetResourceString(SR.ID0011));
}

if (message.Address is null)
{
throw new InvalidOperationException(SR.GetResourceString(SR.ID0014));
}

if (message.Type is not (OpenNettyMessageType.BusCommand or OpenNettyMessageType.DimensionSet))
{
throw new InvalidOperationException(SR.GetResourceString(SR.ID0012));
Expand All @@ -165,11 +168,6 @@ public async ValueTask SendAsync(
{
throw new InvalidOperationException(SR.GetResourceString(SR.ID0013));
}

if (address is null)
{
throw new InvalidOperationException(SR.GetResourceString(SR.ID0014));
}
}

if (!await _semaphore.WaitAsync(TimeSpan.Zero, cancellationToken))
Expand All @@ -179,6 +177,8 @@ public async ValueTask SendAsync(

try
{
var address = message.Address;

var messages = _observable.ObserveOn(TaskPoolAsyncScheduler.Default)
.Where(message => message switch
{
Expand Down
Loading