Skip to content

Commit 2e19fec

Browse files
committed
clean up roslyn warnings
Signed-off-by: Neil South <[email protected]>
1 parent 8236618 commit 2e19fec

17 files changed

+59
-47
lines changed

src/Api/Models/BaseApplicationEntity.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public class BaseApplicationEntity : MongoDBEntityBase
5858

5959
public BaseApplicationEntity()
6060
{
61-
SetDefaultValues();
6261
}
6362

6463
public virtual void SetDefaultValues()

src/Api/Models/DestinationApplicationEntity.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ namespace Monai.Deploy.InformaticsGateway.Api.Models
3232
/// </example>
3333
public class DestinationApplicationEntity : BaseApplicationEntity
3434
{
35+
public DestinationApplicationEntity() : base()
36+
{
37+
SetDefaultValues();
38+
}
39+
3540
/// <summary>
3641
/// Gets or sets the port to connect to.
3742
/// </summary>

src/Api/SourceApplicationEntity.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ namespace Monai.Deploy.InformaticsGateway.Api
3333
/// </example>
3434
public class SourceApplicationEntity : BaseApplicationEntity
3535
{
36+
public SourceApplicationEntity() : base()
37+
{
38+
SetDefaultValues();
39+
}
40+
3641
/// <summary>
3742
/// Gets or sets the AE Title (AET) used to identify itself in a DICOM association.
3843
/// </summary>

src/Api/Storage/Payload.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public Payload(string key, string correlationId, string? workflowInstanceId, str
106106
DataTrigger = dataTrigger;
107107
}
108108

109-
public Payload(string key, string correlationId, string? workflowInstanceId, string? taskId, DataOrigin dataTrigger, uint timeout, string? payloadId = null) :
109+
public Payload(string key, string correlationId, string? workflowInstanceId, string? taskId, DataOrigin dataTrigger, uint timeout, string? payloadId) :
110110
this(key, correlationId, workflowInstanceId, taskId, dataTrigger, timeout)
111111
{
112112
Guard.Against.NullOrWhiteSpace(key, nameof(key));

src/Database/DatabaseMigrationManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private static Type[] FindMatchingTypesFromAssemblies(Assembly[] assemblies)
6868
}
6969
}
7070

71-
return matchingTypes.ToArray();
71+
return [.. matchingTypes];
7272
}
7373
}
7474
}

src/Database/EntityFramework/Migrations/20221116172042_R3_0.3.4.cs

