Skip to content

Commit 080946f

Browse files
Add Particular.Obsoletes (#1221)
* Add Particular.Obsoletes and remove Fody * Fix obsolete attribute on obsoletes file * Fix obsolete attributes for migration topology * Move the constants for the obsolete messages to their own class * Add pragmas when needed * Add Obsolete attribute when needed. * Tweaks * Suppress warnings in tests * Update APIApprovals * Update approval test that had typo in message * Stop using custom PreObsoleteAttribute --------- Co-authored-by: Brandon Ording <[email protected]>
1 parent a0e1490 commit 080946f

26 files changed

+128
-68
lines changed

src/AcceptanceTests/When_loading_from_options.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
using Azure.Messaging.ServiceBus.Administration;
99
using NServiceBus.AcceptanceTests.EndpointTemplates;
1010
using NUnit.Framework;
11-
using Conventions = NServiceBus.AcceptanceTesting.Customization.Conventions;
11+
using Conventions = AcceptanceTesting.Customization.Conventions;
1212

1313
public class When_loading_from_options
1414
{
@@ -64,16 +64,21 @@ await Scenario.Define<Context>()
6464
{
6565
var transport = c.ConfigureTransport<AzureServiceBusTransport>();
6666
// doing a deliberate roundtrip to ensure that the options are correctly serialized and deserialized
67+
#pragma warning disable CS0618 // Type or member is obsolete
6768
var serializedOptions = JsonSerializer.Serialize(new MigrationTopologyOptions
69+
#pragma warning restore CS0618 // Type or member is obsolete
6870
{
6971
QueueNameToSubscriptionNameMap = { { Conventions.EndpointNamingConvention(typeof(Publisher)), TopicName } },
7072
SubscribedEventToRuleNameMap = { { typeof(Event).FullName, typeof(Event).FullName.Shorten() } },
7173
TopicToPublishTo = TopicName,
7274
TopicToSubscribeOn = TopicName,
7375
EventsToMigrateMap = [typeof(Event).FullName]
7476
}, TopologyOptionsSerializationContext.Default.TopologyOptions);
77+
7578
var options = JsonSerializer.Deserialize(serializedOptions, TopologyOptionsSerializationContext.Default.TopologyOptions);
79+
#pragma warning disable CS0618 // Type or member is obsolete
7680
var topology = (MigrationTopology)TopicTopology.FromOptions(options);
81+
#pragma warning restore CS0618 // Type or member is obsolete
7782
transport.Topology = topology;
7883
});
7984
b.When((session, c) => session.Publish(new Event()));

src/MigrationAcceptanceTests/ConfigureEndpointAzureServiceBusTransport.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ public Task Configure(string endpointName, EndpointConfiguration configuration,
1919
throw new InvalidOperationException("envvar AzureServiceBus_ConnectionString not set");
2020
}
2121

22+
#pragma warning disable CS0618 // Type or member is obsolete
2223
var topology = TopicTopology.MigrateFromSingleDefaultTopic();
24+
#pragma warning restore CS0618 // Type or member is obsolete
2325
topology.OverrideSubscriptionNameFor(endpointName, endpointName.Shorten());
2426

2527
foreach (var eventType in publisherMetadata.Publishers.SelectMany(p => p.Events))

src/MigrationAcceptanceTests/Migration/When_migrating.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
using System;
44
using System.Threading.Tasks;
55
using AcceptanceTesting;
6-
using Azure.Messaging.ServiceBus.Administration;
76
using Azure.Messaging.ServiceBus;
7+
using Azure.Messaging.ServiceBus.Administration;
88
using EndpointTemplates;
99
using NUnit.Framework;
1010
using Transport.AzureServiceBus.AcceptanceTests;
@@ -38,7 +38,9 @@ public async Task Should_not_lose_any_events()
3838
{
3939
b.CustomConfig(c =>
4040
{
41+
#pragma warning disable CS0618 // Type or member is obsolete
4142
var topology = TopicTopology.MigrateFromNamedSingleTopic(bundleTopicName);
43+
#pragma warning restore CS0618 // Type or member is obsolete
4244
topology.EventToMigrate<MyEvent>();
4345

4446
c.ConfigureTransport<AzureServiceBusTransport>().Topology = topology;
@@ -49,7 +51,9 @@ public async Task Should_not_lose_any_events()
4951
{
5052
b.CustomConfig(c =>
5153
{
54+
#pragma warning disable CS0618 // Type or member is obsolete
5255
var topology = TopicTopology.MigrateFromNamedSingleTopic(bundleTopicName);
56+
#pragma warning restore CS0618 // Type or member is obsolete
5357
topology.EventToMigrate<MyEvent>(ruleNameOverride: typeof(MyEvent).FullName.Shorten());
5458

5559
c.ConfigureTransport<AzureServiceBusTransport>().Topology = topology;
@@ -69,7 +73,9 @@ public async Task Should_not_lose_any_events()
6973
{
7074
b.CustomConfig(c =>
7175
{
76+
#pragma warning disable CS0618 // Type or member is obsolete
7277
var topology = TopicTopology.MigrateFromNamedSingleTopic(bundleTopicName);
78+
#pragma warning restore CS0618 // Type or member is obsolete
7379
topology.EventToMigrate<MyEvent>();
7480

7581
c.ConfigureTransport<AzureServiceBusTransport>().Topology = topology;

src/MigrationAcceptanceTests/Receiving/When_publishing_from_different_topics.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ public PublisherOnTopicA() =>
7575
EndpointSetup<DefaultPublisher>(b =>
7676
{
7777
var transport = b.ConfigureTransport<AzureServiceBusTransport>();
78+
#pragma warning disable CS0618 // Type or member is obsolete
7879
var topology = TopicTopology.MigrateFromNamedSingleTopic("bundle-a");
80+
#pragma warning restore CS0618 // Type or member is obsolete
7981
topology.EventToMigrate<EventFromTopicA>(ruleNameOverride: typeof(EventFromTopicA).FullName.Shorten());
8082
topology.EventToMigrate<EventFromTopicB>(ruleNameOverride: typeof(EventFromTopicB).FullName.Shorten());
8183
topology.EventToMigrate<EventFromTopicC>(ruleNameOverride: typeof(EventFromTopicC).FullName.Shorten());
@@ -119,7 +121,9 @@ public SubscriberOnTopicB()
119121
=>
120122
{
121123
var transport = b.ConfigureTransport<AzureServiceBusTransport>();
124+
#pragma warning disable CS0618 // Type or member is obsolete
122125
var topology = TopicTopology.MigrateFromTopicHierarchy("bundle-a", "bundle-b");
126+
#pragma warning restore CS0618 // Type or member is obsolete
123127
topology.EventToMigrate<EventFromTopicA>(ruleNameOverride: typeof(EventFromTopicA).FullName.Shorten());
124128
topology.EventToMigrate<EventFromTopicB>(ruleNameOverride: typeof(EventFromTopicB).FullName.Shorten());
125129
transport.Topology = topology;
@@ -143,7 +147,9 @@ public SubscriberOnTopicC()
143147
=>
144148
{
145149
var transport = b.ConfigureTransport<AzureServiceBusTransport>();
150+
#pragma warning disable CS0618 // Type or member is obsolete
146151
var topology = TopicTopology.MigrateFromTopicHierarchy("bundle-a", "bundle-c");
152+
#pragma warning restore CS0618 // Type or member is obsolete
147153
topology.EventToMigrate<EventFromTopicA>(ruleNameOverride: typeof(EventFromTopicA).FullName.Shorten());
148154
topology.EventToMigrate<EventFromTopicC>(ruleNameOverride: typeof(EventFromTopicC).FullName.Shorten());
149155
transport.Topology = topology;

src/MigrationAcceptanceTests/Receiving/When_publishing_sendonly_and_subscribing_on_different_topics.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ public SendOnlyPublisherOnTopicA() =>
7575
EndpointSetup<DefaultPublisher>(b =>
7676
{
7777
var transport = b.ConfigureTransport<AzureServiceBusTransport>();
78+
#pragma warning disable CS0618 // Type or member is obsolete
7879
MigrationTopology topology = TopicTopology.MigrateFromNamedSingleTopic("bundle-a");
80+
#pragma warning restore CS0618 // Type or member is obsolete
7981
topology.EventToMigrate<MyEvent>();
8082
transport.Topology = topology;
8183
b.SendOnly();
@@ -89,7 +91,9 @@ public SubscriberOnTopicB()
8991
=>
9092
{
9193
var transport = b.ConfigureTransport<AzureServiceBusTransport>();
94+
#pragma warning disable CS0618 // Type or member is obsolete
9295
MigrationTopology topology = TopicTopology.MigrateFromTopicHierarchy("bundle-a", "bundle-b");
96+
#pragma warning restore CS0618 // Type or member is obsolete
9397
string endpointName = Conventions.EndpointNamingConvention(typeof(SubscriberOnTopicB));
9498
topology.OverrideSubscriptionNameFor(endpointName, endpointName.Shorten());
9599
topology.EventToMigrate<MyEvent>(ruleNameOverride: typeof(MyEvent).FullName.Shorten());
@@ -114,7 +118,9 @@ public SubscriberOnTopicC()
114118
=>
115119
{
116120
var transport = b.ConfigureTransport<AzureServiceBusTransport>();
121+
#pragma warning disable CS0618 // Type or member is obsolete
117122
MigrationTopology topology = TopicTopology.MigrateFromTopicHierarchy("bundle-a", "bundle-c");
123+
#pragma warning restore CS0618 // Type or member is obsolete
118124
string endpointName = Conventions.EndpointNamingConvention(typeof(SubscriberOnTopicC));
119125
topology.OverrideSubscriptionNameFor(endpointName, endpointName.Shorten());
120126
topology.EventToMigrate<MyEvent>(ruleNameOverride: typeof(MyEvent).FullName.Shorten());

src/Tests/ApprovalFiles/APIApprovals.Approve.approved.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ namespace NServiceBus
1414
public int? PrefetchCount { get; set; }
1515
public int PrefetchMultiplier { get; set; }
1616
public Azure.Messaging.ServiceBus.ServiceBusRetryOptions? RetryPolicyOptions { get; set; }
17-
[System.Obsolete("The transport no longer supports sending the transport encoding header. The membe" +
18-
"r currently throws a NotImplementedException. Will be removed in version 7.0.0.", true)]
17+
[System.Obsolete("The transport no longer supports sending the transport encoding header. Will be r" +
18+
"emoved in version 7.0.0.", true)]
1919
public bool SendTransportEncodingHeader { get; set; }
2020
public System.TimeSpan TimeToWaitBeforeTriggeringCircuitBreaker { get; set; }
2121
[System.Diagnostics.CodeAnalysis.MemberNotNull("topology")]
@@ -35,8 +35,8 @@ namespace NServiceBus
3535
public static NServiceBus.TransportExtensions<NServiceBus.AzureServiceBusTransport> MaxAutoLockRenewalDuration(this NServiceBus.TransportExtensions<NServiceBus.AzureServiceBusTransport> transportExtensions, System.TimeSpan maximumAutoLockRenewalDuration) { }
3636
public static NServiceBus.TransportExtensions<NServiceBus.AzureServiceBusTransport> PrefetchCount(this NServiceBus.TransportExtensions<NServiceBus.AzureServiceBusTransport> transportExtensions, int prefetchCount) { }
3737
public static NServiceBus.TransportExtensions<NServiceBus.AzureServiceBusTransport> PrefetchMultiplier(this NServiceBus.TransportExtensions<NServiceBus.AzureServiceBusTransport> transportExtensions, int prefetchMultiplier) { }
38-
[System.Obsolete("The transport no longer supports sending the transport encoding header. The membe" +
39-
"r currently throws a NotImplementedException. Will be removed in version 7.0.0.", true)]
38+
[System.Obsolete("The transport no longer supports sending the transport encoding header. Will be r" +
39+
"emoved in version 7.0.0.", true)]
4040
public static NServiceBus.TransportExtensions<NServiceBus.AzureServiceBusTransport> SendTransportEncodingHeader(this NServiceBus.TransportExtensions<NServiceBus.AzureServiceBusTransport> transportExtensions) { }
4141
public static NServiceBus.TransportExtensions<NServiceBus.AzureServiceBusTransport> TimeToWaitBeforeTriggeringCircuitBreaker(this NServiceBus.TransportExtensions<NServiceBus.AzureServiceBusTransport> transportExtensions, System.TimeSpan timeToWait) { }
4242
public static NServiceBus.TransportExtensions<NServiceBus.AzureServiceBusTransport> UseTransport<TTransport>(this NServiceBus.EndpointConfiguration endpointConfiguration, string connectionString, NServiceBus.TopicTopology topology)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
EventsToMigrateMap: TopicToPublishTo, PublishedEventToTopicsMap: The topic to publish 'TopicToPublishTo' for 'NServiceBus.Transport.AzureServiceBus.Tests.MigrationTopologyTests+MyEvent' cannot be the sames as the topic to publish to 'TopicToPublishTo' for the migration topology.; TopicToSubscribeOn, SubscribedEventToTopicsMap: The topic to subscribe 'TopicToSubscribeOn' for 'NServiceBus.Transport.AzureServiceBus.Tests.MigrationTopologyTests+MyEvent' cannot be the sames as the topic to subscribe to 'TopicToSubscribeOn' for the migration topology.; SubscribedEventToTopicsMap: Event 'NServiceBus.Transport.AzureServiceBus.Tests.MigrationTopologyTests+MyEventMappedTwice' is in the migration map and in the subscribed event to topics map. An event type cannot be marked for migration and mapped to a topic at the same time.
1+
EventsToMigrateMap: TopicToPublishTo, PublishedEventToTopicsMap: The topic to publish 'TopicToPublishTo' for 'NServiceBus.Transport.AzureServiceBus.Tests.MigrationTopologyTests+MyEvent' cannot be the same as the topic to publish to 'TopicToPublishTo' for the migration topology.; TopicToSubscribeOn, SubscribedEventToTopicsMap: The topic to subscribe 'TopicToSubscribeOn' for 'NServiceBus.Transport.AzureServiceBus.Tests.MigrationTopologyTests+MyEvent' cannot be the same as the topic to subscribe to 'TopicToSubscribeOn' for the migration topology.; SubscribedEventToTopicsMap: Event 'NServiceBus.Transport.AzureServiceBus.Tests.MigrationTopologyTests+MyEventMappedTwice' is in the migration map and in the subscribed event to topics map. An event type cannot be marked for migration and mapped to a topic at the same time.

src/Tests/EventRouting/MigrationTopologyCreatorTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ public class MigrationTopologyCreatorTests
1010
[Test]
1111
public async Task Should_create_single_topic_topology()
1212
{
13+
#pragma warning disable CS0618 // Type or member is obsolete
1314
var topology = TopicTopology.MigrateFromNamedSingleTopic("bundle-1");
15+
#pragma warning restore CS0618 // Type or member is obsolete
1416
var transportSettings = new AzureServiceBusTransport("connection-string", topology);
1517

1618
var recordingAdministrationClient = new RecordingServiceBusAdministrationClient();
@@ -24,7 +26,9 @@ public async Task Should_create_single_topic_topology()
2426
[Test]
2527
public async Task Should_create_default_single_topic_topology()
2628
{
29+
#pragma warning disable CS0618 // Type or member is obsolete
2730
var topology = TopicTopology.MigrateFromSingleDefaultTopic();
31+
#pragma warning restore CS0618 // Type or member is obsolete
2832
var transportSettings = new AzureServiceBusTransport("connection-string", topology);
2933

3034
var recordingAdministrationClient = new RecordingServiceBusAdministrationClient();
@@ -38,7 +42,9 @@ public async Task Should_create_default_single_topic_topology()
3842
[Test]
3943
public async Task Should_hierarchy()
4044
{
45+
#pragma warning disable CS0618 // Type or member is obsolete
4146
var topology = TopicTopology.MigrateFromTopicHierarchy("bundle-1", "bundle-2");
47+
#pragma warning restore CS0618 // Type or member is obsolete
4248
var transportSettings = new AzureServiceBusTransport("connection-string", topology);
4349

4450
var recordingAdministrationClient = new RecordingServiceBusAdministrationClient();

src/Tests/EventRouting/MigrationTopologySubscriptionManagerTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ public class MigrationTopologySubscriptionManagerTests
1313
[Test]
1414
public async Task Should_create_topology_for_events_to_migrate()
1515
{
16+
#pragma warning disable CS0618 // Type or member is obsolete
1617
var topologyOptions = new MigrationTopologyOptions
18+
#pragma warning restore CS0618 // Type or member is obsolete
1719
{
1820
TopicToPublishTo = "PublishTopic",
1921
TopicToSubscribeOn = "SubscribeTopic",
@@ -49,7 +51,9 @@ public async Task Should_create_topology_for_events_to_migrate()
4951
[Test]
5052
public async Task Should_create_topology_for_migrated_and_not_migrated_events()
5153
{
54+
#pragma warning disable CS0618 // Type or member is obsolete
5255
var topologyOptions = new MigrationTopologyOptions
56+
#pragma warning restore CS0618 // Type or member is obsolete
5357
{
5458
TopicToPublishTo = "PublishTopic",
5559
TopicToSubscribeOn = "SubscribeTopic",
@@ -78,7 +82,9 @@ public async Task Should_create_topology_for_migrated_and_not_migrated_events()
7882
[Test]
7983
public async Task Should_throw_when_event_is_not_mapped()
8084
{
85+
#pragma warning disable CS0618 // Type or member is obsolete
8186
var topologyOptions = new MigrationTopologyOptions
87+
#pragma warning restore CS0618 // Type or member is obsolete
8288
{
8389
TopicToPublishTo = "TopicToPublishTo",
8490
TopicToSubscribeOn = "TopicToSubscribeOn",

src/Tests/EventRouting/MigrationTopologyTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ public class MigrationTopologyTests
1010
[Test]
1111
public void Should_self_validate()
1212
{
13+
#pragma warning disable CS0618 // Type or member is obsolete
1314
var topologyOptions = new MigrationTopologyOptions
15+
#pragma warning restore CS0618 // Type or member is obsolete
1416
{
1517
TopicToPublishTo = new string('a', 261),
1618
TopicToSubscribeOn = new string('a', 261),
@@ -37,7 +39,9 @@ public void Should_self_validate()
3739
[Test]
3840
public void Should_self_validate_consistency()
3941
{
42+
#pragma warning disable CS0618 // Type or member is obsolete
4043
var topologyOptions = new MigrationTopologyOptions
44+
#pragma warning restore CS0618 // Type or member is obsolete
4145
{
4246
TopicToPublishTo = "TopicToPublishTo",
4347
TopicToSubscribeOn = "TopicToSubscribeOn",
@@ -62,7 +66,9 @@ public void Should_self_validate_consistency()
6266
[Test]
6367
public void Should_allow_disabling_validation()
6468
{
69+
#pragma warning disable CS0618 // Type or member is obsolete
6570
var topologyOptions = new MigrationTopologyOptions
71+
#pragma warning restore CS0618 // Type or member is obsolete
6672
{
6773
TopicToPublishTo = new string('a', 261),
6874
TopicToSubscribeOn = new string('a', 261)

0 commit comments

Comments
 (0)