Skip to content

Commit b5aba8f

Browse files
authored
Merge pull request #181 from bytedreamer/develop
v5.0.4 Beta Release
2 parents f6ac881 + 56273e3 commit b5aba8f

File tree

13 files changed

+59
-59
lines changed

13 files changed

+59
-59
lines changed

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ variables:
1616
buildConfiguration: 'Release'
1717
major: 5
1818
minor: 0
19-
patch: 3
19+
patch: 4
2020
AssemblyVersion: $(major).$(minor).$(patch)
2121
NugetVersion: $(major).$(minor).$(patch)-beta
2222

src/Console/Console.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020

2121
<ItemGroup>
2222
<PackageReference Include="apache.log4net.Extensions.Logging" Version="2.0.0.12" />
23-
<PackageReference Include="log4net" Version="2.0.15" />
23+
<PackageReference Include="log4net" Version="3.0.2" />
2424
<PackageReference Include="Microsoft.NETCore.Platforms" Version="7.0.4" />
2525
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3">
2626
<PrivateAssets>all</PrivateAssets>
2727
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2828
</PackageReference>
29-
<PackageReference Include="Terminal.Gui" Version="1.16.0" />
29+
<PackageReference Include="Terminal.Gui" Version="1.17.1" />
3030
</ItemGroup>
3131

3232
<ItemGroup>

src/Console/Program.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ namespace Console;
3030

