Closed LukasGelke closed 2 weeks ago
Tagging subscribers to this area: @dotnet/ncl See info in area-owners.md if you want to be subscribed.
This calls getdomainname
under the cover e.g. this is not DNS domain name. However the documentation is clear about empty string and we return null
on Linux. So we should ether update the code to fix the nullability annotation and documentation. I feel former would be easier and perhaps more appropriate.
Description
as per Documentation, the property should either return the actual domain name or
string.Empty
.Reproduction Steps
pwsh
[System.Net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties().DomainName
Expected behavior
either return the actual domain name or
string.Empty
Actual behavior
returns
"(none)"
Regression?
(we're using C# on Linux for the first time here, so no idea)
Known Workarounds
pwsh
$h = [System.Net.DNS]::GetHostname()
[System.Net.DNS]::GetHostEntry($h).HostName
BUILD-SERVER-LX.company.local
But this approach might be unreliable if the DNS is not reachable, or perhaps misconfigured(?)
Configuration
Local:
Linux MY-WORK-PC-123 4.4.0-19041-Microsoft #4355-Microsoft Thu Apr 12 17:37:00 PST 2024 x86_64 x86_64 x86_64 GNU/Linux
/etc/hosts
contains a line a la127.0.1.1 MY-WORK-PC-123.company.local MY-WORK-PC-123
(actual names replaced)Build Server:
Linux BUILD-SERVER-LX 5.15.0-113-generic #123-Ubuntu SMP Mon Jun 10 08:16:17 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
"BUILD-SERVER-LX.(none)"
, which was (with additional strings) passed tonew Uri(...)
This issue was caught by our tests (net6.0), but
[Environment]::Version
(pwsh
) shows 8.0.6 (ob both machines) and it experiences the same behavior (build server)Not sure if C# gets the information from the hosts file, just something i noticed. WSL re-creates the file upon restart, and on the build server I currently do not have sufficient permissions to change the host file.
Other information
No response