Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce HostName to EnvironmentInfo. #4550

Merged
merged 2 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion samples/aspnetapp/aspnetapp/EnvironmentInfo.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Net;
using System.Runtime.InteropServices;

public struct EnvironmentInfo
Expand Down Expand Up @@ -38,10 +39,10 @@ public EnvironmentInfo()
public long TotalAvailableMemoryBytes { get; }
public long MemoryLimit { get; }
public long MemoryUsage { get; }
public string HostName => Dns.GetHostName();

private static long GetBestValue(string[] paths)
{
string value = string.Empty;
foreach (string path in paths)
{
if (Path.Exists(path) &&
Expand Down
4 changes: 3 additions & 1 deletion samples/dotnetapp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Net;
using System.Runtime.InteropServices;
using static System.Console;

Expand Down Expand Up @@ -55,6 +56,7 @@ 8b 42 8b d8 42 42 42 8PP!!!!!!! 42
WriteLine($"{nameof(RuntimeInformation.OSArchitecture)}: {RuntimeInformation.OSArchitecture}");
WriteLine($"{nameof(Environment.ProcessorCount)}: {Environment.ProcessorCount}");
WriteLine($"{nameof(GCMemoryInfo.TotalAvailableMemoryBytes)}: {totalMemoryBytes} ({GetInBestUnit(totalMemoryBytes)})");
WriteLine($"HostName : {Dns.GetHostName()}");

string[] memoryLimitPaths = new string[]
{
Expand Down