Erroneous behaviour with CreateSegmentPairProperties() in Sdl.FileTypeSupport.Framework.BilingualApi

While I was testing our internal MT plugin in Studio 2022 SR1 and when copying content from a custom viewpart in Editor to target segment, the following piece of code gave curious results

So every time I choose to copy content from viewpart to target segment, CreateSegmentPairProperties() changes the ID of the active segment pair. It seems to create a new segment pair with new ID on top of the old one. It counts the number of segment pairs in the active document, increments it by 1 and changes the ID to that, which will then cause "Sequence contains no matching element" as the segment pair ID doesn't match anymore. The change is irreversible and trying to cancel the edit crashes Studio.

The same piece of code is used in all versions of the plugin, but only in 2022 SR1 it produces these results. A quick fix is to just comment out that one line, so it's not that drastic, but I'd like to know if that's actually the intended behaviour for this method (creating a new segment pair by default) and is it just redundant to use it like this, as each segment pair seems to have ISegmentPairProperties without creating them first. This piece of code has probably been around since Studio 2014 era.

-Mikko

emoji
Parents
  • Hi  , Can you please explain why you would need to create new segment pair properties on the active segment?

    The segment pair properties already exist with the active segment pair, therefore it's not expected to re-initialize those properties on the active segment; which includes the segment id.  I would recommend to simply update the properties as you have demonstrated above, updating the ComfirmationLevel etc...

    emoji
  • Hi  , thanks for confirming that segment pair has innate properties. Unfortunately, I cannot say what has been the motivation for adding initialization of properties as an extra step, that piece of code has been in place for quite some time now and it's being used to writing content (ConfirmationLevel, Origin etc) in segment pair properties to logs. I just noticed that after the SR1 update, Studio 2022 throws an exception, which makes sense as the properties already exist. Maybe in an earlier incarnation of API things had to be done differently if you wanted to read properties data and inject it into logs.

Reply
  • Hi  , thanks for confirming that segment pair has innate properties. Unfortunately, I cannot say what has been the motivation for adding initialization of properties as an extra step, that piece of code has been in place for quite some time now and it's being used to writing content (ConfirmationLevel, Origin etc) in segment pair properties to logs. I just noticed that after the SR1 update, Studio 2022 throws an exception, which makes sense as the properties already exist. Maybe in an earlier incarnation of API things had to be done differently if you wanted to read properties data and inject it into logs.

Children
No Data