Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sentry to global usings #3043

Merged
merged 8 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## Unreleased

### Significant change in behavior

- Added `Sentry` namespace to global usings when `ImplicitUsings` is enabled ([#3043](https://github.com/getsentry/sentry-dotnet/pull/3043))
If you have conflicts, you can opt-out by adding the following to your `csproj`:
```
<PropertyGroup>
<SentryImplicitUsings>false</SentryImplicitUsings>
</PropertyGroup>
```

## 4.0.0-beta.8

### Features
Expand Down
1 change: 0 additions & 1 deletion benchmarks/Sentry.Benchmarks/LastActiveSpanBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using BenchmarkDotNet.Attributes;
using Perfolizer.Mathematics.Randomization;

namespace Sentry.Benchmarks;

Expand Down
1 change: 0 additions & 1 deletion benchmarks/Sentry.Benchmarks/StackFrameBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using BenchmarkDotNet.Attributes;
using Sentry.Extensibility;

namespace Sentry.Benchmarks;

Expand Down
1 change: 0 additions & 1 deletion samples/Sentry.Samples.AspNetCore.Blazor.Wasm/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Diagnostics;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Sentry;
using Sentry.Samples.AspNetCore.Blazor.Wasm;

// Capture blazor bootstrapping errors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Samples.AspNetCore.Mvc.Models;
using Sentry;

namespace Samples.AspNetCore.Mvc.Controllers;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Sentry;
using Sentry.Extensibility;

namespace Samples.AspNetCore.Mvc;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Sentry;
using Sentry.Extensibility;

namespace Samples.AspNetCore.Mvc;
Expand Down
2 changes: 0 additions & 2 deletions samples/Sentry.Samples.Console.Basic/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* For more advanced features of the SDK, see Sentry.Samples.Console.Customized.
*/

using Sentry;

// Initialize the Sentry SDK. (It is not necessary to dispose it.)
SentrySdk.Init(options =>
{
Expand Down
2 changes: 0 additions & 2 deletions samples/Sentry.Samples.Console.Customized/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Reflection;
using System.Xml.Xsl;
using Sentry;
using Sentry.Extensibility;

internal static class Program
Expand Down
4 changes: 1 addition & 3 deletions samples/Sentry.Samples.Console.Metrics/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Numerics;

namespace Sentry.Samples.Console.Metrics;
namespace Sentry.Samples.Console.Metrics;

internal static class Program
{
Expand Down
1 change: 0 additions & 1 deletion samples/Sentry.Samples.Console.Native/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*
* This sample demonstrates a native crash handling in a NativeAOT published application.
*/
using Sentry;

// Initialize the Sentry SDK. (It is not necessary to dispose it.)
SentrySdk.Init(options =>
Expand Down
1 change: 0 additions & 1 deletion samples/Sentry.Samples.Console.Profiling/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Diagnostics;
using Sentry;
using Sentry.Profiling;

internal static class Program
Expand Down
1 change: 0 additions & 1 deletion samples/Sentry.Samples.EntityFramework/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.ComponentModel.DataAnnotations;
using System.Data.Common;
using System.Data.Entity;
using Sentry;

using var _ = SentrySdk.Init(o =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Sentry;

internal class SampleHostedService : IHostedService
{
Expand Down
1 change: 0 additions & 1 deletion samples/Sentry.Samples.GraphQL.Client.Http/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using GraphQL;
using GraphQL.Client.Http;
using GraphQL.Client.Serializer.SystemTextJson;
using Sentry;

SentrySdk.Init(options =>
{
Expand Down
2 changes: 0 additions & 2 deletions samples/Sentry.Samples.GraphQL.Server/Notes/NotesData.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections.Concurrent;

namespace Sentry.Samples.GraphQL.Server.Notes;

public class NotesData
Expand Down
1 change: 0 additions & 1 deletion samples/Sentry.Samples.OpenTelemetry.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using OpenTelemetry;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;
using Sentry;
using Sentry.OpenTelemetry;

var serviceName = "Sentry.Samples.OpenTelemetry.Console";
Expand Down
1 change: 0 additions & 1 deletion src/Sentry.AspNet/SentryHttpServerUtilityExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Sentry.Extensibility;
using Sentry.Protocol;

namespace Sentry.AspNet;

Expand Down
4 changes: 0 additions & 4 deletions src/Sentry.AspNetCore/BindableSentryAspNetCoreOptions.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Sentry.Extensibility;
using Sentry.Extensions.Logging;

#if NETSTANDARD2_0
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
#else
using Microsoft.Extensions.Hosting;
#endif

namespace Sentry.AspNetCore;
Expand Down
2 changes: 0 additions & 2 deletions src/Sentry.AspNetCore/SentryAspNetCoreOptionsSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using Microsoft.Extensions.Options;
using Sentry.Extensions.Logging;

using IHostingEnvironment = Microsoft.AspNetCore.Hosting.IWebHostEnvironment;

namespace Sentry.AspNetCore;

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/Sentry.AspNetCore/SentryTracingBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

namespace Sentry.AspNetCore;
Expand Down
2 changes: 0 additions & 2 deletions src/Sentry.AspNetCore/SentryTracingMiddlewareExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Sentry;
using Sentry.AspNetCore;
using Sentry.Extensibility;
using Sentry.Internal.Extensions;

// ReSharper disable once CheckNamespace
Expand Down
1 change: 0 additions & 1 deletion src/Sentry.AspNetCore/SentryWebHostBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Configuration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Azure.Functions.Worker.Middleware;
using Sentry.Extensibility;
using Sentry.Internal;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Sentry.Extensibility;
using Sentry.Internal.Extensions;

namespace Sentry.Internal.DiagnosticSource;

Expand Down
1 change: 0 additions & 1 deletion src/Sentry.Maui/SentryMauiAppBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
Expand Down
3 changes: 0 additions & 3 deletions src/Sentry.Profiling/Downsampler.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Microsoft.Diagnostics.Tracing;
using Microsoft.Diagnostics.Tracing.EventPipe;

/// <summary>
/// Reduce sampling rate from 1 Hz that is the default for the provider to the configured SamplingRateMs.
/// </summary>
Expand Down
1 change: 0 additions & 1 deletion src/Sentry.Profiling/SampleProfileBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Microsoft.Diagnostics.Tracing;
using Microsoft.Diagnostics.Tracing.Etlx;
using Sentry.Extensibility;
using Sentry.Internal;
using Sentry.Protocol;

namespace Sentry.Profiling;
Expand Down
1 change: 0 additions & 1 deletion src/Sentry/Extensibility/HubAdapter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Sentry.Infrastructure;
using Sentry.Internal;

namespace Sentry.Extensibility;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Sentry.Extensibility;
using Sentry.Internal;
using Sentry.Protocol;

namespace Sentry.Integrations;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Sentry.Internal;
using Sentry.Protocol;

namespace Sentry.Integrations;

Expand Down
1 change: 0 additions & 1 deletion src/Sentry/Internal/Extensions/PEReaderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Sentry.Extensibility;
using Sentry.Protocol;

namespace Sentry.Internal.Extensions;
Expand Down
2 changes: 0 additions & 2 deletions src/Sentry/Internal/ITransactionProfiler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Sentry.Protocol;

namespace Sentry.Internal;

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/Sentry/Internal/MainSentryEventProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Sentry.Extensibility;
using Sentry.Internal.Extensions;
using Sentry.Reflection;

namespace Sentry.Internal;
Expand Down
2 changes: 0 additions & 2 deletions src/Sentry/Internal/NoOpTransaction.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Sentry.Protocol;

namespace Sentry.Internal;

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/Sentry/Internal/ScopeObserver.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Sentry.Extensibility;
using Sentry.Internal.Extensions;

namespace Sentry.Internal;
Expand Down
3 changes: 0 additions & 3 deletions src/Sentry/Internal/StackFrame.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Sentry.Internal.Extensions;
using Sentry.Extensibility;

namespace Sentry.Internal;

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/Sentry/MetricAggregator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using Sentry.Extensibility;
using Sentry.Internal;
using Sentry.Internal.Extensions;
Expand Down
2 changes: 0 additions & 2 deletions src/Sentry/PlatformAbstractions/RuntimeInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace Sentry.PlatformAbstractions;

// https://github.com/dotnet/corefx/issues/17452
Expand Down
1 change: 0 additions & 1 deletion src/Sentry/Platforms/Android/SentrySdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Sentry.Android;
using Sentry.Android.Callbacks;
using Sentry.Android.Extensions;
using Sentry.Internal;
using Sentry.JavaSdk.Android.Core;

// Don't let the Sentry Android SDK auto-init, as we do that manually in SentrySdk.Init
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Sentry.Extensibility;
using Sentry.Internal;

namespace Sentry.Cocoa.Facades;

Expand Down
3 changes: 0 additions & 3 deletions src/Sentry/Platforms/Native/NativeScopeObserver.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Runtime.InteropServices;
using Sentry.Extensibility;
using Sentry.Internal;

namespace Sentry.Native;
Expand Down
1 change: 0 additions & 1 deletion src/Sentry/Protocol/ProfileInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Sentry.Extensibility;
using Sentry.Internal;
using Sentry.Internal.Extensions;

namespace Sentry.Protocol;
Expand Down
1 change: 0 additions & 1 deletion src/Sentry/Protocol/SampleProfile.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Sentry.Extensibility;
using Sentry.Internal;
using Sentry.Internal.Extensions;

#if NETFRAMEWORK
Expand Down
3 changes: 0 additions & 3 deletions src/Sentry/Scope.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using Sentry.Extensibility;
using Sentry.Internal;
using Sentry.Internal.Extensions;
using Sentry.Internal.OpenTelemetry;
using Sentry.Protocol;

namespace Sentry;

Expand Down
1 change: 0 additions & 1 deletion src/Sentry/SentryEvent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Sentry.Extensibility;
using Sentry.Integrations;
using Sentry.Internal;
using Sentry.Internal.Extensions;
using Sentry.Protocol;

Expand Down
1 change: 0 additions & 1 deletion src/Sentry/SentryHttpFailedRequestHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Sentry.Internal;
using Sentry.Protocol;

namespace Sentry;
Expand Down
2 changes: 0 additions & 2 deletions src/Sentry/SentryHttpMessageHandler.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Sentry.Extensibility;
using Sentry.Internal;
using Sentry.Internal.Extensions;
using Sentry.Internal.OpenTelemetry;

namespace Sentry;
Expand Down
2 changes: 0 additions & 2 deletions src/Sentry/SentryMessageHandler.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Sentry.Extensibility;
using Sentry.Internal;
using Sentry.Internal.Extensions;
using Sentry.Internal.OpenTelemetry;

namespace Sentry;

Expand Down
1 change: 0 additions & 1 deletion src/Sentry/TransactionTracer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Sentry.Extensibility;
using Sentry.Internal;
using Sentry.Internal.ScopeStack;
using Sentry.Protocol;

namespace Sentry;
Expand Down
4 changes: 4 additions & 0 deletions src/Sentry/buildTransitive/Sentry.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<ItemGroup Condition="$(Language) == 'C#' and $(SentryImplicitUsings) != 'false' and ($(ImplicitUsings) == 'enable' or $(ImplicitUsings) == 'true')">
<Using Include="Sentry" />
</ItemGroup>

<PropertyGroup>
<SentryAttributesFile>Sentry.Attributes$(MSBuildProjectExtension.Replace('proj', ''))</SentryAttributesFile>
</PropertyGroup>
Expand Down
1 change: 0 additions & 1 deletion test/Sentry.AspNetCore.Tests/SentryMiddlewareTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.Logging;
using Sentry.AspNetCore.Extensions;

#if NETCOREAPP3_1_OR_GREATER
using IHostingEnvironment = Microsoft.AspNetCore.Hosting.IWebHostEnvironment;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Microsoft.EntityFrameworkCore.Storage;
using Sentry.Internal.DiagnosticSource;
using Sentry.Internal.Extensions;
using static Sentry.Internal.DiagnosticSource.SentrySqlListener;

namespace Sentry.DiagnosticSource.Tests;
Expand Down
1 change: 0 additions & 1 deletion test/Sentry.Maui.Tests/MauiEventsBinderTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Microsoft.Extensions.Options;
using Sentry.Maui.Internal;

namespace Sentry.Maui.Tests;
Expand Down
2 changes: 0 additions & 2 deletions test/Sentry.Maui.Tests/SentryMauiScreenshotTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Microsoft.Extensions.Options;
using Sentry.Internal.Http;
using Sentry.Maui.Internal;

namespace Sentry.Maui.Tests;

Expand Down
3 changes: 0 additions & 3 deletions test/Sentry.OpenTelemetry.Tests/SentrySpanProcessorTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using OpenTelemetry;
using OpenTelemetry.Trace;
using Sentry.Internal.OpenTelemetry;
using Sentry.PlatformAbstractions;

namespace Sentry.OpenTelemetry.Tests;

Expand Down
Loading
Loading