Skip to content

Commit 1a672a1

Browse files
Merge pull request #7291 from Particular/code-analysis-cleanup-9.2
Code analysis cleanup 9.2
2 parents 902e7a3 + 4b481f0 commit 1a672a1

File tree

7 files changed

+34
-35
lines changed

7 files changed

+34
-35
lines changed

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -636,19 +636,19 @@ public void TestInterfaces()
636636
};
637637
o.Foos = new Dictionary<string, List<Foo>>
638638
{
639-
["foo1"] = new List<Foo>(new[]
640-
{
641-
new Foo
642-
{
643-
Name = "1",
644-
Title = "1"
645-
},
646-
new Foo
647-
{
648-
Name = "2",
649-
Title = "2"
650-
}
651-
})
639+
["foo1"] = new List<Foo>(
640+
[
641+
new Foo
642+
{
643+
Name = "1",
644+
Title = "1"
645+
},
646+
new Foo
647+
{
648+
Name = "2",
649+
Title = "2"
650+
}
651+
])
652652
};
653653
o.Data =
654654
[

src/NServiceBus.Core/Features/Feature.cs

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace NServiceBus;
22

33
using System;
4-
using System.Collections.Generic;
54
using System.Diagnostics;
65
using System.Threading.Tasks;
76
using Extensibility;
@@ -38,13 +37,13 @@ public static void SetErrorStatus(this Activity activity, Exception ex)
3837
activity.SetTag("otel.status_code", "ERROR");
3938
activity.SetTag("otel.status_description", ex.Message);
4039
activity.AddEvent(new ActivityEvent("exception", DateTimeOffset.UtcNow,
41-
new ActivityTagsCollection(new[]
40+
new ActivityTagsCollection
4241
{
43-
new KeyValuePair<string, object>("exception.escaped", true),
44-
new KeyValuePair<string, object>("exception.type", ex.GetType()),
45-
new KeyValuePair<string, object>("exception.message", ex.Message),
46-
new KeyValuePair<string, object>("exception.stacktrace", ex.ToString()),
47-
})));
42+
{ "exception.escaped", true },
43+
{ "exception.type", ex.GetType() },
44+
{ "exception.message", ex.Message },
45+
{ "exception.stacktrace", ex.ToString() }
46+
}));
4847

4948
if (ex is TaskCanceledException)
5049
{

src/NServiceBus.Core/Recoverability/IRecoverabilityActionContext.cs

Lines changed: 5 additions & 5 deletions
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

Lines changed: 6 additions & 6 deletions
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

Lines changed: 1 addition & 1 deletion
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)