Skip to content

Conversation

@bhufmann
Copy link
Contributor

@bhufmann bhufmann commented May 29, 2025

What it does

  • swagger: Allow double and remove boolean in OutputElementStyle
    Previously only float values were allowed. Don't restrict to float and allow Double as well. Note when deserializing JSON strings a floating point value will be deserialized to Double, e.g. when using Jackson deserializer (Java) or in Javascript. Remove boolean because it can be expressed as String and boolean have no equivalent type in CSS where the StyleProperties are inspired of.

  • server: Only serialize supported value types in OutputElementStyle
    This will make sure that only objects that comply with the TSP specification are serialized. Added unit tests to verify this.

Contributes to:
eclipse-cdt-cloud/trace-server-protocol#102

How to test

Successful execution of newly added test case

Follow-ups

TSP spec. update

Review checklist

  • As an author, I have thoroughly tested my changes and carefully followed the instructions in this template

Previously only float values were allowed. Don't restrict to float and
allow Double as well. Note when deserializing JSON strings a floating
point value will be deserialized to Double, e.g. when using Jackson
deserializer (Java) or in Javascript.

Remove boolean because it can be expressed as String and boolean have
no equivalent type in CSS where the StyleProperties are inspired of.

Contributes to:
eclipse-cdt-cloud/trace-server-protocol#102

Signed-off-by: Bernd Hufmann <[email protected]>
assertTrue(deserialized.getStyleValues().isEmpty());
}

private static void veryStyles(OutputElementStyle testStyle, OutputElementStyleStub deserialized) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verifyStyles?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

gen.writeStringField("parentKey", value.getParentKey());

// Verify the type of style values. Make sure only supported types are returned.
Map<String, Object> newValues = new HashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe could use startObject/writeField/endObject pattern to write directly without needing copied map, and preserve original map order.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. This will avoid looping through the map multiple times. The order doesn't really matter, unless the input map is a LinkedHashMap that preserves the insertion order.

@bhufmann bhufmann changed the title Fix tsp bugs Allow double and remove boolean in OutputElementStyle (type of property values) May 29, 2025
bhufmann added a commit to bhufmann/trace-server-protocol that referenced this pull request May 29, 2025
Previously only float values were allowed. Don't restrict to float and
allow Double as well. Note when deserializing JSON strings a floating
point value will be deserialized to Double, e.g. when using Jackson
deserializer (Java) or in Javascript.

Remove boolean because it can be expressed as String and boolean have
no equivalent type in CSS where the StyleProperties are inspired of.

Contributes to:
eclipse-cdt-cloud#102

Corresponding swagger model update:
eclipse-tracecompass-incubator/org.eclipse.tracecompass.incubator#192

Signed-off-by: Bernd Hufmann <[email protected]>
This will make sure that only objects that comply with the TSP
specification are serialized.

Added unit tests to verify this.

eclipse-cdt-cloud/trace-server-protocol#102

Signed-off-by: Bernd Hufmann <[email protected]>
@bhufmann bhufmann merged commit dad714c into eclipse-tracecompass-incubator:master May 29, 2025
2 checks passed
@bhufmann bhufmann deleted the fix-tsp-bugs branch May 29, 2025 18:12
bhufmann added a commit to eclipse-cdt-cloud/trace-server-protocol that referenced this pull request May 29, 2025
Previously only float values were allowed. Don't restrict to float and
allow Double as well. Note when deserializing JSON strings a floating
point value will be deserialized to Double, e.g. when using Jackson
deserializer (Java) or in Javascript.

Remove boolean because it can be expressed as String and boolean have
no equivalent type in CSS where the StyleProperties are inspired of.

Contributes to:
#102

Corresponding swagger model update:
eclipse-tracecompass-incubator/org.eclipse.tracecompass.incubator#192

Signed-off-by: Bernd Hufmann <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants