Skip to content

Commit

Permalink
Fix some warning messages (#1355)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored Nov 30, 2021
1 parent ad9f5ff commit 35b72f2
Show file tree
Hide file tree
Showing 58 changed files with 73 additions and 142 deletions.
1 change: 0 additions & 1 deletion samples/Sentry.Samples.AspNetCore.Mvc/GameService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ public class GameService : IGameService
{
throw ae; // re-throw the AggregateException to capture all errors
}

}
}
4 changes: 0 additions & 4 deletions samples/Sentry.Samples.Console.Customized/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ await SentrySdk.ConfigureScopeAsync(async scope =>
SentrySdk.CaptureException(error);
}


var count = 10;
for (var i = 0; i < count; i++)
{
Expand Down Expand Up @@ -201,12 +200,10 @@ await SentrySdk.ConfigureScopeAsync(async scope =>
var middleware = new AdminPartMiddleware(adminClient, null);
var request = new { Path = "/admin" }; // made up request
middleware.Invoke(request);

} // Dispose the client which flushes any queued events

SentrySdk.CaptureException(
new Exception("Error outside of the admin section: Goes to the default DSN"));

} // On Dispose: SDK closed, events queued are flushed/sent to Sentry
}

Expand Down Expand Up @@ -239,7 +236,6 @@ public void Invoke(dynamic request)
// Else it uses the default client

_middleware?.Invoke(request);

} // Scope is disposed.
}
}
Expand Down
1 change: 0 additions & 1 deletion samples/Sentry.Samples.ME.Logging/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ private static void Main()
// Handle an exception and log it:
logger.LogError(e, "7 - An event that includes the scope key-value (A, B, C) and also the breadcrumbs: (2, 4, 6) and events (3, 5)");
}

} // Dispose scope C, drops state C and breadcrumb 6

// An exception that will go unhandled and crash the app:
Expand Down
8 changes: 3 additions & 5 deletions src/Sentry.AspNetCore.Grpc/GrpcRequestAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ namespace Sentry.AspNetCore.Grpc;
internal class GrpcRequestAdapter<TRequest> : IProtobufRequest<TRequest>
where TRequest : class, IMessage
{
private readonly TRequest _request;
public GrpcRequestAdapter(TRequest request) => Request = request;

public GrpcRequestAdapter(TRequest request) => _request = request;
public long? ContentLength => Request.CalculateSize();

public long? ContentLength => _request.CalculateSize();

public TRequest Request => _request;
public TRequest Request { get; }
}
5 changes: 1 addition & 4 deletions src/Sentry.AspNetCore.Grpc/ScopeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ private static void SetBody<TRequest>(Scope scope, ServerCallContext context, TR
if (message != null)
{
// Convert message into JSON format for readability

string jsonData = JsonFormatter.Default.Format(message);

scope.Request.Data = jsonData;
scope.Request.Data = JsonFormatter.Default.Format(message);
}
}
}
1 change: 0 additions & 1 deletion src/Sentry.AspNetCore.Grpc/SentryBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public static class SentryBuilderExtensions
/// Adds gRPC integration to Sentry
/// </summary>
/// <param name="builder"></param>
/// <returns></returns>
public static ISentryBuilder AddGrpc(this ISentryBuilder builder)
{
_ = builder.Services
Expand Down
3 changes: 0 additions & 3 deletions src/Sentry.AspNetCore.Grpc/SentryGrpcInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public SentryGrpcInterceptor(
/// <param name="continuation">The continuation</param>
/// <typeparam name="TRequest">The request type</typeparam>
/// <typeparam name="TResponse">The response type</typeparam>
/// <returns></returns>
public override async Task<TResponse> UnaryServerHandler<TRequest, TResponse>(
TRequest request,
ServerCallContext context,
Expand Down Expand Up @@ -88,7 +87,6 @@ public override async Task<TResponse> UnaryServerHandler<TRequest, TResponse>(
/// <param name="continuation">The continuation</param>
/// <typeparam name="TRequest">The request type</typeparam>
/// <typeparam name="TResponse">The response type</typeparam>
/// <returns></returns>
public override async Task ServerStreamingServerHandler<TRequest, TResponse>(TRequest request,
IServerStreamWriter<TResponse> responseStream,
ServerCallContext context, ServerStreamingServerMethod<TRequest, TResponse> continuation)
Expand Down Expand Up @@ -170,7 +168,6 @@ public override async Task<TResponse> ClientStreamingServerHandler<TRequest, TRe
/// <param name="continuation">The continuation</param>
/// <typeparam name="TRequest">The request type</typeparam>
/// <typeparam name="TResponse">The response type</typeparam>
/// <returns></returns>
public override async Task DuplexStreamingServerHandler<TRequest, TResponse>(
IAsyncStreamReader<TRequest> requestStream, IServerStreamWriter<TResponse> responseStream,
ServerCallContext context, DuplexStreamingServerMethod<TRequest, TResponse> continuation)
Expand Down
1 change: 0 additions & 1 deletion src/Sentry.AspNetCore/ApplicationBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ internal static class ApplicationBuilderExtensions
/// Use Sentry integration
/// </summary>
/// <param name="app">The application.</param>
/// <returns></returns>
public static IApplicationBuilder UseSentry(this IApplicationBuilder app)
{
// Container is built so resolve a logger and modify the SDK internal logger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public static class ServiceCollectionExtensions
/// Adds Sentry's services to the <see cref="IServiceCollection"/>
/// </summary>
/// <param name="services">The services.</param>
/// <returns></returns>
public static ISentryBuilder AddSentry(this IServiceCollection services)
{
services.AddSingleton<ISentryEventProcessor, AspNetCoreEventProcessor>();
Expand Down
1 change: 0 additions & 1 deletion src/Sentry.AspNetCore/SentryBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public static class SentryBuilderExtensions
/// </summary>
/// <param name="builder">The Sentry builder</param>
/// <param name="configureOptions">The configure options</param>
/// <returns></returns>
public static ISentryBuilder AddSentryOptions(this ISentryBuilder builder,
Action<SentryAspNetCoreOptions>? configureOptions)
{
Expand Down
1 change: 0 additions & 1 deletion src/Sentry.AspNetCore/SentryMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public SentryMiddleware(
/// Handles the <see cref="HttpContext"/> while capturing any errors
/// </summary>
/// <param name="context">The context.</param>
/// <returns></returns>
public async Task InvokeAsync(HttpContext context)
{
var hub = _getHub();
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry.AspNetCore/SentryTracingMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public static class SentryTracingMiddlewareExtensions
{
/// <summary>
/// Adds Sentry's tracing middleware to the pipeline.
/// Make sure to place this middleware after <code>UseRouting(...)</code>.
/// Make sure to place this middleware after <c>UseRouting(...)</c>.
/// </summary>
public static IApplicationBuilder UseSentryTracing(this IApplicationBuilder builder)
{
Expand Down
6 changes: 0 additions & 6 deletions src/Sentry.AspNetCore/SentryWebHostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public static class SentryWebHostBuilderExtensions
/// Uses Sentry integration.
/// </summary>
/// <param name="builder">The builder.</param>
/// <returns></returns>
public static IWebHostBuilder UseSentry(this IWebHostBuilder builder)
=> UseSentry(builder, (Action<SentryAspNetCoreOptions>?)null);

Expand All @@ -27,7 +26,6 @@ public static IWebHostBuilder UseSentry(this IWebHostBuilder builder)
/// </summary>
/// <param name="builder">The builder.</param>
/// <param name="dsn">The DSN.</param>
/// <returns></returns>
public static IWebHostBuilder UseSentry(this IWebHostBuilder builder, string dsn)
=> builder.UseSentry(o => o.Dsn = dsn);

Expand All @@ -36,7 +34,6 @@ public static IWebHostBuilder UseSentry(this IWebHostBuilder builder, string dsn
/// </summary>
/// <param name="builder">The builder.</param>
/// <param name="configureOptions">The configure options.</param>
/// <returns></returns>
public static IWebHostBuilder UseSentry(
this IWebHostBuilder builder,
Action<SentryAspNetCoreOptions>? configureOptions)
Expand All @@ -47,7 +44,6 @@ public static IWebHostBuilder UseSentry(
/// </summary>
/// <param name="builder">The builder.</param>
/// <param name="configureOptions">The configure options.</param>
/// <returns></returns>
public static IWebHostBuilder UseSentry(
this IWebHostBuilder builder,
Action<WebHostBuilderContext, SentryAspNetCoreOptions>? configureOptions)
Expand All @@ -59,7 +55,6 @@ public static IWebHostBuilder UseSentry(
/// </summary>
/// <param name="builder">The builder.</param>
/// <param name="configureSentry">The Sentry builder.</param>
/// <returns></returns>
public static IWebHostBuilder UseSentry(
this IWebHostBuilder builder,
Action<ISentryBuilder>? configureSentry) =>
Expand All @@ -70,7 +65,6 @@ public static IWebHostBuilder UseSentry(
/// </summary>
/// <param name="builder">The builder.</param>
/// <param name="configureSentry">The Sentry builder.</param>
/// <returns></returns>
public static IWebHostBuilder UseSentry(
this IWebHostBuilder builder,
Action<WebHostBuilderContext, ISentryBuilder>? configureSentry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private enum SentryEFSpanType
internal const string EFCommandFailed = "Microsoft.EntityFrameworkCore.Database.Command.CommandError";

/// <summary>
/// Used for EF Core 2.X and 3.X.
/// Used for EF Core 2.X and 3.X.
/// <seealso href="https://docs.microsoft.com/dotnet/api/microsoft.entityframeworkcore.diagnostics.coreeventid.querymodelcompiling?view=efcore-3.1"></seealso>
/// </summary>
internal const string EFQueryStartCompiling = "Microsoft.EntityFrameworkCore.Query.QueryCompilationStarting";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,21 @@ public SentrySqlListener(IHub hub, SentryOptions options)
_options = options;
}

private void SetConnectionId(ISpan span, Guid? connectionId)
private static void SetConnectionId(ISpan span, Guid? connectionId)
{
Debug.Assert(connectionId != Guid.Empty);

span.SetExtra(ConnectionExtraKey, connectionId);
}

private void SetOperationId(ISpan span, Guid? operationId)
private static void SetOperationId(ISpan span, Guid? operationId)
{
Debug.Assert(operationId != Guid.Empty);

span.SetExtra(OperationExtraKey, operationId);
}

private Guid? TryGetOperationId(ISpan span)
private static Guid? TryGetOperationId(ISpan span)
{
if (span.Extra.TryGetValue(OperationExtraKey, out var key) && key is Guid guid)
{
Expand All @@ -73,7 +73,7 @@ private void SetOperationId(ISpan span, Guid? operationId)
return null;
}

private Guid? TryGetConnectionId(ISpan span)
private static Guid? TryGetConnectionId(ISpan span)
{
if (span.Extra.TryGetValue(ConnectionExtraKey, out var key) && key is Guid guid)
{
Expand Down Expand Up @@ -167,13 +167,13 @@ span is SpanTracer executionTracer &&
return span;
}

private ISpan? TryStartChild(ISpan? parent, string operation, string? description)
private static ISpan? TryStartChild(ISpan? parent, string operation, string? description)
=> parent?.StartChild(operation, description);

private ISpan? TryGetConnectionSpan(Scope scope, Guid connectionId)
private static ISpan? TryGetConnectionSpan(Scope scope, Guid connectionId)
=> scope.Transaction?.Spans.FirstOrDefault(span => !span.IsFinished && span.Operation is "db.connection" && TryGetConnectionId(span) == connectionId);

private ISpan? TryGetQuerySpan(Scope scope, Guid operationId)
private static ISpan? TryGetQuerySpan(Scope scope, Guid operationId)
=> scope.Transaction?.Spans.FirstOrDefault(span => TryGetOperationId(span) == operationId);

private void UpdateConnectionSpan(Guid operationId, Guid connectionId)
Expand Down Expand Up @@ -242,7 +242,7 @@ public void OnNext(KeyValuePair<string, object?> value)
}
}

private void TrySetConnectionStatistics(ISpan span, KeyValuePair<string, object?> value)
private static void TrySetConnectionStatistics(ISpan span, KeyValuePair<string, object?> value)
{
if (value.GetProperty<Dictionary<object, object>>("Statistics") is { } statistics)
{
Expand Down
4 changes: 0 additions & 4 deletions src/Sentry.EntityFramework/SentryOptionsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ public static class SentryOptionsExtensions
/// Adds the entity framework integration.
/// </summary>
/// <param name="sentryOptions">The sentry options.</param>
/// <returns></returns>
public static SentryOptions AddEntityFramework(this SentryOptions sentryOptions)
{
try
{
#pragma warning disable 618 // TODO: We can make the method internal on a new major release.
_ = SentryDatabaseLogging.UseBreadcrumbs(diagnosticLogger: sentryOptions.DiagnosticLogger);
#pragma warning restore 618
}
catch (Exception e)
{
Expand All @@ -42,7 +39,6 @@ public static SentryOptions AddEntityFramework(this SentryOptions sentryOptions)
return sentryOptions;
}


/// <summary>
/// Disables the integrations with DbInterception.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public static class ServiceCollectionExtensions
/// Adds Sentry's services to the <see cref="IServiceCollection"/>
/// </summary>
/// <param name="services">The services.</param>
/// <returns></returns>
public static IServiceCollection AddSentry<TOptions>(this IServiceCollection services)
where TOptions : SentryLoggingOptions, new()
{
Expand Down
1 change: 0 additions & 1 deletion src/Sentry.Extensions.Logging/ILogEntryFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public interface ILogEntryFilter
/// <param name="logLevel">The event level.</param>
/// <param name="eventId">The EventId.</param>
/// <param name="exception">The Exception, if any.</param>
/// <returns></returns>
bool Filter(
string categoryName,
LogLevel logLevel,
Expand Down
3 changes: 0 additions & 3 deletions src/Sentry.Extensions.Logging/LoggingBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public static class LoggingBuilderExtensions
/// Adds the Sentry logging integration.
/// </summary>
/// <param name="builder">The builder.</param>
/// <returns></returns>
public static ILoggingBuilder AddSentry(this ILoggingBuilder builder)
=> builder.AddSentry((Action<SentryLoggingOptions>?)null);

Expand All @@ -28,7 +27,6 @@ public static ILoggingBuilder AddSentry(this ILoggingBuilder builder)
/// </summary>
/// <param name="builder">The builder.</param>
/// <param name="dsn">The DSN.</param>
/// <returns></returns>
public static ILoggingBuilder AddSentry(this ILoggingBuilder builder, string dsn)
=> builder.AddSentry(o => o.Dsn = dsn);

Expand All @@ -37,7 +35,6 @@ public static ILoggingBuilder AddSentry(this ILoggingBuilder builder, string dsn
/// </summary>
/// <param name="builder">The builder.</param>
/// <param name="optionsConfiguration">The options configuration.</param>
/// <returns></returns>
public static ILoggingBuilder AddSentry(
this ILoggingBuilder builder,
Action<SentryLoggingOptions>? optionsConfiguration)
Expand Down
1 change: 0 additions & 1 deletion src/Sentry.Extensions.Logging/MelDiagnosticLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public MelDiagnosticLogger(ILogger<ISentryClient> logger, SentryLevel level)
/// set via the options and also the inner <see cref="ILogger{TCategoryName}"/>
/// </remarks>
/// <param name="level"></param>
/// <returns></returns>
public bool IsEnabled(SentryLevel level) => _logger.IsEnabled(level.ToMicrosoft()) && level >= _level;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public static class SentryLoggerFactoryExtensions
/// </remarks>
/// <param name="factory">The factory.</param>
/// <param name="optionsConfiguration">The options configuration.</param>
/// <returns></returns>
public static ILoggerFactory AddSentry(
this ILoggerFactory factory,
Action<SentryLoggingOptions>? optionsConfiguration = null)
Expand Down
3 changes: 1 addition & 2 deletions src/Sentry.Google.Cloud.Functions/SentryStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace Google.Cloud.Functions.Framework;
/// </summary>
public class SentryStartup : FunctionsStartup
{

/// <summary>
/// Configure Sentry logging.
/// </summary>
Expand Down Expand Up @@ -122,7 +121,7 @@ public async Task InvokeAsync(HttpContext httpContext)

private class SentryGoogleCloudFunctionsRouteName : ISentryRouteName
{
private static readonly Lazy<string?> RouteName = new Lazy<string?>(() => Environment.GetEnvironmentVariable("K_SERVICE"));
private static readonly Lazy<string?> RouteName = new(() => Environment.GetEnvironmentVariable("K_SERVICE"));

// K_SERVICE is where the name of the FAAS is stored.
// It'll return null. if GCP Function is running locally.
Expand Down
6 changes: 2 additions & 4 deletions src/Sentry.Serilog/SentrySink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,9 @@ private string FormatLogEvent(LogEvent logEvent)
}
}

private IEnumerable<KeyValuePair<string, object?>> GetLoggingEventProperties(LogEvent logEvent)
private static IEnumerable<KeyValuePair<string, object?>> GetLoggingEventProperties(LogEvent logEvent)
{
var properties = logEvent.Properties;

foreach (var property in properties)
foreach (var property in logEvent.Properties)
{
var value = property.Value;
if (value is ScalarValue scalarValue)
Expand Down
1 change: 0 additions & 1 deletion src/Sentry.Serilog/SentrySinkExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ public static void ConfigureSentrySerilogOptions(
/// </summary>
/// <param name="loggerConfiguration">The logger configuration.</param>
/// <param name="configureOptions">The configure options callback.</param>
/// <returns></returns>
public static LoggerConfiguration Sentry(
this LoggerSinkConfiguration loggerConfiguration,
Action<SentrySerilogOptions> configureOptions)
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/Attachment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public enum AttachmentType

/// <summary>
/// Minidump file that creates an error event and is symbolicated.
/// The file should start with the <code>MDMP</code> magic bytes.
/// The file should start with the <c>MDMP</c> magic bytes.
/// </summary>
Minidump,

Expand Down
Loading

0 comments on commit 35b72f2

Please sign in to comment.