3131
internal static class Program
3232
{
33-
private static ILogger<ControlPanel> _panelLogger;
3433
private static ControlPanel _controlPanel;
3534
private static readonly Queue<string> Messages = new ();
3635
private static readonly object MessageLock = new ();
@@ -58,17 +57,16 @@ internal static class Program
5857
private static async Task Main()
5958
{
6059
XmlConfigurator.Configure(
61-
LogManager.GetRepository(Assembly.GetAssembly(typeof(LogManager))),
60+
LogManager.GetRepository(Assembly.GetEntryAssembly() ?? Assembly.GetCallingAssembly()),
6261
new FileInfo("log4net.config"));
6362

6463
_lastConfigFilePath = Path.Combine(Environment.CurrentDirectory, "appsettings.config");
6564
_lastOsdpConfigFilePath = Environment.CurrentDirectory;
6665

6766
var factory = new LoggerFactory();
6867
factory.AddLog4Net();
69-
_panelLogger = factory.CreateLogger<ControlPanel>();
7068

71-
_controlPanel = new ControlPanel(_panelLogger);
69+
_controlPanel = new ControlPanel(factory);
7270

7371
_settings = GetConnectionSettings();
7472

@@ -96,10 +94,8 @@ private static async Task Main()
9694
new MenuItem("_Quit", "", () =>
9795
{
9896
SaveConfigurationSettings(_settings);
99-
100-
Application.RequestStop();
101-
102-
Environment.Exit(Environment.ExitCode);
97+
98+
Application.Shutdown();
10399
})
104100
}),
105101
new MenuBarItem("Co_nnections", new[]

src/OSDP.Net.Tests/ControlPanelTest.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Threading;
55
using System.Threading.Tasks;
6+
using Microsoft.Extensions.Logging.Abstractions;
67
using Moq;
78
using NUnit.Framework;
89
using OSDP.Net.Connections;
@@ -24,7 +25,7 @@ public async Task DeviceGoesOnlineTest()
2425
// Arrange
2526
var mockConnection = new MockConnection();
2627

27-
var panel = new ControlPanel();
28+
var panel = new ControlPanel(NullLoggerFactory.Instance);
2829
Guid id = panel.StartConnection(mockConnection.Object);
2930
panel.AddDevice(id, 0, true, false);
3031

@@ -40,7 +41,7 @@ public async Task ShutdownTest()
4041
// Arrange
4142
var mockConnection = new MockConnection();
4243

43-
var panel = new ControlPanel();
44+
var panel = new ControlPanel(NullLoggerFactory.Instance);
4445
Guid id = panel.StartConnection(mockConnection.Object);
4546
panel.AddDevice(id, 0, true, false);
4647

@@ -59,7 +60,7 @@ public async Task StartConnectionTest()
5960
{
6061
// Arrange
6162
var mockConnection = new MockConnection();
62-
var panel = new ControlPanel();
63+
var panel = new ControlPanel(NullLoggerFactory.Instance);
6364

6465
// Act
6566
Guid id = panel.StartConnection(mockConnection.Object);
@@ -75,7 +76,7 @@ public void StartConnectionWithSameConnectionTwiceTest()
7576
{
7677
// Arrange
7778
var mockConnection = new MockConnection();
78-
var panel = new ControlPanel();
79+
var panel = new ControlPanel(NullLoggerFactory.Instance);
7980
var id = panel.StartConnection(mockConnection.Object);
8081

8182
// Act/Assert
@@ -91,7 +92,7 @@ public void StartSameConnectionConcurrentlyShouldOnlyStartItOnce()
9192
// Arrange
9293
var mockConnection = new MockConnection();
9394
var instance = mockConnection.Object;
94-
var panel = new ControlPanel();
95+
var panel = new ControlPanel(NullLoggerFactory.Instance);
9596

9697
// Act
9798
var tasks = Enumerable
@@ -115,7 +116,7 @@ public void StopSameConnectionConcurrentlyShouldSucceed()
115116
{
116117
// Arrange
117118
var mockConnection = new MockConnection();
118-
var panel = new ControlPanel();
119+
var panel = new ControlPanel(NullLoggerFactory.Instance);
119120
var id = panel.StartConnection(mockConnection.Object);
120121

121122
// Act
@@ -139,7 +140,7 @@ public async Task StartConnectionRestartWithSameConnectionTest()
139140
{
140141
// Arrange
141142
var mockConnection = new MockConnection();
142-
var panel = new ControlPanel();
143+
var panel = new ControlPanel(NullLoggerFactory.Instance);
143144

144145
// Act
145146
var id1 = panel.StartConnection(mockConnection.Object);
@@ -157,7 +158,7 @@ public async Task StopConnectionTest()
157158
{
158159
// Arrange
159160
var mockConnection = new MockConnection();
160-
var panel = new ControlPanel();
161+
var panel = new ControlPanel(NullLoggerFactory.Instance);
161162

162163
Guid id = panel.StartConnection(mockConnection.Object);
163164
panel.AddDevice(id, 0, true, false);
@@ -178,7 +179,7 @@ public class IdRequestCommandTest
178179
[Test]
179180
public async Task ReturnsValidReportTest()
180181
{
181-
var panel = new ControlPanel(GlobalSetup.CreateLogger<ControlPanel>());
182+
var panel = new ControlPanel(NullLoggerFactory.Instance);
182183
var idReportCommand = new IdReport();
183184
var deviceIdentificationReply =
184185
new DeviceIdentification([0x5C, 0x26, 0x23], 0x19, 0x02, 719912960, 0x03, 0x00, 0x00);
@@ -203,7 +204,7 @@ public async Task ReturnsValidReportTest()
203204
[Test]
204205
public void ThrowOnNakReplyTest()
205206
{
206-
var panel = new ControlPanel(GlobalSetup.CreateLogger<ControlPanel>());
207+
var panel = new ControlPanel(NullLoggerFactory.Instance);
207208
var idReportCommand = new IdReport();
208209
var nakReply = new Nak(ErrorCode.UnknownCommandCode);
209210

src/OSDP.Net.Tests/Global.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/OSDP.Net.Tests/IntegrationTests/PeripheryDeviceTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace OSDP.Net.Tests.IntegrationTests;
1313

14-
1514
//
1615
// NOTE: Majority of naming/structure in this file is very much a work-in-progress
1716
// and will be updated if we continue to build out a set of integration tests

src/OSDP.Net.Tests/OSDP.Net.Tests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
<ItemGroup>
1212
<PackageReference Include="apache.log4net.Extensions.Logging" Version="2.0.0.12" />
13-
<PackageReference Include="log4net" Version="2.0.15" />
14-
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
15-
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
13+
<PackageReference Include="log4net" Version="3.0.2" />
14+
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
15+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
1616
<PackageReference Include="Microsoft.NETCore.Platforms" Version="7.0.4" />
1717
<PackageReference Include="Moq" Version="4.20.69" />
1818
<PackageReference Include="nunit" Version="3.13.3" />

src/OSDP.Net/Bus.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using OSDP.Net.Model.CommandData;
1414
using OSDP.Net.Model.ReplyData;
1515
using OSDP.Net.Tracing;
16+
1617
#if NETSTANDARD2_0
1718
using OSDP.Net.Utilities;
1819
#endif

src/OSDP.Net/ControlPanel.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Threading;
77
using System.Threading.Tasks;
88
using Microsoft.Extensions.Logging;
9+
using Microsoft.Extensions.Logging.Abstractions;
910
using OSDP.Net.Connections;
1011
using OSDP.Net.Messages;
1112
using OSDP.Net.Model.CommandData;
@@ -37,11 +38,32 @@ public class ControlPanel
3738

3839
/// <summary>Initializes a new instance of the <see cref="T:OSDP.Net.ControlPanel" /> class.</summary>
3940
/// <param name="logger">The logger definition used for logging.</param>
41+
[Obsolete("Sending a ILogger is deprecated, please send ILoggerFactory instead.")]
4042
public ControlPanel(ILogger<ControlPanel> logger = null) : this(null, logger) { }
4143

44+
/// <summary>Initializes a new instance of the <see cref="T:OSDP.Net.ControlPanel" /> class.</summary>
45+
/// <param name="loggerFactory">The logger factory used to create logging facilities.</param>
46+
public ControlPanel(ILoggerFactory loggerFactory = null) : this(null, loggerFactory) { }
47+
4248
internal ControlPanel(IDeviceProxyFactory deviceProxyFactory, ILogger<ControlPanel> logger = null)
4349
{
44-
_logger = logger;
50+
_logger = logger ?? NullLoggerFactory.Instance.CreateLogger<ControlPanel>();
51+
_deviceProxyFactory = deviceProxyFactory ?? new DeviceProxyFactory();
52+
53+
Task.Factory.StartNew(() =>
54+
{
55+
foreach (var reply in _replies.GetConsumingEnumerable())
56+
{
57+
OnReplyReceived(reply);
58+
}
59+
}, TaskCreationOptions.LongRunning);
60+
}
61+
62+
internal ControlPanel(IDeviceProxyFactory deviceProxyFactory, ILoggerFactory loggerFactory = null)
63+
{
64+
_logger = loggerFactory != null
65+
? loggerFactory.CreateLogger<ControlPanel>()
66+
: NullLoggerFactory.Instance.CreateLogger<ControlPanel>();
4567
_deviceProxyFactory = deviceProxyFactory ?? new DeviceProxyFactory();
4668

4769
Task.Factory.StartNew(() =>

src/OSDP.Net/OSDP.Net.csproj

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@
2525
<None Include="Images\icon.png" Pack="true" PackagePath="" />
2626
</ItemGroup>
2727

28-
<ItemGroup>
28+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
2929
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
30-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
30+
<PackageReference Include="System.Text.Json" Version="8.0.5" />
3131
<PackageReference Include="System.Collections" Version="4.3.0" />
32-
<PackageReference Include="System.IO.Ports" Version="8.0.0" />
3332
<PackageReference Include="System.Memory" Version="4.5.5" />
34-
<PackageReference Include="System.Text.Json" Version="8.0.4" />
33+
</ItemGroup>
34+
35+
<ItemGroup>
36+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" />
3537
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
38+
<PackageReference Include="System.IO.Ports" Version="8.0.0" />
3639
</ItemGroup>
3740

3841
</Project>

0 commit comments

Comments
 (0)