doc comment improvements

This commit is contained in:
Morten Nielsen 2020-02-01 16:37:42 -08:00
parent 4e1f6fad35
commit d33430b582
9 changed files with 47 additions and 142 deletions

View file

@ -34,7 +34,7 @@ namespace NmeaParser
/// <summary>
/// Gets a list of bluetooth devices that supports serial communication
/// </summary>
/// <returns></returns>
/// <returns>A set of bluetooth devices available that supports serial connections</returns>
public static IEnumerable<Android.Bluetooth.BluetoothDevice> GetBluetoothSerialDevices()
{
var adapter = Android.Bluetooth.BluetoothAdapter.DefaultAdapter;
@ -54,10 +54,7 @@ namespace NmeaParser
m_device = device ?? throw new ArgumentNullException(nameof(device));
}
/// <summary>
/// Creates the stream the NmeaDevice is working on top off.
/// </summary>
/// <returns></returns>
/// <inheritdoc />
protected override Task<System.IO.Stream> OpenStreamAsync()
{
var adapter = Android.Bluetooth.BluetoothAdapter.DefaultAdapter;
@ -70,11 +67,7 @@ namespace NmeaParser
return Task.FromResult<Stream>(socket.InputStream);
}
/// <summary>
/// Closes the stream the NmeaDevice is working on top off.
/// </summary>
/// <param name="stream">The stream.</param>
/// <returns></returns>
/// <inheritdoc />
protected override Task CloseStreamAsync(System.IO.Stream stream)
{
if (stream == null)

View file

@ -42,7 +42,7 @@ namespace NmeaParser
/// <summary>
/// Gets a list of bluetooth devices that supports serial communication
/// </summary>
/// <returns></returns>
/// <returns>A set of bluetooth devices available that supports serial connections</returns>
public static async Task<IEnumerable<RfcommDeviceService>> GetBluetoothSerialDevicesAsync()
{
string serialDeviceType = RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort);
@ -83,10 +83,7 @@ namespace NmeaParser
base.Dispose(disposing);
}
/// <summary>
/// Creates the stream the NmeaDevice is working on top off.
/// </summary>
/// <returns></returns>
/// <inheritdoc />
protected override async Task<System.IO.Stream> OpenStreamAsync()
{
var socket = new Windows.Networking.Sockets.StreamSocket();
@ -120,11 +117,7 @@ namespace NmeaParser
public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException();
}
/// <summary>
/// Closes the stream the NmeaDevice is working on top off.
/// </summary>
/// <param name="stream">The stream.</param>
/// <returns></returns>
/// <inheritdoc />
protected override Task CloseStreamAsync(System.IO.Stream stream)
{
if(m_socket == null)

View file

@ -48,14 +48,11 @@ namespace NmeaParser
/// <summary>
/// Gets the stream to perform buffer reads on.
/// </summary>
/// <returns></returns>
/// <returns>The opened data stream.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
protected abstract Task<System.IO.Stream> GetStreamAsync();
/// <summary>
/// Opens the stream asynchronous.
/// </summary>
/// <returns></returns>
/// <inheritdoc />
protected sealed async override Task<System.IO.Stream> OpenStreamAsync()
{
var stream = await GetStreamAsync();
@ -64,11 +61,7 @@ namespace NmeaParser
return m_stream;
}
/// <summary>
/// Closes the stream asynchronous.
/// </summary>
/// <param name="stream">The stream.</param>
/// <returns></returns>
/// <inheritdoc />
protected override Task CloseStreamAsync(System.IO.Stream stream)
{
m_stream?.Dispose();
@ -135,46 +128,23 @@ namespace NmeaParser
m_sr.BaseStream.Seek(0, SeekOrigin.Begin); //start over
return m_sr.ReadLine() + '\n';
}
/// <summary>
/// Gets a value indicating whether this instance can read.
/// </summary>
/// <value>
/// <c>true</c> if this instance can read; otherwise, <c>false</c>.
/// </value>
/// <inheritdoc />
public override bool CanRead { get { return true; } }
/// <summary>
/// Gets a value indicating whether this instance can seek.
/// </summary>
/// <value>
/// <c>true</c> if this instance can seek; otherwise, <c>false</c>.
/// </value>
/// <inheritdoc />
public override bool CanSeek { get { return false; } }
/// <summary>
/// Gets a value indicating whether this instance can write.
/// </summary>
/// <value>
/// <c>true</c> if this instance can write; otherwise, <c>false</c>.
/// </value>
/// <inheritdoc />
public override bool CanWrite { get { return false; } }
/// <summary>
/// Flushes this instance.
/// </summary>
/// <inheritdoc />
public override void Flush() { }
/// <summary>
/// Gets the length.
/// </summary>
/// <value>
/// The length.
/// </value>
/// <inheritdoc />
public override long Length { get { return m_sr.BaseStream.Length; } }
/// <summary>
/// Gets or sets the position.
/// </summary>
/// <value>
/// The position.
/// </value>
/// <exception cref="System.NotSupportedException"></exception>
/// <inheritdoc />
public override long Position
{
get { return m_sr.BaseStream.Position; }
@ -183,13 +153,8 @@ namespace NmeaParser
throw new NotSupportedException();
}
}
/// <summary>
/// Reads the specified buffer.
/// </summary>
/// <param name="buffer">The buffer.</param>
/// <param name="offset">The offset.</param>
/// <param name="count">The count.</param>
/// <returns></returns>
/// <inheritdoc />
public override int Read(byte[] buffer, int offset, int count)
{
lock (lockObj)
@ -212,44 +177,25 @@ namespace NmeaParser
}
}
/// <summary>
/// Seeks the specified offset.
/// </summary>
/// <param name="offset">The offset.</param>
/// <param name="origin">The origin.</param>
/// <returns></returns>
/// <exception cref="System.NotSupportedException"></exception>
/// <inheritdoc />
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotSupportedException();
}
/// <summary>
/// Sets the length.
/// </summary>
/// <param name="value">The value.</param>
/// <exception cref="System.NotSupportedException"></exception>
/// <inheritdoc />
public override void SetLength(long value)
{
throw new NotSupportedException();
}
/// <summary>
/// Writes the specified buffer to the device.
/// </summary>
/// <param name="buffer">The buffer.</param>
/// <param name="offset">The offset.</param>
/// <param name="count">The count.</param>
/// <exception cref="System.NotSupportedException"></exception>
/// <inheritdoc />
public override void Write(byte[] buffer, int offset, int count)
{
throw new NotSupportedException();
}
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
/// <inheritdoc />
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);

