indice-co / EDI.Net

EDI Serializer/Deserializer. Supports EDIFact, X12 and TRADACOMS formats
MIT License
450 stars 170 forks source link

Optional EdiValue segments in segment group generate empty lines #151

Open GVG opened 4 years ago

GVG commented 4 years ago

Hello! I have an issue with serializer when defining segments in segment groups like this:

[EdiSegmentGroup(.....)]
public class SG
{
        ...

        [EdiValue("X(100)", Path = "FTX/0")]
        public string Aaa { get; set; }

        public LOC Bbb { get; set; }

        ...
}

Both properties are nulls (they are optional) and they must not be in the EDI document, but I get line FTX+' instead. This can be fixed by moving Aaa to separate segment class similar to Bbb, but it's just excess code in my case. I want to keep those optional single-parameter segments in segment group class. Is this by design?

GVG commented 4 years ago

@cleftheris did you check this?

cleftheris commented 4 years ago

Hi @GVG This is not supported at the moment. This could be an improvement in the way compression is handled inside the EdiWriter. The only workaround is the one you mentioned already. That is create a segment class instead.

GVG commented 4 years ago

@cleftheris thanks!