Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jas88 authored Nov 24, 2022
2 parents 7135d82 + bff3dc5 commit 53a2da5
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 31 deletions.
2 changes: 0 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ updates:
target-branch: develop
reviewers:
- rkm
- tznind
- jas88
- package-ecosystem: nuget
directory: "/"
Expand All @@ -17,5 +16,4 @@ updates:
target-branch: develop
reviewers:
- rkm
- tznind
- jas88
10 changes: 6 additions & 4 deletions .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ jobs:
runs-on: ubuntu-20.04

steps:
- name: Disable disk flush for CI
run: sudo apt-get install -y libeatmydata1
- uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.x
dotnet-version: 6.0.x
- name: Install MS SQL Server and Postgresql, start existing MySQL
run: |
sudo wget -qO/etc/apt/trusted.gpg.d/microsoft.asc https://packages.microsoft.com/keys/microsoft.asc
Expand All @@ -28,9 +30,9 @@ jobs:
sudo -E /opt/mssql/bin/mssql-conf -n setup accept-eula
sudo service mysql start
- name: Build
run: dotnet build --configuration Release
run: dotnet build --configuration Release --nologo
- name: Test
run: dotnet test --no-restore --verbosity normal
run: dotnet test --no-restore --verbosity normal --nologo
- name: Pack and push
if: contains(github.ref,'refs/tags/')
run: |
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

...
### Changed

- Add information on problematic tag to exception in `GetValueFromDatasetWithMultiplicity`

### [4.0.1] - 2022-06-06

Expand Down
6 changes: 3 additions & 3 deletions DicomTypeTranslation.Tests/DicomTypeTranslation.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1"><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1"><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="NunitXml.TestLogger" Version="3.0.117" />
<PackageReference Include="NunitXml.TestLogger" Version="3.0.127" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DicomTypeTranslation\DicomTypeTranslation.csproj" />
Expand Down
25 changes: 13 additions & 12 deletions DicomTypeTranslation.Tests/DicomTypeTranslatorTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -268,20 +268,21 @@ public void CheckForNewVrs()
Assert.AreEqual(34, TranslationTestHelpers.AllVrCodes.Length);
}

public void TestVrsWithNoTags(string vrName)
[Test]
public void GetCSharpValue_ExceptionIncludesTag()
{
DicomVR vr = DicomVR.Parse(vrName);
// Arrange
var tag = DicomTag.NumericValue;
var ds = new DicomDataset
{
new DicomDecimalString(tag, new[] { "3.40282347e+038", "3.0e+038" }),
};

// NOTE(rkm 2020-03-25) When this fails, add an entry for the new VR to the datasets TranslationTestHelpers
// NOTE(jas 2022-03-18) No VRs seem to fall in this category now with fo-dicom 5?
List<DicomTag> vrTags = typeof(DicomTag)
.GetFields(BindingFlags.Static | BindingFlags.Public)
.Where(field => field.FieldType == typeof(DicomTag))
.Select(x => (DicomTag)x.GetValue(null))
.Where(tag => tag.DictionaryEntry.ValueRepresentations[0] == vr)
.ToList();
// Act
var exc = Assert.Throws<ArgumentException>(() => DicomTypeTranslaterReader.GetCSharpValue(ds, tag));

Assert.AreEqual(0, vrTags.Count);
// Assert
Assert.AreEqual(@"Tag NumericValue (0040,a30a) has invalid value(s): '3.40282347e+038\3.0e+038'", exc.Message);
}

#endregion
Expand Down
4 changes: 2 additions & 2 deletions DicomTypeTranslation.Tests/Helpers/TranslationTestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static DicomDataset BuildVrDataset(DicomVR singleVr = null)
}),
new DicomSignedShort(DicomTag.SelectorSSValue, 0, short.MinValue, short.MaxValue),
new DicomShortText(DicomTag.SelectorSTValue, @"Short\\Text\\Backslashes should be ok: \\\\\\"),
new DicomSignedVeryLong(DicomTag.SelectorSVValue,1,7), // NOTE(rkm 2020-03-25) No tags actually have this VR yet! JS 2022-03-18 there are now...
new DicomSignedVeryLong(DicomTag.SelectorSVValue,1,7),
new DicomTime(DicomTag.SelectorTMValue, "123456", "235959"),
new DicomUnlimitedCharacters(DicomTag.SelectorUCValue, "UnlimitedCharacters-1"),
new DicomUniqueIdentifier(DicomTag.SelectorUIValue, "1.2.3.4", "5.6.7.8"),
Expand All @@ -63,7 +63,7 @@ public static DicomDataset BuildVrDataset(DicomVR singleVr = null)
new DicomUniversalResource(DicomTag.URNCodeValue, "https://example.com?q=1"),
new DicomUnsignedShort(DicomTag.SelectorUSValue, 0, 1, ushort.MaxValue),
new DicomUnlimitedText(DicomTag.SelectorUTValue, "unlimited!"),
new DicomUnsignedVeryLong(DicomTag.SelectorUVValue,new UInt64[]{1}), // NOTE(rkm 2020-03-25) No tags actually have this VR yet! JS 2022-03-18 there are now...
new DicomUnsignedVeryLong(DicomTag.SelectorUVValue,new UInt64[]{1}),
};

if (singleVr != null)
Expand Down
12 changes: 11 additions & 1 deletion DicomTypeTranslation/DicomTypeTranslaterReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,17 @@ private static object GetSequenceFromDataset(DicomDataset ds, DicomTag tag)

private static object GetValueFromDatasetWithMultiplicity<TNaturalType>(DicomDataset dataset, DicomTag tag)
{
Array array = dataset.GetValues<TNaturalType>(tag);
Array array;

try
{
array = dataset.GetValues<TNaturalType>(tag);
}
catch (Exception e)
{
var vals = dataset.GetString(tag);
throw new ArgumentException($"Tag {tag.DictionaryEntry.Keyword} {tag} has invalid value(s): '{vals}'", e);
}

if (array == null || array.Length == 0)
return null;
Expand Down
12 changes: 6 additions & 6 deletions DicomTypeTranslation/DicomTypeTranslation.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.1;net6.0</TargetFrameworks>
<LangVersion>9.0</LangVersion>
<AssemblyTitle>DicomTypeTranslation</AssemblyTitle>
<Product>DicomTypeTranslation</Product>
Expand Down Expand Up @@ -31,10 +31,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="fo-dicom" Version="5.0.3" />
<PackageReference Include="HIC.FAnsiSql" Version="2.0.4" />
<PackageReference Include="MongoDB.Driver" Version="2.15.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NLog" Version="5.0.0" />
<PackageReference Include="YamlDotNet" Version="11.2.1" />
<PackageReference Include="HIC.FAnsiSql" Version="3.0.1" />
<PackageReference Include="MongoDB.Driver" Version="2.18.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="NLog" Version="5.0.5" />
<PackageReference Include="YamlDotNet" Version="12.0.2" />
</ItemGroup>
</Project>
5 changes: 5 additions & 0 deletions lgtm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extraction:
csharp:
index:
dotnet:
version: 6.0.400

0 comments on commit 53a2da5

Please sign in to comment.