mirror of
https://github.com/dotMorten/NmeaParser.git
synced 2025-12-06 07:12:04 +01:00
Merge pull request #60 from dotMorten/EnableNullable
Use nullability tags
This commit is contained in:
commit
f742fb76d3
2
.github/workflows/CIBuild.yml
vendored
2
.github/workflows/CIBuild.yml
vendored
|
|
@ -21,5 +21,5 @@ jobs:
|
|||
- name: Build
|
||||
run: |
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat"
|
||||
msbuild /restore /t:Build src/NmeaParser.sln /p:Configuration=Release
|
||||
msbuild /restore /t:Build src/NmeaParser.sln /p:Configuration=Release /p:JavaSdkDirectory="$(JAVA_HOME_8_X64)"
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ trigger:
|
|||
- master
|
||||
|
||||
pool:
|
||||
vmImage: 'windows-latest'
|
||||
vmImage: 'windows-2019'
|
||||
|
||||
variables:
|
||||
solution: '**/*.sln'
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27130.2003
|
||||
# Visual Studio 16
|
||||
VisualStudioVersion = 16.0.0.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NmeaParser", "NmeaParser", "{1701F3BA-A09C-4706-A612-24FD9340FC18}"
|
||||
EndProject
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace NmeaParser
|
|||
{
|
||||
private static Java.Util.UUID SERIAL_UUID = Java.Util.UUID.FromString("00001101-0000-1000-8000-00805F9B34FB");
|
||||
private Android.Bluetooth.BluetoothDevice m_device;
|
||||
private BluetoothSocket m_socket;
|
||||
private BluetoothSocket? m_socket;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of bluetooth devices that supports serial communication
|
||||
|
|
@ -51,7 +51,7 @@ namespace NmeaParser
|
|||
/// <param name="device">The Android Bluetooth Device.</param>
|
||||
public BluetoothDevice(Android.Bluetooth.BluetoothDevice device)
|
||||
{
|
||||
m_device = device;
|
||||
m_device = device ?? throw new ArgumentNullException(nameof(device));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -80,7 +80,7 @@ namespace NmeaParser
|
|||
if (stream == null)
|
||||
throw new ArgumentNullException("stream");
|
||||
stream.Dispose();
|
||||
m_socket.Dispose();
|
||||
m_socket?.Dispose();
|
||||
m_socket = null;
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ namespace NmeaParser
|
|||
/// </summary>
|
||||
public class BluetoothDevice : NmeaDevice
|
||||
{
|
||||
private Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService m_deviceService;
|
||||
private Windows.Networking.Proximity.PeerInformation m_devicePeer;
|
||||
private StreamSocket m_socket;
|
||||
private Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService? m_deviceService;
|
||||
private Windows.Networking.Proximity.PeerInformation? m_devicePeer;
|
||||
private StreamSocket? m_socket;
|
||||
private bool m_disposeService;
|
||||
private SemaphoreSlim m_semaphoreSlim = new SemaphoreSlim(1, 1);
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ namespace NmeaParser
|
|||
/// <param name="disposeService">Whether this devicee should also dispose the RfcommDeviceService provided when this device disposes.</param>
|
||||
public BluetoothDevice(RfcommDeviceService service, bool disposeService = false)
|
||||
{
|
||||
m_deviceService = service;
|
||||
m_deviceService = service ?? throw new ArgumentNullException(nameof(service));
|
||||
m_disposeService = disposeService;
|
||||
}
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ namespace NmeaParser
|
|||
/// <param name="peer">The peer information device.</param>
|
||||
public BluetoothDevice(Windows.Networking.Proximity.PeerInformation peer)
|
||||
{
|
||||
m_devicePeer = peer;
|
||||
m_devicePeer = peer ?? throw new ArgumentNullException(nameof(peer));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
@ -95,20 +95,37 @@ namespace NmeaParser
|
|||
{
|
||||
await socket.ConnectAsync(m_devicePeer.HostName, "1");
|
||||
}
|
||||
else
|
||||
else if (m_deviceService != null)
|
||||
{
|
||||
await socket.ConnectAsync(m_deviceService.ConnectionHostName, m_deviceService.ConnectionServiceName);
|
||||
}
|
||||
else
|
||||
throw new InvalidOperationException();
|
||||
m_socket = socket;
|
||||
return null; //We're going to use WinRT buffers instead and will handle read/write, so no reason to return a stream. This is mainly done to avoid locking issues reading and writing at the same time
|
||||
|
||||
return new DummyStream(); //We're going to use WinRT buffers instead and will handle read/write, so no reason to return a real stream. This is mainly done to avoid locking issues reading and writing at the same time
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the stream the NmeaDevice is working on top off.
|
||||
/// </summary>
|
||||
/// <param name="stream">The stream.</param>
|
||||
/// <returns></returns>
|
||||
protected override Task CloseStreamAsync(System.IO.Stream stream)
|
||||
private class DummyStream : Stream
|
||||
{
|
||||
public override bool CanRead => false;
|
||||
public override bool CanSeek => false;
|
||||
public override bool CanWrite => false;
|
||||
public override long Length => throw new NotSupportedException();
|
||||
public override long Position { get => throw new NotSupportedException(); set => throw new NotSupportedException(); }
|
||||
public override void Flush() => throw new NotSupportedException();
|
||||
public override int Read(byte[] buffer, int offset, int count) => throw new NotSupportedException();
|
||||
public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException();
|
||||
public override void SetLength(long value) => throw new NotSupportedException();
|
||||
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>
|
||||
protected override Task CloseStreamAsync(System.IO.Stream stream)
|
||||
{
|
||||
if(m_socket == null)
|
||||
throw new InvalidOperationException("No connection to close");
|
||||
|
|
@ -124,6 +141,8 @@ namespace NmeaParser
|
|||
// Reading and writing to the Bluetooth serial connection at the same time seems very unstable in UWP,
|
||||
// so we use a semaphore to ensure we don't read and write at the same time
|
||||
await m_semaphoreSlim.WaitAsync().ConfigureAwait(false);
|
||||
if (m_socket == null)
|
||||
throw new InvalidOperationException("Socket not initialized");
|
||||
try
|
||||
{
|
||||
var r = await m_socket.InputStream.ReadAsync(buffer.AsBuffer(), (uint)count, Windows.Storage.Streams.InputStreamOptions.None);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace NmeaParser
|
|||
/// </summary>
|
||||
public abstract class BufferedStreamDevice : NmeaDevice
|
||||
{
|
||||
private BufferedStream m_stream;
|
||||
private BufferedStream? m_stream;
|
||||
private readonly int m_readSpeed;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -71,7 +71,7 @@ namespace NmeaParser
|
|||
/// <returns></returns>
|
||||
protected override Task CloseStreamAsync(System.IO.Stream stream)
|
||||
{
|
||||
m_stream.Dispose();
|
||||
m_stream?.Dispose();
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
|
|
@ -83,8 +83,8 @@ namespace NmeaParser
|
|||
private byte[] m_buffer = new byte[0];
|
||||
private readonly System.Threading.Timer m_timer;
|
||||
private readonly object lockObj = new object();
|
||||
private string groupToken = null;
|
||||
private string lastLineRead = null;
|
||||
private string? groupToken = null;
|
||||
private string? lastLineRead = null;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BufferedStream"/> class.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -63,11 +63,11 @@ namespace NmeaParser.Nmea
|
|||
/// <summary>
|
||||
/// Name of origin
|
||||
/// </summary>
|
||||
public string OriginId { get; }
|
||||
public string? OriginId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Name of destination
|
||||
/// </summary>
|
||||
public string DestinationId { get; }
|
||||
public string? DestinationId { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -228,7 +228,7 @@ namespace NmeaParser.Nmea
|
|||
/// <summary>
|
||||
/// eference station ID1, range 0000-4095 - Null if talker ID is GN, additional GNS messages follow with GP and/or GL Reference station ID
|
||||
/// </summary>
|
||||
public string DgpsStationId { get; }
|
||||
public string? DgpsStationId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Navigational status
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@ namespace NmeaParser
|
|||
{
|
||||
private readonly object m_lockObject = new object();
|
||||
private string m_message = "";
|
||||
private Stream m_stream;
|
||||
private CancellationTokenSource m_cts;
|
||||
private Stream? m_stream;
|
||||
private CancellationTokenSource? m_cts;
|
||||
private bool m_isOpening;
|
||||
private Task m_ParserTask;
|
||||
private Task? m_ParserTask;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NmeaDevice"/> class.
|
||||
|
|
@ -183,7 +183,9 @@ namespace NmeaParser
|
|||
|
||||
private void OnMessageReceived(Nmea.NmeaMessage msg)
|
||||
{
|
||||
Nmea.NmeaMessage[] messageParts = null;
|
||||
if (msg == null)
|
||||
return;
|
||||
Nmea.NmeaMessage[]? messageParts = null;
|
||||
if (msg is IMultiPartMessage multi)
|
||||
{
|
||||
string messageType = msg.MessageType.Substring(2); //We don't care about the two first characters. Ie GPGSV, GLGSV, GAGSV etc are all part of the same multi-part message
|
||||
|
|
@ -221,7 +223,7 @@ namespace NmeaParser
|
|||
/// <summary>
|
||||
/// Occurs when an NMEA message is received.
|
||||
/// </summary>
|
||||
public event EventHandler<NmeaMessageReceivedEventArgs> MessageReceived;
|
||||
public event EventHandler<NmeaMessageReceivedEventArgs>? MessageReceived;
|
||||
|
||||
/// <summary>
|
||||
/// Releases unmanaged and - optionally - managed resources.
|
||||
|
|
@ -287,7 +289,7 @@ namespace NmeaParser
|
|||
/// </summary>
|
||||
public sealed class NmeaMessageReceivedEventArgs : EventArgs
|
||||
{
|
||||
internal NmeaMessageReceivedEventArgs(Nmea.NmeaMessage message, IReadOnlyList<Nmea.NmeaMessage> messageParts)
|
||||
internal NmeaMessageReceivedEventArgs(Nmea.NmeaMessage message, IReadOnlyList<Nmea.NmeaMessage>? messageParts)
|
||||
{
|
||||
Message = message;
|
||||
MessageParts = messageParts;
|
||||
|
|
@ -315,6 +317,6 @@ namespace NmeaParser
|
|||
/// <value>
|
||||
/// The message parts.
|
||||
/// </value>
|
||||
public IReadOnlyList<Nmea.NmeaMessage> MessageParts { get; }
|
||||
public IReadOnlyList<Nmea.NmeaMessage>? MessageParts { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace NmeaParser
|
|||
public class NmeaFileDevice : BufferedStreamDevice
|
||||
{
|
||||
#if NETFX_CORE
|
||||
private Windows.Storage.IStorageFile m_storageFile;
|
||||
private Windows.Storage.IStorageFile? m_storageFile;
|
||||
#endif
|
||||
private string m_filename;
|
||||
|
||||
|
|
@ -44,8 +44,8 @@ namespace NmeaParser
|
|||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NmeaFileDevice"/> class.
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
public NmeaFileDevice(Windows.Storage.IStorageFile fileName) : this(fileName, 1000)
|
||||
/// <param name="storageFile"></param>
|
||||
public NmeaFileDevice(Windows.Storage.IStorageFile storageFile) : this(storageFile, 1000)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
|
@ -63,12 +63,13 @@ namespace NmeaParser
|
|||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NmeaFileDevice"/> class.
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="storageFile"></param>
|
||||
/// <param name="readSpeed">The time to wait between each group of lines being read in milliseconds</param>
|
||||
public NmeaFileDevice(Windows.Storage.IStorageFile fileName, int readSpeed)
|
||||
public NmeaFileDevice(Windows.Storage.IStorageFile storageFile, int readSpeed)
|
||||
: base(readSpeed)
|
||||
{
|
||||
m_storageFile = fileName;
|
||||
m_storageFile = storageFile ?? throw new ArgumentNullException(nameof(storageFile));
|
||||
m_filename = storageFile.Path;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -79,10 +80,6 @@ namespace NmeaParser
|
|||
{
|
||||
get
|
||||
{
|
||||
#if NETFX_CORE
|
||||
if (m_storageFile != null)
|
||||
return m_storageFile.Path;
|
||||
#endif
|
||||
return m_filename;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="MSBuild.Sdk.Extras/1.6.68">
|
||||
<Project Sdk="MSBuild.Sdk.Extras/2.0.54">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard1.4;net451;monoandroid50;monoandroid70;xamarinios10;uap10.0.14393</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard1.4;net451;monoandroid50;monoandroid70;xamarinios10;uap10.0.16299</TargetFrameworks>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
|
|
@ -27,9 +27,10 @@ Updated license to Apache 2.0</PackageReleaseNotes>
|
|||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
||||
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<TreatWarningsAsErrors Condition="'$(Configuration)'=='Release'">true</TreatWarningsAsErrors>
|
||||
<CodeAnalysisTreatWarningsAsErrors Condition="'$(Configuration)'=='Release'">true</CodeAnalysisTreatWarningsAsErrors>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard1.4'">
|
||||
|
|
@ -41,11 +42,13 @@ Updated license to Apache 2.0</PackageReleaseNotes>
|
|||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'monoandroid50'">
|
||||
<DesignTimeBuild>false</DesignTimeBuild> <!-- workaround for MSBuildSdkExtras issue in VS16.2 -->
|
||||
<DefineConstants>$(DefineConstants);XAMARIN;API_LEVEL_21</DefineConstants>
|
||||
<NoWarn>$(NoWarn);XA0113;XA0114</NoWarn>
|
||||
<AndroidEnableGooglePlayStoreChecks>false</AndroidEnableGooglePlayStoreChecks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'monoandroid70'">
|
||||
<DesignTimeBuild>false</DesignTimeBuild> <!-- workaround for MSBuildSdkExtras issue in VS16.2 -->
|
||||
<DefineConstants>$(DefineConstants);XAMARIN;API_LEVEL_24</DefineConstants>
|
||||
<NoWarn>$(NoWarn);XA0113;XA0114</NoWarn>
|
||||
<AndroidEnableGooglePlayStoreChecks>false</AndroidEnableGooglePlayStoreChecks>
|
||||
|
|
@ -56,10 +59,10 @@ Updated license to Apache 2.0</PackageReleaseNotes>
|
|||
<NoWarn>$(NoWarn);VSX1000</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'uap10.0.14393'">
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'uap10.0.16299'">
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'uap10.0.14393'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'uap10.0.16299'">
|
||||
<EmbeddedResource Include="**\*.rd.xml" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ namespace NmeaParser
|
|||
{
|
||||
if (Port.IsOpen)
|
||||
Port.Close();
|
||||
return Task.FromResult<object>(null);
|
||||
return Task.FromResult<object?>(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -90,7 +90,7 @@ namespace NmeaParser
|
|||
throw new InvalidOperationException("Device not open");
|
||||
|
||||
Port.Write(buffer, offset, length);
|
||||
return Task.FromResult<object>(null);
|
||||
return Task.FromResult<object?>(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace NmeaParser
|
|||
/// <param name="stream">The stream.</param>
|
||||
public StreamDevice(Stream stream) : base()
|
||||
{
|
||||
m_stream = stream;
|
||||
m_stream = stream ?? throw new ArgumentNullException(nameof(stream));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -64,7 +64,6 @@ namespace NmeaParser
|
|||
base.Dispose(disposing);
|
||||
if (m_stream != null)
|
||||
m_stream.Dispose();
|
||||
m_stream = null;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
|||
|
|
@ -32,16 +32,18 @@ namespace NmeaParser
|
|||
/// </summary>
|
||||
public class SystemNmeaDevice : NmeaDevice
|
||||
{
|
||||
private StringStream stream;
|
||||
private Listener listener;
|
||||
private StringStream? stream;
|
||||
private Listener? listener;
|
||||
private LocationManager manager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SystemNmeaDevice"/> class.
|
||||
/// </summary>
|
||||
public SystemNmeaDevice()
|
||||
public SystemNmeaDevice(Context context)
|
||||
{
|
||||
manager = Application.Context.GetSystemService(Context.LocationService) as LocationManager;
|
||||
if (context == null)
|
||||
throw new ArgumentNullException(nameof(context));
|
||||
manager = context.GetSystemService(Context.LocationService) as LocationManager ?? throw new InvalidOperationException("Cannot acces the Location Service");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -76,10 +78,10 @@ namespace NmeaParser
|
|||
{
|
||||
manager.RemoveUpdates(listener);
|
||||
manager.RemoveNmeaListener(listener);
|
||||
listener.Dispose();
|
||||
listener?.Dispose();
|
||||
listener = null;
|
||||
stream.Dispose();
|
||||
return Task.FromResult<object>(null);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private class Listener : Java.Lang.Object,
|
||||
|
|
@ -102,7 +104,7 @@ namespace NmeaParser
|
|||
NmeaMessage?.Invoke(this, message);
|
||||
}
|
||||
|
||||
public event EventHandler<string> NmeaMessage;
|
||||
public event EventHandler<string>? NmeaMessage;
|
||||
|
||||
public float Accuracy = float.NaN;
|
||||
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ namespace SampleApp.Droid
|
|||
return;
|
||||
|
||||
launched = true;
|
||||
listener = new NmeaParser.SystemNmeaDevice();
|
||||
listener = new NmeaParser.SystemNmeaDevice(ApplicationContext);
|
||||
}
|
||||
else //Bluetooth
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
<AssemblyName>SampleApp.UWP</AssemblyName>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
|
||||
<TargetPlatformVersion>10.0.14393.0</TargetPlatformVersion>
|
||||
<TargetPlatformMinVersion>10.0.14393.0</TargetPlatformMinVersion>
|
||||
<TargetPlatformVersion>10.0.16299.0</TargetPlatformVersion>
|
||||
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
|
||||
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
|
||||
<EnableDotNetNativeCompatibleProfile>true</EnableDotNetNativeCompatibleProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
<TestProjectType>UnitTest</TestProjectType>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
|
|
|||
|
|
@ -13,12 +13,14 @@
|
|||
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
|
||||
<TargetPlatformVersion>10.0.17763.0</TargetPlatformVersion>
|
||||
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
|
||||
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
|
||||
<MinimumVisualStudioVersion>16</MinimumVisualStudioVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<PackageCertificateKeyFile>NmeaParser.Tests.UWP_TemporaryKey.pfx</PackageCertificateKeyFile>
|
||||
<UnitTestPlatformVersion Condition="'$(UnitTestPlatformVersion)' == ''">$(VisualStudioVersion)</UnitTestPlatformVersion>
|
||||
<PackageCertificateThumbprint>D07B149B4E796AB0184B2E2FC9DDC1A2F5CA5A7E</PackageCertificateThumbprint>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace NmeaParser.Tests.UWP
|
|||
}
|
||||
#endif
|
||||
|
||||
Frame rootFrame = Window.Current.Content as Frame;
|
||||
Frame? rootFrame = Window.Current?.Content as Frame;
|
||||
|
||||
// Do not repeat app initialization when the Window already has content,
|
||||
// just ensure that the window is active
|
||||
|
|
@ -64,13 +64,15 @@ namespace NmeaParser.Tests.UWP
|
|||
}
|
||||
|
||||
// Place the frame in the current Window
|
||||
Window.Current.Content = rootFrame;
|
||||
if (Window.Current != null)
|
||||
Window.Current.Content = rootFrame;
|
||||
}
|
||||
|
||||
Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI();
|
||||
|
||||
// Ensure the current window is active
|
||||
Window.Current.Activate();
|
||||
if (Window.Current != null)
|
||||
Window.Current.Activate();
|
||||
|
||||
Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(e.Arguments);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ namespace NmeaParser.Tests
|
|||
{
|
||||
[TestMethod]
|
||||
[TestCategory("Device")]
|
||||
[Timeout(2000)]
|
||||
public async Task TestGpgsvGroupMessage()
|
||||
{
|
||||
var message = "$GPGSV,3,1,9,00,30,055,48,00,19,281,00,27,19,275,00,12,16,319,00*4C\n$GPGSV,3,2,9,00,30,055,48,00,19,281,00,27,19,275,00,12,16,319,00*4F\n$GPGSV,3,3,9,32,10,037,00,,,,,,,,,,,,*74";
|
||||
|
|
@ -26,7 +27,7 @@ namespace NmeaParser.Tests
|
|||
{
|
||||
Assert.IsTrue(e.IsMultipart, "IsMultiPart");
|
||||
Assert.IsInstanceOfType(e.Message, typeof(NmeaParser.Nmea.Gsv));
|
||||
var msg = e.Message as NmeaParser.Nmea.Gsv;
|
||||
var msg = (NmeaParser.Nmea.Gsv)e.Message;
|
||||
if (msg.TotalMessages == msg.MessageNumber)
|
||||
{
|
||||
Assert.IsNotNull(e.MessageParts);
|
||||
|
|
@ -50,6 +51,7 @@ namespace NmeaParser.Tests
|
|||
|
||||
[TestMethod]
|
||||
[TestCategory("Device")]
|
||||
[Timeout(2000)]
|
||||
public async Task TestMixedGsvGroupMessage()
|
||||
{
|
||||
// A group message can have multiple diffent GSV types.
|
||||
|
|
@ -67,7 +69,7 @@ $GAGSV,4,4,14,19,82,349,40,1,44,220,40,4,24,314,38*5F";
|
|||
{
|
||||
Assert.IsTrue(e.IsMultipart, "IsMultiPart");
|
||||
Assert.IsInstanceOfType(e.Message, typeof(NmeaParser.Nmea.Gsv));
|
||||
var msg = e.Message as NmeaParser.Nmea.Gsv;
|
||||
var msg = (NmeaParser.Nmea.Gsv)e.Message;
|
||||
if (msg.TotalMessages == msg.MessageNumber)
|
||||
{
|
||||
Assert.IsNotNull(e.MessageParts);
|
||||
|
|
@ -100,7 +102,8 @@ $GAGSV,4,4,14,19,82,349,40,1,44,220,40,4,24,314,38*5F";
|
|||
|
||||
[TestMethod]
|
||||
[TestCategory("Device")]
|
||||
public async Task TestInvalidGpgsvGroupMessage()
|
||||
[Timeout(2000)]
|
||||
public async Task TestInvalidGpgsvGroupMessage()
|
||||
{
|
||||
var message = "$GPGSV,3,2,9,00,30,055,48,00,19,281,00,27,19,275,00,12,16,319,00*4D\n$GPGSV,3,2,9,00,30,055,48,00,19,281,00,27,19,275,00,12,16,319,00*4F\n$GPGSV,3,3,9,32,10,037,00,,,,,,,,,,,,*74";
|
||||
NmeaDevice dev = new BufferedStringDevice(message);
|
||||
|
|
|
|||
Loading…
Reference in a new issue