Skip to content
Merged
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
14 changes: 11 additions & 3 deletions src/Verify/Naming/Namer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ static Namer()
Architecture = RuntimeInformation
.ProcessArchitecture.ToString()
.ToLowerInvariant();
OperatingSystemPlatform = GetOsPlatform();
}

static string GetOsPlatform()
Expand Down Expand Up @@ -181,7 +180,7 @@ static string GetOsPlatform()
return "IOS";
}

throw new("Unknown OS");
throw new($"Unknown OS: {RuntimeInformation.OSDescription}. UniqueForOSPlatform cannot name this platform.");
}

public static string Runtime { get; }
Expand All @@ -190,7 +189,16 @@ static string GetOsPlatform()

public static string Architecture { get; }

public static string OperatingSystemPlatform { get; }
static string? operatingSystemPlatform;

/// <summary>
/// Resolved on demand rather than in the static constructor. GetOsPlatform throws for
/// any platform outside the handful it names, and VerifySettings creates a Namer, so
/// resolving eagerly failed every verification on an unrecognized platform
/// (FreeBSD, browser-wasm, tvOS) with a TypeInitializationException, even for tests
/// that never asked for UniqueForOSPlatform.
/// </summary>
public static string OperatingSystemPlatform => operatingSystemPlatform ??= GetOsPlatform();

internal Namer()
{
Expand Down
Loading