EDI.Net icon indicating copy to clipboard operation
EDI.Net copied to clipboard

[Q] Error was thrown for repeated segment groups

Open EloToJaa opened this issue 10 months ago • 3 comments

Code that was run

EloToJaa/EDI Program.cs INVOIC EdiMessage

INVOIC was created based on stylusstudio using EDIFACT D97A

Error details

indice.Edi.EdiException
  HResult=0x80131500
  Message=More than one properties on type 'INVOIC' have the 'SegmentGroup' attribute. Please add a 'Condition' attribute to all properties in order to discriminate where each SegmentGroup will go.
  Source=indice.Edi
  StackTrace:
   at indice.Edi.EdiSerializer.ConditionalMatch(EdiReader reader, EdiStructure currentStructure, EdiStructureType newContainerType, EdiPropertyDescriptor[] candidates)
   at indice.Edi.EdiSerializer.FindForCurrentSegment(EdiReader reader, EdiStructure currentStructure, EdiStructureType newContainerType)
   at indice.Edi.EdiSerializer.TryCreateContainer(EdiReader reader, Stack`1 stack, EdiStructureType newContainer)
   at indice.Edi.EdiSerializer.DeserializeInternal(EdiReader reader, Type objectType)
   at indice.Edi.EdiSerializer.Deserialize(EdiReader reader, Type objectType)
   at indice.Edi.EdiSerializer.Deserialize(TextReader reader, IEdiGrammar grammar, Type objectType)
   at indice.Edi.EdiSerializer.Deserialize[T](TextReader reader, IEdiGrammar grammar)
   at Edi.Program.CheckParse() in C:\PATH\edi\Edi\Program.cs:line 33
   at Edi.Program.Main(String[] args) in C:\PATH\edi\Edi\Program.cs:line 13

Cause of the problem

It seems like this problem was caused by segment groups with repeated segments (SG6 & SG51).

I would appreciate any help on how to deal with this Exception

EloToJaa avatar Apr 09 '24 21:04 EloToJaa

Hi @EloToJaa,

thanks for your interest in the library. Do you think it would be easy to isolate the problem into a test with a pull request so I can take a look. Add your models a sample transmission and a test.

C.

cleftheris avatar Apr 10 '24 07:04 cleftheris

I wrote the test like you asked

EloToJaa avatar Apr 11 '24 09:04 EloToJaa

Thank you for putting in the work and making this library available. @cleftheris are there any updates on this issue?

EloToJaa avatar Jun 03 '24 11:06 EloToJaa