Skip to content

Commit

Permalink
Misc code cleanup (#2063)
Browse files Browse the repository at this point in the history
* Use global namespaces

* Move class to separate file

* Use file-scoped namespaces

* Don't use global usings in samples
  • Loading branch information
mattjohnsonpint authored Nov 24, 2022
1 parent 539f255 commit e75d537
Show file tree
Hide file tree
Showing 349 changed files with 2,784 additions and 3,335 deletions.
5 changes: 5 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@
<PackageReference Include="Nullable" Version="1.*" PrivateAssets="All" />
</ItemGroup>

<!-- Import the root global usings, except for samples. -->
<ItemGroup Condition="!$(MSBuildProjectName.Contains('Samples'))">
<Compile Include="$(SolutionDir)GlobalUsings.cs" />
</ItemGroup>

</Project>
5 changes: 0 additions & 5 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,4 @@
<Compile Remove="**\Tizen\**\*.cs" />
</ItemGroup>

<!-- Workaround the fact that http doesnt exist in earlier frameworks -->
<ItemGroup>
<Using Remove="System.Net.Http" />
<Using Remove="System.Net.Http.Json" />
</ItemGroup>
</Project>
30 changes: 30 additions & 0 deletions GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// These are used in all projects except samples.

global using System.Buffers;
global using System.Collections;
global using System.Collections.Concurrent;
global using System.Collections.Immutable;
global using System.Collections.ObjectModel;
global using System.ComponentModel;
global using System.Diagnostics;
global using System.Diagnostics.CodeAnalysis;
global using System.Globalization;
global using System.IO.Compression;
global using System.Net;
global using System.Net.Http.Headers;
global using System.Net.NetworkInformation;
global using System.Net.Sockets;
global using System.Reflection;
global using System.Runtime.CompilerServices;
global using System.Runtime.ExceptionServices;
global using System.Runtime.InteropServices;
global using System.Runtime.Serialization;
global using System.Security;
global using System.Security.Authentication;
global using System.Security.Principal;
global using System.Security.Claims;
global using System.Security.Cryptography;
global using System.Text;
global using System.Text.Json;
global using System.Text.Json.Serialization;
global using System.Text.RegularExpressions;
1 change: 1 addition & 0 deletions Sentry.sln
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".root", ".root", "{9D7E2F87
Directory.Build.targets = Directory.Build.targets
README.md = README.md
global.json = global.json
GlobalUsings.cs = GlobalUsings.cs
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{77454495-55EE-4B40-A089-71B9E8F82E89}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using BenchmarkDotNet.Attributes;
using Sentry.Extensibility;
using Sentry.Internal;
using Sentry.Protocol.Envelopes;
using BackgroundWorker = Sentry.Internal.BackgroundWorker;

namespace Sentry.Benchmarks;

Expand Down
3 changes: 0 additions & 3 deletions benchmarks/Sentry.Benchmarks/FakeHttpClientFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using Sentry.Http;

namespace Sentry.Benchmarks;
Expand Down
2 changes: 0 additions & 2 deletions benchmarks/Sentry.Benchmarks/Properties/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
using System.Diagnostics.CodeAnalysis;

[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "benchmarks", Scope = "module")]
2 changes: 0 additions & 2 deletions benchmarks/Sentry.Benchmarks/RetryAfterHandlerOverhead.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Net;
using System.Net.Http;
using BenchmarkDotNet.Attributes;
using Sentry.Internal.Http;
using static System.Threading.CancellationToken;
Expand Down
6 changes: 0 additions & 6 deletions samples/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,4 @@
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<Using Include="Sentry" />
<Using Include="Sentry.Extensibility" />
<Using Include="System.Diagnostics" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/"
@using Microsoft.AspNetCore.Mvc.TagHelpers
@namespace Sentry.Samples.AspNetCore.Blazor.Server.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Mvc.TagHelpers
@namespace Sentry.Samples.AspNetCore.Blazor.Server.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

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

// Capture blazor bootstrapping errors
Expand Down
1 change: 0 additions & 1 deletion samples/Sentry.Samples.AspNetCore.Grpc/GameService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Data;
using System.Net.Http;
using Google.Protobuf.WellKnownTypes;
using Grpc.Core;
using Sentry.AspNetCore.Samples.Grpc;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
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,3 +1,6 @@
using Sentry;
using Sentry.Extensibility;

namespace Samples.AspNetCore.Mvc;

public class ExampleEventProcessor : ISentryEventProcessor
Expand Down
1 change: 0 additions & 1 deletion samples/Sentry.Samples.AspNetCore.Mvc/GameService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Data;
using System.Net.Http;

namespace Samples.AspNetCore.Mvc;

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

namespace Samples.AspNetCore.Mvc;

public class SpecialExceptionProcessor : SentryEventExceptionProcessor<SpecialException>
Expand Down
2 changes: 2 additions & 0 deletions samples/Sentry.Samples.AspNetCore.Mvc/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Sentry.Extensibility;

