Skip to content

Commit

Permalink
File scoped namespace. (#938)
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle authored Nov 9, 2022
1 parent 082fdb7 commit c652b50
Show file tree
Hide file tree
Showing 2,288 changed files with 129,280 additions and 131,560 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
working-directory: backend/tests

- name: RUN TEST
uses: kohlerdominik/docker-run-action@v1.0.2
uses: kohlerdominik/docker-run-action@v1.1.0
with:
image: squidex/build
environment: |
Expand All @@ -124,7 +124,7 @@ jobs:
run: dotnet test /src/backend/tools/TestSuite/TestSuite.ApiTests/TestSuite.ApiTests.csproj --filter Category!=NotAutomated

- name: RUN TEST on path
uses: kohlerdominik/docker-run-action@v1.0.2
uses: kohlerdominik/docker-run-action@v1.1.0
with:
image: squidex/build
environment: |
Expand All @@ -138,7 +138,7 @@ jobs:
run: dotnet test /src/backend/tools/TestSuite/TestSuite.ApiTests/TestSuite.ApiTests.csproj --filter Category!=NotAutomated

- name: RUN TEST with dedicated collections
uses: kohlerdominik/docker-run-action@v1.0.2
uses: kohlerdominik/docker-run-action@v1.1.0
with:
image: squidex/build
environment: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
working-directory: backend/tests

- name: RUN TEST
uses: kohlerdominik/docker-run-action@v1.0.2
uses: kohlerdominik/docker-run-action@v1.1.0
with:
image: squidex/build
environment: |
Expand All @@ -107,7 +107,7 @@ jobs:
run: dotnet test /src/backend/tools/TestSuite/TestSuite.ApiTests/TestSuite.ApiTests.csproj --filter Category!=NotAutomated

- name: RUN TEST on path
uses: kohlerdominik/docker-run-action@v1.0.2
uses: kohlerdominik/docker-run-action@v1.1.0
with:
image: squidex/build
environment: |
Expand All @@ -121,7 +121,7 @@ jobs:
run: dotnet test /src/backend/tools/TestSuite/TestSuite.ApiTests/TestSuite.ApiTests.csproj --filter Category!=NotAutomated

- name: RUN TEST with dedicated collections
uses: kohlerdominik/docker-run-action@v1.0.2
uses: kohlerdominik/docker-run-action@v1.1.0
with:
image: squidex/build
environment: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,34 @@
using Squidex.Infrastructure;
using Squidex.Infrastructure.Plugins;

namespace Squidex.Extensions.APM.ApplicationInsights
namespace Squidex.Extensions.APM.ApplicationInsights;

public sealed class ApplicationInsightsPlugin : IPlugin
{
public sealed class ApplicationInsightsPlugin : IPlugin
private sealed class Configurator : ITelemetryConfigurator
{
private sealed class Configurator : ITelemetryConfigurator
{
private readonly IConfiguration config;
private readonly IConfiguration config;

public Configurator(IConfiguration config)
{
this.config = config;
}
public Configurator(IConfiguration config)
{
this.config = config;
}

public void Configure(TracerProviderBuilder builder)
public void Configure(TracerProviderBuilder builder)
{
builder.AddAzureMonitorTraceExporter(options =>
{
builder.AddAzureMonitorTraceExporter(options =>
{
config.GetSection("logging:applicationInsights").Bind(options);
});
}
config.GetSection("logging:applicationInsights").Bind(options);
});
}
}

public void ConfigureServices(IServiceCollection services, IConfiguration config)
public void ConfigureServices(IServiceCollection services, IConfiguration config)
{
if (config.GetValue<bool>("logging:applicationInsights:enabled"))
{
if (config.GetValue<bool>("logging:applicationInsights:enabled"))
{
services.AddSingleton<ITelemetryConfigurator,
Configurator>();
}
services.AddSingleton<ITelemetryConfigurator,
Configurator>();
}
}
}
45 changes: 22 additions & 23 deletions backend/extensions/Squidex.Extensions/APM/Otlp/OtlpPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,37 @@
using Squidex.Infrastructure;
using Squidex.Infrastructure.Plugins;

namespace Squidex.Extensions.APM.Otlp
namespace Squidex.Extensions.APM.Otlp;

public sealed class OtlpPlugin : IPlugin
{
public sealed class OtlpPlugin : IPlugin
private sealed class Configurator : ITelemetryConfigurator
{
private sealed class Configurator : ITelemetryConfigurator
private readonly IConfiguration config;

public Configurator(IConfiguration config)
{
private readonly IConfiguration config;
this.config = config;
}

public Configurator(IConfiguration config)
{
this.config = config;
}
public void Configure(TracerProviderBuilder builder)
{
// See: https://docs.microsoft.com/aspnet/core/grpc/troubleshoot#call-insecure-grpc-services-with-net-core-client
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);

public void Configure(TracerProviderBuilder builder)
builder.AddOtlpExporter(options =>
{
// See: https://docs.microsoft.com/aspnet/core/grpc/troubleshoot#call-insecure-grpc-services-with-net-core-client
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);

builder.AddOtlpExporter(options =>
{
config.GetSection("logging:otlp").Bind(options);
});
}
config.GetSection("logging:otlp").Bind(options);
});
}
}

