Skip to content

Commit

Permalink
Make Sentry.PlatformAbstractions.Runtime.Identifier get only (#2764)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescrosswell authored Oct 27, 2023
1 parent 79ddcb0 commit 99105fe
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ API Changes:
});
```
- `ISpan` and `ITransaction` have been renamed to `ISpanTracer` and `ITransactionTracer`. You will need to update any references to these interfaces in your code to use the new interface names ([#2731](https://github.com/getsentry/sentry-dotnet/pull/2731))
- Removed obsolete setter from `Sentry.PlatformAbstractions.Runtime.Identifier` ([2764](https://github.com/getsentry/sentry-dotnet/pull/2764))

## Unreleased

Expand Down
19 changes: 4 additions & 15 deletions src/Sentry/PlatformAbstractions/Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,7 @@ public class Runtime : IEquatable<Runtime>
/// <remarks>
/// This property will be populated for .NET 5 and newer, or <c>null</c> otherwise.
/// </remarks>
public string? Identifier
{
get => _identifier;

[Obsolete("This setter is nonfunctional, and will be removed in a future version.")]
// ReSharper disable ValueParameterNotUsed
set { }
// ReSharper restore ValueParameterNotUsed
}

// TODO: Convert to get-only auto-property in next major version
private readonly string? _identifier;
public string? Identifier { get; }

/// <summary>
/// Creates a new Runtime instance
Expand All @@ -81,7 +70,7 @@ public Runtime(
Version = version;
FrameworkInstallation = frameworkInstallation;
Raw = raw;
_identifier = null;
Identifier = null;
}
#else
public Runtime(
Expand All @@ -93,7 +82,7 @@ public Runtime(
Name = name;
Version = version;
Raw = raw;
_identifier = identifier;
Identifier = identifier;
}
#endif

Expand Down Expand Up @@ -183,7 +172,7 @@ public override int GetHashCode()
#if NETFRAMEWORK
hashCode = (hashCode * 397) ^ (FrameworkInstallation?.GetHashCode() ?? 0);
#else
hashCode = (hashCode * 397) ^ (_identifier?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (Identifier?.GetHashCode() ?? 0);
#endif
return hashCode;
}
Expand Down
3 changes: 1 addition & 2 deletions test/Sentry.Tests/ApiApprovalTests.Run.Core3_1.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1468,8 +1468,7 @@ namespace Sentry.PlatformAbstractions
public class Runtime : System.IEquatable<Sentry.PlatformAbstractions.Runtime>
{
public Runtime(string? name = null, string? version = null, string? raw = null, string? identifier = null) { }
[set: System.Obsolete("This setter is nonfunctional, and will be removed in a future version.")]
public string? Identifier { get; set; }
public string? Identifier { get; }
public string? Name { get; }
public string? Raw { get; }
public string? Version { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1469,8 +1469,7 @@ namespace Sentry.PlatformAbstractions
public class Runtime : System.IEquatable<Sentry.PlatformAbstractions.Runtime>
{
public Runtime(string? name = null, string? version = null, string? raw = null, string? identifier = null) { }
[set: System.Obsolete("This setter is nonfunctional, and will be removed in a future version.")]
public string? Identifier { get; set; }
public string? Identifier { get; }
public string? Name { get; }
public string? Raw { get; }
public string? Version { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1469,8 +1469,7 @@ namespace Sentry.PlatformAbstractions
public class Runtime : System.IEquatable<Sentry.PlatformAbstractions.Runtime>
{
public Runtime(string? name = null, string? version = null, string? raw = null, string? identifier = null) { }
[set: System.Obsolete("This setter is nonfunctional, and will be removed in a future version.")]
public string? Identifier { get; set; }
public string? Identifier { get; }
public string? Name { get; }
public string? Raw { get; }
public string? Version { get; }
Expand Down
3 changes: 1 addition & 2 deletions test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1468,8 +1468,7 @@ namespace Sentry.PlatformAbstractions
{
public Runtime(string? name = null, string? version = null, Sentry.PlatformAbstractions.FrameworkInstallation? frameworkInstallation = null, string? raw = null) { }
public Sentry.PlatformAbstractions.FrameworkInstallation? FrameworkInstallation { get; }
[set: System.Obsolete("This setter is nonfunctional, and will be removed in a future version.")]
public string? Identifier { get; set; }
public string? Identifier { get; }
public string? Name { get; }
public string? Raw { get; }
public string? Version { get; }
Expand Down

0 comments on commit 99105fe

Please sign in to comment.