Skip to content

Commit 3874d7c

Browse files
particularbotnystagmustamararivera
authored
Prepare for NServiceBus 10 - Set LangVersion (#1567)
* Add LangVersion=preview to Custom.Build.props * Use auto-properties * Back to generic exceptions to keep it consistent --------- Co-authored-by: Ryan Thomas <[email protected]> Co-authored-by: Tamara Rivera <[email protected]>
1 parent fa6dabb commit 3874d7c

File tree

9 files changed

+48
-83
lines changed

9 files changed

+48
-83
lines changed

src/Custom.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<MinVerMinimumMajorMinor>9.0</MinVerMinimumMajorMinor>
55
<MinVerAutoIncrement>minor</MinVerAutoIncrement>
6+
<LangVersion>preview</LangVersion>
67
</PropertyGroup>
78

89
</Project>

src/NServiceBus.Transport.PostgreSql/Configuration/QueuePeekerOptions.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,33 @@ internal QueuePeekerOptions() { }
1515
/// </summary>
1616
public TimeSpan Delay
1717
{
18-
get => delay;
18+
get;
1919
set
2020
{
2121
if (value < TimeSpan.FromMilliseconds(100))
2222
{
23-
var message = "Delay requested is invalid. The value should be greater than 100 ms and less than 10 seconds.";
23+
var message =
24+
"Delay requested is invalid. The value should be greater than 100 ms and less than 10 seconds.";
2425
throw new Exception(message);
2526
}
2627

2728
if (value > TimeSpan.FromSeconds(10))
2829
{
29-
var message = $"Delay requested of {value} is not recommended. The recommended delay value is between 100 milliseconds to 10 seconds.";
30+
var message =
31+
$"Delay requested of {value} is not recommended. The recommended delay value is between 100 milliseconds to 10 seconds.";
3032
Logger.Warn(message);
3133
}
3234

33-
delay = value;
35+
field = value;
3436
}
35-
}
37+
} = TimeSpan.FromSeconds(1);
3638

3739
/// <summary>
3840
/// Maximal number of records to peek.
3941
/// </summary>
4042
public int? MaxRecordsToPeek
4143
{
42-
get => maxRecordsToPeek;
44+
get;
4345
set
4446
{
4547
if (value.HasValue && value < 1)
@@ -48,13 +50,10 @@ public int? MaxRecordsToPeek
4850
throw new Exception(message);
4951
}
5052

51-
maxRecordsToPeek = value;
53+
field = value;
5254
}
5355
}
5456

55-
TimeSpan delay = TimeSpan.FromSeconds(1);
56-
int? maxRecordsToPeek;
57-
5857
static ILog Logger = LogManager.GetLogger<QueuePeekerOptions>();
5958
}
6059
}

src/NServiceBus.Transport.PostgreSql/Configuration/TransactionScopeOptions.cs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,20 @@ internal TransactionScopeOptions() { }
1515
/// </summary>
1616
public TimeSpan Timeout
1717
{
18-
get => timeout;
18+
get;
1919
set
2020
{
21-
if (value > TransactionManager.MaximumTimeout)
22-
{
23-
var message = "Timeout requested is longer than the maximum value for this machine. Override using the maxTimeout setting of the system.transactions section in machine.config";
24-
25-
throw new Exception(message);
26-
}
27-
28-
timeout = value;
21+
ArgumentOutOfRangeException.ThrowIfGreaterThan(value, TransactionManager.MaximumTimeout);
22+
field = value;
2923
}
30-
}
24+
} = TransactionManager.DefaultTimeout;
3125

3226
/// <summary>
3327
/// Transaction isolation level.
3428
/// </summary>
3529
public IsolationLevel IsolationLevel { get; set; } = IsolationLevel.ReadCommitted;
3630

37-
internal TransactionOptions TransactionOptions => new TransactionOptions { IsolationLevel = IsolationLevel, Timeout = timeout };
31+
internal TransactionOptions TransactionOptions => new() { IsolationLevel = IsolationLevel, Timeout = Timeout };
3832

39-
TimeSpan timeout = TransactionManager.DefaultTimeout;
4033
}
4134
}

