Skip to content

Commit 2890430

Browse files
committed
make IBP35SerialPortStreamFactory disposable
1 parent e6b096d commit 2890430

4 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/Smdn.Devices.BP35XX/Smdn.Devices.BP35XX/BP35A1.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ private BP35A1(
6767
)
6868
: base(
6969
serialPortName: configurations.SerialPortName,
70+
#pragma warning disable CA2000
7071
serialPortStreamFactory: serviceProvider?.GetService<IBP35SerialPortStreamFactory>() ?? new BP35A1SerialPortStreamFactory(configurations),
72+
#pragma warning restore CA2000
7173
erxudpDataFormat: SkStackERXUDPDataFormat.Binary,
7274
logger: serviceProvider?.GetService<ILoggerFactory>()?.CreateLogger<BP35A1>()
7375
)

src/Smdn.Devices.BP35XX/Smdn.Devices.BP35XX/BP35Base.SerialPortStreamFactory.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ partial class BP35Base {
1313
private protected abstract class SerialPortStreamFactory : IBP35SerialPortStreamFactory {
1414
public abstract BP35UartBaudRate BaudRate { get; }
1515

16+
public void Dispose()
17+
{
18+
// nothing to do in this class
19+
}
20+
1621
public Stream CreateSerialPortStream(string? serialPortName)
1722
{
1823
if (string.IsNullOrEmpty(serialPortName)) {
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
// SPDX-FileCopyrightText: 2024 smdn <smdn@smdn.jp>
22
// SPDX-License-Identifier: MIT
3+
using System;
34
using System.IO;
45

56
namespace Smdn.Devices.BP35XX;
67

7-
public interface IBP35SerialPortStreamFactory {
8+
public interface IBP35SerialPortStreamFactory : IDisposable {
89
Stream CreateSerialPortStream(string? serialPortName);
910
}

tests/Smdn.Devices.BP35XX/Smdn.Devices.BP35XX/PseudoSerialPortStreamFactory.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ public PseudoSerialPortStreamFactory()
1111
{
1212
}
1313

14+
public void Dispose()
15+
{
16+
// nothing to do in this class
17+
}
18+
1419
public Stream CreateSerialPortStream(string? serialPortName)
1520
=> Stream;
1621
}

0 commit comments

Comments
 (0)