100644100755
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ namespace Monai.Deploy.InformaticsGateway.Database.Migrations
66
{
77
public partial class R3_034 : Migration
88
{
9+
private static readonly string[] StorageMetadataWrapperEntitiesColumns = ["CorrelationId", "Identity"];
10+
private static readonly string[] StorageMetadataWrapperColumns = ["CorrelationId", "Identity"];
11+
912
protected override void Up(MigrationBuilder migrationBuilder)
1013
{
1114
migrationBuilder.DropTable(
@@ -87,7 +90,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
8790
migrationBuilder.CreateIndex(
8891
name: "idx_storagemetadata_ids",
8992
table: "StorageMetadataWrapperEntities",
90-
columns: new[] { "CorrelationId", "Identity" });
93+
columns: StorageMetadataWrapperEntitiesColumns);
9194

9295
migrationBuilder.CreateIndex(
9396
name: "idx_storagemetadata_uploaded",
@@ -166,7 +169,7 @@ protected override void Down(MigrationBuilder migrationBuilder)
166169
migrationBuilder.CreateIndex(
167170
name: "idx_storagemetadata_ids",
168171
table: "StorageMetadataWrapper",
169-
columns: new[] { "CorrelationId", "Identity" });
172+
columns: StorageMetadataWrapperColumns);
170173

171174
migrationBuilder.CreateIndex(
172175
name: "idx_storagemetadata_uploaded",

src/Database/EntityFramework/Migrations/20231204113501_Hl7DEstinationAndConfig.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ namespace Monai.Deploy.InformaticsGateway.Database.Migrations
77
{
88
public partial class Hl7DEstinationAndConfig : Migration
99
{
10+
private static readonly string[] HL7DestinationEntitiesColumns = ["Name", "AeTitle", "HostIp", "Port"];
11+
1012
protected override void Up(MigrationBuilder migrationBuilder)
1113
{
1214
migrationBuilder.CreateTable(
@@ -58,7 +60,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
5860
migrationBuilder.CreateIndex(
5961
name: "idx_source_all_HL7Destination",
6062
table: "HL7DestinationEntities",
61-
columns: new[] { "Name", "AeTitle", "HostIp", "Port" },
63+
columns: HL7DestinationEntitiesColumns,
6264
unique: true);
6365
}
6466

src/Database/EntityFramework/Migrations/20240118154616_MinorModelChanges.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ protected override void Up(MigrationBuilder migrationBuilder)
2525
migrationBuilder.CreateIndex(
2626
name: "idx_source_all_HL7Destination",
2727
table: "HL7DestinationEntities",
28-
columns: new[] { "Name", "HostIp", "Port" },
28+
columns: NewColumns,
2929
unique: true);
3030
}
3131

32+
private static readonly string[] OldColumns = ["Name", "AeTitle", "HostIp", "Port"];
33+
private static readonly string[] NewColumns = ["Name", "HostIp", "Port"];
34+
3235
/// <inheritdoc />
3336
protected override void Down(MigrationBuilder migrationBuilder)
3437
{
@@ -53,7 +56,7 @@ protected override void Down(MigrationBuilder migrationBuilder)
5356
migrationBuilder.CreateIndex(
5457
name: "idx_source_all_HL7Destination",
5558
table: "HL7DestinationEntities",
56-
columns: new[] { "Name", "AeTitle", "HostIp", "Port" },
59+
columns: OldColumns,
5760
unique: true);
5861
}
5962
}

src/InformaticsGateway/Logging/Log.5000.DataPlugins.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,9 @@ public static partial class Log
4444

4545
[LoggerMessage(EventId = 5007, Level = LogLevel.Error, Message = "Error executing plug-in: {plugin}.")]
4646
public static partial void ErrorAddingOutputDataPlugIn(this ILogger logger, Exception d, string plugin);
47+
48+
[LoggerMessage(EventId = 5008, Level = LogLevel.Trace, Message = "InputDataPlugInEngine: {pluginName} executed. fileMetadata now: {fileMetadata}")]
49+
public static partial void ExecutedInputDataPlugIn(this ILogger logger, string pluginName, string fileMetadata);
50+
4751
}
4852
}

src/InformaticsGateway/Logging/Log.700.PayloadService.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,8 @@ public static partial class Log
163163

164164
[LoggerMessage(EventId = 752, Level = LogLevel.Debug, Message = "Payload in Notification handler {payloadId}.")]
165165
public static partial void PayloadNotifyAsync(this ILogger logger, string payloadId);
166+
167+
[LoggerMessage(EventId = 753, Level = LogLevel.Trace, Message = "Adding files to ArtifactsReceivedEvent files {payload}")]
168+
public static partial void AddingFilesToArtifactsReceivedEvent(this ILogger logger, string payload);
166169
}
167170
}

src/InformaticsGateway/Logging/Log.800.Hl7Service.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,8 @@ public static partial class Log
114114
[LoggerMessage(EventId = 830, Level = LogLevel.Error, Message = "Error generating HL7 acknowledgment. for message {message}")]
115115
public static partial void ErrorGeneratingHl7Acknowledgment(this ILogger logger, Exception ex, string message);
116116

117+
[LoggerMessage(EventId = 831, Level = LogLevel.Trace, Message = "HL7 message after plug-in processing: {message} correlationId: {CorrelationId}")]
118+
public static partial void HL7MessageAfterPluginProcessing(this ILogger logger, string message, string CorrelationId);
119+
117120
}
118121
}

src/InformaticsGateway/Services/Common/InputDataPluginEngine.cs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
using System;
1818
using System.Collections.Generic;
19-
using System.Linq;
2019
using System.Text.Json;
2120
using System.Threading.Tasks;
2221
using FellowOakDicom;
@@ -28,18 +27,12 @@
2827

