From e1ce1956ffb7a98cd0a171ceecac533e05dc1be4 Mon Sep 17 00:00:00 2001 From: samatrhea Date: Tue, 14 May 2024 14:13:41 +0200 Subject: [PATCH] [Implement] SonarQube improvements --- ...SpecElementWithAttributesExtensionTestFixture.cs | 2 +- .../SpecElementWithAttributesExtensions.cs | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ReqIFSharp.Extensions.Tests/ReqIFExtensions/SpecElementWithAttributesExtensionTestFixture.cs b/ReqIFSharp.Extensions.Tests/ReqIFExtensions/SpecElementWithAttributesExtensionTestFixture.cs index 3ee9bd3..8440302 100644 --- a/ReqIFSharp.Extensions.Tests/ReqIFExtensions/SpecElementWithAttributesExtensionTestFixture.cs +++ b/ReqIFSharp.Extensions.Tests/ReqIFExtensions/SpecElementWithAttributesExtensionTestFixture.cs @@ -39,7 +39,7 @@ public class SpecElementWithAttributesExtensionTestFixture { private ReqIF reqIf; - private IReqIFLoaderService reqIFLoaderService; + private ReqIFLoaderService reqIFLoaderService; [SetUp] public async Task SetUp() diff --git a/ReqIFSharp.Extensions/ReqIFExtensions/SpecElementWithAttributesExtensions.cs b/ReqIFSharp.Extensions/ReqIFExtensions/SpecElementWithAttributesExtensions.cs index c0b80b4..d414655 100644 --- a/ReqIFSharp.Extensions/ReqIFExtensions/SpecElementWithAttributesExtensions.cs +++ b/ReqIFSharp.Extensions/ReqIFExtensions/SpecElementWithAttributesExtensions.cs @@ -69,14 +69,15 @@ public static async Task>> QueryBase64 { var result = new List>(); - var cts = new CancellationTokenSource(); - - foreach (var specObjectValue in specElementWithAttributes.Values.OfType()) + using (var cts = new CancellationTokenSource()) { - foreach (var externalObject in specObjectValue.ExternalObjects) + foreach (var specObjectValue in specElementWithAttributes.Values.OfType()) { - var payload = await reqIfLoaderService.QueryData(externalObject, cts.Token); - result.Add(new Tuple(externalObject, payload)); + foreach (var externalObject in specObjectValue.ExternalObjects) + { + var payload = await reqIfLoaderService.QueryData(externalObject, cts.Token); + result.Add(new Tuple(externalObject, payload)); + } } }