From 325476f2937b4771da8bd7e8d68be2e9f2b9d0ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Thu, 18 Mar 2021 09:23:21 +0000 Subject: [PATCH] Improvements in Network information - Add GetIsNetworkAvailable to NetworkInformation. - Add IPGlobalProperties class implementing GetIPAddress. - Add sonarlint rules to solution. - Add several exclude rules to project file. - Bump version to 1.6.4-preview. - Bump AssemblyNativeVersion to 100.1.3.2. --- .gitignore | 1 + .../NetworkInformation/IPGlobalProperties.cs | 25 +++++++++++ .../NetworkInformation/NetworkInterface.cs | 19 +++++--- .../Properties/AssemblyInfo.cs | 2 +- nanoFramework.System.Net/System.Net.nfproj | 44 ++++++++++++++++++- version.json | 2 +- 6 files changed, 84 insertions(+), 9 deletions(-) create mode 100644 nanoFramework.System.Net/NetworkInformation/IPGlobalProperties.cs diff --git a/.gitignore b/.gitignore index ce3e1b1..36fda64 100644 --- a/.gitignore +++ b/.gitignore @@ -253,3 +253,4 @@ paket-files/ #SoundCloud *.sonarqube/ +.sonarlint diff --git a/nanoFramework.System.Net/NetworkInformation/IPGlobalProperties.cs b/nanoFramework.System.Net/NetworkInformation/IPGlobalProperties.cs new file mode 100644 index 0000000..2ad328d --- /dev/null +++ b/nanoFramework.System.Net/NetworkInformation/IPGlobalProperties.cs @@ -0,0 +1,25 @@ +// +// Copyright (c) .NET Foundation and Contributors +// See LICENSE file in the project root for full license information. +// + +using System.Runtime.CompilerServices; + +namespace System.Net.NetworkInformation +{ + /// + /// Provides information about the network connectivity of the local computer. + /// + public static class IPGlobalProperties + { + /// + /// Gets the IP address of the network interface. + /// + /// An if a valid IP address is available; otherwise, an . + /// + /// This method is exclusive of .NET nanoFramework. + /// + [MethodImpl(MethodImplOptions.InternalCall)] + public extern static IPAddress GetIPAddress(); + } +} diff --git a/nanoFramework.System.Net/NetworkInformation/NetworkInterface.cs b/nanoFramework.System.Net/NetworkInformation/NetworkInterface.cs index 77191d5..df292e8 100644 --- a/nanoFramework.System.Net/NetworkInformation/NetworkInterface.cs +++ b/nanoFramework.System.Net/NetworkInformation/NetworkInterface.cs @@ -22,12 +22,12 @@ public class NetworkInterface [Flags] internal enum UpdateOperation : byte { - Invalid = 0x00, - Dns = 0x01, - Dhcp = 0x02, - DhcpRenew = 0x04, - DhcpRelease = 0x08, - Mac = 0x10, + Invalid = 0x00, + Dns = 0x01, + Dhcp = 0x02, + DhcpRenew = 0x04, + DhcpRelease = 0x08, + Mac = 0x10, } private readonly int _interfaceIndex; @@ -53,6 +53,13 @@ internal enum UpdateOperation : byte private NetworkInterfaceType _networkInterfaceType; + /// + /// Indicates whether any network connection is available. + /// + /// if a network connection is available; otherwise, . + [MethodImpl(MethodImplOptions.InternalCall)] + public extern static bool GetIsNetworkAvailable(); + /// /// Initializes a new instance of the class. /// diff --git a/nanoFramework.System.Net/Properties/AssemblyInfo.cs b/nanoFramework.System.Net/Properties/AssemblyInfo.cs index fb40718..6215019 100644 --- a/nanoFramework.System.Net/Properties/AssemblyInfo.cs +++ b/nanoFramework.System.Net/Properties/AssemblyInfo.cs @@ -12,7 +12,7 @@ //////////////////////////////////////////////////////////////// // update this whenever the native assembly signature changes // -[assembly: AssemblyNativeVersion("100.1.3.1")] +[assembly: AssemblyNativeVersion("100.1.3.2")] //////////////////////////////////////////////////////////////// // Setting ComVisible to false makes the types in this assembly not visible diff --git a/nanoFramework.System.Net/System.Net.nfproj b/nanoFramework.System.Net/System.Net.nfproj index a92c29b..a08aaee 100644 --- a/nanoFramework.System.Net/System.Net.nfproj +++ b/nanoFramework.System.Net/System.Net.nfproj @@ -32,11 +32,51 @@ bin\$(Configuration)\Stubs sys_net_native System.Net + ..\.sonarlint\nanoframework_lib-nanoframework.system.netcsharp.ruleset false + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + @@ -57,6 +97,7 @@ + @@ -93,6 +134,7 @@ + @@ -122,4 +164,4 @@ - + \ No newline at end of file diff --git a/version.json b/version.json index 67fe77b..a51b395 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "1.6.3-preview.{height}", + "version": "1.6.4-preview.{height}", "assemblyVersion": { "precision": "revision" },