src/NServiceBus.Transport.PostgreSql/DelayedDelivery/DelayedDeliveryOptions.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,34 @@
77
/// </summary>
88
public partial class DelayedDeliveryOptions
99
{
10-
string tableSuffix = "Delayed";
11-
int batchSize = 100;
12-
1310
internal DelayedDeliveryOptions() { }
1411

1512
/// <summary>
1613
/// Suffix to be appended to the table name storing delayed messages.
1714
/// </summary>
1815
public string TableSuffix
1916
{
20-
get => tableSuffix;
17+
get;
2118
set
2219
{
2320
ArgumentException.ThrowIfNullOrWhiteSpace(value);
2421

25-
tableSuffix = value;
22+
field = value;
2623
}
27-
}
24+
} = "Delayed";
2825

2926
/// <summary>
3027
/// Size of the batch when moving matured timeouts to the input queue.
3128
/// </summary>
3229
public int BatchSize
3330
{
34-
get => batchSize;
31+
get;
3532
set
3633
{
3734
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(value);
3835

39-
batchSize = value;
36+
field = value;
4037
}
41-
}
38+
} = 100;
4239
}
4340
}

src/NServiceBus.Transport.PostgreSql/SubscriptionOptions.cs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,24 @@
77
/// </summary>
88
public class SubscriptionOptions
99
{
10-
/// <summary>
11-
/// Default to 5 seconds caching. If a system is under load that prevent doing an extra roundtrip for each Publish
12-
/// operation. If
13-
/// a system is not under load, doing an extra roundtrip every 5 seconds is not a problem and 5 seconds is small enough
14-
/// value that
15-
/// people accepts as we always say that subscription operation is not instantaneous.
16-
/// </summary>
17-
TimeSpan cacheInvalidationPeriod = TimeSpan.FromSeconds(5);
18-
1910
/// <summary>
2011
/// Subscription table. All endpoints in a given system need to agree on that name in order for them to be able
2112
/// to subscribe to and publish events.
2213
/// </summary>
2314
public SubscriptionTableName SubscriptionTableName { get; set; } = new SubscriptionTableName("SubscriptionRouting");
2415

2516
/// <summary>
26-
/// Cache subscriptions for a given <see cref="TimeSpan" />.
17+
/// Cache subscriptions for a given <see cref="TimeSpan" />. Defaults to 5 seconds.
2718
/// </summary>
2819
public TimeSpan CacheInvalidationPeriod
2920
{
30-
get => cacheInvalidationPeriod;
21+
get;
3122
set
3223
{
3324
ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(value, TimeSpan.Zero);
34-
cacheInvalidationPeriod = value;
25+
field = value;
3526
}
36-
}
27+
} = TimeSpan.FromSeconds(5);
3728

3829
/// <summary>
3930
/// Do not cache subscriptions.

src/NServiceBus.Transport.SqlServer/Configuration/QueuePeekerOptions.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,33 @@ internal QueuePeekerOptions() { }
1515
/// </summary>
1616
public TimeSpan Delay
1717
{
18-
get => delay;
18+
get;
1919
set
2020
{
2121
if (value < TimeSpan.FromMilliseconds(100))
2222
{
23-
var message = "Delay requested is invalid. The value should be greater than 100 ms and less than 10 seconds.";
23+
var message =
24+
"Delay requested is invalid. The value should be greater than 100 ms and less than 10 seconds.";
2425
throw new Exception(message);
2526
}
2627

2728
if (value > TimeSpan.FromSeconds(10))
2829
{
29-
var message = $"Delay requested of {value} is not recommended. The recommended delay value is between 100 milliseconds to 10 seconds.";
30+
var message =
31+
$"Delay requested of {value} is not recommended. The recommended delay value is between 100 milliseconds to 10 seconds.";
3032
Logger.Warn(message);
3133
}
3234

33-
delay = value;
35+
field = value;
3436
}
35-
}
37+
} = TimeSpan.FromSeconds(1);
3638

3739
/// <summary>
3840
/// Maximal number of records to peek.
3941
/// </summary>
4042
public int? MaxRecordsToPeek
4143
{
42-
get => maxRecordsToPeek;
44+
get;
4345
set
4446
{
4547
if (value.HasValue && value < 1)
@@ -48,13 +50,10 @@ public int? MaxRecordsToPeek
4850
throw new Exception(message);
4951
}
5052

51-
maxRecordsToPeek = value;
53+
field = value;
5254
}
5355
}
5456

