From 24df60d967fbdc8e3314ac0b2845910133e30a70 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Thu, 11 Jan 2024 20:14:53 +1300 Subject: [PATCH 1/3] Fix Coverlet (#3019) * Replaced Coverlet with Microsoft.CodeCoverage * Update Directory.Build.props * Changed from microsoft.codecoverage to coverlet.collector --- .github/workflows/build.yml | 2 +- .gitignore | 3 +- CodeCoverage.runsettings | 58 +++++++++++++++++++++++++++++++++++++ test/Directory.Build.props | 17 ++--------- 4 files changed, 62 insertions(+), 18 deletions(-) create mode 100644 CodeCoverage.runsettings diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 64d7f223ee..a7467eba2f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -114,7 +114,7 @@ jobs: run: dotnet build Sentry-CI-Build-${{ runner.os }}.slnf -c Release --no-restore --nologo -flp:logfile=build.log -p:CopyLocalLockFileAssemblies=true - name: Test - run: dotnet test Sentry-CI-Build-${{ runner.os }}.slnf -c Release --no-build --nologo -l GitHubActions -l "trx;LogFilePrefix=testresults_${{ runner.os }}" /p:CollectCoverage=true + run: dotnet test Sentry-CI-Build-${{ runner.os }}.slnf -c Release --no-build --nologo -l GitHubActions -l "trx;LogFilePrefix=testresults_${{ runner.os }}" --collect "XPlat Code Coverage" - name: Upload code coverage uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d diff --git a/.gitignore b/.gitignore index e04df01865..c7e1484b7e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,12 +5,11 @@ *.userprefs *.user *opencover.xml +*cobertura.xml codecov.sh lcov.info bin/ obj/ -**/coverage/*.xml -**/coverage/*.json .DS_Store Thumbs.db **/BenchmarkDotNet.Artifacts/*.log diff --git a/CodeCoverage.runsettings b/CodeCoverage.runsettings new file mode 100644 index 0000000000..6637b5e020 --- /dev/null +++ b/CodeCoverage.runsettings @@ -0,0 +1,58 @@ + + + + + + + + + + + + + ^System\.Diagnostics\.DebuggerHiddenAttribute$ + ^System\.Diagnostics\.DebuggerNonUserCodeAttribute$ + ^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$ + ^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$ + + + + + + + .*\\benchmarks\\.* + .*\\modules\\.* + .*\\samples\\.* + .*\\test\\.* + + + + + + + True + + True + + True + + False + + True + + True + + True + + + + + + + diff --git a/test/Directory.Build.props b/test/Directory.Build.props index deae655850..59a92df6cb 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -52,29 +52,16 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - [Sentry.Protocol.Test*]*,[xunit.*]*,[System.*]*,[Microsoft.*]*,[Sentry.Test*]* - ./coverage/ - opencover - - false - - - + + From 089fb758f97749c48ff3d501cc1e0b44ffdccd26 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Thu, 11 Jan 2024 20:20:37 +1300 Subject: [PATCH 2/3] Clarify the use of Solutions vs Solution Filters in the repository (#3037) * Update CONTRIBUTING.md * Renamed Sentry.NoMobile.sln to .generated.NoMobile.sln --- Sentry.NoMobile.sln => .generated.NoMobile.sln | 0 CONTRIBUTING.md | 8 +++++++- Directory.Build.props | 2 +- SentryAspNetCore.slnf | 2 +- SentryCore.slnf | 2 +- SentryDiagnosticSource.slnf | 2 +- SentryNoMobile.slnf | 2 +- scripts/generate-solution-filters-config.yaml | 10 +++++----- 8 files changed, 17 insertions(+), 11 deletions(-) rename Sentry.NoMobile.sln => .generated.NoMobile.sln (100%) diff --git a/Sentry.NoMobile.sln b/.generated.NoMobile.sln similarity index 100% rename from Sentry.NoMobile.sln rename to .generated.NoMobile.sln diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2e61ed89c8..40032561fe 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -57,10 +57,16 @@ Also note `/Directory.Build.targets` contains some [convention based rules](http ## Solution Filters -Most contributors will rarely need to load Sentry.sln. The repository contains various solution filters that will be more practical for day to day tasks. +_TLDR;_ when working with the the Sentry codebase, you should use the solution filters (not the solutions). + +_Full explanation:_ + +The `Sentry.sln` solution contains all of the projects required to build Sentry, it's integrations and samples for every platform. However the repository contains various solution filters that will be more practical for day to day tasks. These solution filters get generated automatically by `/scripts/generate-solution-filters.ps1` so, although you can certainly create your own solution filters and manage these how you wish, don't try to modify any of the `*.slnf` files that are committed to source control. Instead, changes to these can be made by modifying `/scripts/generate-solution-filters-config.yml` and re-running the script that generates these. +Also note that script generates a `.generated.NoMobile.sln` solution, which is an identical copy of `Sentry.sln`. Again, we don't recommend opening this directly. It exists as a round about way to conditionally set build properties in certain solution filters. You should instead use those solution filters (e.g. `SentryNoMobile.slnf`) when working in the Sentry codebase. + ## API changes approval process This repository uses [Verify](https://github.com/VerifyTests/Verify) to store the public API diffs in snapshot files. diff --git a/Directory.Build.props b/Directory.Build.props index d1af4dc52a..aebc4b33fa 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -15,7 +15,7 @@ $(NoWarn);CS8002 - + true diff --git a/SentryAspNetCore.slnf b/SentryAspNetCore.slnf index a07e91ff14..5d6d12125d 100644 --- a/SentryAspNetCore.slnf +++ b/SentryAspNetCore.slnf @@ -1,6 +1,6 @@ { "solution": { - "path": "Sentry.NoMobile.sln", + "path": ".generated.NoMobile.sln", "projects": [ "samples\\Sentry.Samples.AspNetCore.Basic\\Sentry.Samples.AspNetCore.Basic.csproj", "samples\\Sentry.Samples.AspNetCore.Blazor.Server\\Sentry.Samples.AspNetCore.Blazor.Server.csproj", diff --git a/SentryCore.slnf b/SentryCore.slnf index e5e06b98b5..d2eb48df03 100644 --- a/SentryCore.slnf +++ b/SentryCore.slnf @@ -1,6 +1,6 @@ { "solution": { - "path": "Sentry.NoMobile.sln", + "path": ".generated.NoMobile.sln", "projects": [ "benchmarks\\Sentry.Benchmarks\\Sentry.Benchmarks.csproj", "samples\\Sentry.Samples.Console.Basic\\Sentry.Samples.Console.Basic.csproj", diff --git a/SentryDiagnosticSource.slnf b/SentryDiagnosticSource.slnf index c3bf33b7c7..def6547901 100644 --- a/SentryDiagnosticSource.slnf +++ b/SentryDiagnosticSource.slnf @@ -1,6 +1,6 @@ { "solution": { - "path": "Sentry.NoMobile.sln", + "path": ".generated.NoMobile.sln", "projects": [ "src\\Sentry.DiagnosticSource\\Sentry.DiagnosticSource.csproj", "src\\Sentry.Extensions.Logging\\Sentry.Extensions.Logging.csproj", diff --git a/SentryNoMobile.slnf b/SentryNoMobile.slnf index 3932f9c12f..0287068055 100644 --- a/SentryNoMobile.slnf +++ b/SentryNoMobile.slnf @@ -1,6 +1,6 @@ { "solution": { - "path": "Sentry.NoMobile.sln", + "path": ".generated.NoMobile.sln", "projects": [ "benchmarks\\Sentry.Benchmarks\\Sentry.Benchmarks.csproj", "samples\\Sentry.Samples.AspNetCore.Basic\\Sentry.Samples.AspNetCore.Basic.csproj", diff --git a/scripts/generate-solution-filters-config.yaml b/scripts/generate-solution-filters-config.yaml index 84ac17e54e..4ea27fd67f 100644 --- a/scripts/generate-solution-filters-config.yaml +++ b/scripts/generate-solution-filters-config.yaml @@ -8,7 +8,7 @@ coreSolution: Sentry.sln # copies of Sentry.sln that are used to set certain build # properties when using solution filters that are based on these buildSolutions: - - Sentry.NoMobile.sln + - .generated.NoMobile.sln groupConfigs: allProjects: @@ -83,7 +83,7 @@ filterConfigs: - "test/**/*.csproj" - outputPath: SentryAspNetCore.slnf - solution: Sentry.NoMobile.sln + solution: .generated.NoMobile.sln include: patterns: - "**/*AspNetCore*.csproj" @@ -109,7 +109,7 @@ filterConfigs: - "**/Sentry.Tests.csproj" - outputPath: SentryCore.slnf - solution: Sentry.NoMobile.sln + solution: .generated.NoMobile.sln include: patterns: - "**/Sentry.Benchmarks.csproj" @@ -123,7 +123,7 @@ filterConfigs: - "**/Sentry.Tests.csproj" - outputPath: SentryDiagnosticSource.slnf - solution: Sentry.NoMobile.sln + solution: .generated.NoMobile.sln include: patterns: - "**/*DiagnosticSource*.csproj" @@ -155,7 +155,7 @@ filterConfigs: - "test/MauiTestUtils/**/*.csproj" - outputPath: SentryNoMobile.slnf - solution: Sentry.NoMobile.sln + solution: .generated.NoMobile.sln include: groups: - "allProjects" From bb71eafbfffe849e77b2219377673be101004539 Mon Sep 17 00:00:00 2001 From: Stefan Jandl Date: Thu, 11 Jan 2024 11:30:52 +0100 Subject: [PATCH 3/3] feat: Renamed `Sentry.Runtime` to `SentryRuntime` (#3016) --- CHANGELOG.md | 2 + .../NetFxInstallationsIntegration.cs | 2 +- src/Sentry/Internal/Enricher.cs | 4 +- .../PlatformAbstractions/RuntimeInfo.cs | 32 ++++----- .../{Runtime.cs => SentryRuntime.cs} | 14 ++-- ...tensions.cs => SentryRuntimeExtensions.cs} | 14 ++-- src/Sentry/Protocol/SampleProfile.cs | 2 +- src/Sentry/SentryOptions.cs | 4 +- src/Sentry/{Span.cs => SentrySpan.cs} | 14 ++-- src/Sentry/Transaction.cs | 8 +-- test/Sentry.Testing/VerifyExtensions.cs | 4 +- ...piApprovalTests.Run.DotNet6_0.verified.txt | 68 +++++++++---------- ...piApprovalTests.Run.DotNet7_0.verified.txt | 68 +++++++++---------- ...piApprovalTests.Run.DotNet8_0.verified.txt | 68 +++++++++---------- .../ApiApprovalTests.Run.Net4_8.verified.txt | 68 +++++++++---------- .../Integrations/AppDomainAdapterTests.cs | 3 +- .../NetFxInstallationsIntegrationTests.cs | 5 +- .../NetFxInstallationsEventProcessorTests.cs | 7 +- .../PlatformAbstractions/RuntimeTests.cs | 12 ---- ...sts.cs => SentryRuntimeExtensionsTests.cs} | 9 ++- .../SentryRuntimeTests.cs | 12 ++++ ...{RuntimeTests.cs => SentryRuntimeTests.cs} | 4 +- 22 files changed, 211 insertions(+), 213 deletions(-) rename src/Sentry/PlatformAbstractions/{Runtime.cs => SentryRuntime.cs} (92%) rename src/Sentry/PlatformAbstractions/{RuntimeExtensions.cs => SentryRuntimeExtensions.cs} (70%) rename src/Sentry/{Span.cs => SentrySpan.cs} (93%) delete mode 100644 test/Sentry.Tests/PlatformAbstractions/RuntimeTests.cs rename test/Sentry.Tests/PlatformAbstractions/{RuntimeExtensionsTests.cs => SentryRuntimeExtensionsTests.cs} (87%) create mode 100644 test/Sentry.Tests/PlatformAbstractions/SentryRuntimeTests.cs rename test/Sentry.Tests/Protocol/Context/{RuntimeTests.cs => SentryRuntimeTests.cs} (96%) diff --git a/CHANGELOG.md b/CHANGELOG.md index b35a84afaf..17c80ea65d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ #### Changed APIs - Class renamed `Sentry.User` to `Sentry.SentryUser` ([#3015](https://github.com/getsentry/sentry-dotnet/pull/3015)) +- Class renamed `Sentry.Runtime` to `Sentry.SentryRuntime` ([#3016](https://github.com/getsentry/sentry-dotnet/pull/3016)) +- Class renamed `Sentry.Span` to `Sentry.SentrySpan` ([#3021](https://github.com/getsentry/sentry-dotnet/pull/3021)) ### Dependencies diff --git a/src/Sentry/Integrations/NetFxInstallationsIntegration.cs b/src/Sentry/Integrations/NetFxInstallationsIntegration.cs index 00060e8454..005f04f2ea 100644 --- a/src/Sentry/Integrations/NetFxInstallationsIntegration.cs +++ b/src/Sentry/Integrations/NetFxInstallationsIntegration.cs @@ -10,7 +10,7 @@ public void Register(IHub hub, SentryOptions options) { try { - if (!Runtime.Current.IsMono()) + if (!SentryRuntime.Current.IsMono()) { options.AddEventProcessor(new NetFxInstallationsEventProcessor(options)); } diff --git a/src/Sentry/Internal/Enricher.cs b/src/Sentry/Internal/Enricher.cs index 11d7d76ab7..0a3371efec 100644 --- a/src/Sentry/Internal/Enricher.cs +++ b/src/Sentry/Internal/Enricher.cs @@ -12,7 +12,7 @@ internal class Enricher private readonly Lazy _runtimeLazy = new(() => { - var current = PlatformAbstractions.Runtime.Current; + var current = PlatformAbstractions.SentryRuntime.Current; return new Runtime { Name = current.Name, @@ -36,7 +36,7 @@ public void Apply(IEventLike eventLike) if (!eventLike.Contexts.ContainsKey(OperatingSystem.Type)) { // RuntimeInformation.OSDescription is throwing on Mono 5.12 - if (!PlatformAbstractions.Runtime.Current.IsMono()) + if (!PlatformAbstractions.SentryRuntime.Current.IsMono()) { #if NETFRAMEWORK // RuntimeInformation.* throws on .NET Framework on macOS/Linux diff --git a/src/Sentry/PlatformAbstractions/RuntimeInfo.cs b/src/Sentry/PlatformAbstractions/RuntimeInfo.cs index 8a40596a96..047cb73f87 100644 --- a/src/Sentry/PlatformAbstractions/RuntimeInfo.cs +++ b/src/Sentry/PlatformAbstractions/RuntimeInfo.cs @@ -13,7 +13,7 @@ internal static class RuntimeInfo /// Gets the current runtime. /// /// A new instance for the current runtime - internal static Runtime GetRuntime() + internal static SentryRuntime GetRuntime() { var runtime = GetFromRuntimeInformation(); runtime ??= GetFromMonoRuntime(); @@ -21,45 +21,45 @@ internal static Runtime GetRuntime() return runtime.WithAdditionalProperties(); } - internal static Runtime WithAdditionalProperties(this Runtime runtime) + internal static SentryRuntime WithAdditionalProperties(this SentryRuntime runtime) { #if NETFRAMEWORK GetNetFxInstallationAndVersion(runtime, out var inst, out var ver); var version = runtime.Version ?? ver; var installation = runtime.FrameworkInstallation ?? inst; - return new Runtime(runtime.Name, version, installation, runtime.Raw); + return new SentryRuntime(runtime.Name, version, installation, runtime.Raw); #elif NET5_0_OR_GREATER var version = runtime.Version ?? GetNetCoreVersion(runtime); var identifier = runtime.Identifier ?? GetRuntimeIdentifier(runtime); - return new Runtime(runtime.Name, version, runtime.Raw, identifier); + return new SentryRuntime(runtime.Name, version, runtime.Raw, identifier); #else var version = runtime.Version ?? GetNetCoreVersion(runtime); - return new Runtime(runtime.Name, version, runtime.Raw); + return new SentryRuntime(runtime.Name, version, runtime.Raw); #endif } - internal static Runtime? Parse(string? rawRuntimeDescription, string? name = null) + internal static SentryRuntime? Parse(string? rawRuntimeDescription, string? name = null) { if (rawRuntimeDescription == null) { - return name == null ? null : new Runtime(name); + return name == null ? null : new SentryRuntime(name); } var match = RuntimeParseRegex.Match(rawRuntimeDescription); if (match.Success) { - return new Runtime( + return new SentryRuntime( name ?? (match.Groups["name"].Value == string.Empty ? null : match.Groups["name"].Value.Trim()), match.Groups["version"].Value == string.Empty ? null : match.Groups["version"].Value.Trim(), raw: rawRuntimeDescription); } - return new Runtime(name, raw: rawRuntimeDescription); + return new SentryRuntime(name, raw: rawRuntimeDescription); } #if NETFRAMEWORK internal static void GetNetFxInstallationAndVersion( - Runtime runtime, + SentryRuntime runtime, out FrameworkInstallation? frameworkInstallation, out string? version) { @@ -85,7 +85,7 @@ internal static void GetNetFxInstallationAndVersion( } } #else - private static string? GetNetCoreVersion(Runtime runtime) + private static string? GetNetCoreVersion(SentryRuntime runtime) { var description = RuntimeInformation.FrameworkDescription; return RemovePrefixOrNull(description, ".NET Core") @@ -101,7 +101,7 @@ internal static void GetNetFxInstallationAndVersion( #endif #if NET5_0_OR_GREATER - internal static string? GetRuntimeIdentifier(Runtime runtime) + internal static string? GetRuntimeIdentifier(SentryRuntime runtime) { try { @@ -114,7 +114,7 @@ internal static void GetNetFxInstallationAndVersion( } #endif - private static Runtime? GetFromRuntimeInformation() + private static SentryRuntime? GetFromRuntimeInformation() { try { @@ -132,7 +132,7 @@ internal static void GetNetFxInstallationAndVersion( } } - private static Runtime? GetFromMonoRuntime() + private static SentryRuntime? GetFromMonoRuntime() => Type.GetType("Mono.Runtime", false) ?.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static) ?.Invoke(null, null) is string monoVersion @@ -146,7 +146,7 @@ internal static void GetNetFxInstallationAndVersion( : null; // This should really only be used on .NET 1.0, 1.1, 2.0, 3.0, 3.5 and 4.0 - private static Runtime GetFromEnvironmentVariable() + private static SentryRuntime GetFromEnvironmentVariable() { // Environment.Version: NET Framework 4, 4.5, 4.5.1, 4.5.2 = 4.0.30319.xxxxx // .NET Framework 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1 = 4.0.30319.42000 @@ -158,6 +158,6 @@ private static Runtime GetFromEnvironmentVariable() 1 => "", _ => version.ToString() }; - return new Runtime(".NET Framework", friendlyVersion, raw: "Environment.Version=" + version); + return new SentryRuntime(".NET Framework", friendlyVersion, raw: "Environment.Version=" + version); } } diff --git a/src/Sentry/PlatformAbstractions/Runtime.cs b/src/Sentry/PlatformAbstractions/SentryRuntime.cs similarity index 92% rename from src/Sentry/PlatformAbstractions/Runtime.cs rename to src/Sentry/PlatformAbstractions/SentryRuntime.cs index ad9985faac..d960ea98aa 100644 --- a/src/Sentry/PlatformAbstractions/Runtime.cs +++ b/src/Sentry/PlatformAbstractions/SentryRuntime.cs @@ -3,9 +3,9 @@ namespace Sentry.PlatformAbstractions; /// /// Details of the runtime /// -public class Runtime : IEquatable +public class SentryRuntime : IEquatable { - private static Lazy _currentRuntime = new(RuntimeInfo.GetRuntime); + private static Lazy _currentRuntime = new(RuntimeInfo.GetRuntime); /// /// Gets the current runtime @@ -13,7 +13,7 @@ public class Runtime : IEquatable /// /// The current runtime. /// - public static Runtime Current => _currentRuntime.Value; + public static SentryRuntime Current => _currentRuntime.Value; /// /// The name of the runtime @@ -62,7 +62,7 @@ public class Runtime : IEquatable /// Creates a new Runtime instance /// #if NETFRAMEWORK - public Runtime( + public SentryRuntime( string? name = null, string? version = null, FrameworkInstallation? frameworkInstallation = null, @@ -75,7 +75,7 @@ public Runtime( Identifier = null; } #else - public Runtime( + public SentryRuntime( string? name = null, string? version = null, string? raw = null, @@ -113,7 +113,7 @@ public Runtime( /// /// The instance to compare against. /// True if the instances are equal by reference or its state. - public bool Equals(Runtime? other) + public bool Equals(SentryRuntime? other) { if (other is null) { @@ -157,7 +157,7 @@ public override bool Equals(object? obj) return false; } - return Equals((Runtime)obj); + return Equals((SentryRuntime)obj); } /// diff --git a/src/Sentry/PlatformAbstractions/RuntimeExtensions.cs b/src/Sentry/PlatformAbstractions/SentryRuntimeExtensions.cs similarity index 70% rename from src/Sentry/PlatformAbstractions/RuntimeExtensions.cs rename to src/Sentry/PlatformAbstractions/SentryRuntimeExtensions.cs index c2eb809309..f55326cb26 100644 --- a/src/Sentry/PlatformAbstractions/RuntimeExtensions.cs +++ b/src/Sentry/PlatformAbstractions/SentryRuntimeExtensions.cs @@ -1,24 +1,24 @@ namespace Sentry.PlatformAbstractions; /// -/// Extension method to the class. +/// Extension method to the class. /// [EditorBrowsable(EditorBrowsableState.Never)] -public static class RuntimeExtensions +public static class SentryRuntimeExtensions { /// /// Is the runtime instance .NET Framework. /// /// The runtime instance to check. /// True if it's .NET Framework, otherwise false. - public static bool IsNetFx(this Runtime runtime) => runtime.StartsWith(".NET Framework"); + public static bool IsNetFx(this SentryRuntime runtime) => runtime.StartsWith(".NET Framework"); /// /// Is the runtime instance .NET Core (or .NET). /// /// The runtime instance to check. /// True if it's .NET Core (or .NET), otherwise false. - public static bool IsNetCore(this Runtime runtime) => + public static bool IsNetCore(this SentryRuntime runtime) => runtime.StartsWith(".NET Core") || (runtime.StartsWith(".NET") && !runtime.StartsWith(".NET Framework")); @@ -27,16 +27,16 @@ public static bool IsNetCore(this Runtime runtime) => /// /// The runtime instance to check. /// True if it's Mono, otherwise false. - public static bool IsMono(this Runtime runtime) => runtime.StartsWith("Mono"); + public static bool IsMono(this SentryRuntime runtime) => runtime.StartsWith("Mono"); /// /// Is the runtime instance Browser Web Assembly. /// /// The runtime instance to check. /// True if it's Browser WASM, otherwise false. - internal static bool IsBrowserWasm(this Runtime runtime) => runtime.Identifier == "browser-wasm"; + internal static bool IsBrowserWasm(this SentryRuntime runtime) => runtime.Identifier == "browser-wasm"; - private static bool StartsWith(this Runtime? runtime, string runtimeName) => + private static bool StartsWith(this SentryRuntime? runtime, string runtimeName) => runtime?.Name?.StartsWith(runtimeName, StringComparison.OrdinalIgnoreCase) == true || runtime?.Raw?.StartsWith(runtimeName, StringComparison.OrdinalIgnoreCase) == true; } diff --git a/src/Sentry/Protocol/SampleProfile.cs b/src/Sentry/Protocol/SampleProfile.cs index 9836e6d893..d750e2ff3d 100644 --- a/src/Sentry/Protocol/SampleProfile.cs +++ b/src/Sentry/Protocol/SampleProfile.cs @@ -30,7 +30,7 @@ public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger) writer.WriteEndObject(); #if NETFRAMEWORK - if (PlatformAbstractions.Runtime.Current.IsMono()) + if (PlatformAbstractions.SentryRuntime.Current.IsMono()) { // STJ doesn't like HashableGrowableArray on Mono, failing with: // Invalid IL code in (wrapper dynamic-method) object:.ctor (): IL_0005: ret diff --git a/src/Sentry/SentryOptions.cs b/src/Sentry/SentryOptions.cs index caa9916933..53af99daa8 100644 --- a/src/Sentry/SentryOptions.cs +++ b/src/Sentry/SentryOptions.cs @@ -68,7 +68,7 @@ public bool IsGlobalModeEnabled /// public bool IsGlobalModeEnabled { - get => _isGlobalModeEnabled ??= Runtime.Current.IsBrowserWasm(); + get => _isGlobalModeEnabled ??= SentryRuntime.Current.IsBrowserWasm(); set => _isGlobalModeEnabled = value; } #endif @@ -938,7 +938,7 @@ public StackTraceMode StackTraceMode { // from 3.0.0 uses Enhanced (Ben.Demystifier) by default which is a breaking change // unless you are using .NET Native which isn't compatible with Ben.Demystifier. - _stackTraceMode = Runtime.Current.Name == ".NET Native" + _stackTraceMode = SentryRuntime.Current.Name == ".NET Native" ? StackTraceMode.Original : StackTraceMode.Enhanced; } diff --git a/src/Sentry/Span.cs b/src/Sentry/SentrySpan.cs similarity index 93% rename from src/Sentry/Span.cs rename to src/Sentry/SentrySpan.cs index b12f375c12..cff5f927d3 100644 --- a/src/Sentry/Span.cs +++ b/src/Sentry/SentrySpan.cs @@ -9,7 +9,7 @@ namespace Sentry; /// /// Transaction span. /// -public class Span : ISpanData, IJsonSerializable +public class SentrySpan : ISpanData, IJsonSerializable { /// public SpanId SpanId { get; private set; } @@ -75,9 +75,9 @@ public void SetExtra(string key, object? value) => (_extra ??= new Dictionary())[key] = value; /// - /// Initializes an instance of . + /// Initializes an instance of . /// - public Span(SpanId? parentSpanId, string operation) + public SentrySpan(SpanId? parentSpanId, string operation) { SpanId = SpanId.Create(); ParentSpanId = parentSpanId; @@ -86,9 +86,9 @@ public Span(SpanId? parentSpanId, string operation) } /// - /// Initializes an instance of . + /// Initializes an instance of . /// - public Span(ISpan tracer) + public SentrySpan(ISpan tracer) : this(tracer.ParentSpanId, tracer.Operation) { SpanId = tracer.SpanId; @@ -141,7 +141,7 @@ public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger) /// /// Parses a span from JSON. /// - public static Span FromJson(JsonElement json) + public static SentrySpan FromJson(JsonElement json) { var spanId = json.GetPropertyOrNull("span_id")?.Pipe(SpanId.FromJson) ?? SpanId.Empty; var parentSpanId = json.GetPropertyOrNull("parent_span_id")?.Pipe(SpanId.FromJson); @@ -156,7 +156,7 @@ public static Span FromJson(JsonElement json) var measurements = json.GetPropertyOrNull("measurements")?.GetDictionaryOrNull(Measurement.FromJson); var data = json.GetPropertyOrNull("data")?.GetDictionaryOrNull()?.ToDict(); - return new Span(parentSpanId, operation) + return new SentrySpan(parentSpanId, operation) { SpanId = spanId, TraceId = traceId, diff --git a/src/Sentry/Transaction.cs b/src/Sentry/Transaction.cs index cda4b57701..b88d09ca81 100644 --- a/src/Sentry/Transaction.cs +++ b/src/Sentry/Transaction.cs @@ -184,12 +184,12 @@ public IReadOnlyList Fingerprint public IReadOnlyDictionary Tags => _tags; // Not readonly because of deserialization - private Span[] _spans = Array.Empty(); + private SentrySpan[] _spans = Array.Empty(); /// /// Flat list of spans within this transaction. /// - public IReadOnlyCollection Spans => _spans; + public IReadOnlyCollection Spans => _spans; /// public bool IsFinished => EndTimestamp is not null; @@ -265,7 +265,7 @@ public Transaction(ITransactionTracer tracer) _tags = tracer.Tags.ToDict(); _spans = tracer.Spans .Where(s => s is not SpanTracer { IsSentryRequest: true }) // Filter sentry requests created by Sentry.OpenTelemetry.SentrySpanProcessor - .Select(s => new Span(s)).ToArray(); + .Select(s => new SentrySpan(s)).ToArray(); _measurements = tracer.Measurements.ToDict(); // Some items are not on the interface, but we only ever pass in a TransactionTracer anyway. @@ -383,7 +383,7 @@ public static Transaction FromJson(JsonElement json) var measurements = json.GetPropertyOrNull("measurements")? .GetDictionaryOrNull(Measurement.FromJson) ?? new(); var spans = json.GetPropertyOrNull("spans")? - .EnumerateArray().Select(Span.FromJson).ToArray() ?? Array.Empty(); + .EnumerateArray().Select(SentrySpan.FromJson).ToArray() ?? Array.Empty(); return new Transaction(name, nameSource) { diff --git a/test/Sentry.Testing/VerifyExtensions.cs b/test/Sentry.Testing/VerifyExtensions.cs index b35d8bb8fa..e4f0d2cddc 100644 --- a/test/Sentry.Testing/VerifyExtensions.cs +++ b/test/Sentry.Testing/VerifyExtensions.cs @@ -41,9 +41,9 @@ public static SettingsTask IgnoreStandardSentryMembers(this SettingsTask setting .IgnoreStackTrace(); } - private class SpansConverter : WriteOnlyJsonConverter> + private class SpansConverter : WriteOnlyJsonConverter> { - public override void Write(VerifyJsonWriter writer, IReadOnlyCollection spans) + public override void Write(VerifyJsonWriter writer, IReadOnlyCollection spans) { var ordered = spans .OrderBy(x => x.StartTimestamp) diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt index 908954b917..46d98fd264 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt @@ -771,6 +771,31 @@ namespace Sentry public static Sentry.ITransactionTracer StartTransaction(string name, string operation, Sentry.SentryTraceHeader traceHeader) { } public static Sentry.ITransactionTracer StartTransaction(string name, string operation, string? description) { } } + public class SentrySpan : Sentry.IHasExtra, Sentry.IHasTags, Sentry.IJsonSerializable, Sentry.ISpanData, Sentry.Protocol.ITraceContext + { + public SentrySpan(Sentry.ISpan tracer) { } + public SentrySpan(Sentry.SpanId? parentSpanId, string operation) { } + public string? Description { get; set; } + public System.DateTimeOffset? EndTimestamp { get; } + public System.Collections.Generic.IReadOnlyDictionary Extra { get; } + public bool IsFinished { get; } + public bool? IsSampled { get; } + public System.Collections.Generic.IReadOnlyDictionary Measurements { get; } + public string Operation { get; set; } + public Sentry.SpanId? ParentSpanId { get; } + public Sentry.SpanId SpanId { get; } + public System.DateTimeOffset StartTimestamp { get; } + public Sentry.SpanStatus? Status { get; set; } + public System.Collections.Generic.IReadOnlyDictionary Tags { get; } + public Sentry.SentryId TraceId { get; } + public Sentry.SentryTraceHeader GetTraceHeader() { } + public void SetExtra(string key, object? value) { } + public void SetMeasurement(string name, Sentry.Protocol.Measurement measurement) { } + public void SetTag(string key, string value) { } + public void UnsetTag(string key) { } + public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { } + public static Sentry.SentrySpan FromJson(System.Text.Json.JsonElement json) { } + } public sealed class SentryStackFrame : Sentry.IJsonSerializable { public SentryStackFrame() { } @@ -879,31 +904,6 @@ namespace Sentry public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { } public static Sentry.SessionUpdate FromJson(System.Text.Json.JsonElement json) { } } - public class Span : Sentry.IHasExtra, Sentry.IHasTags, Sentry.IJsonSerializable, Sentry.ISpanData, Sentry.Protocol.ITraceContext - { - public Span(Sentry.ISpan tracer) { } - public Span(Sentry.SpanId? parentSpanId, string operation) { } - public string? Description { get; set; } - public System.DateTimeOffset? EndTimestamp { get; } - public System.Collections.Generic.IReadOnlyDictionary Extra { get; } - public bool IsFinished { get; } - public bool? IsSampled { get; } - public System.Collections.Generic.IReadOnlyDictionary Measurements { get; } - public string Operation { get; set; } - public Sentry.SpanId? ParentSpanId { get; } - public Sentry.SpanId SpanId { get; } - public System.DateTimeOffset StartTimestamp { get; } - public Sentry.SpanStatus? Status { get; set; } - public System.Collections.Generic.IReadOnlyDictionary Tags { get; } - public Sentry.SentryId TraceId { get; } - public Sentry.SentryTraceHeader GetTraceHeader() { } - public void SetExtra(string key, object? value) { } - public void SetMeasurement(string name, Sentry.Protocol.Measurement measurement) { } - public void SetTag(string key, string value) { } - public void UnsetTag(string key) { } - public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { } - public static Sentry.Span FromJson(System.Text.Json.JsonElement json) { } - } public class SpanContext : Sentry.Protocol.ITraceContext { public SpanContext(string operation, Sentry.SpanId? spanId = default, Sentry.SpanId? parentSpanId = default, Sentry.SentryId? traceId = default, string? description = null, Sentry.SpanStatus? status = default, bool? isSampled = default) { } @@ -1054,7 +1054,7 @@ namespace Sentry public double? SampleRate { get; } public Sentry.SdkVersion Sdk { get; } public Sentry.SpanId SpanId { get; } - public System.Collections.Generic.IReadOnlyCollection Spans { get; } + public System.Collections.Generic.IReadOnlyCollection Spans { get; } public System.DateTimeOffset StartTimestamp { get; } public Sentry.SpanStatus? Status { get; } public System.Collections.Generic.IReadOnlyDictionary Tags { get; } @@ -1442,24 +1442,24 @@ namespace Sentry.PlatformAbstractions Client = 0, Full = 1, } - public class Runtime : System.IEquatable + public class SentryRuntime : System.IEquatable { - public Runtime(string? name = null, string? version = null, string? raw = null, string? identifier = null) { } + public SentryRuntime(string? name = null, string? version = null, string? raw = null, string? identifier = null) { } public string? Identifier { get; } public string? Name { get; } public string? Raw { get; } public string? Version { get; } - public static Sentry.PlatformAbstractions.Runtime Current { get; } - public bool Equals(Sentry.PlatformAbstractions.Runtime? other) { } + public static Sentry.PlatformAbstractions.SentryRuntime Current { get; } + public bool Equals(Sentry.PlatformAbstractions.SentryRuntime? other) { } public override bool Equals(object? obj) { } public override int GetHashCode() { } public override string? ToString() { } } - public static class RuntimeExtensions + public static class SentryRuntimeExtensions { - public static bool IsMono(this Sentry.PlatformAbstractions.Runtime runtime) { } - public static bool IsNetCore(this Sentry.PlatformAbstractions.Runtime runtime) { } - public static bool IsNetFx(this Sentry.PlatformAbstractions.Runtime runtime) { } + public static bool IsMono(this Sentry.PlatformAbstractions.SentryRuntime runtime) { } + public static bool IsNetCore(this Sentry.PlatformAbstractions.SentryRuntime runtime) { } + public static bool IsNetFx(this Sentry.PlatformAbstractions.SentryRuntime runtime) { } } } namespace Sentry.Protocol diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt index 908954b917..46d98fd264 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt @@ -771,6 +771,31 @@ namespace Sentry public static Sentry.ITransactionTracer StartTransaction(string name, string operation, Sentry.SentryTraceHeader traceHeader) { } public static Sentry.ITransactionTracer StartTransaction(string name, string operation, string? description) { } } + public class SentrySpan : Sentry.IHasExtra, Sentry.IHasTags, Sentry.IJsonSerializable, Sentry.ISpanData, Sentry.Protocol.ITraceContext + { + public SentrySpan(Sentry.ISpan tracer) { } + public SentrySpan(Sentry.SpanId? parentSpanId, string operation) { } + public string? Description { get; set; } + public System.DateTimeOffset? EndTimestamp { get; } + public System.Collections.Generic.IReadOnlyDictionary Extra { get; } + public bool IsFinished { get; } + public bool? IsSampled { get; } + public System.Collections.Generic.IReadOnlyDictionary Measurements { get; } + public string Operation { get; set; } + public Sentry.SpanId? ParentSpanId { get; } + public Sentry.SpanId SpanId { get; } + public System.DateTimeOffset StartTimestamp { get; } + public Sentry.SpanStatus? Status { get; set; } + public System.Collections.Generic.IReadOnlyDictionary Tags { get; } + public Sentry.SentryId TraceId { get; } + public Sentry.SentryTraceHeader GetTraceHeader() { } + public void SetExtra(string key, object? value) { } + public void SetMeasurement(string name, Sentry.Protocol.Measurement measurement) { } + public void SetTag(string key, string value) { } + public void UnsetTag(string key) { } + public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { } + public static Sentry.SentrySpan FromJson(System.Text.Json.JsonElement json) { } + } public sealed class SentryStackFrame : Sentry.IJsonSerializable { public SentryStackFrame() { } @@ -879,31 +904,6 @@ namespace Sentry public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { } public static Sentry.SessionUpdate FromJson(System.Text.Json.JsonElement json) { } } - public class Span : Sentry.IHasExtra, Sentry.IHasTags, Sentry.IJsonSerializable, Sentry.ISpanData, Sentry.Protocol.ITraceContext - { - public Span(Sentry.ISpan tracer) { } - public Span(Sentry.SpanId? parentSpanId, string operation) { } - public string? Description { get; set; } - public System.DateTimeOffset? EndTimestamp { get; } - public System.Collections.Generic.IReadOnlyDictionary Extra { get; } - public bool IsFinished { get; } - public bool? IsSampled { get; } - public System.Collections.Generic.IReadOnlyDictionary Measurements { get; } - public string Operation { get; set; } - public Sentry.SpanId? ParentSpanId { get; } - public Sentry.SpanId SpanId { get; } - public System.DateTimeOffset StartTimestamp { get; } - public Sentry.SpanStatus? Status { get; set; } - public System.Collections.Generic.IReadOnlyDictionary Tags { get; } - public Sentry.SentryId TraceId { get; } - public Sentry.SentryTraceHeader GetTraceHeader() { } - public void SetExtra(string key, object? value) { } - public void SetMeasurement(string name, Sentry.Protocol.Measurement measurement) { } - public void SetTag(string key, string value) { } - public void UnsetTag(string key) { } - public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { } - public static Sentry.Span FromJson(System.Text.Json.JsonElement json) { } - } public class SpanContext : Sentry.Protocol.ITraceContext { public SpanContext(string operation, Sentry.SpanId? spanId = default, Sentry.SpanId? parentSpanId = default, Sentry.SentryId? traceId = default, string? description = null, Sentry.SpanStatus? status = default, bool? isSampled = default) { } @@ -1054,7 +1054,7 @@ namespace Sentry public double? SampleRate { get; } public Sentry.SdkVersion Sdk { get; } public Sentry.SpanId SpanId { get; } - public System.Collections.Generic.IReadOnlyCollection Spans { get; } + public System.Collections.Generic.IReadOnlyCollection Spans { get; } public System.DateTimeOffset StartTimestamp { get; } public Sentry.SpanStatus? Status { get; } public System.Collections.Generic.IReadOnlyDictionary Tags { get; } @@ -1442,24 +1442,24 @@ namespace Sentry.PlatformAbstractions Client = 0, Full = 1, } - public class Runtime : System.IEquatable + public class SentryRuntime : System.IEquatable { - public Runtime(string? name = null, string? version = null, string? raw = null, string? identifier = null) { } + public SentryRuntime(string? name = null, string? version = null, string? raw = null, string? identifier = null) { } public string? Identifier { get; } public string? Name { get; } public string? Raw { get; } public string? Version { get; } - public static Sentry.PlatformAbstractions.Runtime Current { get; } - public bool Equals(Sentry.PlatformAbstractions.Runtime? other) { } + public static Sentry.PlatformAbstractions.SentryRuntime Current { get; } + public bool Equals(Sentry.PlatformAbstractions.SentryRuntime? other) { } public override bool Equals(object? obj) { } public override int GetHashCode() { } public override string? ToString() { } } - public static class RuntimeExtensions + public static class SentryRuntimeExtensions { - public static bool IsMono(this Sentry.PlatformAbstractions.Runtime runtime) { } - public static bool IsNetCore(this Sentry.PlatformAbstractions.Runtime runtime) { } - public static bool IsNetFx(this Sentry.PlatformAbstractions.Runtime runtime) { } + public static bool IsMono(this Sentry.PlatformAbstractions.SentryRuntime runtime) { } + public static bool IsNetCore(this Sentry.PlatformAbstractions.SentryRuntime runtime) { } + public static bool IsNetFx(this Sentry.PlatformAbstractions.SentryRuntime runtime) { } } } namespace Sentry.Protocol diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt index 7e9aba3bdd..74ffac9493 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt @@ -772,6 +772,31 @@ namespace Sentry public static Sentry.ITransactionTracer StartTransaction(string name, string operation, Sentry.SentryTraceHeader traceHeader) { } public static Sentry.ITransactionTracer StartTransaction(string name, string operation, string? description) { } } + public class SentrySpan : Sentry.IHasExtra, Sentry.IHasTags, Sentry.IJsonSerializable, Sentry.ISpanData, Sentry.Protocol.ITraceContext + { + public SentrySpan(Sentry.ISpan tracer) { } + public SentrySpan(Sentry.SpanId? parentSpanId, string operation) { } + public string? Description { get; set; } + public System.DateTimeOffset? EndTimestamp { get; } + public System.Collections.Generic.IReadOnlyDictionary Extra { get; } + public bool IsFinished { get; } + public bool? IsSampled { get; } + public System.Collections.Generic.IReadOnlyDictionary Measurements { get; } + public string Operation { get; set; } + public Sentry.SpanId? ParentSpanId { get; } + public Sentry.SpanId SpanId { get; } + public System.DateTimeOffset StartTimestamp { get; } + public Sentry.SpanStatus? Status { get; set; } + public System.Collections.Generic.IReadOnlyDictionary Tags { get; } + public Sentry.SentryId TraceId { get; } + public Sentry.SentryTraceHeader GetTraceHeader() { } + public void SetExtra(string key, object? value) { } + public void SetMeasurement(string name, Sentry.Protocol.Measurement measurement) { } + public void SetTag(string key, string value) { } + public void UnsetTag(string key) { } + public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { } + public static Sentry.SentrySpan FromJson(System.Text.Json.JsonElement json) { } + } public sealed class SentryStackFrame : Sentry.IJsonSerializable { public SentryStackFrame() { } @@ -880,31 +905,6 @@ namespace Sentry public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { } public static Sentry.SessionUpdate FromJson(System.Text.Json.JsonElement json) { } } - public class Span : Sentry.IHasExtra, Sentry.IHasTags, Sentry.IJsonSerializable, Sentry.ISpanData, Sentry.Protocol.ITraceContext - { - public Span(Sentry.ISpan tracer) { } - public Span(Sentry.SpanId? parentSpanId, string operation) { } - public string? Description { get; set; } - public System.DateTimeOffset? EndTimestamp { get; } - public System.Collections.Generic.IReadOnlyDictionary Extra { get; } - public bool IsFinished { get; } - public bool? IsSampled { get; } - public System.Collections.Generic.IReadOnlyDictionary Measurements { get; } - public string Operation { get; set; } - public Sentry.SpanId? ParentSpanId { get; } - public Sentry.SpanId SpanId { get; } - public System.DateTimeOffset StartTimestamp { get; } - public Sentry.SpanStatus? Status { get; set; } - public System.Collections.Generic.IReadOnlyDictionary Tags { get; } - public Sentry.SentryId TraceId { get; } - public Sentry.SentryTraceHeader GetTraceHeader() { } - public void SetExtra(string key, object? value) { } - public void SetMeasurement(string name, Sentry.Protocol.Measurement measurement) { } - public void SetTag(string key, string value) { } - public void UnsetTag(string key) { } - public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { } - public static Sentry.Span FromJson(System.Text.Json.JsonElement json) { } - } public class SpanContext : Sentry.Protocol.ITraceContext { public SpanContext(string operation, Sentry.SpanId? spanId = default, Sentry.SpanId? parentSpanId = default, Sentry.SentryId? traceId = default, string? description = null, Sentry.SpanStatus? status = default, bool? isSampled = default) { } @@ -1055,7 +1055,7 @@ namespace Sentry public double? SampleRate { get; } public Sentry.SdkVersion Sdk { get; } public Sentry.SpanId SpanId { get; } - public System.Collections.Generic.IReadOnlyCollection Spans { get; } + public System.Collections.Generic.IReadOnlyCollection Spans { get; } public System.DateTimeOffset StartTimestamp { get; } public Sentry.SpanStatus? Status { get; } public System.Collections.Generic.IReadOnlyDictionary Tags { get; } @@ -1443,24 +1443,24 @@ namespace Sentry.PlatformAbstractions Client = 0, Full = 1, } - public class Runtime : System.IEquatable + public class SentryRuntime : System.IEquatable { - public Runtime(string? name = null, string? version = null, string? raw = null, string? identifier = null) { } + public SentryRuntime(string? name = null, string? version = null, string? raw = null, string? identifier = null) { } public string? Identifier { get; } public string? Name { get; } public string? Raw { get; } public string? Version { get; } - public static Sentry.PlatformAbstractions.Runtime Current { get; } - public bool Equals(Sentry.PlatformAbstractions.Runtime? other) { } + public static Sentry.PlatformAbstractions.SentryRuntime Current { get; } + public bool Equals(Sentry.PlatformAbstractions.SentryRuntime? other) { } public override bool Equals(object? obj) { } public override int GetHashCode() { } public override string? ToString() { } } - public static class RuntimeExtensions + public static class SentryRuntimeExtensions { - public static bool IsMono(this Sentry.PlatformAbstractions.Runtime runtime) { } - public static bool IsNetCore(this Sentry.PlatformAbstractions.Runtime runtime) { } - public static bool IsNetFx(this Sentry.PlatformAbstractions.Runtime runtime) { } + public static bool IsMono(this Sentry.PlatformAbstractions.SentryRuntime runtime) { } + public static bool IsNetCore(this Sentry.PlatformAbstractions.SentryRuntime runtime) { } + public static bool IsNetFx(this Sentry.PlatformAbstractions.SentryRuntime runtime) { } } } namespace Sentry.Protocol diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt index 31c458b540..85970158d3 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt @@ -768,6 +768,31 @@ namespace Sentry public static Sentry.ITransactionTracer StartTransaction(string name, string operation, Sentry.SentryTraceHeader traceHeader) { } public static Sentry.ITransactionTracer StartTransaction(string name, string operation, string? description) { } } + public class SentrySpan : Sentry.IHasExtra, Sentry.IHasTags, Sentry.IJsonSerializable, Sentry.ISpanData, Sentry.Protocol.ITraceContext + { + public SentrySpan(Sentry.ISpan tracer) { } + public SentrySpan(Sentry.SpanId? parentSpanId, string operation) { } + public string? Description { get; set; } + public System.DateTimeOffset? EndTimestamp { get; } + public System.Collections.Generic.IReadOnlyDictionary Extra { get; } + public bool IsFinished { get; } + public bool? IsSampled { get; } + public System.Collections.Generic.IReadOnlyDictionary Measurements { get; } + public string Operation { get; set; } + public Sentry.SpanId? ParentSpanId { get; } + public Sentry.SpanId SpanId { get; } + public System.DateTimeOffset StartTimestamp { get; } + public Sentry.SpanStatus? Status { get; set; } + public System.Collections.Generic.IReadOnlyDictionary Tags { get; } + public Sentry.SentryId TraceId { get; } + public Sentry.SentryTraceHeader GetTraceHeader() { } + public void SetExtra(string key, object? value) { } + public void SetMeasurement(string name, Sentry.Protocol.Measurement measurement) { } + public void SetTag(string key, string value) { } + public void UnsetTag(string key) { } + public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { } + public static Sentry.SentrySpan FromJson(System.Text.Json.JsonElement json) { } + } public sealed class SentryStackFrame : Sentry.IJsonSerializable { public SentryStackFrame() { } @@ -876,31 +901,6 @@ namespace Sentry public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { } public static Sentry.SessionUpdate FromJson(System.Text.Json.JsonElement json) { } } - public class Span : Sentry.IHasExtra, Sentry.IHasTags, Sentry.IJsonSerializable, Sentry.ISpanData, Sentry.Protocol.ITraceContext - { - public Span(Sentry.ISpan tracer) { } - public Span(Sentry.SpanId? parentSpanId, string operation) { } - public string? Description { get; set; } - public System.DateTimeOffset? EndTimestamp { get; } - public System.Collections.Generic.IReadOnlyDictionary Extra { get; } - public bool IsFinished { get; } - public bool? IsSampled { get; } - public System.Collections.Generic.IReadOnlyDictionary Measurements { get; } - public string Operation { get; set; } - public Sentry.SpanId? ParentSpanId { get; } - public Sentry.SpanId SpanId { get; } - public System.DateTimeOffset StartTimestamp { get; } - public Sentry.SpanStatus? Status { get; set; } - public System.Collections.Generic.IReadOnlyDictionary Tags { get; } - public Sentry.SentryId TraceId { get; } - public Sentry.SentryTraceHeader GetTraceHeader() { } - public void SetExtra(string key, object? value) { } - public void SetMeasurement(string name, Sentry.Protocol.Measurement measurement) { } - public void SetTag(string key, string value) { } - public void UnsetTag(string key) { } - public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { } - public static Sentry.Span FromJson(System.Text.Json.JsonElement json) { } - } public class SpanContext : Sentry.Protocol.ITraceContext { public SpanContext(string operation, Sentry.SpanId? spanId = default, Sentry.SpanId? parentSpanId = default, Sentry.SentryId? traceId = default, string? description = null, Sentry.SpanStatus? status = default, bool? isSampled = default) { } @@ -1051,7 +1051,7 @@ namespace Sentry public double? SampleRate { get; } public Sentry.SdkVersion Sdk { get; } public Sentry.SpanId SpanId { get; } - public System.Collections.Generic.IReadOnlyCollection Spans { get; } + public System.Collections.Generic.IReadOnlyCollection Spans { get; } public System.DateTimeOffset StartTimestamp { get; } public Sentry.SpanStatus? Status { get; } public System.Collections.Generic.IReadOnlyDictionary Tags { get; } @@ -1439,25 +1439,25 @@ namespace Sentry.PlatformAbstractions Client = 0, Full = 1, } - public class Runtime : System.IEquatable + public class SentryRuntime : System.IEquatable { - public Runtime(string? name = null, string? version = null, Sentry.PlatformAbstractions.FrameworkInstallation? frameworkInstallation = null, string? raw = null) { } + public SentryRuntime(string? name = null, string? version = null, Sentry.PlatformAbstractions.FrameworkInstallation? frameworkInstallation = null, string? raw = null) { } public Sentry.PlatformAbstractions.FrameworkInstallation? FrameworkInstallation { get; } public string? Identifier { get; } public string? Name { get; } public string? Raw { get; } public string? Version { get; } - public static Sentry.PlatformAbstractions.Runtime Current { get; } - public bool Equals(Sentry.PlatformAbstractions.Runtime? other) { } + public static Sentry.PlatformAbstractions.SentryRuntime Current { get; } + public bool Equals(Sentry.PlatformAbstractions.SentryRuntime? other) { } public override bool Equals(object? obj) { } public override int GetHashCode() { } public override string? ToString() { } } - public static class RuntimeExtensions + public static class SentryRuntimeExtensions { - public static bool IsMono(this Sentry.PlatformAbstractions.Runtime runtime) { } - public static bool IsNetCore(this Sentry.PlatformAbstractions.Runtime runtime) { } - public static bool IsNetFx(this Sentry.PlatformAbstractions.Runtime runtime) { } + public static bool IsMono(this Sentry.PlatformAbstractions.SentryRuntime runtime) { } + public static bool IsNetCore(this Sentry.PlatformAbstractions.SentryRuntime runtime) { } + public static bool IsNetFx(this Sentry.PlatformAbstractions.SentryRuntime runtime) { } } } namespace Sentry.Protocol diff --git a/test/Sentry.Tests/Integrations/AppDomainAdapterTests.cs b/test/Sentry.Tests/Integrations/AppDomainAdapterTests.cs index f36a9bbd5f..57623d955c 100644 --- a/test/Sentry.Tests/Integrations/AppDomainAdapterTests.cs +++ b/test/Sentry.Tests/Integrations/AppDomainAdapterTests.cs @@ -1,6 +1,5 @@ #if !NETCOREAPP // Test runner fails when running on netcoreapp using Sentry.PlatformAbstractions; -using Runtime = Sentry.PlatformAbstractions.Runtime; namespace Sentry.Tests.Integrations; @@ -10,7 +9,7 @@ public class AppDomainAdapterTests public void UnhandledException_FiredOnExceptionUnhandledInThread() { // Test flaky on Mono - Skip.If(Runtime.Current.IsMono()); + Skip.If(SentryRuntime.Current.IsMono()); var evt = new ManualResetEventSlim(false); AppDomainAdapter.Instance.UnhandledException += (_, _) => evt.Set(); diff --git a/test/Sentry.Tests/Integrations/NetFxInstallationsIntegrationTests.cs b/test/Sentry.Tests/Integrations/NetFxInstallationsIntegrationTests.cs index 7f6bbb6768..e7cd780862 100644 --- a/test/Sentry.Tests/Integrations/NetFxInstallationsIntegrationTests.cs +++ b/test/Sentry.Tests/Integrations/NetFxInstallationsIntegrationTests.cs @@ -1,6 +1,5 @@ #if NETFRAMEWORK using Sentry.PlatformAbstractions; -using Runtime = Sentry.PlatformAbstractions.Runtime; namespace Sentry.Tests.Integrations; @@ -9,7 +8,7 @@ public class NetFxInstallationsIntegrationTests [SkippableFact] public void Register_CurrentRuntimeIsMono_NetFxInstallationsEventProcessorNotAdded() { - Skip.If(!Runtime.Current.IsMono()); + Skip.If(!SentryRuntime.Current.IsMono()); //Arrange var options = new SentryOptions(); @@ -25,7 +24,7 @@ public void Register_CurrentRuntimeIsMono_NetFxInstallationsEventProcessorNotAdd [SkippableFact] public void Register_CurrentRuntimeIsNotMono_NetFxInstallationsEventProcessorAdded() { - Skip.If(Runtime.Current.IsMono()); + Skip.If(SentryRuntime.Current.IsMono()); //Arrange var options = new SentryOptions(); diff --git a/test/Sentry.Tests/PlatformAbstractions/NetFxInstallationsEventProcessorTests.cs b/test/Sentry.Tests/PlatformAbstractions/NetFxInstallationsEventProcessorTests.cs index 9640e1d744..c6f6cc0759 100644 --- a/test/Sentry.Tests/PlatformAbstractions/NetFxInstallationsEventProcessorTests.cs +++ b/test/Sentry.Tests/PlatformAbstractions/NetFxInstallationsEventProcessorTests.cs @@ -1,6 +1,5 @@ #if NETFRAMEWORK using Sentry.PlatformAbstractions; -using Runtime = Sentry.PlatformAbstractions.Runtime; namespace Sentry.Tests.PlatformAbstractions; @@ -18,7 +17,7 @@ private class Fixture [SkippableFact] public void Process_SentryEventWithNetFxList() { - Skip.If(Runtime.Current.IsMono(), "Mono not supported."); + Skip.If(SentryRuntime.Current.IsMono(), "Mono not supported."); //Arrange var @event = new SentryEvent(); @@ -34,7 +33,7 @@ public void Process_SentryEventWithNetFxList() [SkippableFact] public void Process_ContextWithGetInstallationsData() { - Skip.If(Runtime.Current.IsMono(), "Mono not supported."); + Skip.If(SentryRuntime.Current.IsMono(), "Mono not supported."); //Arrange var @event = new SentryEvent(); @@ -54,7 +53,7 @@ public void Process_ContextWithGetInstallationsData() [SkippableFact] public void Process_NetFxInstallationsKeyExist_UnchangedSentryEvent() { - Skip.If(Runtime.Current.IsMono(), "Mono not supported."); + Skip.If(SentryRuntime.Current.IsMono(), "Mono not supported."); //Arrange var @event = new SentryEvent(); diff --git a/test/Sentry.Tests/PlatformAbstractions/RuntimeTests.cs b/test/Sentry.Tests/PlatformAbstractions/RuntimeTests.cs deleted file mode 100644 index c14a700d76..0000000000 --- a/test/Sentry.Tests/PlatformAbstractions/RuntimeTests.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Runtime = Sentry.PlatformAbstractions.Runtime; - -namespace Sentry.Tests.PlatformAbstractions; - -public class RuntimeTests -{ - [Fact] - public void Current_Equal() - { - Assert.Equal(Runtime.Current, Runtime.Current); - } -} diff --git a/test/Sentry.Tests/PlatformAbstractions/RuntimeExtensionsTests.cs b/test/Sentry.Tests/PlatformAbstractions/SentryRuntimeExtensionsTests.cs similarity index 87% rename from test/Sentry.Tests/PlatformAbstractions/RuntimeExtensionsTests.cs rename to test/Sentry.Tests/PlatformAbstractions/SentryRuntimeExtensionsTests.cs index aaeca317bf..174d713dae 100644 --- a/test/Sentry.Tests/PlatformAbstractions/RuntimeExtensionsTests.cs +++ b/test/Sentry.Tests/PlatformAbstractions/SentryRuntimeExtensionsTests.cs @@ -1,9 +1,8 @@ using Sentry.PlatformAbstractions; -using Runtime = Sentry.PlatformAbstractions.Runtime; namespace Sentry.Tests.PlatformAbstractions; -public class RuntimeExtensionsTests +public class SentryRuntimeExtensionsTests { [Theory] [InlineData(".NET Framework", true)] @@ -16,7 +15,7 @@ public class RuntimeExtensionsTests [InlineData("Mono Foo", false)] public void IsNetFx(string name, bool shouldMatch) { - var runtime = new Runtime(name); + var runtime = new SentryRuntime(name); var result = runtime.IsNetFx(); Assert.Equal(shouldMatch, result); } @@ -32,7 +31,7 @@ public void IsNetFx(string name, bool shouldMatch) [InlineData("Mono Foo", false)] public void IsNetCore(string name, bool shouldMatch) { - var runtime = new Runtime(name); + var runtime = new SentryRuntime(name); var result = runtime.IsNetCore(); Assert.Equal(shouldMatch, result); } @@ -48,7 +47,7 @@ public void IsNetCore(string name, bool shouldMatch) [InlineData("Mono Foo", true)] public void IsMono(string name, bool shouldMatch) { - var runtime = new Runtime(name); + var runtime = new SentryRuntime(name); var result = runtime.IsMono(); Assert.Equal(shouldMatch, result); } diff --git a/test/Sentry.Tests/PlatformAbstractions/SentryRuntimeTests.cs b/test/Sentry.Tests/PlatformAbstractions/SentryRuntimeTests.cs new file mode 100644 index 0000000000..1e99ff2306 --- /dev/null +++ b/test/Sentry.Tests/PlatformAbstractions/SentryRuntimeTests.cs @@ -0,0 +1,12 @@ +using Sentry.PlatformAbstractions; + +namespace Sentry.Tests.PlatformAbstractions; + +public class SentryRuntimeTests +{ + [Fact] + public void Current_Equal() + { + Assert.Equal(SentryRuntime.Current, SentryRuntime.Current); + } +} diff --git a/test/Sentry.Tests/Protocol/Context/RuntimeTests.cs b/test/Sentry.Tests/Protocol/Context/SentryRuntimeTests.cs similarity index 96% rename from test/Sentry.Tests/Protocol/Context/RuntimeTests.cs rename to test/Sentry.Tests/Protocol/Context/SentryRuntimeTests.cs index 6bae95b3c1..bea7b1108d 100644 --- a/test/Sentry.Tests/Protocol/Context/RuntimeTests.cs +++ b/test/Sentry.Tests/Protocol/Context/SentryRuntimeTests.cs @@ -1,10 +1,10 @@ namespace Sentry.Tests.Protocol.Context; -public class RuntimeTests +public class SentryRuntimeTests { private readonly IDiagnosticLogger _testOutputLogger; - public RuntimeTests(ITestOutputHelper output) + public SentryRuntimeTests(ITestOutputHelper output) { _testOutputLogger = new TestOutputDiagnosticLogger(output); }