[Q] Error was thrown for repeated segment groups
- Dominant language
- C#
- Stars
- 490
- Forks
- 173
- PR merge metrics
- No merged PRs in 30d
Description
## Code that was run
[EloToJaa/EDI](https://github.com/EloToJaa/EDI)
[Program.cs](https://github.com/EloToJaa/EDI/blob/main/Edi/Program.cs)
[INVOIC EdiMessage](https://github.com/EloToJaa/EDI/blob/main/Edi.Contracts/Messages/INVOIC.cs)
INVOIC was created based on [stylusstudio](https://www.stylusstudio.com/edifact/D97A/INVOIC.htm) 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
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the exception from Edi/Program.cs using the INVOIC definition in Edi.Contracts/Messages/INVOIC.cs, then trace the reported ConditionalMatch path through EdiSerializer. Compare how the repeated SG6 and SG51 segment groups are represented; done means the repeated groups can be handled without the reported SegmentGroup exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100