dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.27k stars 4.73k forks source link

`IPGlobalProperties.DomainName` returns `"(none)"` on Linux #104882

Closed LukasGelke closed 2 weeks ago

LukasGelke commented 3 months ago

Description

as per Documentation, the property should either return the actual domain name or string.Empty.

Reproduction Steps

Expected behavior

either return the actual domain name or string.Empty

Actual behavior

returns "(none)"

image

Regression?

(we're using C# on Linux for the first time here, so no idea)

Known Workarounds

But this approach might be unreliable if the DNS is not reachable, or perhaps misconfigured(?)

Configuration

Local:

Build Server:

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

dotnet-policy-service[bot] commented 3 months ago

Tagging subscribers to this area: @dotnet/ncl See info in area-owners.md if you want to be subscribed.

wfurt commented 3 months ago

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.