2928
namespace Monai.Deploy.InformaticsGateway.Services.Common
3029
{
31-
internal class InputDataPlugInEngine : IInputDataPlugInEngine
30+
internal class InputDataPlugInEngine(IServiceProvider serviceProvider, ILogger<InputDataPlugInEngine> logger) : IInputDataPlugInEngine
3231
{
33-
private readonly IServiceProvider _serviceProvider;
34-
private readonly ILogger<InputDataPlugInEngine> _logger;
32+
private readonly IServiceProvider _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
33+
private readonly ILogger<InputDataPlugInEngine> _logger = logger ?? throw new ArgumentNullException(nameof(logger));
3534
private IReadOnlyList<IInputDataPlugIn>? _plugins;
3635

37-
public InputDataPlugInEngine(IServiceProvider serviceProvider, ILogger<InputDataPlugInEngine> logger)
38-
{
39-
_serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
40-
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
41-
}
42-
4336
public void Configure(IReadOnlyList<string> pluginAssemblies)
4437
{
4538
_plugins = LoadPlugIns(_serviceProvider, pluginAssemblies);
@@ -57,13 +50,13 @@ public async Task<Tuple<DicomFile, FileStorageMetadata>> ExecutePlugInsAsync(Dic
5750
_logger.ExecutingInputDataPlugIn(plugin.Name);
5851
(dicomFile, fileMetadata) = await plugin.ExecuteAsync(dicomFile, fileMetadata).ConfigureAwait(false);
5952

60-
_logger.LogTrace($"InputDataPlugInEngine: {plugin.Name} executed. fileMetadata now: {JsonSerializer.Serialize(fileMetadata)}");
53+
_logger.ExecutedInputDataPlugIn(plugin.Name, JsonSerializer.Serialize(fileMetadata));
6154
}
6255

6356
return new Tuple<DicomFile, FileStorageMetadata>(dicomFile, fileMetadata);
6457
}
6558

66-
private IReadOnlyList<IInputDataPlugIn> LoadPlugIns(IServiceProvider serviceProvider, IReadOnlyList<string> pluginAssemblies)
59+
private List<IInputDataPlugIn> LoadPlugIns(IServiceProvider serviceProvider, IReadOnlyList<string> pluginAssemblies)
6760
{
6861
var exceptions = new List<Exception>();
6962
var list = new List<IInputDataPlugIn>();
@@ -80,7 +73,7 @@ private IReadOnlyList<IInputDataPlugIn> LoadPlugIns(IServiceProvider serviceProv
8073
}
8174
}
8275

83-
if (exceptions.Any())
76+
if (exceptions.Count is not 0)
8477
{
8578
throw new AggregateException("Error loading plug-in(s).", exceptions);
8679
}

src/InformaticsGateway/Services/Common/InputHL7DataPlugInEngine.cs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
using System;
1818
using System.Collections.Generic;
19-
using System.Linq;
2019
using System.Threading.Tasks;
2120
using HL7.Dotnetcore;
2221
using Microsoft.Extensions.Logging;
@@ -28,26 +27,20 @@
2827

2928
namespace Monai.Deploy.InformaticsGateway.Services.Common
3029
{
31-
public class InputHL7DataPlugInEngine : IInputHL7DataPlugInEngine
30+
public class InputHL7DataPlugInEngine(IServiceProvider serviceProvider, ILogger<InputHL7DataPlugInEngine> logger) : IInputHL7DataPlugInEngine
3231
{
33-
private readonly IServiceProvider _serviceProvider;
34-
private readonly ILogger<InputHL7DataPlugInEngine> _logger;
32+
private readonly IServiceProvider _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
33+
private readonly ILogger<InputHL7DataPlugInEngine> _logger = logger ?? throw new ArgumentNullException(nameof(logger));
3534
private IReadOnlyList<IInputHL7DataPlugIn>? _plugsins;
3635

37-
public InputHL7DataPlugInEngine(IServiceProvider serviceProvider, ILogger<InputHL7DataPlugInEngine> logger)
38-
{
39-
_serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
40-
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
41-
}
42-
4336
public void Configure(IReadOnlyList<string> pluginAssemblies)
4437
{
4538
_plugsins = LoadPlugIns(_serviceProvider, pluginAssemblies);
4639
}
4740

4841
public async Task<Tuple<Message, FileStorageMetadata>> ExecutePlugInsAsync(Message hl7File, FileStorageMetadata fileMetadata, Hl7ApplicationConfigEntity? configItem)
4942
{
50-
if (configItem?.PlugInAssemblies is not null && configItem.PlugInAssemblies.Any())
43+
if (configItem?.PlugInAssemblies is not null && configItem.PlugInAssemblies.Count is not 0)
5144
{
5245
if (_plugsins == null)
5346
{
@@ -56,7 +49,7 @@ public async Task<Tuple<Message, FileStorageMetadata>> ExecutePlugInsAsync(Messa
5649

5750
foreach (var plugin in _plugsins)
5851
{
59-
if (configItem is not null && configItem.PlugInAssemblies.Exists(a => a.StartsWith(plugin.ToString()!)))
52+
if (configItem.PlugInAssemblies.Exists(a => a.StartsWith(plugin.ToString()!)))
6053
{
6154
_logger.ExecutingInputDataPlugIn(plugin.Name);
6255
(hl7File, fileMetadata) = await plugin.ExecuteAsync(hl7File, fileMetadata).ConfigureAwait(false);
@@ -66,7 +59,7 @@ public async Task<Tuple<Message, FileStorageMetadata>> ExecutePlugInsAsync(Messa
6659
return new Tuple<Message, FileStorageMetadata>(hl7File, fileMetadata);
6760
}
6861

69-
private IReadOnlyList<IInputHL7DataPlugIn> LoadPlugIns(IServiceProvider serviceProvider, IReadOnlyList<string> pluginAssemblies)
62+
private List<IInputHL7DataPlugIn> LoadPlugIns(IServiceProvider serviceProvider, IReadOnlyList<string> pluginAssemblies)
7063
{
7164
var exceptions = new List<Exception>();
7265
var list = new List<IInputHL7DataPlugIn>();
@@ -83,7 +76,7 @@ private IReadOnlyList<IInputHL7DataPlugIn> LoadPlugIns(IServiceProvider serviceP
8376
}
8477
}
8578

86-
if (exceptions.Any())
79+
if (exceptions.Count is not 0)
8780
{
8881
throw new AggregateException("Error loading plug-in(s).", exceptions);
8982
}

src/InformaticsGateway/Services/Connectors/PayloadNotificationActionHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ private async Task SendArtifactRecievedEvent(Payload payload)
170170
};
171171
artifiactRecievedEvent.DataOrigins.AddRange(payload.DataOrigins);
172172

173-
_logger.LogTrace($"Adding files to ArtifactsReceivedEvent files {JsonSerializer.Serialize(payload)}");
173+
_logger.AddingFilesToArtifactsReceivedEvent(JsonSerializer.Serialize(payload));
174174

175175
artifiactRecievedEvent.Artifacts = payload.Files.Select(f => new Artifact { Type = f.DataOrigin.ArtifactType, Path = f.File.UploadPath }).ToList();
176176

src/InformaticsGateway/Services/Export/Hl7ExportService.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
using Monai.Deploy.InformaticsGateway.Api.Mllp;
3232
using Monai.Deploy.Messaging.Common;
3333
using Polly;
34-
using System.Linq;
3534

3635
namespace Monai.Deploy.InformaticsGateway.Services.Export
3736
{
@@ -120,7 +119,7 @@ private async Task ExecuteHl7Export(
120119
.ExecuteAsync(async () =>
121120
{
122121
await _mllpService.SendMllp(
123-
Dns.GetHostAddresses(destination.HostIp).First(),
122+
Dns.GetHostAddresses(destination.HostIp)[0],
124123
destination.Port, Encoding.UTF8.GetString(exportRequestData.FileContent),
125124
cancellationToken
126125
).ConfigureAwait(false);

src/InformaticsGateway/Services/HealthLevel7/MllpService.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ public int ActiveConnections
7979
public MllpService(IServiceScopeFactory serviceScopeFactory,
8080
IOptions<InformaticsGatewayConfiguration> configuration)
8181
{
82-
if (serviceScopeFactory is null)
83-
{
84-
throw new ArgumentNullException(nameof(serviceScopeFactory));
85-
}
82+
ArgumentNullException.ThrowIfNull(serviceScopeFactory, nameof(serviceScopeFactory));
8683

8784
_configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
8885

@@ -193,7 +190,7 @@ private async Task OnDisconnect(IMllpClient client, MllpClientResult result)
193190
await _inputHL7DataPlugInEngine.ExecutePlugInsAsync(message, hl7Filemetadata, configItem).ConfigureAwait(false);
194191
newMessage = await _mIIpExtract.ExtractInfo(hl7Filemetadata, message, configItem).ConfigureAwait(false);
195192

196-
_logger.LogTrace($"HL7 message after plug-in processing: {newMessage.HL7Message} correlationId: {hl7Filemetadata.CorrelationId}");
193+
_logger.HL7MessageAfterPluginProcessing(newMessage.HL7Message, hl7Filemetadata.CorrelationId);
197194
}
198195
_logger.Hl7MessageReceieved(newMessage.HL7Message);
199196
await hl7Filemetadata.SetDataStream(newMessage.HL7Message, _configuration.Value.Storage.TemporaryDataStorage, _fileSystem, _configuration.Value.Storage.LocalTemporaryStoragePath).ConfigureAwait(false);
@@ -217,7 +214,7 @@ private async Task OnDisconnect(IMllpClient client, MllpClientResult result)
217214
private async Task ConfigurePlugInEngine()
218215
{
219216
var configs = await _hl7ApplicationConfigRepository.GetAllAsync().ConfigureAwait(false);
220-
if (configs is not null && configs.Any() && configs.Max(c => c.LastModified) > _lastConfigRead)
217+
if (configs is not null && configs.Count is not 0 && configs.Max(c => c.LastModified) > _lastConfigRead)
221218
{
222219
var pluginAssemblies = new List<string>();
223220
foreach (var config in configs.Where(p => p.PlugInAssemblies?.Count > 0))
@@ -231,7 +228,7 @@ private async Task ConfigurePlugInEngine()
231228
_logger.HL7PluginLoadingExceptions(ex);
232229
}
233230
}
234-
if (pluginAssemblies.Any())
231+
if (pluginAssemblies.Count is not 0)
235232
{
236233
_inputHL7DataPlugInEngine.Configure(pluginAssemblies);
237234
}

src/Plug-ins/RemoteAppExecution/Migrations/20230818161328_R4_0.4.0.cs

100644100755
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ namespace Monai.Deploy.InformaticsGateway.PlugIns.RemoteAppExecution.Migrations
66
{
77
public partial class R4_040 : Migration
88
{
9+
private static readonly string[] Columns = ["WorkflowInstanceId", "ExportTaskId", "StudyInstanceUid"];
10+
private static readonly string[] StudyColumns = ["WorkflowInstanceId", "ExportTaskId", "StudyInstanceUid", "SeriesInstanceUid"];
11+
912
protected override void Up(MigrationBuilder migrationBuilder)
1013
{
1114
migrationBuilder.CreateTable(
@@ -30,7 +33,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
3033
migrationBuilder.CreateIndex(
3134
name: "idx_remoteapp_all",
3235
table: "RemoteAppExecutions",
33-
columns: new[] { "WorkflowInstanceId", "ExportTaskId", "StudyInstanceUid", "SeriesInstanceUid" });
36+
columns: StudyColumns);
3437

3538
migrationBuilder.CreateIndex(
3639
name: "idx_remoteapp_instance",
@@ -40,7 +43,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
4043
migrationBuilder.CreateIndex(
4144
name: "idx_remoteapp_study",
4245
table: "RemoteAppExecutions",
43-
columns: new[] { "WorkflowInstanceId", "ExportTaskId", "StudyInstanceUid" });
46+
columns: Columns);
4447
}
4548

4649
protected override void Down(MigrationBuilder migrationBuilder)

0 commit comments

Comments
 (0)