public void ConfigureServices(IServiceCollection services, IConfiguration config)
public void ConfigureServices(IServiceCollection services, IConfiguration config)
{
if (config.GetValue<bool>("logging:otlp:enabled"))
{
if (config.GetValue<bool>("logging:otlp:enabled"))
{
services.AddSingleton<ITelemetryConfigurator,
Configurator>();
}
services.AddSingleton<ITelemetryConfigurator,
Configurator>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,58 +11,57 @@
using Squidex.Infrastructure;
using Squidex.Log;

namespace Squidex.Extensions.APM.Stackdriver
namespace Squidex.Extensions.APM.Stackdriver;

internal sealed class StackdriverExceptionHandler : ILogAppender
{
internal sealed class StackdriverExceptionHandler : ILogAppender
private readonly IContextExceptionLogger logger;
private readonly HttpContextWrapper httpContextWrapper;

public sealed class HttpContextWrapper : IContextWrapper
{
private readonly IContextExceptionLogger logger;
private readonly HttpContextWrapper httpContextWrapper;
private readonly IHttpContextAccessor httpContextAccessor;

public sealed class HttpContextWrapper : IContextWrapper
internal HttpContextWrapper(IHttpContextAccessor httpContextAccessor)
{
private readonly IHttpContextAccessor httpContextAccessor;

internal HttpContextWrapper(IHttpContextAccessor httpContextAccessor)
{
this.httpContextAccessor = httpContextAccessor;
}

public string GetHttpMethod()
{
return httpContextAccessor.HttpContext?.Request?.Method ?? string.Empty;
}

public string GetUri()
{
return httpContextAccessor.HttpContext?.Request?.GetDisplayUrl() ?? string.Empty;
}
this.httpContextAccessor = httpContextAccessor;
}

public string GetUserAgent()
{
return httpContextAccessor.HttpContext?.Request?.Headers["User-Agent"].ToString() ?? string.Empty;
}
public string GetHttpMethod()
{
return httpContextAccessor.HttpContext?.Request?.Method ?? string.Empty;
}

public StackdriverExceptionHandler(IContextExceptionLogger logger, IHttpContextAccessor httpContextAccessor)
public string GetUri()
{
this.logger = logger;
return httpContextAccessor.HttpContext?.Request?.GetDisplayUrl() ?? string.Empty;
}

httpContextWrapper = new HttpContextWrapper(httpContextAccessor);
public string GetUserAgent()
{
return httpContextAccessor.HttpContext?.Request?.Headers["User-Agent"].ToString() ?? string.Empty;
}
}

public void Append(IObjectWriter writer, SemanticLogLevel logLevel, Exception exception)
public StackdriverExceptionHandler(IContextExceptionLogger logger, IHttpContextAccessor httpContextAccessor)
{
this.logger = logger;

httpContextWrapper = new HttpContextWrapper(httpContextAccessor);
}

public void Append(IObjectWriter writer, SemanticLogLevel logLevel, Exception exception)
{
try
{
try
{
if (exception != null && exception is not DomainException && exception is not OperationCanceledException)
{
logger.Log(exception, httpContextWrapper);
}
}
catch
if (exception != null && exception is not DomainException && exception is not OperationCanceledException)
{
return;
logger.Log(exception, httpContextWrapper);
}
}
catch
{
return;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,54 +14,53 @@
using Squidex.Infrastructure.Plugins;
using Squidex.Log;

namespace Squidex.Extensions.APM.Stackdriver
namespace Squidex.Extensions.APM.Stackdriver;

public sealed class StackdriverPlugin : IPlugin
{
public sealed class StackdriverPlugin : IPlugin
private sealed class Configurator : ITelemetryConfigurator
{
private sealed class Configurator : ITelemetryConfigurator
{
private readonly string projectId;
private readonly string projectId;

public Configurator(string projectId)
{
this.projectId = projectId;
}

public void Configure(TracerProviderBuilder builder)
{
builder.UseStackdriverExporter(projectId);
}
public Configurator(string projectId)
{
this.projectId = projectId;
}

public void ConfigureServices(IServiceCollection services, IConfiguration config)
public void Configure(TracerProviderBuilder builder)
{
var isEnabled = config.GetValue<bool>("logging:stackdriver:enabled");
builder.UseStackdriverExporter(projectId);
}
}

if (!isEnabled)
{
return;
}
public void ConfigureServices(IServiceCollection services, IConfiguration config)
{
var isEnabled = config.GetValue<bool>("logging:stackdriver:enabled");

var projectId = config.GetValue<string>("logging:stackdriver:projectId");
if (!isEnabled)
{
return;
}

var projectId = config.GetValue<string>("logging:stackdriver:projectId");

if (string.IsNullOrWhiteSpace(projectId))
{
return;
}
if (string.IsNullOrWhiteSpace(projectId))
{
return;
}

services.AddSingleton<ITelemetryConfigurator>(
new Configurator(projectId));
services.AddSingleton<ITelemetryConfigurator>(
new Configurator(projectId));

services.AddSingleton<ILogAppender,
StackdriverSeverityLogAppender>();
services.AddSingleton<ILogAppender,
StackdriverSeverityLogAppender>();

services.AddSingleton<ILogAppender,
StackdriverExceptionHandler>();
services.AddSingleton<ILogAppender,
StackdriverExceptionHandler>();

var serviceName = config.GetValue<string>("logging:name") ?? "Squidex";
var serviceVersion = Assembly.GetEntryAssembly()?.GetName().Version?.ToString();
var serviceName = config.GetValue<string>("logging:name") ?? "Squidex";
var serviceVersion = Assembly.GetEntryAssembly()?.GetName().Version?.ToString();

services.AddSingleton(c => ContextExceptionLogger.Create(projectId, serviceVersion, serviceVersion, null));
}
services.AddSingleton(c => ContextExceptionLogger.Create(projectId, serviceVersion, serviceVersion, null));
}
}
Loading

0 comments on commit c652b50

Please sign in to comment.