View file

@ -137,7 +137,7 @@ namespace NmeaParser.Messages
/// </summary>
/// <param name="message">The NMEA message string.</param>
/// <param name="previousSentence">The previously received message (only used if parsing multi-sentence messages)</param>
/// <returns></returns>
/// <returns>The nmea message that was parsed.</returns>
/// <exception cref="System.ArgumentException">
/// Invalid nmea message: Missing starting character '$'
/// or checksum failure
@ -199,6 +199,7 @@ namespace NmeaParser.Messages
/// <summary>
/// Gets the NMEA type id for the message.
/// </summary>
/// <value>The 5 character string that identifies the message type</value>
public string MessageType { get; }
/// <summary>
@ -211,12 +212,7 @@ namespace NmeaParser.Messages
/// </summary>
public bool IsProprietary => MessageType[0] == 'P'; //Appendix B
/// <summary>
/// Returns a <see cref="System.String" /> that represents this instance.
/// </summary>
/// <returns>
/// A <see cref="System.String" /> that represents this instance.
/// </returns>
/// <inheritdoc />
public override string ToString()
{
return string.Format(CultureInfo.InvariantCulture, "${0},{1}*{2:X2}", MessageType, string.Join(",", MessageParts), Checksum);

View file

@ -42,10 +42,10 @@ namespace NmeaParser
{
}
/// <summary>
/// Opens the device connection.
/// </summary>
/// <returns></returns>
/// <summary>
/// Creates and opens the stream the <see cref="NmeaDevice"/> will be working on top off.
/// </summary>
/// <returns>A task that represents the asynchronous action.</returns>
public async Task OpenAsync()
{
lock (m_lockObject)
@ -112,15 +112,16 @@ namespace NmeaParser
}
/// <summary>
/// Creates the stream the NmeaDevice is working on top off.
/// Creates and opens the stream the NmeaDevice is working on top off.
/// </summary>
/// <returns></returns>
/// <returns>The opened data stream.</returns>
/// <seealso cref="CloseStreamAsync(Stream)"/>
protected abstract Task<Stream> OpenStreamAsync();
/// <summary>
/// Closes the device.
/// </summary>
/// <returns></returns>
/// <returns>A task that represents the asynchronous action.</returns>
public async Task CloseAsync()
{
if (m_cts != null)
@ -144,8 +145,9 @@ namespace NmeaParser
/// <summary>
/// Closes the stream the NmeaDevice is working on top off.
/// </summary>
/// <param name="stream">The stream.</param>
/// <returns></returns>
/// <param name="stream">The stream to be closed.</param>
/// <returns>A task that represents the asynchronous action.</returns>
/// <seealso cref="OpenStreamAsync"/>
protected abstract Task CloseStreamAsync(Stream stream);
private void OnData(byte[] data)
@ -170,7 +172,6 @@ namespace NmeaParser
ProcessMessage(line);
}
private IMultiSentenceMessage? _lastMultiMessage;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification="Must silently handle invalid/corrupt input")]