55-
TimeSpan delay = TimeSpan.FromSeconds(1);
56-
int? maxRecordsToPeek;
57-
5857
static ILog Logger = LogManager.GetLogger<QueuePeekerOptions>();
5958
}
6059
}

src/NServiceBus.Transport.SqlServer/Configuration/TransactionScopeOptions.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ internal TransactionScopeOptions() { }
1515
/// </summary>
1616
public TimeSpan Timeout
1717
{
18-
get => timeout;
18+
get;
1919
set
2020
{
2121
if (value > TransactionManager.MaximumTimeout)
@@ -24,18 +24,15 @@ public TimeSpan Timeout
2424

2525
throw new Exception(message);
2626
}
27-
28-
timeout = value;
27+
field = value;
2928
}
30-
}
29+
} = TransactionManager.DefaultTimeout;
3130

3231
/// <summary>
3332
/// Transaction isolation level.
3433
/// </summary>
3534
public IsolationLevel IsolationLevel { get; set; } = IsolationLevel.ReadCommitted;
3635

37-
internal TransactionOptions TransactionOptions => new TransactionOptions { IsolationLevel = IsolationLevel, Timeout = timeout };
38-
39-
TimeSpan timeout = TransactionManager.DefaultTimeout;
36+
internal TransactionOptions TransactionOptions => new() { IsolationLevel = IsolationLevel, Timeout = Timeout };
4037
}
4138
}

src/NServiceBus.Transport.SqlServer/DelayedDelivery/DelayedDeliveryOptions.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,34 @@
77
/// </summary>
88
public partial class DelayedDeliveryOptions
99
{
10-
string tableSuffix = "Delayed";
11-
int batchSize = 100;
12-
1310
internal DelayedDeliveryOptions() { }
1411

1512
/// <summary>
1613
/// Suffix to be appended to the table name storing delayed messages.
1714
/// </summary>
1815
public string TableSuffix
1916
{
20-
get => tableSuffix;
17+
get;
2118
set
2219
{
2320
ArgumentException.ThrowIfNullOrWhiteSpace(value);
2421

25-
tableSuffix = value;
22+
field = value;
2623
}
27-
}
24+
} = "Delayed";
2825

2926
/// <summary>
3027
/// Size of the batch when moving matured timeouts to the input queue.
3128
/// </summary>
3229
public int BatchSize
3330
{
34-
get => batchSize;
31+
get;
3532
set
3633
{
3734
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(value);
3835

39-
batchSize = value;
36+
field = value;
4037
}
41-
}
38+
} = 100;
4239
}
4340
}

src/NServiceBus.Transport.SqlServer/PubSub/SubscriptionOptions.cs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,25 @@
77
/// </summary>
88
public class SubscriptionOptions
99
{
10-
/// <summary>
11-
/// Default to 5 seconds caching. If a system is under load that prevent doing an extra roundtrip for each Publish
12-
/// operation. If
13-
/// a system is not under load, doing an extra roundtrip every 5 seconds is not a problem and 5 seconds is small enough
14-
/// value that
15-
/// people accepts as we always say that subscription operation is not instantaneous.
16-
/// </summary>
17-
TimeSpan cacheInvalidationPeriod = TimeSpan.FromSeconds(5);
18-
1910
/// <summary>
2011
/// Subscription table. All endpoints in a given system need to agree on that name in order for them to be able
2112
/// to subscribe to and publish events.
2213
/// </summary>
2314
public SubscriptionTableName SubscriptionTableName { get; set; } = new SubscriptionTableName("SubscriptionRouting");
2415

2516
/// <summary>
26-
/// Cache subscriptions for a given <see cref="TimeSpan" />.
17+
/// Cache subscriptions for a given <see cref="TimeSpan" />. Defaults to 5 seconds.
2718
/// </summary>
2819
public TimeSpan CacheInvalidationPeriod
2920
{
30-
get => cacheInvalidationPeriod;
21+
get;
3122
set
3223
{
3324
ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(value, TimeSpan.Zero);
3425

35-
cacheInvalidationPeriod = value;
26+
field = value;
3627
}
37-
}
28+
} = TimeSpan.FromSeconds(5);
3829

3930
/// <summary>
4031
/// Do not cache subscriptions.

0 commit comments

Comments
 (0)