You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
DicomDirectory() throws exception
dir.FileSetID' threw an exception of type 'Dicom.DicomDataException
Stack trace:
at Dicom.DicomDataset.GetSingleValue[T](DicomTag tag) in C:\\dev\\GitHub\\fo-dicom\\fo-dicom\\DICOM\\DicomDataset.cs:line 496\r\n at Dicom.Media.DicomDirectory.get_FileSetID() in C:\\dev\\GitHub\\fo-dicom\\fo-dicom\\DICOM\\Media\\DicomDirectory.cs:line 62
To Reproduce
Steps to reproduce the behavior (code snippet or clear description)
Type the following code and run in debug to see the exception that is thrown
DicomDirectory dir = new DicomDirectory();
Note there is an easy workaround to just set the FileSetID yourself after construction.
DicomDirectory dir = new DicomDirectory
{
FileSetID = "DICOMDIR"
};
Expected behavior
DicomDirectory() constructor should not throw that exception since the user didn't supply the FileSetId string empty or otherwise. The constructor code itself sets FileSetID to empty string. See DicomDirectory.cs
/// <summary>
/// Initializes a new instance of the <see cref="DicomDirectory"/> class.
/// </summary>
/// <param name="explicitVr">Indicates whether or not Value Representation of the DICOM directory should be explicit.</param>
public DicomDirectory(bool explicitVr = true)
{
FileMetaInfo.Version = new byte[] { 0x00, 0x01 };
FileMetaInfo.MediaStorageSOPClassUID = DicomUID.MediaStorageDirectoryStorage;
FileMetaInfo.MediaStorageSOPInstanceUID = DicomUID.Generate();
FileMetaInfo.TransferSyntax = explicitVr
? DicomTransferSyntax.ExplicitVRLittleEndian
: DicomTransferSyntax.ImplicitVRLittleEndian;
FileMetaInfo.ImplementationClassUID = DicomImplementation.ClassUID;
FileMetaInfo.ImplementationVersionName = DicomImplementation.Version;
_directoryRecordSequence = new DicomSequence(DicomTag.DirectoryRecordSequence);
Dataset.Add(DicomTag.FileSetID, string.Empty)
.Add<ushort>(DicomTag.FileSetConsistencyFlag, 0)
.Add(DicomTag.OffsetOfTheFirstDirectoryRecordOfTheRootDirectoryEntity, 0U)
.Add(DicomTag.OffsetOfTheLastDirectoryRecordOfTheRootDirectoryEntity, 0U)
.Add(_directoryRecordSequence);
}
Screenshots or test DICOM files
Environment
Fellow Oak DICOM version: 4.0.7
OS: Windows 10 Pro x64
Platform: Microsoft .NET Framework Version 4.8.04084
The text was updated successfully, but these errors were encountered:
To get you right: This exception does not happen in your production code, but you only observe the exception when debugging and viewing the properties of dir in your inspector window?
At least that is what I can reproduce.
The FileSetID shall be an ID for your fileset, e.g. the DICOM Standard says that for burned CDs this FileSetID should be the same als the volume name of the CD. It is not a good idea if fo-dicom would initialize it with something like "DICOMDIR", since it does not make any sense (as if you would initialize every DicomDataset with Patientname "John^Doe").
You expect that the exception does not throw, would you mean that the property should return a string.empty when accessed in code before it was set with a meaningfull value?
The exception does happen in production code as I call this constructor: DicomDirectory dir = new DicomDirectory();
In fact, I just copied the WriteMedia example here
I understand why it's best to initialize it to empty string, but yes, I think it's better not to throw an exception just for accessing it. Maybe at some later point when empty string FileSetID makes it impossible to continue.
Describe the bug
DicomDirectory() throws exception
Stack trace:
To Reproduce
Steps to reproduce the behavior (code snippet or clear description)
Type the following code and run in debug to see the exception that is thrown
Note there is an easy workaround to just set the FileSetID yourself after construction.
Expected behavior
DicomDirectory() constructor should not throw that exception since the user didn't supply the FileSetId string empty or otherwise. The constructor code itself sets FileSetID to empty string. See DicomDirectory.cs
Screenshots or test DICOM files
Environment
Fellow Oak DICOM version: 4.0.7
OS: Windows 10 Pro x64
Platform: Microsoft .NET Framework Version 4.8.04084
The text was updated successfully, but these errors were encountered: