diff --git a/Net/DhcpClient.cs b/Net/DhcpClient.cs
index 9c4a9229..86259383 100644
--- a/Net/DhcpClient.cs
+++ b/Net/DhcpClient.cs
@@ -31,7 +31,7 @@ public class DhcpClient : IDisposable
/// Occurs when the value related to a has changed.
/// Use the to set the list of identifiers that are watched.
///
- public event Action ParamChanged;
+ public event Action? ParamChanged;
///
/// Specifies whether or not the client may assume that all subnets of the IP network to which the client is connected use the same MTU
@@ -59,7 +59,7 @@ public class DhcpClient : IDisposable
/// Identifies a bootstrap file. If supported by the client, it should have the same effect as the filename declaration. BOOTP clients
/// are unlikely to support this option. Some DHCP clients will support it, and others actually require it.
///
- public string BootfileName => GetParam(DHCP_OPTION_ID.OPTION_BOOTFILE_NAME);
+ public string? BootfileName => GetParam(DHCP_OPTION_ID.OPTION_BOOTFILE_NAME);
/// This option specifies the length in 512-octet blocks of the default boot image for the client.
public ushort BootFileSize => GetParam(DHCP_OPTION_ID.OPTION_BOOT_FILE_SIZE);
@@ -81,8 +81,8 @@ public class DhcpClient : IDisposable
{
ClearListeners();
updateList.Set();
- if (value is null || value.Length == 0) return;
- string adapter = Adapter;
+ string? adapter = Adapter;
+ if (value is null || value.Length == 0 || adapter is null) return;
foreach (DHCP_OPTION_ID id in value)
{
if (DhcpRegisterParamChange(DHCPCAPI_REGISTER_HANDLE_EVENT, default, adapter, default, DHCPCAPI_PARAMS_ARRAY.Make(out _, id), out HEVENT hEvt).Succeeded)
@@ -97,20 +97,20 @@ public class DhcpClient : IDisposable
///
/// Class identifier (ID) that should be used if DHCP INFORM messages are being transmitted onto the network. This value is optional.
///
- public byte[] ClassId { get; set; }
+ public byte[]? ClassId { get; set; }
///
/// This option is used by some DHCP clients as a way for users to specify identifying information to the client. This can be used in a
/// similar way to the vendor-class-identifier option, but the value of the option is specified by the user, not the vendor. Most recent
/// DHCP clients have a way in the user interface to specify the value for this identifier, usually as a text string.
///
- public string ClientClassInfo => GetParam(DHCP_OPTION_ID.OPTION_CLIENT_CLASS_INFO);
+ public string? ClientClassInfo => GetParam(DHCP_OPTION_ID.OPTION_CLIENT_CLASS_INFO);
///
/// This option can be used to specify a DHCP client identifier in a host declaration, so that dhcpd can find the host record by matching
/// against the client identifier.
///
- public string ClientId => GetParam(DHCP_OPTION_ID.OPTION_CLIENT_ID);
+ public string? ClientId => GetParam(DHCP_OPTION_ID.OPTION_CLIENT_ID);
///
/// The cookie server option specifies a list of RFC 865 cookie servers available to the client. Servers should be listed in order of preference.
@@ -121,7 +121,7 @@ public class DhcpClient : IDisposable
public byte DefaultTTL => GetParam(DHCP_OPTION_ID.OPTION_DEFAULT_TTL);
/// This option specifies the domain name that client should use when resolving hostnames via the Domain Name System.
- public string DomainName => GetParam(DHCP_OPTION_ID.OPTION_DOMAIN_NAME);
+ public string? DomainName => GetParam(DHCP_OPTION_ID.OPTION_DOMAIN_NAME);
///
/// The domain-name-servers option specifies a list of Domain Name System (STD 13, RFC 1035) name servers available to the client.
@@ -140,14 +140,14 @@ public class DhcpClient : IDisposable
/// This option specifies the name of a file containing additional options to be interpreted according to the DHCP option format as
/// specified in RFC2132.
///
- public string ExtensionsPath => GetParam(DHCP_OPTION_ID.OPTION_EXTENSIONS_PATH);
+ public string? ExtensionsPath => GetParam(DHCP_OPTION_ID.OPTION_EXTENSIONS_PATH);
///
/// This option specifies the name of the client. The name may or may not be qualified with the local domain name (it is preferable to
/// use the domain-name option to specify the domain name). See RFC 1035 for character set restrictions. This option is only honored by
/// dhclient-script(8) if the hostname for the client machine is not set.
///
- public string HostName => GetParam(DHCP_OPTION_ID.OPTION_HOST_NAME);
+ public string? HostName => GetParam(DHCP_OPTION_ID.OPTION_HOST_NAME);
///
/// The ien116-name-servers option specifies a list of IEN 116 name servers available to the client. Servers should be listed in order of preference.
@@ -155,7 +155,7 @@ public class DhcpClient : IDisposable
public IPAddress[] IEN116NameServers => ToIP(GetParam(DHCP_OPTION_ID.OPTION_IEN116_NAME_SERVERS));
/// The Internet Explorer proxy.
- public string IEProxy => GetParam(DHCP_OPTION_ID.OPTION_MSFT_IE_PROXY);
+ public string? IEProxy => GetParam(DHCP_OPTION_ID.OPTION_MSFT_IE_PROXY);
///
/// The impress-server option specifies a list of Imagen Impress servers available to the client. Servers should be listed in order of preference.
@@ -197,13 +197,13 @@ public class DhcpClient : IDisposable
/// This option specifies the path-name of a file to which the client’s core image should be dumped in the event the client crashes. The
/// path is formatted as a character string consisting of characters from the NVT ASCII character set.
///
- public string MeritDumpFile => GetParam(DHCP_OPTION_ID.OPTION_MERIT_DUMP_FILE);
+ public string? MeritDumpFile => GetParam(DHCP_OPTION_ID.OPTION_MERIT_DUMP_FILE);
///
/// This option is used by a DHCP server to provide an error message to a DHCP client in a DHCPNAK message in the event of a failure. A
/// client may use this option in a DHCPDECLINE message to indicate why the client declined the offered parameters.
///
- public string Message => GetParam(DHCP_OPTION_ID.OPTION_MESSAGE);
+ public string? Message => GetParam(DHCP_OPTION_ID.OPTION_MESSAGE);
///
/// This option, when sent by the client, specifies the maximum size of any response that the server sends to the client. When specified
@@ -239,7 +239,7 @@ public class DhcpClient : IDisposable
/// The NetBIOS scope option specifies the NetBIOS over TCP/IP scope parameter for the client as specified in RFC 1001/1002. See RFC1001,
/// RFC1002, and RFC1035 for character-set restrictions.
///
- public string NetBIOSScopeOption => GetParam(DHCP_OPTION_ID.OPTION_NETBIOS_SCOPE_OPTION);
+ public string? NetBIOSScopeOption => GetParam(DHCP_OPTION_ID.OPTION_NETBIOS_SCOPE_OPTION);
///
/// The netinfo-server-address option has not been described in any RFC, but has been allocated (and is claimed to be in use) by Apple
@@ -252,7 +252,7 @@ public class DhcpClient : IDisposable
/// This option specifies the name of the client’s NIS (Sun Network Information Services) domain. The domain is formatted as a character
/// string consisting of characters from the NVT ASCII character set.
///
- public string NetworkInfoServiceDomain => GetParam(DHCP_OPTION_ID.OPTION_NETWORK_INFO_SERVICE_DOM);
+ public string? NetworkInfoServiceDomain => GetParam(DHCP_OPTION_ID.OPTION_NETWORK_INFO_SERVICE_DOM);
///
/// The NNTP server option specifies a list of NNTP servers available to the client. Servers should be listed in order of preference.
@@ -276,7 +276,7 @@ public class DhcpClient : IDisposable
/// specified options. This can be used to force a client to take options that it hasn’t requested, and it can also be used to tailor the
/// response of the DHCP server for clients that may need a more limited set of options than those the server would normally return.
///
- public byte[] ParameterRequestList => GetParam(DHCP_OPTION_ID.OPTION_PARAMETER_REQUEST_LIST);
+ public byte[] ParameterRequestList => GetParam(DHCP_OPTION_ID.OPTION_PARAMETER_REQUEST_LIST) ?? new byte[0];
///
/// This option specifies the timeout (in seconds) to use when aging Path MTU values discovered by the mechanism defined in RFC 1191.
@@ -287,7 +287,7 @@ public class DhcpClient : IDisposable
/// This option specifies a table of MTU sizes to use when performing Path MTU Discovery as defined in RFC 1191. The table is formatted
/// as a list of 16-bit unsigned integers, ordered from smallest to largest. The minimum MTU value cannot be smaller than 68.
///
- public ushort[] PathMTUPlateauTable => GetParam(DHCP_OPTION_ID.OPTION_PMTU_PLATEAU_TABLE);
+ public ushort[] PathMTUPlateauTable => GetParam(DHCP_OPTION_ID.OPTION_PMTU_PLATEAU_TABLE) ?? new ushort[0];
///
/// This option specifies whether or not the client should perform subnet mask discovery using ICMP. A value of false indicates that the
@@ -344,7 +344,7 @@ public class DhcpClient : IDisposable
/// This option specifies the path-name that contains the client’s root disk. The path is formatted as a character string consisting of
/// characters from the NVT ASCII character set.
///
- public string RootDisk => GetParam(DHCP_OPTION_ID.OPTION_ROOT_DISK);
+ public string? RootDisk => GetParam(DHCP_OPTION_ID.OPTION_ROOT_DISK);
///
/// The routers option specifies a list of IP addresses for routers on the client’s subnet. Routers should be listed in order of preference.
@@ -358,7 +358,7 @@ public class DhcpClient : IDisposable
/// GUID of the adapter on which requested data is being made. Must be under 256 characters. If this value is , the
/// first adapter with an address supplied via DHCP will be used.
///
- public string SelectedAdapterId { get; set; }
+ public string? SelectedAdapterId { get; set; }
///
///
@@ -405,7 +405,7 @@ public class DhcpClient : IDisposable
/// This option is used to identify a TFTP server and, if supported by the client, should have the same effect as the server-name
/// declaration. BOOTP clients are unlikely to support this option. Some DHCP clients will support it, and others actually require it.
///
- public string TFTPServerName => GetParam(DHCP_OPTION_ID.OPTION_TFTP_SERVER_NAME);
+ public string? TFTPServerName => GetParam(DHCP_OPTION_ID.OPTION_TFTP_SERVER_NAME);
/// The time-offset option specifies the offset of the client’s subnet in seconds from Coordinated Universal Time (UTC).
public DateTimeOffset TimeOffset => new(0, TimeSpan.FromSeconds(GetParam(DHCP_OPTION_ID.OPTION_TIME_OFFSET)));
@@ -442,7 +442,7 @@ public class DhcpClient : IDisposable
/// vendor-encapsulated-options option. Please see the VENDOR ENCAPSULATED OPTIONS section later in this manual page for further information.
///
///
- public string VendorSpecInfo => GetParam(DHCP_OPTION_ID.OPTION_VENDOR_SPEC_INFO);
+ public string? VendorSpecInfo => GetParam(DHCP_OPTION_ID.OPTION_VENDOR_SPEC_INFO);
///
/// This option specifies a list of systems that are running the X Window System Display Manager and are available to the client.
@@ -455,17 +455,18 @@ public class DhcpClient : IDisposable
///
public IPAddress[] XwindowFontServer => ToIP(GetParam(DHCP_OPTION_ID.OPTION_XWINDOW_FONT_SERVER));
- internal static NetworkInterface CurrentAdapter => NetworkInterface.GetAllNetworkInterfaces().
+ internal static NetworkInterface? CurrentAdapter => NetworkInterface.GetAllNetworkInterfaces().
Where(i => i.NetworkInterfaceType == NetworkInterfaceType.Ethernet && i.OperationalStatus == OperationalStatus.Up &&
i.Supports(NetworkInterfaceComponent.IPv4) && (i.GetIPProperties()?.GetIPv4Properties().IsDhcpEnabled ?? false)).
FirstOrDefault();
- internal string Adapter => SelectedAdapterId ?? CurrentAdapter?.Id;
+ internal string? Adapter => SelectedAdapterId ?? CurrentAdapter?.Id;
/// Gets the original subnet mask.
/// The retrieved subnet mask.
public IPAddress GetOriginalSubnetMask()
{
+ if (Adapter is null) return IPAddress.None;
DhcpGetOriginalSubnetMask(Adapter, out DHCP_IP_ADDRESS mask);
return new(mask.value);
}
@@ -494,16 +495,17 @@ public class DhcpClient : IDisposable
paramChgEvents.Clear();
}
- private T GetParam(DHCP_OPTION_ID optionId)
+ private T? GetParam(DHCP_OPTION_ID optionId)
{
- using SafeCoTaskMemHandle pClassIdData = new(ClassId);
+ string? adapter = Adapter ?? throw new InvalidOperationException("No adapter selected.");
+
+ using SafeCoTaskMemHandle pClassIdData = ClassId is null ? SafeCoTaskMemHandle.Null : new(ClassId);
using SafeCoTaskMemStruct pClass = (DHCPCAPI_CLASSID?)(ClassId is null ? null : new DHCPCAPI_CLASSID() { nBytesData = (uint)ClassId.Length, Data = pClassIdData });
DHCPCAPI_PARAMS_ARRAY sendParams = new();
- DHCPCAPI_PARAMS_ARRAY reqParams = DHCPCAPI_PARAMS_ARRAY.Make(out SafeNativeArray pparam, optionId);
+ DHCPCAPI_PARAMS_ARRAY reqParams = DHCPCAPI_PARAMS_ARRAY.Make(out SafeNativeArray? pparam, optionId);
uint sz = 0;
- string adapter = Adapter;
DhcpRequestParams(DHCPCAPI_REQUEST.DHCPCAPI_REQUEST_SYNCHRONOUS, default, adapter, pClass, sendParams, reqParams, IntPtr.Zero, ref sz, null).ThrowUnless(Win32Error.ERROR_MORE_DATA);
using SafeCoTaskMemHandle buffer = new(sz);
@@ -512,12 +514,12 @@ public class DhcpClient : IDisposable
if (sz == 0)
return default;
- DHCPAPI_PARAMS p = pparam[0];
+ DHCPAPI_PARAMS p = pparam?[0] ?? default;
if (typeof(T).IsArray)
{
- Type elemType = typeof(T).GetElementType();
+ Type elemType = typeof(T).GetElementType()!;
System.Diagnostics.Debug.WriteLine($"Array: type={elemType.Name}, elemSz={InteropExtensions.SizeOf(elemType)}, memSz={sz}");
- return (T)(object)p.Data.ToArray(elemType, sz / InteropExtensions.SizeOf(elemType), 0, sz);
+ return (T)(object)p.Data.ToArray(elemType, sz / InteropExtensions.SizeOf(elemType), 0, sz)!;
}
else
{
@@ -528,7 +530,7 @@ public class DhcpClient : IDisposable
private static uint ThreadProc(IntPtr hgc)
{
- var c = (DhcpClient)GCHandle.FromIntPtr(hgc).Target;
+ var c = (DhcpClient)GCHandle.FromIntPtr(hgc).Target!;
HEVENT[] hevts;
RebuildList();
do
@@ -553,7 +555,7 @@ public class DhcpClient : IDisposable
void RebuildList() => hevts = c.paramChgEvents.Keys.Concat(new HEVENT[] { c.closing, c.updateList }).ToArray();
}
- private IPAddress[] ToIP(uint[] ips) => ips is null ? new IPAddress[0] : Array.ConvertAll(ips, i => new IPAddress(i));
+ private IPAddress[] ToIP(uint[]? ips) => ips is null ? new IPAddress[0] : Array.ConvertAll(ips, i => new IPAddress(i));
internal class DhcpInit
{
diff --git a/Net/DistributedRoutingTable.cs b/Net/DistributedRoutingTable.cs
index 560a1edb..438218df 100644
--- a/Net/DistributedRoutingTable.cs
+++ b/Net/DistributedRoutingTable.cs
@@ -65,14 +65,14 @@ public class CustomDnsBootstapper : DrtCustomBootstrapProvider
}
}
- if (!CallbackComplete.IsInvalid && (m_hCallbackComplete != CallbackComplete))
+ if (!CallbackComplete.IsInvalid && !Equals(CallbackComplete, m_hCallbackComplete))
{
// This thread was not the first to call EndResolve, so its event is not in use, release it (m_hCallbackComplete is released in
// the destructor)
CallbackComplete.Dispose();
}
- if (fWaitForCallback && m_hCallbackComplete != null)
+ if (fWaitForCallback && m_hCallbackComplete is not null)
{
WaitForSingleObject(m_hCallbackComplete, INFINITE);
}
@@ -173,7 +173,7 @@ public class CustomDnsBootstapper : DrtCustomBootstrapProvider
lock (m_lock)
{
- if (m_hCallbackComplete != null && !m_hCallbackComplete.IsInvalid)
+ if (m_hCallbackComplete is not null && !m_hCallbackComplete.IsInvalid)
{
// Notify EndResolve that callbacks have completed
m_hCallbackComplete.Set();
@@ -287,21 +287,21 @@ public class DistributedRoutingTable : IDisposable
{
var Drt = (DistributedRoutingTable?)GCHandle.FromIntPtr(Param).Target;
- HRESULT hr = DrtGetEventDataSize(Drt?.hDrt, out var ulDrtEventDataLen);
+ HRESULT hr = DrtGetEventDataSize(Drt?.hDrt ?? HDRT.NULL, out var ulDrtEventDataLen);
if (hr.Failed)
{
if (hr != HRESULT.DRT_E_NO_MORE)
- throw hr.GetException();
+ throw hr.GetException()!;
goto Cleanup;
}
using (SafeCoTaskMemStruct pEventData = new(ulDrtEventDataLen))
{
- hr = DrtGetEventData(Drt?.hDrt, ulDrtEventDataLen, pEventData);
+ hr = DrtGetEventData(Drt?.hDrt ?? HDRT.NULL, ulDrtEventDataLen, pEventData);
if (hr.Failed)
{
if (hr != HRESULT.DRT_E_NO_MORE)
- throw hr.GetException();
+ throw hr.GetException()!;
goto Cleanup;
}
@@ -374,7 +374,7 @@ public class DrtBootstrapProvider : IDisposable
get
{
Win32Error.ThrowLastErrorIfFalse(GetComputerNameEx(COMPUTER_NAME_FORMAT.ComputerNameDnsFullyQualified, out string? name));
- return name;
+ return name!;
}
}
@@ -585,8 +585,8 @@ public class DrtLeafSetKeyChangeEventArgs : DrtEventArgs
internal DrtLeafSetKeyChangeEventArgs(in DRT_EVENT_DATA data) : base(data)
{
Type = data.union.leafsetKeyChange.change;
- LocalKey = (byte[])data.union.leafsetKeyChange.localKey;
- RemoteKey = (byte[])data.union.leafsetKeyChange.remoteKey;
+ LocalKey = (byte[])data.union.leafsetKeyChange.localKey!;
+ RemoteKey = (byte[])data.union.leafsetKeyChange.remoteKey!;
}
/// Specifies the local key associated with the leaf set that has changed.
@@ -606,7 +606,7 @@ public class DrtRegistrationStateChangeEventArgs : DrtEventArgs
internal DrtRegistrationStateChangeEventArgs(in DRT_EVENT_DATA data) : base(data)
{
State = data.union.registrationStateChange.state;
- LocalKey = (byte[])data.union.registrationStateChange.localKey;
+ LocalKey = (byte[])data.union.registrationStateChange.localKey!;
}
/// Specifies the local key associated with the registration that has changed.
@@ -1014,7 +1014,7 @@ public abstract class DrtCustomSecurityProvider : DrtSecurityProvider
}
private HRESULT InternalDecryptData(IntPtr pvContext, in DRT_DATA pKeyToken, IntPtr pvKeyContext, uint dwBuffers, DRT_DATA[] pData) =>
- DecryptData((byte[])pKeyToken, pvKeyContext, Array.ConvertAll(pData, p => (byte[])p));
+ DecryptData((byte[])pKeyToken!, pvKeyContext, Array.ConvertAll(pData, p => (byte[])p!)!);
private void InternalDetach(IntPtr pvContext)
{
@@ -1024,7 +1024,7 @@ public abstract class DrtCustomSecurityProvider : DrtSecurityProvider
private HRESULT InternalEncryptData(IntPtr pvContext, in DRT_DATA pRemoteCredential, uint dwBuffers, DRT_DATA[] pDataBuffers, DRT_DATA[] pEncryptedBuffers, out DRT_DATA pKeyToken)
{
- var hr = EncryptData((byte[])pRemoteCredential, Array.ConvertAll(pDataBuffers, p => (byte[])p), Array.ConvertAll(pEncryptedBuffers, p => (byte[])p), out byte[]? pkt);
+ var hr = EncryptData((byte[])pRemoteCredential!, Array.ConvertAll(pDataBuffers, p => (byte[])p!)!, Array.ConvertAll(pEncryptedBuffers, p => (byte[])p!), out byte[]? pkt);
pKeyToken = ToData(pkt);
return hr;
}
@@ -1044,8 +1044,8 @@ public abstract class DrtCustomSecurityProvider : DrtSecurityProvider
uint dwFlags, in DRT_DATA pKey, DRT_DATA* pPayload, IntPtr pAddressList, in DRT_DATA pNonce, out DRT_DATA pSecuredAddressPayload,
DRT_DATA* pClassifier, DRT_DATA* pSecuredPayload, DRT_DATA* pCertChain)
{
- HRESULT hr = SecureAndPackPayload(pvContext, bProtocolMajor, bProtocolMinor, dwFlags, (byte[])pKey, pPayload is null ? null : (byte[])(*pPayload),
- ToEndPoints(pAddressList.ToNullableStructure()), (byte[])pNonce, out byte[]? sap, out byte[]? cl, out byte[]? sp, out byte[]? cc);
+ HRESULT hr = SecureAndPackPayload(pvContext, bProtocolMajor, bProtocolMinor, dwFlags, (byte[])pKey!, pPayload is null ? null : (byte[])(*pPayload)!,
+ ToEndPoints(pAddressList.ToNullableStructure()), (byte[])pNonce!, out byte[]? sap, out byte[]? cl, out byte[]? sp, out byte[]? cc);
pSecuredAddressPayload = ToData(sap);
if (cl is not null)
*pClassifier = ToData(cl);
@@ -1058,22 +1058,22 @@ public abstract class DrtCustomSecurityProvider : DrtSecurityProvider
private HRESULT InternalSignData(IntPtr pvContext, uint dwBuffers, DRT_DATA[] pDataBuffers, out DRT_DATA pKeyIdentifier, out DRT_DATA pSignature)
{
- HRESULT hr = SignData(Array.ConvertAll(pDataBuffers, b => (byte[])b), out byte[]? id, out byte[]? sig);
+ HRESULT hr = SignData(Array.ConvertAll(pDataBuffers, b => (byte[])b!)!, out byte[]? id, out byte[]? sig);
pKeyIdentifier = ToData(id);
pSignature = ToData(sig);
return hr;
}
private HRESULT InternalUnregisterKey(IntPtr pvContext, in DRT_DATA pKey, IntPtr pvKeyContext) =>
- UnregisterKey((byte[])pKey);
+ UnregisterKey((byte[])pKey!);
private unsafe HRESULT InternalValidateAndUnpackPayload(IntPtr pvContext, in DRT_DATA pSecuredAddressPayload, DRT_DATA* pCertChain,
DRT_DATA* pClassifier, DRT_DATA* pNonce, DRT_DATA* pSecuredPayload, byte* pbProtocolMajor, byte* pbProtocolMinor,
out DRT_DATA pKey, DRT_DATA* pPayload, CERT_PUBLIC_KEY_INFO** ppPublicKey, void** ppAddressList, out uint pdwFlags)
{
- HRESULT hr = ValidateAndUnpackPayload(pSecuredAddressPayload, pCertChain is null ? null : (byte[])(*pCertChain),
- pClassifier is null ? null : (byte[])(*pClassifier), pNonce is null ? null : (byte[])(*pNonce),
- pSecuredPayload is null ? null : (byte[])(*pSecuredPayload), out byte maj, out byte min, out byte[]? k,
+ HRESULT hr = ValidateAndUnpackPayload(pSecuredAddressPayload!, pCertChain is null ? null : (byte[])(*pCertChain)!,
+ pClassifier is null ? null : (byte[])(*pClassifier)!, pNonce is null ? null : (byte[])(*pNonce)!,
+ pSecuredPayload is null ? null : (byte[])(*pSecuredPayload)!, out byte maj, out byte min, out byte[]? k,
out byte[]? pl, out SafeCoTaskMemStruct? pk, out IPEndPoint[]? al, out pdwFlags);
*pbProtocolMajor = maj;
*pbProtocolMinor = min;
@@ -1086,10 +1086,10 @@ public abstract class DrtCustomSecurityProvider : DrtSecurityProvider
}
private HRESULT InternalValidateRemoteCredential(IntPtr pvContext, in DRT_DATA pRemoteCredential) =>
- ValidateRemoteCredential((byte[])pRemoteCredential);
+ ValidateRemoteCredential((byte[])pRemoteCredential!);
private HRESULT InternalVerifyData(IntPtr pvContext, uint dwBuffers, DRT_DATA[] pDataBuffers, in DRT_DATA pRemoteCredentials, in DRT_DATA pKeyIdentifier, in DRT_DATA pSignature) =>
- VerifyData(Array.ConvertAll(pDataBuffers, b => (byte[])b), (byte[])pRemoteCredentials, (byte[])pKeyIdentifier, (byte[])pSignature);
+ VerifyData(Array.ConvertAll(pDataBuffers, b => (byte[])b!), (byte[])pRemoteCredentials!, (byte[])pKeyIdentifier!, (byte[])pSignature!);
}
/*
diff --git a/PInvoke/Drt/Drt.cs b/PInvoke/Drt/Drt.cs
index e61fcc96..684ed072 100644
--- a/PInvoke/Drt/Drt.cs
+++ b/PInvoke/Drt/Drt.cs
@@ -769,7 +769,7 @@ public static partial class Drt
// https://learn.microsoft.com/en-us/windows/win32/api/drt/nf-drt-drtcreatenullsecurityprovider
// HRESULT DrtCreateNullSecurityProvider( [out] DRT_SECURITY_PROVIDER **ppSecurityProvider );
[PInvokeData("drt.h", MSDNShortId = "NF:drt.DrtCreateNullSecurityProvider")]
- [DllImport(Lib_Drt, SetLastError = false, ExactSpelling = true)]
+ [DllImport(Lib_DrtProv, SetLastError = false, ExactSpelling = true)]
public static extern HRESULT DrtCreateNullSecurityProvider(out IntPtr ppSecurityProvider);
///
diff --git a/UnitTests/Net/NetTests.cs b/UnitTests/Net/NetTests.cs
index c76683c6..be24dd1e 100644
--- a/UnitTests/Net/NetTests.cs
+++ b/UnitTests/Net/NetTests.cs
@@ -4,9 +4,9 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
-using System.Xml.Linq;
using Vanara.Net;
using static Vanara.PInvoke.Dhcp;
+using static Vanara.PInvoke.FirewallApi;
namespace Vanara.PInvoke.Tests;
@@ -62,7 +62,7 @@ public class NetTests
{
client.ChangeEventIds = new[] { DHCP_OPTION_ID.OPTION_DEFAULT_TTL, DHCP_OPTION_ID.OPTION_LEASE_TIME, DHCP_OPTION_ID.OPTION_MESSAGE };
Thread.Sleep(1000);
- client.ChangeEventIds = null;
+ client.ChangeEventIds = new DHCP_OPTION_ID[0];
Thread.Sleep(1000);
}
finally
@@ -76,7 +76,7 @@ public class NetTests
{
using Firewall fw = new();
if (TestHelper.IsElevated)
- fw.AddApp(Process.GetCurrentProcess().ProcessName, Process.GetCurrentProcess().MainModule.FileName);
+ fw.AddApp(Process.GetCurrentProcess().ProcessName, Process.GetCurrentProcess().MainModule!.FileName!);
try
{
using DistributedRoutingTable drt = new(null, new(null, 0));
@@ -88,7 +88,7 @@ public class NetTests
}
finally
{
- try { fw.RemoveApp(Process.GetCurrentProcess().MainModule.FileName); } catch { }
+ try { fw.RemoveApp(Process.GetCurrentProcess()!.MainModule!.FileName!); } catch { }
}
}