namespace Samples.AspNetCore.Mvc;

public class Startup
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@{
@using Sentry
@{
ViewData["Title"] = "Contact";
}
<h2>@ViewData["Title"]</h2>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@{
@using Microsoft.AspNetCore.Mvc.TagHelpers
@{
ViewData["Title"] = "Home Page";
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!DOCTYPE html>
@using Microsoft.AspNetCore.Mvc.TagHelpers
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@using Microsoft.AspNetCore.Mvc.TagHelpers
<environment include="Development">
<script src="~/lib/jquery-validation/dist/jquery.validate.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
Expand Down
2 changes: 2 additions & 0 deletions samples/Sentry.Samples.Console.Basic/Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Sentry;

using (SentrySdk.Init("https://[email protected]/5428537"))
{
// The following exception is captured and sent to Sentry
Expand Down
3 changes: 2 additions & 1 deletion samples/Sentry.Samples.Console.Customized/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Net.Http;
using System.Reflection;
using System.Xml.Xsl;
using Sentry;
using Sentry.Extensibility;

// One of the ways to set your DSN is via an attribute:
// It could be set via AssemblyInfo.cs and patched via CI.
Expand Down
1 change: 1 addition & 0 deletions samples/Sentry.Samples.EntityFramework/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.ComponentModel.DataAnnotations;
using System.Data.Common;
using System.Data.Entity;
using Sentry;

using var _ = SentrySdk.Init(o =>
{
Expand Down
1 change: 1 addition & 0 deletions samples/Sentry.Samples.GenericHost/SampleHostedService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Sentry;

internal class SampleHostedService : IHostedService
{
Expand Down
2 changes: 0 additions & 2 deletions src/Sentry.AspNet/HttpContextExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.ComponentModel;
using System.Web;
using Sentry.Extensibility;

namespace Sentry.AspNet;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Web;
using Sentry.Internal.ScopeStack;

namespace Sentry.AspNet.Internal;
Expand Down
1 change: 0 additions & 1 deletion src/Sentry.AspNet/Internal/SystemWebHttpRequest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Web;
using Sentry.Extensibility;

namespace Sentry.AspNet.Internal;
Expand Down
2 changes: 0 additions & 2 deletions src/Sentry.AspNet/Internal/SystemWebRequestEventProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Security.Claims;
using System.Web;
using Sentry.Extensibility;
using Sentry.Reflection;

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

namespace Sentry.AspNet.Internal;
Expand Down
2 changes: 0 additions & 2 deletions src/Sentry.AspNet/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Sentry.AspNet.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
1 change: 1 addition & 0 deletions src/Sentry.AspNet/Sentry.AspNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

<ItemGroup>
<Reference Include="System.Web" />
<Using Include="System.Web" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 0 additions & 2 deletions src/Sentry.AspNet/SentryAspNetOptionsExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.ComponentModel;
using System.Web;
using Sentry.AspNet.Internal;
using Sentry.Extensibility;
using Sentry.Infrastructure;
Expand Down
2 changes: 0 additions & 2 deletions src/Sentry.AspNet/SentryHttpServerUtilityExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.ComponentModel;
using System.Web;
using Sentry.Extensibility;
using Sentry.Protocol;

Expand Down
2 changes: 0 additions & 2 deletions src/Sentry.AspNetCore.Grpc/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Sentry.AspNetCore.Grpc.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
1 change: 0 additions & 1 deletion src/Sentry.AspNetCore.Grpc/ScopeExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.ComponentModel;
using Google.Protobuf;
using Grpc.Core;
using Microsoft.Extensions.DependencyInjection;
Expand Down
1 change: 0 additions & 1 deletion src/Sentry.AspNetCore.Grpc/SentryBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.ComponentModel;
using Microsoft.Extensions.DependencyInjection;
using Sentry.Extensibility;
using Sentry.Reflection;
Expand Down
1 change: 0 additions & 1 deletion src/Sentry.AspNetCore.Grpc/SentryGrpcInterceptor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Runtime.ExceptionServices;
using Grpc.Core;
using Grpc.Core.Interceptors;
using Microsoft.Extensions.Options;
Expand Down
1 change: 0 additions & 1 deletion src/Sentry.AspNetCore/ApplicationBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.ComponentModel;
#if NETSTANDARD2_0
using IHostApplicationLifetime = Microsoft.AspNetCore.Hosting.IApplicationLifetime;
#else
Expand Down
1 change: 0 additions & 1 deletion src/Sentry.AspNetCore/DefaultUserFactory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Security.Claims;
using Microsoft.AspNetCore.Http;

namespace Sentry.AspNetCore;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.ComponentModel;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Sentry.AspNetCore;
using Sentry.Extensibility;
Expand Down
Loading

0 comments on commit e75d537

Please sign in to comment.