Skip to content

Commit

Permalink
Obsoletes cleanup round 2 (#6819)
Browse files Browse the repository at this point in the history
* Convert ToTransportAddress from abstract to virtual

* Add default implementation for AddAuditData

* Approve API changes
  • Loading branch information
bording authored Aug 30, 2023
1 parent 109c997 commit 0321ec8
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace NServiceBus
{
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -26,11 +25,6 @@ public override async Task<TransportInfrastructure> Initialize(HostSettings host
return infrastructure;
}

[Obsolete("This should be removed when TransportDefinition.ToTransportAddress is removed in v10.", true)]
#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member
public override string ToTransportAddress(QueueAddress address) => throw new NotImplementedException();
#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member

public override IReadOnlyCollection<TransportTransactionMode> GetSupportedTransactionModes()
{
return new[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ public override Task<TransportInfrastructure> Initialize(HostSettings hostSettin
return Task.FromResult<TransportInfrastructure>(infrastructure);
}

[Obsolete("This should be removed when TransportDefinition.ToTransportAddress is removed in v10.", true)]
#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member
public override string ToTransportAddress(QueueAddress address) => throw new NotImplementedException();
#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member

public override IReadOnlyCollection<TransportTransactionMode> GetSupportedTransactionModes()
{
return new[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ public override Task<TransportInfrastructure> Initialize(HostSettings hostSettin
return Task.FromResult<TransportInfrastructure>(new FakeTransportInfrastructure(receivers));
}

[Obsolete("This should be removed when TransportDefinition.ToTransportAddress is removed in v10.", true)]
#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member
public override string ToTransportAddress(QueueAddress address) => throw new NotImplementedException();
#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member

public override IReadOnlyCollection<TransportTransactionMode> GetSupportedTransactionModes()
{
return new[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,6 @@ namespace NServiceBus
public string StorageDirectory { get; set; }
public override System.Collections.Generic.IReadOnlyCollection<NServiceBus.TransportTransactionMode> GetSupportedTransactionModes() { }
public override System.Threading.Tasks.Task<NServiceBus.Transport.TransportInfrastructure> Initialize(NServiceBus.Transport.HostSettings hostSettings, NServiceBus.Transport.ReceiveSettings[] receivers, string[] sendingAddresses, System.Threading.CancellationToken cancellationToken = default) { }
[System.Obsolete("Inject the ITransportAddressResolver type to access the address translation mecha" +
"nism at runtime. See the NServiceBus version 8 upgrade guide for further details" +
". The member currently throws a NotImplementedException. Will be removed in vers" +
"ion 10.0.0.", true)]
public override string ToTransportAddress(NServiceBus.Transport.QueueAddress queueAddress) { }
}
public static class LearningTransportConfigurationExtensions
{
Expand Down Expand Up @@ -1573,7 +1568,8 @@ namespace NServiceBus.Pipeline
System.Collections.Generic.Dictionary<string, string> AuditMetadata { get; }
NServiceBus.Transport.OutgoingMessage Message { get; }
System.TimeSpan? TimeToBeReceived { get; }
[System.Obsolete("Use `AuditMetadata` instead. Will be removed in version 10.0.0.", true)]
[System.Obsolete("Use `AuditMetadata` instead. The member currently throws a NotImplementedExceptio" +
"n. Will be removed in version 10.0.0.", true)]
void AddAuditData(string key, string value);
NServiceBus.Pipeline.IAuditActionContext PreventChanges();
}
Expand Down Expand Up @@ -2225,8 +2221,9 @@ namespace NServiceBus.Transport
public abstract System.Threading.Tasks.Task<NServiceBus.Transport.TransportInfrastructure> Initialize(NServiceBus.Transport.HostSettings hostSettings, NServiceBus.Transport.ReceiveSettings[] receivers, string[] sendingAddresses, System.Threading.CancellationToken cancellationToken = default);
[System.Obsolete("Inject the ITransportAddressResolver type to access the address translation mecha" +
"nism at runtime. See the NServiceBus version 8 upgrade guide for further details" +
". Will be removed in version 10.0.0.", true)]
public abstract string ToTransportAddress(NServiceBus.Transport.QueueAddress address);
". The member currently throws a NotImplementedException. Will be removed in vers" +
"ion 10.0.0.", true)]
public virtual string ToTransportAddress(NServiceBus.Transport.QueueAddress address) { }
}
public abstract class TransportInfrastructure
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace NServiceBus.Core.Tests.Config;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
Expand Down Expand Up @@ -90,11 +89,6 @@ public Task Initialize(PushRuntimeSettings limitations, OnMessage onMessage, OnE
public override string ToTransportAddress(QueueAddress address) => address.BaseAddress;
}

[Obsolete("This should be removed when TransportDefinition.ToTransportAddress is removed in v10.", true)]
#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member
public override string ToTransportAddress(QueueAddress address) => throw new NotImplementedException();
#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member

public override IReadOnlyCollection<TransportTransactionMode> GetSupportedTransactionModes() => new[]
{
TransportTransactionMode.ReceiveOnly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,6 @@ public override Task<TransportInfrastructure> Initialize(HostSettings hostSettin
throw new NotImplementedException();
}

[Obsolete("This should be removed when TransportDefinition.ToTransportAddress is removed in v10.", true)]
#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member
public override string ToTransportAddress(QueueAddress address) => throw new NotImplementedException();
#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member

public override IReadOnlyCollection<TransportTransactionMode> GetSupportedTransactionModes()
{
throw new NotImplementedException();
Expand Down
2 changes: 1 addition & 1 deletion src/NServiceBus.Core/Audit/AuditContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace NServiceBus
using Pipeline;
using Transport;

partial class AuditContext : BehaviorContext, IAuditContext, IAuditActionContext
class AuditContext : BehaviorContext, IAuditContext, IAuditActionContext
{
public AuditContext(OutgoingMessage message, string auditAddress, TimeSpan? timeToBeReceived, IBehaviorContext parent)
: base(parent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/// <summary>
/// A transport optimized for development and learning use. DO NOT use in production.
/// </summary>
public partial class LearningTransport : TransportDefinition
public class LearningTransport : TransportDefinition
{
/// <summary>
/// Creates a new instance of a learning transport.
Expand Down
25 changes: 6 additions & 19 deletions src/NServiceBus.Core/obsoletes-v9.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@ namespace NServiceBus
using NServiceBus.Settings;
using NServiceBus.Transport;

partial class AuditContext
{
[ObsoleteEx(
ReplacementTypeOrMember = nameof(AuditMetadata),
TreatAsErrorFromVersion = "9.0",
RemoveInVersion = "10.0")]
public void AddAuditData(string key, string value) => throw new NotImplementedException();
}

public static partial class ConnectorContextExtensions
{
[ObsoleteEx(
Expand Down Expand Up @@ -45,14 +36,6 @@ public static partial class ImmediateDispatchOptionExtensions
TreatAsErrorFromVersion = "9.0")]
public static bool RequiredImmediateDispatch(this ExtendableOptions options) => throw new NotImplementedException();
}
public partial class LearningTransport
{
[ObsoleteEx(
Message = "Inject the ITransportAddressResolver type to access the address translation mechanism at runtime. See the NServiceBus version 8 upgrade guide for further details.",
TreatAsErrorFromVersion = "9",
RemoveInVersion = "10")]
public override string ToTransportAddress(QueueAddress queueAddress) => throw new NotImplementedException();
}

[ObsoleteEx(
Message = "Error notification events have been replaced with a Task-based API available on the recoverability settings.",
Expand Down Expand Up @@ -191,13 +174,15 @@ public static class ServiceProviderExtensions

namespace NServiceBus.Pipeline
{
using System;

public partial interface IAuditContext : IBehaviorContext
{
[ObsoleteEx(
ReplacementTypeOrMember = nameof(AuditMetadata),
TreatAsErrorFromVersion = "9.0",
RemoveInVersion = "10.0")]
void AddAuditData(string key, string value);
void AddAuditData(string key, string value) => throw new NotImplementedException();
}
}

Expand All @@ -217,13 +202,15 @@ public static partial class RuntimeEnvironment

namespace NServiceBus.Transport
{
using System;

public abstract partial class TransportDefinition
{
[ObsoleteEx(
Message = "Inject the ITransportAddressResolver type to access the address translation mechanism at runtime. See the NServiceBus version 8 upgrade guide for further details.",
TreatAsErrorFromVersion = "9",
RemoveInVersion = "10")]
public abstract string ToTransportAddress(QueueAddress address);
public virtual string ToTransportAddress(QueueAddress address) => throw new NotImplementedException();
}
}

Expand Down
3 changes: 0 additions & 3 deletions src/NServiceBus.Testing.Fakes/TestableAuditContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ public partial class TestableAuditContext : TestableBehaviorContext, IAuditConte

IReadOnlyDictionary<string, string> IAuditActionContext.AuditMetadata => AuditMetadata;

// This method is being removed from IAuditContext, so this stub method remains until the removal is done in v10
public void AddAuditData(string key, string value) => throw new NotImplementedException();

/// <summary>
/// Locks the audit action for further changes.
/// </summary>
Expand Down

0 comments on commit 0321ec8

Please sign in to comment.