Skip to content

Commit e494eec

Browse files
committed
Fix compilation error and stop using DEBUG macro where applicable
1 parent c06d513 commit e494eec

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

Common/Extensions/ConfigurationExtensions.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ public static class ConfigurationExtensions
77
{
88
public static WebApplicationBuilder RegisterCommonOpenShockOptions(this WebApplicationBuilder builder)
99
{
10-
#if DEBUG
11-
Console.WriteLine(builder.Configuration.GetDebugView());
12-
#endif
10+
if (builder.Environment.IsDevelopment())
11+
{
12+
Console.WriteLine(builder.Configuration.GetDebugView());
13+
}
14+
1315
builder.Services.Configure<DatabaseOptions>(builder.Configuration.GetRequiredSection(DatabaseOptions.SectionName));
1416
builder.Services.AddSingleton<IValidateOptions<DatabaseOptions>, DatabaseOptionsValidator>();
1517

Cron/Program.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Hangfire.PostgreSql;
33
using OpenShock.Common;
44
using OpenShock.Common.Extensions;
5+
using OpenShock.Cron;
56
using OpenShock.Cron.Utils;
67

78
var builder = OpenShockApplication.CreateDefaultBuilder<Program>(args);
@@ -22,15 +23,13 @@
2223

2324
app.UseCommonOpenShockMiddleware();
2425

25-
app.UseHangfireDashboard(options: new DashboardOptions
26+
var hangfireOptions = new DashboardOptions();
27+
if (app.Environment.IsProduction())
2628
{
27-
#if !DEBUG
28-
AsyncAuthorization =
29-
[
30-
new DashboardAdminAuth()
31-
]
32-
#endif
33-
});
29+
hangfireOptions.AsyncAuthorization = [ new DashboardAdminAuth() ];
30+
}
31+
32+
app.UseHangfireDashboard(options: hangfireOptions);
3433

3534
var jobManager = app.Services.GetRequiredService<IRecurringJobManagerV2>();
3635
foreach (var cronJob in CronJobCollector.GetAllCronJobs())

0 commit comments

Comments
 (0)