diff --git a/src/ClaudeDo.Logging/BuildConfig.cs b/src/ClaudeDo.Logging/BuildConfig.cs new file mode 100644 index 0000000..2e13542 --- /dev/null +++ b/src/ClaudeDo.Logging/BuildConfig.cs @@ -0,0 +1,14 @@ +using System.Diagnostics; +using System.Reflection; + +namespace ClaudeDo.Logging; + +/// Runtime build-configuration detection — the replacement for #if DEBUG. +/// Debug builds compile with the JIT optimizer disabled; Release builds enable it. +public static class BuildConfig +{ + public static bool IsDebug { get; } = + Assembly.GetEntryAssembly() + ?.GetCustomAttribute() + ?.IsJITOptimizerDisabled ?? false; +} diff --git a/tests/ClaudeDo.Worker.Tests/Logging/BuildConfigTests.cs b/tests/ClaudeDo.Worker.Tests/Logging/BuildConfigTests.cs new file mode 100644 index 0000000..76d9293 --- /dev/null +++ b/tests/ClaudeDo.Worker.Tests/Logging/BuildConfigTests.cs @@ -0,0 +1,19 @@ +using System.Diagnostics; +using System.Reflection; +using ClaudeDo.Logging; + +namespace ClaudeDo.Worker.Tests.Logging; + +public sealed class BuildConfigTests +{ + [Fact] + public void IsDebug_MatchesEntryAssemblyDebuggableAttribute() + { + var entry = Assembly.GetEntryAssembly(); + var expected = entry? + .GetCustomAttribute() + ?.IsJITOptimizerDisabled ?? false; + + Assert.Equal(expected, BuildConfig.IsDebug); + } +}