Skip to content

Commit b5b2615

Browse files
authored
Improvements in Network information (#162)
***NO_CI***
1 parent 537150b commit b5b2615

File tree

6 files changed

+84
-9
lines changed

6 files changed

+84
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,4 @@ paket-files/
253253

254254
#SoundCloud
255255
*.sonarqube/
256+
.sonarlint
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// Copyright (c) .NET Foundation and Contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
6+
using System.Runtime.CompilerServices;
7+
8+
namespace System.Net.NetworkInformation
9+
{
10+
/// <summary>
11+
/// Provides information about the network connectivity of the local computer.
12+
/// </summary>
13+
public static class IPGlobalProperties
14+
{
15+
/// <summary>
16+
/// Gets the IP address of the network interface.
17+
/// </summary>
18+
/// <returns>An <see cref="IPAddress"/> if a valid IP address is available; otherwise, an <see cref="IPAddress.Any"/>.</returns>
19+
/// <remarks>
20+
/// This method is exclusive of .NET nanoFramework.
21+
/// </remarks>
22+
[MethodImpl(MethodImplOptions.InternalCall)]
23+
public extern static IPAddress GetIPAddress();
24+
}
25+
}

nanoFramework.System.Net/NetworkInformation/NetworkInterface.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ public class NetworkInterface
2222
[Flags]
2323
internal enum UpdateOperation : byte
2424
{
25-
Invalid = 0x00,
26-
Dns = 0x01,
27-
Dhcp = 0x02,
28-
DhcpRenew = 0x04,
29-
DhcpRelease = 0x08,
30-
Mac = 0x10,
25+
Invalid = 0x00,
26+
Dns = 0x01,
27+
Dhcp = 0x02,
28+
DhcpRenew = 0x04,
29+
DhcpRelease = 0x08,
30+
Mac = 0x10,
3131
}
3232

3333
private readonly int _interfaceIndex;
@@ -53,6 +53,13 @@ internal enum UpdateOperation : byte
5353

5454
private NetworkInterfaceType _networkInterfaceType;
5555

56+
/// <summary>
57+
/// Indicates whether any network connection is available.
58+
/// </summary>
59+
/// <returns><see langword="true"/> if a network connection is available; otherwise, <see langword="false"/>.</returns>
60+
[MethodImpl(MethodImplOptions.InternalCall)]
61+
public extern static bool GetIsNetworkAvailable();
62+
5663
/// <summary>
5764
/// Initializes a new instance of the <see cref="NetworkInterface"/> class.
5865
/// </summary>

nanoFramework.System.Net/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
////////////////////////////////////////////////////////////////
1414
// update this whenever the native assembly signature changes //
15-
[assembly: AssemblyNativeVersion("100.1.3.1")]
15+
[assembly: AssemblyNativeVersion("100.1.3.2")]
1616
////////////////////////////////////////////////////////////////
1717

1818
// Setting ComVisible to false makes the types in this assembly not visible

nanoFramework.System.Net/System.Net.nfproj

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,51 @@
3232
<NF_GenerateStubsDirectory>bin\$(Configuration)\Stubs</NF_GenerateStubsDirectory>
3333
<NF_GenerateSkeletonProjectName>sys_net_native</NF_GenerateSkeletonProjectName>
3434
<Name>System.Net</Name>
35+
<CodeAnalysisRuleSet>..\.sonarlint\nanoframework_lib-nanoframework.system.netcsharp.ruleset</CodeAnalysisRuleSet>
3536
</PropertyGroup>
3637
<ItemGroup>
3738
<NFMDP_PE_ExcludeClassByName Include="ThisAssembly">
3839
<InProject>false</InProject>
3940
</NFMDP_PE_ExcludeClassByName>
41+
<NFMDP_PE_ExcludeClassByName Include="NetworkInformationOptions">
42+
<InProject>false</InProject>
43+
</NFMDP_PE_ExcludeClassByName>
44+
<NFMDP_PE_ExcludeClassByName Include="PhyProtocols">
45+
<InProject>false</InProject>
46+
</NFMDP_PE_ExcludeClassByName>
47+
<NFMDP_PE_ExcludeClassByName Include="SslProtocols">
48+
<InProject>false</InProject>
49+
</NFMDP_PE_ExcludeClassByName>
50+
<NFMDP_PE_ExcludeClassByName Include="SslVerification">
51+
<InProject>false</InProject>
52+
</NFMDP_PE_ExcludeClassByName>
53+
<NFMDP_PE_ExcludeClassByName Include="AddressFamily">
54+
<InProject>false</InProject>
55+
</NFMDP_PE_ExcludeClassByName>
56+
<NFMDP_PE_ExcludeClassByName Include="ProtocolFamily">
57+
<InProject>false</InProject>
58+
</NFMDP_PE_ExcludeClassByName>
59+
<NFMDP_PE_ExcludeClassByName Include="ProtocolType">
60+
<InProject>false</InProject>
61+
</NFMDP_PE_ExcludeClassByName>
62+
<NFMDP_PE_ExcludeClassByName Include="SelectMode">
63+
<InProject>false</InProject>
64+
</NFMDP_PE_ExcludeClassByName>
65+
<NFMDP_PE_ExcludeClassByName Include="SocketError">
66+
<InProject>false</InProject>
67+
</NFMDP_PE_ExcludeClassByName>
68+
<NFMDP_PE_ExcludeClassByName Include="SocketFlags">
69+
<InProject>false</InProject>
70+
</NFMDP_PE_ExcludeClassByName>
71+
<NFMDP_PE_ExcludeClassByName Include="SocketOptionLevel">
72+
<InProject>false</InProject>
73+
</NFMDP_PE_ExcludeClassByName>
74+
<NFMDP_PE_ExcludeClassByName Include="SocketOptionName">
75+
<InProject>false</InProject>
76+
</NFMDP_PE_ExcludeClassByName>
77+
<NFMDP_PE_ExcludeClassByName Include="SocketType">
78+
<InProject>false</InProject>
79+
</NFMDP_PE_ExcludeClassByName>
4080
</ItemGroup>
4181
<ItemGroup>
4282
<NFMDP_PE_LoadHints Include="..\packages\nanoFramework.CoreLibrary.1.10.1-preview.11\lib\mscorlib.dll">
@@ -57,6 +97,7 @@
5797
<Compile Include="IPEndPoint.cs" />
5898
<Compile Include="IPHostEntry.cs" />
5999
<Compile Include="NetworkInformation\AuthenticationType.cs" />
100+
<Compile Include="NetworkInformation\IPGlobalProperties.cs" />
60101
<Compile Include="NetworkInformation\RadioType.cs" />
61102
<Compile Include="NetworkInformation\EncryptionType.cs" />
62103
<Compile Include="NetworkInformation\NetworkInformationOptions.cs" />
@@ -93,6 +134,7 @@
93134
<None Include="packages.config" />
94135
</ItemGroup>
95136
<ItemGroup>
137+
<AdditionalFiles Include="..\.sonarlint\nanoframework_lib-nanoframework.system.net\CSharp\SonarLint.xml" Link="SonarLint.xml" />
96138
<Content Include="README.txt" />
97139
</ItemGroup>
98140
<ItemGroup>
@@ -122,4 +164,4 @@
122164
</PropertyGroup>
123165
<Error Condition="!Exists('..\packages\Nerdbank.GitVersioning.3.1.91\build\Nerdbank.GitVersioning.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Nerdbank.GitVersioning.3.1.91\build\Nerdbank.GitVersioning.targets'))" />
124166
</Target>
125-
</Project>
167+
</Project>

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3-
"version": "1.6.3-preview.{height}",
3+
"version": "1.6.4-preview.{height}",
44
"assemblyVersion": {
55
"precision": "revision"
66
},

0 commit comments

Comments
 (0)