github.com/anchore/syft@v1.38.2/syft/pkg/cataloger/dotnet/test-fixtures/image-net8-app-no-depjson/src/Program.cs (about)

     1  using System;
     2  using System.Net;
     3  using System.Runtime.InteropServices;
     4  using static System.Console;
     5  
     6  WriteLine("Runtime and Environment Information");
     7  
     8  // OS and .NET information
     9  WriteLine($"{nameof(RuntimeInformation.OSArchitecture)}: {RuntimeInformation.OSArchitecture}");
    10  WriteLine($"{nameof(RuntimeInformation.OSDescription)}: {RuntimeInformation.OSDescription}");
    11  WriteLine($"{nameof(RuntimeInformation.FrameworkDescription)}: {RuntimeInformation.FrameworkDescription}");
    12  WriteLine();
    13  
    14  // Environment information
    15  WriteLine($"{nameof(Environment.UserName)}: {Environment.UserName}");
    16  WriteLine($"HostName: {Dns.GetHostName()}");
    17  WriteLine($"{nameof(Environment.ProcessorCount)}: {Environment.ProcessorCount}");
    18  WriteLine();
    19  
    20  // Memory information
    21  WriteLine($"Available Memory (GC): {GetInBestUnit(GC.GetGCMemoryInfo().TotalAvailableMemoryBytes)}");
    22  
    23  string GetInBestUnit(long size)
    24  {
    25      const double Mebi = 1024 * 1024;
    26      const double Gibi = Mebi * 1024;
    27  
    28      if (size < Mebi) return $"{size} bytes";
    29      if (size < Gibi) return $"{size / Mebi:F} MiB";
    30      return $"{size / Gibi:F} GiB";
    31  }