View file

@ -84,10 +84,7 @@ namespace NmeaParser
}
}
/// <summary>
/// Gets the stream to perform buffer reads on.
/// </summary>
/// <returns></returns>
/// <inheritdoc />
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
protected override Task<Stream> GetStreamAsync()
{

View file

@ -44,10 +44,7 @@ namespace NmeaParser
/// </summary>
public System.IO.Ports.SerialPort Port { get; }
/// <summary>
/// Creates the stream the NmeaDevice is working on top off.
/// </summary>
/// <returns></returns>
/// <inheritdoc />
protected override Task<System.IO.Stream> OpenStreamAsync()
{
if (!Port.IsOpen)
@ -55,11 +52,7 @@ namespace NmeaParser
return Task.FromResult<System.IO.Stream>(Port.BaseStream);
}
/// <summary>
/// Closes the stream the NmeaDevice is working on top off.
/// </summary>
/// <param name="stream">The stream.</param>
/// <returns></returns>
/// <inheritdoc />
protected override Task CloseStreamAsync(System.IO.Stream stream)
{
if (Port.IsOpen)

View file

@ -54,20 +54,13 @@ namespace NmeaParser
}
}
/// <summary>
/// Creates the stream the NmeaDevice is working on top off.
/// </summary>
/// <returns></returns>
/// <inheritdoc />
protected override Task<System.IO.Stream> OpenStreamAsync()
{
return Task.FromResult<System.IO.Stream>(m_port.InputStream.AsStreamForRead(0));
}
/// <summary>
/// Closes the stream the NmeaDevice is working on top off.
/// </summary>
/// <param name="stream">The stream.</param>
/// <returns></returns>
/// <inheritdoc />
protected override Task CloseStreamAsync(System.IO.Stream stream)
{
return Task.CompletedTask;

View file

@ -36,20 +36,13 @@ namespace NmeaParser
m_stream = stream ?? throw new ArgumentNullException(nameof(stream));
}
/// <summary>
/// Opens the stream asynchronous.
/// </summary>
/// <returns></returns>
/// <inheritdoc />
protected override Task<Stream> OpenStreamAsync()
{
return Task.FromResult(m_stream);
}
/// <summary>
/// Closes the stream asynchronous.
/// </summary>
/// <param name="stream">The stream.</param>
/// <returns></returns>
/// <inheritdoc />
protected override Task CloseStreamAsync(System.IO.Stream stream)
{
return Task.FromResult(true); //do nothing