Skip to content

Commit e7fda8f

Browse files
Merge pull request #7290 from Particular/code-analysis-cleanup-9.1
Code analysis cleanup 9.1
2 parents 88474cf + 5b874ef commit e7fda8f

File tree

7 files changed

+31
-31
lines changed

7 files changed

+31
-31
lines changed

src/NServiceBus.Core.Tests/Serializers/XML/SerializerTests.cs

+13-13
Original file line numberDiff line numberDiff line change
@@ -621,19 +621,19 @@ public void TestInterfaces()
621621
};
622622
o.Foos = new Dictionary<string, List<Foo>>
623623
{
624-
["foo1"] = new List<Foo>(new[]
625-
{
626-
new Foo
627-
{
628-
Name = "1",
629-
Title = "1"
630-
},
631-
new Foo
632-
{
633-
Name = "2",
634-
Title = "2"
635-
}
636-
})
624+
["foo1"] = new List<Foo>(
625+
[
626+
new Foo
627+
{
628+
Name = "1",
629+
Title = "1"
630+
},
631+
new Foo
632+
{
633+
Name = "2",
634+
Title = "2"
635+
}
636+
])
637637
};
638638
o.Data =
639639
[

src/NServiceBus.Core/Features/Feature.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ protected void DependsOnAtLeastOne(params Type[] features)
125125
}
126126
}
127127

128-
Dependencies.Add(new List<string>(features.Select(GetFeatureName)));
128+
Dependencies.Add(features.Select(GetFeatureName).ToList());
129129
}
130130

131131
/// <summary>
@@ -173,7 +173,7 @@ protected void DependsOnAtLeastOne(params string[] featureNames)
173173
{
174174
ArgumentNullException.ThrowIfNull(featureNames);
175175

176-
Dependencies.Add(new List<string>(featureNames));
176+
Dependencies.Add([.. featureNames]);
177177
}
178178

179179
/// <summary>

src/NServiceBus.Core/Hosting/Helpers/AssemblyScanner.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static string RemoveExtension(string assemblyName) =>
6767

6868
internal IReadOnlyCollection<Type> TypesToSkip
6969
{
70-
set => typesToSkip = new HashSet<Type>(value);
70+
set => typesToSkip = [.. value];
7171
}
7272

7373
internal string AdditionalAssemblyScanningPath { get; set; }

src/NServiceBus.Core/OpenTelemetry/Tracing/ActivityExtensions.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ public static void SetErrorStatus(this Activity activity, Exception ex)
3838
activity.SetTag("otel.status_code", "ERROR");
3939
activity.SetTag("otel.status_description", ex.Message);
4040
activity.AddEvent(new ActivityEvent("exception", DateTimeOffset.UtcNow,
41-
new ActivityTagsCollection(new[]
42-
{
41+
new ActivityTagsCollection(
42+
[
4343
new KeyValuePair<string, object>("exception.escaped", true),
4444
new KeyValuePair<string, object>("exception.type", ex.GetType()),
4545
new KeyValuePair<string, object>("exception.message", ex.Message),
4646
new KeyValuePair<string, object>("exception.stacktrace", ex.ToString()),
47-
})));
47+
])));
4848

4949
if (ex is TaskCanceledException)
5050
{

src/NServiceBus.Core/Recoverability/IRecoverabilityActionContext.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@ public interface IRecoverabilityActionContext : IBehaviorContext
1212
/// <summary>
1313
/// The message that failed processing.
1414
/// </summary>
15-
public IncomingMessage FailedMessage { get; }
15+
IncomingMessage FailedMessage { get; }
1616

1717
/// <summary>
1818
/// The exception that caused processing to fail.
1919
/// </summary>
20-
public Exception Exception { get; }
20+
Exception Exception { get; }
2121

2222
/// <summary>
2323
/// The receive address where this message failed.
2424
/// </summary>
25-
public string ReceiveAddress { get; }
25+
string ReceiveAddress { get; }
2626

2727
/// <summary>
2828
/// The number of times the message have been retried immediately but failed.
2929
/// </summary>
30-
public int ImmediateProcessingFailures { get; }
30+
int ImmediateProcessingFailures { get; }
3131

3232
/// <summary>
3333
/// Number of delayed deliveries performed so far.
3434
/// </summary>
35-
public int DelayedDeliveriesPerformed { get; }
35+
int DelayedDeliveriesPerformed { get; }
3636

3737
/// <summary>
3838
/// Metadata for this message.

src/NServiceBus.Core/Recoverability/IRecoverabilityContext.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,32 @@ public interface IRecoverabilityContext : IBehaviorContext
1212
/// <summary>
1313
/// The message that failed processing.
1414
/// </summary>
15-
public IncomingMessage FailedMessage { get; }
15+
IncomingMessage FailedMessage { get; }
1616

1717
/// <summary>
1818
/// The exception that caused processing to fail.
1919
/// </summary>
20-
public Exception Exception { get; }
20+
Exception Exception { get; }
2121

2222
/// <summary>
2323
/// The receive address where this message failed.
2424
/// </summary>
25-
public string ReceiveAddress { get; }
25+
string ReceiveAddress { get; }
2626

2727
/// <summary>
2828
/// The number of times the message have been retried immediately but failed.
2929
/// </summary>
30-
public int ImmediateProcessingFailures { get; }
30+
int ImmediateProcessingFailures { get; }
3131

3232
/// <summary>
3333
/// Number of delayed deliveries performed so far.
3434
/// </summary>
35-
public int DelayedDeliveriesPerformed { get; }
35+
int DelayedDeliveriesPerformed { get; }
3636

3737
/// <summary>
3838
/// The recoverability configuration for the endpoint.
3939
/// </summary>
40-
public RecoverabilityConfig RecoverabilityConfiguration { get; }
40+
RecoverabilityConfig RecoverabilityConfiguration { get; }
4141

4242
/// <summary>
4343
/// The recoverability action to take for this message.

src/NServiceBus.Core/Recoverability/RecoverabilityComponent.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public IRecoverabilityPipelineExecutor CreateRecoverabilityPipelineExecutor(
8080
if (!settings.TryGet(PolicyOverride, out Func<RecoverabilityConfig, ErrorContext, RecoverabilityAction> policy))
8181
{
8282
policy = (config, context) => DefaultRecoverabilityPolicy.Invoke(config, context);
83-
};
83+
}
8484

8585
return new RecoverabilityPipelineExecutor<(RecoverabilityComponent,
8686
Func<RecoverabilityConfig, ErrorContext, RecoverabilityAction>)>(

0 commit comments

Comments
 (0)