From cfad9a5e1f16324736069d345b87d1d43b6e5d44 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Tue, 9 Jan 2024 05:48:29 +1300 Subject: [PATCH 1/2] Code coverage with coverlet and codecov (#3004) * Added Coverlet to Sentry.Tests (experimental) * Moved coverlet config to Directory.Build.props * Added parameter to dotnet test so code coverage is collected * Added github action to upload code coverage to codecov (currently disabled) * Update .github/workflows/build.yml * Update .github/workflows/build.yml * Update .github/workflows/build.yml * badge * Update .github/workflows/build.yml * Apply suggestions from code review * Update test/Directory.Build.props * fetch depth 2 * Update .gitignore * Switched back to opencover output format * Codecov informational only --------- Co-authored-by: Bruno Garcia --- .codecov.yml | 5 ++++- .github/workflows/build.yml | 6 +++++- .gitignore | 2 ++ README.md | 1 + build.cmd | 2 +- build.sh | 2 +- test/Directory.Build.props | 14 ++++++++++++++ 7 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.codecov.yml b/.codecov.yml index dbb5676b1f..1f99a342f5 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -3,9 +3,12 @@ coverage: changes: false project: default: - threshold: 5% + informational: true patch: off ignore: + - "benchmarks/**/*" + - "modules/**/*" + - "samples/**/*" - "test/**/*" range: 0..100 round: down diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2a86565b20..396bb56a9a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -61,6 +61,7 @@ jobs: uses: actions/checkout@v4 with: submodules: recursive + fetch-depth: 2 # default is 1 and codecov needs > 1 # We use macOS for the final publishing build so we we get all the iOS/macCatalyst targets in the packages - name: Set Environment Variables @@ -113,7 +114,10 @@ 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 }}" + 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 + + - name: Upload code coverage + uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d - name: Upload build and test outputs if: failure() diff --git a/.gitignore b/.gitignore index 8dfba6f948..e04df01865 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ codecov.sh lcov.info bin/ obj/ +**/coverage/*.xml +**/coverage/*.json .DS_Store Thumbs.db **/BenchmarkDotNet.Artifacts/*.log diff --git a/README.md b/README.md index 05c13769d1..8e46436292 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Sentry SDK for .NET =========== [![build](https://github.com/getsentry/sentry-dotnet/workflows/build/badge.svg?branch=main)](https://github.com/getsentry/sentry-dotnet/actions?query=branch%3Amain) +[![codecov](https://codecov.io/gh/getsentry/sentry-dotnet/branch/main/graph/badge.svg)](https://codecov.io/gh/getsentry/sentry-dotnet) [![Discord Chat](https://img.shields.io/discord/621778831602221064?logo=discord&logoColor=ffffff&color=7389D8)](https://discord.gg/PXa5Apfe7K) diff --git a/build.cmd b/build.cmd index 01c0cea7e6..7a73ff07fb 100644 --- a/build.cmd +++ b/build.cmd @@ -1,2 +1,2 @@ dotnet build Sentry.sln -c Release -dotnet test Sentry.sln -c Release --no-build +dotnet test Sentry.sln -c Release --no-build /p:CollectCoverage=true diff --git a/build.sh b/build.sh index 01c0cea7e6..7a73ff07fb 100755 --- a/build.sh +++ b/build.sh @@ -1,2 +1,2 @@ dotnet build Sentry.sln -c Release -dotnet test Sentry.sln -c Release --no-build +dotnet test Sentry.sln -c Release --no-build /p:CollectCoverage=true diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 3fb3aacd9f..deae655850 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -52,8 +52,22 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + [Sentry.Protocol.Test*]*,[xunit.*]*,[System.*]*,[Microsoft.*]*,[Sentry.Test*]* + ./coverage/ + opencover + + false + + From f93d62b1316b6c21c841343fef9abf9a97a1c9c2 Mon Sep 17 00:00:00 2001 From: Stefan Jandl Date: Mon, 8 Jan 2024 18:14:38 +0100 Subject: [PATCH 2/2] feat: Renamed `Sentry.User` to `SentryUser` (#3015) * renamed * Updated CHANGELOG.md * verify * Update CHANGELOG.md --------- Co-authored-by: Bruno Garcia --- CHANGELOG.md | 6 +++ .../Sentry.Samples.Android/MainActivity.cs | 2 +- src/Sentry.AspNetCore/DefaultUserFactory.cs | 6 +-- src/Sentry.Log4Net/SentryAppender.cs | 2 +- src/Sentry.NLog/SentryTarget.cs | 6 +-- src/Sentry/IEventLike.cs | 4 +- src/Sentry/IScopeObserver.cs | 2 +- src/Sentry/ISentryUserFactory.cs | 4 +- src/Sentry/Internal/NoOpTransaction.cs | 2 +- src/Sentry/Internal/ScopeObserver.cs | 4 +- .../Platforms/Android/AndroidScopeObserver.cs | 2 +- .../Android/Extensions/UserExtensions.cs | 4 +- .../Platforms/Cocoa/CocoaScopeObserver.cs | 2 +- .../Cocoa/Extensions/UserExtensions.cs | 4 +- .../Platforms/Native/NativeScopeObserver.cs | 2 +- src/Sentry/Scope.cs | 8 ++-- src/Sentry/SentryEvent.cs | 8 ++-- src/Sentry/{User.cs => SentryUser.cs} | 16 ++++---- src/Sentry/Transaction.cs | 8 ++-- src/Sentry/TransactionTracer.cs | 6 +-- .../AspNetCoreEnricherTests.cs | 2 +- ...piApprovalTests.Run.DotNet6_0.verified.txt | 40 +++++++++---------- ...piApprovalTests.Run.DotNet7_0.verified.txt | 40 +++++++++---------- ...piApprovalTests.Run.DotNet8_0.verified.txt | 40 +++++++++---------- .../ApiApprovalTests.Run.Net4_8.verified.txt | 40 +++++++++---------- test/Sentry.Tests/Protocol/BaseScopeTests.cs | 2 +- .../Protocol/Envelopes/EnvelopeTests.cs | 2 +- .../Protocol/ScopeExtensionsTests.cs | 4 +- .../Sentry.Tests/Protocol/SentryEventTests.cs | 2 +- .../Protocol/SentryEventTests.verify.cs | 2 +- .../Sentry.Tests/Protocol/TransactionTests.cs | 4 +- test/Sentry.Tests/Protocol/UserTests.cs | 20 +++++----- test/Sentry.Tests/ScopeTests.cs | 8 ++-- 33 files changed, 155 insertions(+), 149 deletions(-) rename src/Sentry/{User.cs => SentryUser.cs} (92%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fa8d3d549..7a8d34ac56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## Unreleased +### API breaking Changes + +#### Changed APIs + +- Class renamed `Sentry.User` to `Sentry.SentryUser` ([#3015](https://github.com/getsentry/sentry-dotnet/pull/3015)) + ### Dependencies - Bump CLI from v2.23.2 to v2.24.1 ([#3012](https://github.com/getsentry/sentry-dotnet/pull/3012)) diff --git a/samples/Sentry.Samples.Android/MainActivity.cs b/samples/Sentry.Samples.Android/MainActivity.cs index 727c5626be..5a2eb66b21 100644 --- a/samples/Sentry.Samples.Android/MainActivity.cs +++ b/samples/Sentry.Samples.Android/MainActivity.cs @@ -21,7 +21,7 @@ protected override void OnCreate(Bundle? savedInstanceState) { scope.AddBreadcrumb("Custom Breadcrumb"); scope.SetExtra("Test", "Custom Extra Data"); - scope.User = new User + scope.User = new SentryUser { Username = "SomeUser", Email = "test@example.com", diff --git a/src/Sentry.AspNetCore/DefaultUserFactory.cs b/src/Sentry.AspNetCore/DefaultUserFactory.cs index 2d760e72f1..09f7b20846 100644 --- a/src/Sentry.AspNetCore/DefaultUserFactory.cs +++ b/src/Sentry.AspNetCore/DefaultUserFactory.cs @@ -15,9 +15,9 @@ public DefaultUserFactory(IHttpContextAccessor httpContextAccessor) _httpContextAccessor = httpContextAccessor; } - public User? Create() => _httpContextAccessor?.HttpContext is {} httpContext ? Create(httpContext) : null; + public SentryUser? Create() => _httpContextAccessor?.HttpContext is {} httpContext ? Create(httpContext) : null; - public User? Create(HttpContext context) + public SentryUser? Create(HttpContext context) { var principal = context.User; if (principal is null) @@ -56,7 +56,7 @@ public DefaultUserFactory(IHttpContextAccessor httpContextAccessor) return email is null && id is null && username is null && ipAddress is null ? null - : new User + : new SentryUser { Id = id, Email = email, diff --git a/src/Sentry.Log4Net/SentryAppender.cs b/src/Sentry.Log4Net/SentryAppender.cs index bdc1785ab3..5b8cf40448 100644 --- a/src/Sentry.Log4Net/SentryAppender.cs +++ b/src/Sentry.Log4Net/SentryAppender.cs @@ -125,7 +125,7 @@ protected override void Append(LoggingEvent loggingEvent) if (SendIdentity && !string.IsNullOrEmpty(loggingEvent.Identity)) { - evt.User = new User + evt.User = new SentryUser { Id = loggingEvent.Identity }; diff --git a/src/Sentry.NLog/SentryTarget.cs b/src/Sentry.NLog/SentryTarget.cs index 8445bef42b..3154b9b4ac 100644 --- a/src/Sentry.NLog/SentryTarget.cs +++ b/src/Sentry.NLog/SentryTarget.cs @@ -346,7 +346,7 @@ private void InnerWrite(LogEventInfo logEvent) Level = logEvent.Level.ToSentryLevel(), Release = Options.Release, Environment = Options.Environment, - User = GetUser(logEvent) ?? new User(), + User = GetUser(logEvent) ?? new SentryUser(), }; if (evt.Sdk is { } sdk) @@ -439,14 +439,14 @@ private void InnerWrite(LogEventInfo logEvent) } } - private User? GetUser(LogEventInfo logEvent) + private SentryUser? GetUser(LogEventInfo logEvent) { if (User is null) { return null; } - var user = new User + var user = new SentryUser { Id = User.Id?.Render(logEvent), Username = User.Username?.Render(logEvent), diff --git a/src/Sentry/IEventLike.cs b/src/Sentry/IEventLike.cs index 36edead55e..80531d56c0 100644 --- a/src/Sentry/IEventLike.cs +++ b/src/Sentry/IEventLike.cs @@ -48,7 +48,7 @@ public interface IEventLike : IHasTags, IHasExtra /// /// The user. /// - User User { get; set; } + SentryUser User { get; set; } /// /// The release version of the application. @@ -194,7 +194,7 @@ public static class EventLikeExtensions } /// - /// Whether a has been set to the object with any of its fields non null. + /// Whether a has been set to the object with any of its fields non null. /// public static bool HasUser(this IEventLike eventLike) => eventLike.User.HasAnyData(); diff --git a/src/Sentry/IScopeObserver.cs b/src/Sentry/IScopeObserver.cs index 3df82b5f86..3757122d83 100644 --- a/src/Sentry/IScopeObserver.cs +++ b/src/Sentry/IScopeObserver.cs @@ -28,5 +28,5 @@ public interface IScopeObserver /// /// Sets the user information. /// - void SetUser(User? user); + void SetUser(SentryUser? user); } diff --git a/src/Sentry/ISentryUserFactory.cs b/src/Sentry/ISentryUserFactory.cs index 4bb353734f..e56ae055ad 100644 --- a/src/Sentry/ISentryUserFactory.cs +++ b/src/Sentry/ISentryUserFactory.cs @@ -6,8 +6,8 @@ namespace Sentry; public interface ISentryUserFactory { /// - /// Creates a Sentry representing the current principal. + /// Creates a Sentry representing the current principal. /// /// The protocol user - public User? Create(); + public SentryUser? Create(); } diff --git a/src/Sentry/Internal/NoOpTransaction.cs b/src/Sentry/Internal/NoOpTransaction.cs index 7693e4dddc..da5891de64 100644 --- a/src/Sentry/Internal/NoOpTransaction.cs +++ b/src/Sentry/Internal/NoOpTransaction.cs @@ -51,7 +51,7 @@ public string Name set { } } - public User User + public SentryUser User { get => new(); set { } diff --git a/src/Sentry/Internal/ScopeObserver.cs b/src/Sentry/Internal/ScopeObserver.cs index 741694c6a9..39ef871b16 100644 --- a/src/Sentry/Internal/ScopeObserver.cs +++ b/src/Sentry/Internal/ScopeObserver.cs @@ -65,7 +65,7 @@ public void UnsetTag(string key) public abstract void UnsetTagImpl(string key); - public void SetUser(User? user) + public void SetUser(SentryUser? user) { if (user is null) { @@ -82,7 +82,7 @@ public void SetUser(User? user) } } - public abstract void SetUserImpl(User user); + public abstract void SetUserImpl(SentryUser user); public abstract void UnsetUserImpl(); } diff --git a/src/Sentry/Platforms/Android/AndroidScopeObserver.cs b/src/Sentry/Platforms/Android/AndroidScopeObserver.cs index 329930e97f..dcedfa611e 100644 --- a/src/Sentry/Platforms/Android/AndroidScopeObserver.cs +++ b/src/Sentry/Platforms/Android/AndroidScopeObserver.cs @@ -87,7 +87,7 @@ public void UnsetTag(string key) } } - public void SetUser(User? user) + public void SetUser(SentryUser? user) { try { diff --git a/src/Sentry/Platforms/Android/Extensions/UserExtensions.cs b/src/Sentry/Platforms/Android/Extensions/UserExtensions.cs index 49e0bc91a8..d33585fbc9 100644 --- a/src/Sentry/Platforms/Android/Extensions/UserExtensions.cs +++ b/src/Sentry/Platforms/Android/Extensions/UserExtensions.cs @@ -5,7 +5,7 @@ internal static class UserExtensions private static readonly IDictionary EmptyDictionary = new ReadOnlyDictionary(new Dictionary()); - public static User ToUser(this JavaSdk.Protocol.User user) => + public static SentryUser ToUser(this JavaSdk.Protocol.User user) => new() { Email = user.Email, @@ -16,7 +16,7 @@ internal static class UserExtensions Other = user.Data ?? EmptyDictionary }; - public static JavaSdk.Protocol.User ToJavaUser(this User user) => + public static JavaSdk.Protocol.User ToJavaUser(this SentryUser user) => new() { Email = user.Email, diff --git a/src/Sentry/Platforms/Cocoa/CocoaScopeObserver.cs b/src/Sentry/Platforms/Cocoa/CocoaScopeObserver.cs index 851577711e..2e96952516 100644 --- a/src/Sentry/Platforms/Cocoa/CocoaScopeObserver.cs +++ b/src/Sentry/Platforms/Cocoa/CocoaScopeObserver.cs @@ -89,7 +89,7 @@ public void UnsetTag(string key) } } - public void SetUser(User? user) + public void SetUser(SentryUser? user) { try { diff --git a/src/Sentry/Platforms/Cocoa/Extensions/UserExtensions.cs b/src/Sentry/Platforms/Cocoa/Extensions/UserExtensions.cs index 2871317691..cf4f97b91f 100644 --- a/src/Sentry/Platforms/Cocoa/Extensions/UserExtensions.cs +++ b/src/Sentry/Platforms/Cocoa/Extensions/UserExtensions.cs @@ -4,7 +4,7 @@ namespace Sentry.Cocoa.Extensions; internal static class UserExtensions { - public static User ToUser(this CocoaSdk.SentryUser user, IDiagnosticLogger? logger = null) => + public static SentryUser ToUser(this CocoaSdk.SentryUser user, IDiagnosticLogger? logger = null) => new() { Email = user.Email, @@ -15,7 +15,7 @@ internal static class UserExtensions Other = user.Data.ToStringDictionary(logger) }; - public static CocoaSdk.SentryUser ToCocoaUser(this User user) + public static CocoaSdk.SentryUser ToCocoaUser(this SentryUser user) { var cocoaUser = new CocoaSdk.SentryUser { diff --git a/src/Sentry/Platforms/Native/NativeScopeObserver.cs b/src/Sentry/Platforms/Native/NativeScopeObserver.cs index 122b767bd8..4f859ae9c8 100644 --- a/src/Sentry/Platforms/Native/NativeScopeObserver.cs +++ b/src/Sentry/Platforms/Native/NativeScopeObserver.cs @@ -30,7 +30,7 @@ public override void AddBreadcrumbImpl(Breadcrumb breadcrumb) public override void UnsetTagImpl(string key) => C.sentry_remove_tag(key); - public override void SetUserImpl(User user) + public override void SetUserImpl(SentryUser user) { // see https://develop.sentry.dev/sdk/event-payloads/user/ var cUser = C.sentry_value_new_object(); diff --git a/src/Sentry/Scope.cs b/src/Sentry/Scope.cs index a2bb4cf86b..cebcfc276c 100644 --- a/src/Sentry/Scope.cs +++ b/src/Sentry/Scope.cs @@ -107,7 +107,7 @@ public Contexts Contexts } // Internal for testing. - internal Action UserChanged => user => + internal Action UserChanged => user => { if (Options.EnableScopeSync && Options.ScopeObserver is { } observer) @@ -116,12 +116,12 @@ public Contexts Contexts } }; - private User? _user; + private SentryUser? _user; /// - public User User + public SentryUser User { - get => _user ??= new User + get => _user ??= new SentryUser { PropertyChanged = UserChanged }; diff --git a/src/Sentry/SentryEvent.cs b/src/Sentry/SentryEvent.cs index a81e712a2f..7dcec67e55 100644 --- a/src/Sentry/SentryEvent.cs +++ b/src/Sentry/SentryEvent.cs @@ -139,12 +139,12 @@ public Contexts Contexts set => _contexts.ReplaceWith(value); } - private User? _user; + private SentryUser? _user; /// - public User User + public SentryUser User { - get => _user ??= new User(); + get => _user ??= new SentryUser(); set => _user = value; } @@ -304,7 +304,7 @@ internal static SentryEvent FromJson(JsonElement json, Exception? exception) var transaction = json.GetPropertyOrNull("transaction")?.GetString(); var request = json.GetPropertyOrNull("request")?.Pipe(Request.FromJson); var contexts = json.GetPropertyOrNull("contexts")?.Pipe(Contexts.FromJson); - var user = json.GetPropertyOrNull("user")?.Pipe(User.FromJson); + var user = json.GetPropertyOrNull("user")?.Pipe(SentryUser.FromJson); var environment = json.GetPropertyOrNull("environment")?.GetString(); var sdk = json.GetPropertyOrNull("sdk")?.Pipe(SdkVersion.FromJson) ?? new SdkVersion(); var fingerprint = json.GetPropertyOrNull("fingerprint")?.EnumerateArray().Select(j => j.GetString()).ToArray(); diff --git a/src/Sentry/User.cs b/src/Sentry/SentryUser.cs similarity index 92% rename from src/Sentry/User.cs rename to src/Sentry/SentryUser.cs index f1bee898a2..953c319e3b 100644 --- a/src/Sentry/User.cs +++ b/src/Sentry/SentryUser.cs @@ -7,9 +7,9 @@ namespace Sentry; /// An interface which describes the authenticated User for a request. /// /// -public sealed class User : IJsonSerializable +public sealed class SentryUser : IJsonSerializable { - internal Action? PropertyChanged { get; set; } + internal Action? PropertyChanged { get; set; } private string? _id; private string? _username; @@ -115,17 +115,17 @@ public sealed class User : IJsonSerializable } /// - /// Clones the current instance. + /// Clones the current instance. /// /// The cloned user. - public User Clone() + public SentryUser Clone() { - var user = new User(); + var user = new SentryUser(); CopyTo(user); return user; } - internal void CopyTo(User? user) + internal void CopyTo(SentryUser? user) { if (user == null) { @@ -169,7 +169,7 @@ public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? _) /// /// Parses from JSON. /// - public static User FromJson(JsonElement json) + public static SentryUser FromJson(JsonElement json) { var id = json.GetPropertyOrNull("id")?.GetString(); var username = json.GetPropertyOrNull("username")?.GetString(); @@ -178,7 +178,7 @@ public static User FromJson(JsonElement json) var segment = json.GetPropertyOrNull("segment")?.GetString(); var other = json.GetPropertyOrNull("other")?.GetStringDictionaryOrNull(); - return new User + return new SentryUser { Id = id, Username = username, diff --git a/src/Sentry/Transaction.cs b/src/Sentry/Transaction.cs index e6c530d502..cda4b57701 100644 --- a/src/Sentry/Transaction.cs +++ b/src/Sentry/Transaction.cs @@ -134,12 +134,12 @@ public Contexts Contexts set => _contexts.ReplaceWith(value); } - private User? _user; + private SentryUser? _user; /// - public User User + public SentryUser User { - get => _user ??= new User(); + get => _user ??= new SentryUser(); set => _user = value; } @@ -369,7 +369,7 @@ public static Transaction FromJson(JsonElement json) var distribution = json.GetPropertyOrNull("dist")?.GetString(); var request = json.GetPropertyOrNull("request")?.Pipe(Request.FromJson); var contexts = json.GetPropertyOrNull("contexts")?.Pipe(Contexts.FromJson) ?? new(); - var user = json.GetPropertyOrNull("user")?.Pipe(User.FromJson); + var user = json.GetPropertyOrNull("user")?.Pipe(SentryUser.FromJson); var environment = json.GetPropertyOrNull("environment")?.GetString(); var sdk = json.GetPropertyOrNull("sdk")?.Pipe(SdkVersion.FromJson) ?? new SdkVersion(); var fingerprint = json.GetPropertyOrNull("fingerprint")? diff --git a/src/Sentry/TransactionTracer.cs b/src/Sentry/TransactionTracer.cs index b8d0503541..e5ce135801 100644 --- a/src/Sentry/TransactionTracer.cs +++ b/src/Sentry/TransactionTracer.cs @@ -119,12 +119,12 @@ public Contexts Contexts set => _contexts.ReplaceWith(value); } - private User? _user; + private SentryUser? _user; /// - public User User + public SentryUser User { - get => _user ??= new User(); + get => _user ??= new SentryUser(); set => _user = value; } diff --git a/test/Sentry.OpenTelemetry.Tests/AspNetCoreEnricherTests.cs b/test/Sentry.OpenTelemetry.Tests/AspNetCoreEnricherTests.cs index fb1a1141d1..a2b2987956 100644 --- a/test/Sentry.OpenTelemetry.Tests/AspNetCoreEnricherTests.cs +++ b/test/Sentry.OpenTelemetry.Tests/AspNetCoreEnricherTests.cs @@ -11,7 +11,7 @@ public void Enrich_SendDefaultPii_UserOnScope() var hub = Substitute.For(); hub.ConfigureScope(Arg.Do>(action => action(scope))); - var user = new User{ Id = "foo" }; + var user = new SentryUser{ Id = "foo" }; var userFactory = Substitute.For(); userFactory.Create().Returns(user); diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt index 1014e7160b..c7cdbe53d4 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt @@ -202,7 +202,7 @@ namespace Sentry Sentry.Request Request { get; set; } Sentry.SdkVersion Sdk { get; } string? TransactionName { get; set; } - Sentry.User User { get; set; } + Sentry.SentryUser User { get; set; } void AddBreadcrumb(Sentry.Breadcrumb breadcrumb); } public interface IHasExtra @@ -242,7 +242,7 @@ namespace Sentry void AddBreadcrumb(Sentry.Breadcrumb breadcrumb); void SetExtra(string key, object? value); void SetTag(string key, string value); - void SetUser(Sentry.User? user); + void SetUser(Sentry.SentryUser? user); void UnsetTag(string key); } public interface ISentryClient @@ -269,7 +269,7 @@ namespace Sentry } public interface ISentryUserFactory { - Sentry.User? Create(); + Sentry.SentryUser? Create(); } public interface ISession { @@ -428,7 +428,7 @@ namespace Sentry public System.Collections.Generic.IReadOnlyDictionary Tags { get; } public Sentry.ITransactionTracer? Transaction { get; set; } public string? TransactionName { get; set; } - public Sentry.User User { get; set; } + public Sentry.SentryUser User { get; set; } public void AddAttachment(Sentry.Attachment attachment) { } public void AddBreadcrumb(Sentry.Breadcrumb breadcrumb) { } public void AddBreadcrumb(Sentry.Breadcrumb breadcrumb, Sentry.Hint hint) { } @@ -520,7 +520,7 @@ namespace Sentry public System.Collections.Generic.IReadOnlyDictionary Tags { get; } public System.DateTimeOffset Timestamp { get; } public string? TransactionName { get; set; } - public Sentry.User User { get; set; } + public Sentry.SentryUser User { get; set; } public void AddBreadcrumb(Sentry.Breadcrumb breadcrumb) { } public void SetExtra(string key, object? value) { } public void SetTag(string key, string value) { } @@ -807,6 +807,19 @@ namespace Sentry public override string ToString() { } public static Sentry.SentryTraceHeader Parse(string value) { } } + public sealed class SentryUser : Sentry.IJsonSerializable + { + public SentryUser() { } + public string? Email { get; set; } + public string? Id { get; set; } + public string? IpAddress { get; set; } + public System.Collections.Generic.IDictionary Other { get; set; } + public string? Segment { get; set; } + public string? Username { get; set; } + public Sentry.SentryUser Clone() { } + public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? _) { } + public static Sentry.SentryUser FromJson(System.Text.Json.JsonElement json) { } + } public class Session : Sentry.ISession { public Session(string? distinctId, string release, string? environment) { } @@ -1022,7 +1035,7 @@ namespace Sentry public Sentry.SpanStatus? Status { get; } public System.Collections.Generic.IReadOnlyDictionary Tags { get; } public Sentry.SentryId TraceId { get; } - public Sentry.User User { get; set; } + public Sentry.SentryUser User { get; set; } public void AddBreadcrumb(Sentry.Breadcrumb breadcrumb) { } public Sentry.SentryTraceHeader GetTraceHeader() { } public void SetExtra(string key, object? value) { } @@ -1085,7 +1098,7 @@ namespace Sentry public Sentry.SpanStatus? Status { get; set; } public System.Collections.Generic.IReadOnlyDictionary Tags { get; } public Sentry.SentryId TraceId { get; } - public Sentry.User User { get; set; } + public Sentry.SentryUser User { get; set; } public void AddBreadcrumb(Sentry.Breadcrumb breadcrumb) { } public void Finish() { } public void Finish(Sentry.SpanStatus status) { } @@ -1099,19 +1112,6 @@ namespace Sentry public Sentry.ISpan StartChild(string operation) { } public void UnsetTag(string key) { } } - public sealed class User : Sentry.IJsonSerializable - { - public User() { } - public string? Email { get; set; } - public string? Id { get; set; } - public string? IpAddress { get; set; } - public System.Collections.Generic.IDictionary Other { get; set; } - public string? Segment { get; set; } - public string? Username { get; set; } - public Sentry.User Clone() { } - public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? _) { } - public static Sentry.User FromJson(System.Text.Json.JsonElement json) { } - } public sealed class UserFeedback : Sentry.IJsonSerializable { public UserFeedback(Sentry.SentryId eventId, string? name, string? email, string? comments) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt index 1014e7160b..c7cdbe53d4 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt @@ -202,7 +202,7 @@ namespace Sentry Sentry.Request Request { get; set; } Sentry.SdkVersion Sdk { get; } string? TransactionName { get; set; } - Sentry.User User { get; set; } + Sentry.SentryUser User { get; set; } void AddBreadcrumb(Sentry.Breadcrumb breadcrumb); } public interface IHasExtra @@ -242,7 +242,7 @@ namespace Sentry void AddBreadcrumb(Sentry.Breadcrumb breadcrumb); void SetExtra(string key, object? value); void SetTag(string key, string value); - void SetUser(Sentry.User? user); + void SetUser(Sentry.SentryUser? user); void UnsetTag(string key); } public interface ISentryClient @@ -269,7 +269,7 @@ namespace Sentry } public interface ISentryUserFactory { - Sentry.User? Create(); + Sentry.SentryUser? Create(); } public interface ISession { @@ -428,7 +428,7 @@ namespace Sentry public System.Collections.Generic.IReadOnlyDictionary Tags { get; } public Sentry.ITransactionTracer? Transaction { get; set; } public string? TransactionName { get; set; } - public Sentry.User User { get; set; } + public Sentry.SentryUser User { get; set; } public void AddAttachment(Sentry.Attachment attachment) { } public void AddBreadcrumb(Sentry.Breadcrumb breadcrumb) { } public void AddBreadcrumb(Sentry.Breadcrumb breadcrumb, Sentry.Hint hint) { } @@ -520,7 +520,7 @@ namespace Sentry public System.Collections.Generic.IReadOnlyDictionary Tags { get; } public System.DateTimeOffset Timestamp { get; } public string? TransactionName { get; set; } - public Sentry.User User { get; set; } + public Sentry.SentryUser User { get; set; } public void AddBreadcrumb(Sentry.Breadcrumb breadcrumb) { } public void SetExtra(string key, object? value) { } public void SetTag(string key, string value) { } @@ -807,6 +807,19 @@ namespace Sentry public override string ToString() { } public static Sentry.SentryTraceHeader Parse(string value) { } } + public sealed class SentryUser : Sentry.IJsonSerializable + { + public SentryUser() { } + public string? Email { get; set; } + public string? Id { get; set; } + public string? IpAddress { get; set; } + public System.Collections.Generic.IDictionary Other { get; set; } + public string? Segment { get; set; } + public string? Username { get; set; } + public Sentry.SentryUser Clone() { } + public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? _) { } + public static Sentry.SentryUser FromJson(System.Text.Json.JsonElement json) { } + } public class Session : Sentry.ISession { public Session(string? distinctId, string release, string? environment) { } @@ -1022,7 +1035,7 @@ namespace Sentry public Sentry.SpanStatus? Status { get; } public System.Collections.Generic.IReadOnlyDictionary Tags { get; } public Sentry.SentryId TraceId { get; } - public Sentry.User User { get; set; } + public Sentry.SentryUser User { get; set; } public void AddBreadcrumb(Sentry.Breadcrumb breadcrumb) { } public Sentry.SentryTraceHeader GetTraceHeader() { } public void SetExtra(string key, object? value) { } @@ -1085,7 +1098,7 @@ namespace Sentry public Sentry.SpanStatus? Status { get; set; } public System.Collections.Generic.IReadOnlyDictionary Tags { get; } public Sentry.SentryId TraceId { get; } - public Sentry.User User { get; set; } + public Sentry.SentryUser User { get; set; } public void AddBreadcrumb(Sentry.Breadcrumb breadcrumb) { } public void Finish() { } public void Finish(Sentry.SpanStatus status) { } @@ -1099,19 +1112,6 @@ namespace Sentry public Sentry.ISpan StartChild(string operation) { } public void UnsetTag(string key) { } } - public sealed class User : Sentry.IJsonSerializable - { - public User() { } - public string? Email { get; set; } - public string? Id { get; set; } - public string? IpAddress { get; set; } - public System.Collections.Generic.IDictionary Other { get; set; } - public string? Segment { get; set; } - public string? Username { get; set; } - public Sentry.User Clone() { } - public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? _) { } - public static Sentry.User FromJson(System.Text.Json.JsonElement json) { } - } public sealed class UserFeedback : Sentry.IJsonSerializable { public UserFeedback(Sentry.SentryId eventId, string? name, string? email, string? comments) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt index 0cf19f3b6c..01a0a20629 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt @@ -203,7 +203,7 @@ namespace Sentry Sentry.Request Request { get; set; } Sentry.SdkVersion Sdk { get; } string? TransactionName { get; set; } - Sentry.User User { get; set; } + Sentry.SentryUser User { get; set; } void AddBreadcrumb(Sentry.Breadcrumb breadcrumb); } public interface IHasExtra @@ -243,7 +243,7 @@ namespace Sentry void AddBreadcrumb(Sentry.Breadcrumb breadcrumb); void SetExtra(string key, object? value); void SetTag(string key, string value); - void SetUser(Sentry.User? user); + void SetUser(Sentry.SentryUser? user); void UnsetTag(string key); } public interface ISentryClient @@ -270,7 +270,7 @@ namespace Sentry } public interface ISentryUserFactory { - Sentry.User? Create(); + Sentry.SentryUser? Create(); } public interface ISession { @@ -429,7 +429,7 @@ namespace Sentry public System.Collections.Generic.IReadOnlyDictionary Tags { get; } public Sentry.ITransactionTracer? Transaction { get; set; } public string? TransactionName { get; set; } - public Sentry.User User { get; set; } + public Sentry.SentryUser User { get; set; } public void AddAttachment(Sentry.Attachment attachment) { } public void AddBreadcrumb(Sentry.Breadcrumb breadcrumb) { } public void AddBreadcrumb(Sentry.Breadcrumb breadcrumb, Sentry.Hint hint) { } @@ -521,7 +521,7 @@ namespace Sentry public System.Collections.Generic.IReadOnlyDictionary Tags { get; } public System.DateTimeOffset Timestamp { get; } public string? TransactionName { get; set; } - public Sentry.User User { get; set; } + public Sentry.SentryUser User { get; set; } public void AddBreadcrumb(Sentry.Breadcrumb breadcrumb) { } public void SetExtra(string key, object? value) { } public void SetTag(string key, string value) { } @@ -808,6 +808,19 @@ namespace Sentry public override string ToString() { } public static Sentry.SentryTraceHeader Parse(string value) { } } + public sealed class SentryUser : Sentry.IJsonSerializable + { + public SentryUser() { } + public string? Email { get; set; } + public string? Id { get; set; } + public string? IpAddress { get; set; } + public System.Collections.Generic.IDictionary Other { get; set; } + public string? Segment { get; set; } + public string? Username { get; set; } + public Sentry.SentryUser Clone() { } + public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? _) { } + public static Sentry.SentryUser FromJson(System.Text.Json.JsonElement json) { } + } public class Session : Sentry.ISession { public Session(string? distinctId, string release, string? environment) { } @@ -1023,7 +1036,7 @@ namespace Sentry public Sentry.SpanStatus? Status { get; } public System.Collections.Generic.IReadOnlyDictionary Tags { get; } public Sentry.SentryId TraceId { get; } - public Sentry.User User { get; set; } + public Sentry.SentryUser User { get; set; } public void AddBreadcrumb(Sentry.Breadcrumb breadcrumb) { } public Sentry.SentryTraceHeader GetTraceHeader() { } public void SetExtra(string key, object? value) { } @@ -1086,7 +1099,7 @@ namespace Sentry public Sentry.SpanStatus? Status { get; set; } public System.Collections.Generic.IReadOnlyDictionary Tags { get; } public Sentry.SentryId TraceId { get; } - public Sentry.User User { get; set; } + public Sentry.SentryUser User { get; set; } public void AddBreadcrumb(Sentry.Breadcrumb breadcrumb) { } public void Finish() { } public void Finish(Sentry.SpanStatus status) { } @@ -1100,19 +1113,6 @@ namespace Sentry public Sentry.ISpan StartChild(string operation) { } public void UnsetTag(string key) { } } - public sealed class User : Sentry.IJsonSerializable - { - public User() { } - public string? Email { get; set; } - public string? Id { get; set; } - public string? IpAddress { get; set; } - public System.Collections.Generic.IDictionary Other { get; set; } - public string? Segment { get; set; } - public string? Username { get; set; } - public Sentry.User Clone() { } - public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? _) { } - public static Sentry.User FromJson(System.Text.Json.JsonElement json) { } - } public sealed class UserFeedback : Sentry.IJsonSerializable { public UserFeedback(Sentry.SentryId eventId, string? name, string? email, string? comments) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt index 26718ef234..ec83a0ab55 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt @@ -201,7 +201,7 @@ namespace Sentry Sentry.Request Request { get; set; } Sentry.SdkVersion Sdk { get; } string? TransactionName { get; set; } - Sentry.User User { get; set; } + Sentry.SentryUser User { get; set; } void AddBreadcrumb(Sentry.Breadcrumb breadcrumb); } public interface IHasExtra @@ -241,7 +241,7 @@ namespace Sentry void AddBreadcrumb(Sentry.Breadcrumb breadcrumb); void SetExtra(string key, object? value); void SetTag(string key, string value); - void SetUser(Sentry.User? user); + void SetUser(Sentry.SentryUser? user); void UnsetTag(string key); } public interface ISentryClient @@ -268,7 +268,7 @@ namespace Sentry } public interface ISentryUserFactory { - Sentry.User? Create(); + Sentry.SentryUser? Create(); } public interface ISession { @@ -427,7 +427,7 @@ namespace Sentry public System.Collections.Generic.IReadOnlyDictionary Tags { get; } public Sentry.ITransactionTracer? Transaction { get; set; } public string? TransactionName { get; set; } - public Sentry.User User { get; set; } + public Sentry.SentryUser User { get; set; } public void AddAttachment(Sentry.Attachment attachment) { } public void AddBreadcrumb(Sentry.Breadcrumb breadcrumb) { } public void AddBreadcrumb(Sentry.Breadcrumb breadcrumb, Sentry.Hint hint) { } @@ -519,7 +519,7 @@ namespace Sentry public System.Collections.Generic.IReadOnlyDictionary Tags { get; } public System.DateTimeOffset Timestamp { get; } public string? TransactionName { get; set; } - public Sentry.User User { get; set; } + public Sentry.SentryUser User { get; set; } public void AddBreadcrumb(Sentry.Breadcrumb breadcrumb) { } public void SetExtra(string key, object? value) { } public void SetTag(string key, string value) { } @@ -804,6 +804,19 @@ namespace Sentry public override string ToString() { } public static Sentry.SentryTraceHeader Parse(string value) { } } + public sealed class SentryUser : Sentry.IJsonSerializable + { + public SentryUser() { } + public string? Email { get; set; } + public string? Id { get; set; } + public string? IpAddress { get; set; } + public System.Collections.Generic.IDictionary Other { get; set; } + public string? Segment { get; set; } + public string? Username { get; set; } + public Sentry.SentryUser Clone() { } + public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? _) { } + public static Sentry.SentryUser FromJson(System.Text.Json.JsonElement json) { } + } public class Session : Sentry.ISession { public Session(string? distinctId, string release, string? environment) { } @@ -1019,7 +1032,7 @@ namespace Sentry public Sentry.SpanStatus? Status { get; } public System.Collections.Generic.IReadOnlyDictionary Tags { get; } public Sentry.SentryId TraceId { get; } - public Sentry.User User { get; set; } + public Sentry.SentryUser User { get; set; } public void AddBreadcrumb(Sentry.Breadcrumb breadcrumb) { } public Sentry.SentryTraceHeader GetTraceHeader() { } public void SetExtra(string key, object? value) { } @@ -1082,7 +1095,7 @@ namespace Sentry public Sentry.SpanStatus? Status { get; set; } public System.Collections.Generic.IReadOnlyDictionary Tags { get; } public Sentry.SentryId TraceId { get; } - public Sentry.User User { get; set; } + public Sentry.SentryUser User { get; set; } public void AddBreadcrumb(Sentry.Breadcrumb breadcrumb) { } public void Finish() { } public void Finish(Sentry.SpanStatus status) { } @@ -1096,19 +1109,6 @@ namespace Sentry public Sentry.ISpan StartChild(string operation) { } public void UnsetTag(string key) { } } - public sealed class User : Sentry.IJsonSerializable - { - public User() { } - public string? Email { get; set; } - public string? Id { get; set; } - public string? IpAddress { get; set; } - public System.Collections.Generic.IDictionary Other { get; set; } - public string? Segment { get; set; } - public string? Username { get; set; } - public Sentry.User Clone() { } - public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? _) { } - public static Sentry.User FromJson(System.Text.Json.JsonElement json) { } - } public sealed class UserFeedback : Sentry.IJsonSerializable { public UserFeedback(Sentry.SentryId eventId, string? name, string? email, string? comments) { } diff --git a/test/Sentry.Tests/Protocol/BaseScopeTests.cs b/test/Sentry.Tests/Protocol/BaseScopeTests.cs index 23a22d04b4..1382162a26 100644 --- a/test/Sentry.Tests/Protocol/BaseScopeTests.cs +++ b/test/Sentry.Tests/Protocol/BaseScopeTests.cs @@ -37,7 +37,7 @@ public void User_ByDefault_ReturnsNotNull() [Fact] public void User_Settable() { - var expected = new User(); + var expected = new SentryUser(); _sut.User = expected; Assert.Same(expected, _sut.User); } diff --git a/test/Sentry.Tests/Protocol/Envelopes/EnvelopeTests.cs b/test/Sentry.Tests/Protocol/Envelopes/EnvelopeTests.cs index ff0540b1f7..d206be0d42 100644 --- a/test/Sentry.Tests/Protocol/Envelopes/EnvelopeTests.cs +++ b/test/Sentry.Tests/Protocol/Envelopes/EnvelopeTests.cs @@ -628,7 +628,7 @@ public async Task Roundtrip_WithEvent_Success() var id = Guid.Parse("4b780f4c-ec03-42a7-8ef8-a41c9d5621f8"); var @event = new SentryEvent(ex, timestamp, id) { - User = new User { Id = "user-id" }, + User = new SentryUser { Id = "user-id" }, Request = new Request { Method = "POST" }, Contexts = new Contexts { diff --git a/test/Sentry.Tests/Protocol/ScopeExtensionsTests.cs b/test/Sentry.Tests/Protocol/ScopeExtensionsTests.cs index d6fb093701..a1102e619d 100644 --- a/test/Sentry.Tests/Protocol/ScopeExtensionsTests.cs +++ b/test/Sentry.Tests/Protocol/ScopeExtensionsTests.cs @@ -30,7 +30,7 @@ public void HasUser_NullUser_ReturnsFalse() public void HasUser_EmptyUser_ReturnsFalse() { var sut = _fixture.GetSut(); - sut.User = new User(); + sut.User = new SentryUser(); Assert.False(sut.HasUser()); } @@ -1088,7 +1088,7 @@ public void Apply_User_NotSameReference() var sut = _fixture.GetSut(); var target = _fixture.GetSut(); - sut.User = new User(); + sut.User = new SentryUser(); sut.Apply(target); Assert.NotSame(sut.User, target.User); diff --git a/test/Sentry.Tests/Protocol/SentryEventTests.cs b/test/Sentry.Tests/Protocol/SentryEventTests.cs index 0beea4069c..be831f5b56 100644 --- a/test/Sentry.Tests/Protocol/SentryEventTests.cs +++ b/test/Sentry.Tests/Protocol/SentryEventTests.cs @@ -119,7 +119,7 @@ public void Redact_Redacts_Urls() Method = "GET", Url = requestUrl }, - User = new User + User = new SentryUser { Username = username, Email = email, diff --git a/test/Sentry.Tests/Protocol/SentryEventTests.verify.cs b/test/Sentry.Tests/Protocol/SentryEventTests.verify.cs index 6a16d77c0c..5cac84f2d0 100644 --- a/test/Sentry.Tests/Protocol/SentryEventTests.verify.cs +++ b/test/Sentry.Tests/Protocol/SentryEventTests.verify.cs @@ -11,7 +11,7 @@ public async Task SerializeObject_AllPropertiesSetToNonDefault_SerializesValidOb var id = Guid.Parse("4b780f4c-ec03-42a7-8ef8-a41c9d5621f8"); var sut = new SentryEvent(ex, timestamp, id) { - User = new User { Id = "user-id" }, + User = new SentryUser { Id = "user-id" }, Request = new Request { Method = "POST" }, Contexts = new Contexts { diff --git a/test/Sentry.Tests/Protocol/TransactionTests.cs b/test/Sentry.Tests/Protocol/TransactionTests.cs index dd43d92398..0bfa66d2bc 100644 --- a/test/Sentry.Tests/Protocol/TransactionTests.cs +++ b/test/Sentry.Tests/Protocol/TransactionTests.cs @@ -90,7 +90,7 @@ public void Redact_Redacts_Urls() // We don't redact the User or the Request since, if SendDefaultPii is false, we don't add these to the // transaction in the SDK anyway (by default they don't get sent... but the user can always override this // behavior if they need) - User = new User { Id = "user-id", Username = "username", Email = "bob@foo.com", IpAddress = "127.0.0.1" }, + User = new SentryUser { Id = "user-id", Username = "username", Email = "bob@foo.com", IpAddress = "127.0.0.1" }, Request = new Request { Method = "POST", Url = "https://user@not.redacted"}, Sdk = new SdkVersion { Name = "SDK-test", Version = "1.1.1" }, Environment = environment, @@ -175,7 +175,7 @@ public void SerializeObject_AllPropertiesSetToNonDefault_SerializesValidObject() { Description = "desc123", Status = SpanStatus.Aborted, - User = new User { Id = "user-id" }, + User = new SentryUser { Id = "user-id" }, Request = new Request { Method = "POST" }, Sdk = new SdkVersion { Name = "SDK-test", Version = "1.1.1" }, Environment = "environment", diff --git a/test/Sentry.Tests/Protocol/UserTests.cs b/test/Sentry.Tests/Protocol/UserTests.cs index e1d44a2e96..c7bbfb65fa 100644 --- a/test/Sentry.Tests/Protocol/UserTests.cs +++ b/test/Sentry.Tests/Protocol/UserTests.cs @@ -12,7 +12,7 @@ public UserTests(ITestOutputHelper output) [Fact] public void SerializeObject_AllPropertiesSetToNonDefault_SerializesValidObject() { - var sut = new User + var sut = new SentryUser { Id = "user-id", Username = "user-name", @@ -42,7 +42,7 @@ public void SerializeObject_AllPropertiesSetToNonDefault_SerializesValidObject() [Fact] public void Clone_CopyValues() { - var sut = new User + var sut = new SentryUser { Id = "id", Email = "emal@sentry.io", @@ -67,7 +67,7 @@ public void Clone_CopyValues() [Theory] [MemberData(nameof(TestCases))] - public void SerializeObject_TestCase_SerializesAsExpected((User user, string serialized) @case) + public void SerializeObject_TestCase_SerializesAsExpected((SentryUser user, string serialized) @case) { var actual = @case.user.ToJsonString(_testOutputLogger); Assert.Equal(@case.serialized, actual); @@ -75,14 +75,14 @@ public void SerializeObject_TestCase_SerializesAsExpected((User user, string ser public static IEnumerable TestCases() { - yield return new object[] { (new User(), "{}") }; - yield return new object[] { (new User { Id = "some id" }, """{"id":"some id"}""") }; - yield return new object[] { (new User { Username = "some username" }, """{"username":"some username"}""") }; - yield return new object[] { (new User { Email = "some email" }, """{"email":"some email"}""") }; - yield return new object[] { (new User { IpAddress = "some ipAddress" }, """{"ip_address":"some ipAddress"}""") }; - yield return new object[] { (new User { Segment = "some segment" }, """{"segment":"some segment"}""") }; + yield return new object[] { (new SentryUser(), "{}") }; + yield return new object[] { (new SentryUser { Id = "some id" }, """{"id":"some id"}""") }; + yield return new object[] { (new SentryUser { Username = "some username" }, """{"username":"some username"}""") }; + yield return new object[] { (new SentryUser { Email = "some email" }, """{"email":"some email"}""") }; + yield return new object[] { (new SentryUser { IpAddress = "some ipAddress" }, """{"ip_address":"some ipAddress"}""") }; + yield return new object[] { (new SentryUser { Segment = "some segment" }, """{"segment":"some segment"}""") }; var other = new Dictionary {{"testCustomValueKey", "testCustomValue"}}; - yield return new object[] { (new User { Other = other }, """{"other":{"testCustomValueKey":"testCustomValue"}}""")}; + yield return new object[] { (new SentryUser { Other = other }, """{"other":{"testCustomValueKey":"testCustomValue"}}""")}; } } diff --git a/test/Sentry.Tests/ScopeTests.cs b/test/Sentry.Tests/ScopeTests.cs index 8624cc3ac5..45e0bbb293 100644 --- a/test/Sentry.Tests/ScopeTests.cs +++ b/test/Sentry.Tests/ScopeTests.cs @@ -474,9 +474,9 @@ public void SetUser_ObserverExist_ObserverUserInvokedIfEnabled(string email, str } // Assert - observer.Received(expectedCount).SetUser(Arg.Is(user => user.Email == expectedEmail)); - observer.Received(expectedCount).SetUser(Arg.Is(user => user.Id == expectedId)); - observer.Received(expectedCount).SetUser(Arg.Is(user => user.Username == expectedUsername)); + observer.Received(expectedCount).SetUser(Arg.Is(user => user.Email == expectedEmail)); + observer.Received(expectedCount).SetUser(Arg.Is(user => user.Id == expectedId)); + observer.Received(expectedCount).SetUser(Arg.Is(user => user.Username == expectedUsername)); } [Theory] @@ -623,7 +623,7 @@ public static void ApplyFakeValues(this Scope scope, string salt = "fake") { scope.Request = new() { Data = $"{salt} request" }; scope.Contexts.Add($"{salt} context", "{}"); - scope.User = new User() { Username = $"{salt} username" }; + scope.User = new SentryUser() { Username = $"{salt} username" }; scope.Release = $"{salt} release"; scope.Distribution = $"{salt} distribution"; scope.Environment = $"{salt} environment";