Skip to content

Commit 473a1e9

Browse files
committed
Miscellaneous improvements
- Minor changes from analyzers tips. - Add/fix Intellisense comments.
1 parent 7ace3f4 commit 473a1e9

File tree

9 files changed

+39
-24
lines changed

9 files changed

+39
-24
lines changed

Tests/UnitTestDebugLogging/MyTestComponent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace UnitTestDebugLogging
1111
{
1212
internal class MyTestComponent
1313
{
14-
private ILogger _logger;
14+
private readonly ILogger _logger;
1515

1616
public MyTestComponent()
1717
{

nanoFramework.Logging.Serial/SerialLogger.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
// See LICENSE file in the project root for full license information.
44
//
55

6-
using System;
76
using Microsoft.Extensions.Logging;
7+
using System;
88
using Windows.Devices.SerialCommunication;
99
using Windows.Storage.Streams;
1010

1111
namespace nanoFramework.Logging.Serial
1212
{
1313
/// <summary>
14-
/// A logger that prints to the debug console
14+
/// A logger that outputs to a <see cref="SerialDevice"/>.
1515
/// </summary>
1616
public class SerialLogger : ILogger
1717
{
1818
private readonly DataWriter _outputDataWriter;
1919

2020
/// <summary>
21-
/// Creates a new instance of the <see cref="DebugLogger"/>
21+
/// Creates a new instance of the <see cref="SerialLogger"/>
2222
/// </summary>
2323
/// <param name="serialDevice">The serial port to use</param>
2424
public SerialLogger(ref SerialDevice serialDevice)

nanoFramework.Logging.Serial/SerialLoggerFactory.cs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,29 @@ namespace nanoFramework.Logging.Serial
1414
public class SerialLoggerFactory : ILoggerFactory
1515
{
1616
private SerialDevice _serial;
17-
private string _comPort;
18-
private uint _baudRate;
19-
private ushort _dataBits;
20-
private SerialParity _parity;
21-
private SerialStopBitCount _stopBits;
22-
private SerialHandshake _handshake;
17+
private readonly string _comPort;
18+
private readonly uint _baudRate;
19+
private readonly ushort _dataBits;
20+
private readonly SerialParity _parity;
21+
private readonly SerialStopBitCount _stopBits;
22+
private readonly SerialHandshake _handshake;
2323

24-
public SerialLoggerFactory(string comPort, uint baudRate = 9600, ushort dataBits = 8, SerialParity parity = SerialParity.None, SerialStopBitCount stopBits = SerialStopBitCount.One, SerialHandshake handshake = SerialHandshake.None)
24+
/// <summary>
25+
/// Create a new instance of <see cref="SerialLoggerFactory"/> from a <see cref="SerialDevice"/>.
26+
/// </summary>
27+
/// <param name="comPort"></param>
28+
/// <param name="baudRate"></param>
29+
/// <param name="dataBits"></param>
30+
/// <param name="parity"></param>
31+
/// <param name="stopBits"></param>
32+
/// <param name="handshake"></param>
33+
public SerialLoggerFactory(
34+
string comPort,
35+
uint baudRate = 9600,
36+
ushort dataBits = 8,
37+
SerialParity parity = SerialParity.None,
38+
SerialStopBitCount stopBits = SerialStopBitCount.One,
39+
SerialHandshake handshake = SerialHandshake.None)
2540
{
2641
_comPort = comPort;
2742
_baudRate = baudRate;

nanoFramework.Logging.Stream/StreamLogger.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
// Copyright (c) .NET Foundation and Contributors
33
// See LICENSE file in the project root for full license information.
44
//
5+
using Microsoft.Extensions.Logging;
56
using System;
67
using System.IO;
78
using System.Text;
8-
using Microsoft.Extensions.Logging;
99

1010
namespace nanoFramework.Logging.Stream
1111
{
1212
/// <summary>
13-
/// A logger that prints to the debug console
13+
/// A logger that outputs to a <see cref="Stream"/>.
1414
/// </summary>
1515
public class StreamLogger : ILogger, IDisposable
1616
{
1717
private System.IO.Stream _stream = null;
18-
18+
1919
/// <summary>
20-
/// Creates a new instance of the <see cref="DebugLogger"/>
20+
/// Creates a new instance of the <see cref="ILogger"/>
2121
/// </summary>
22-
/// <param name="fileName">fileName</param>
22+
/// <param name="stream">Stream to output the log to.</param>
2323
public StreamLogger(System.IO.Stream stream)
2424
{
2525
_stream = stream;
@@ -51,9 +51,7 @@ public void Log(LogLevel logLevel, EventId eventId, string state, Exception exce
5151
}
5252
}
5353

54-
/// <summary>
55-
/// Dispose properly the stream
56-
/// </summary>
54+
/// <inheritdoc/>
5755
public void Dispose()
5856
{
5957
if(_stream != null)

nanoFramework.Logging.Stream/StreamLoggerFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ namespace nanoFramework.Logging.Stream
1212
/// </summary>
1313
public class StreamLoggerFactory : ILoggerFactory
1414
{
15-
private System.IO.Stream _stream;
15+
private readonly System.IO.Stream _stream;
1616

1717
/// <summary>
18-
/// Create a new instance of Stream Logger Factory from a stream
18+
/// Create a new instance of <see cref="StreamLoggerFactory"/> from a <see cref="Stream"/>.
1919
/// </summary>
2020
/// <param name="stream">The stream</param>
2121
public StreamLoggerFactory(System.IO.Stream stream)

nanoFramework.Logging/DebugLogger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// See LICENSE file in the project root for full license information.
44
//
55

6-
using System;
76
using Microsoft.Extensions.Logging;
7+
using System;
88

99
namespace nanoFramework.Logging.Debug
1010
{

nanoFramework.Logging/DebugLoggerFactory.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public ILogger CreateLogger(string categoryName)
2121
/// <inheritdoc />
2222
public void Dispose()
2323
{
24+
// nothing to do here
2425
}
2526
}
2627
}

nanoFramework.Logging/ILoggerFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Microsoft.Extensions.Logging
99
{
1010
/// <summary>
1111
/// Represents a type used to configure the logging system and create instances of <see cref="ILogger"/> from
12-
/// the registered <see cref="ILoggerProvider"/>s.
12+
/// the registered <see cref="ILogger"/>s.
1313
/// </summary>
1414
public interface ILoggerFactory : IDisposable
1515
{

nanoFramework.Logging/LogDispatcher.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// See LICENSE file in the project root for full license information.
44
//
55

6-
using System;
76
using Microsoft.Extensions.Logging;
7+
using System;
88

99
namespace nanoFramework.Logging
1010
{
@@ -56,6 +56,7 @@ private class NullLogger : ILogger
5656
{
5757
public void Log(LogLevel logLevel, EventId eventId, string state, Exception exception)
5858
{
59+
// nothing to do here
5960
}
6061

6162
public bool IsEnabled(LogLevel logLevel)

0 commit comments

Comments
 (0)