Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty attributes in a <plugin/> tag are not printed by Element::ToString unless they are in a custom XML namespace #1421

Closed
scpeters opened this issue May 20, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@scpeters
Copy link
Member

scpeters commented May 20, 2024

Environment

Description

  • Expected behavior: as of Allow empty strings in plugin and custom attributes #1407, attributes within a <plugin/> set to an empty string "" can now be parsed without emitting errors, so the empty attributes should be included in the string generated by Element::ToString.
  • Actual behavior: Only empty attributes in a custom XML namespace will be printed by Element::ToString.

Steps to reproduce

  1. Apply the following patch (from Allow empty strings in plugin and custom attributes #1407 (comment)):
diff --git a/test/integration/plugin_attribute.cc b/test/integration/plugin_attribute.cc
index 7f4f9f4c..b66c9da1 100644
--- a/test/integration/plugin_attribute.cc
+++ b/test/integration/plugin_attribute.cc
@@ -65,4 +65,9 @@ TEST(PluginAttribute, ParseAttributes)
     EXPECT_EQ(value->Get<std::string>(""),
               std::string("value"));
   }
+  {
+    auto pluginToString = plugin->ToString("");
+    EXPECT_NE(std::string::npos, pluginToString.find("empty_attribute=''"))
+      << pluginToString;
+  }
 }
  1. Build and run INTEGRATION_plugin_attribute test
  2. Observe test failure
[ RUN      ] PluginAttribute.ParseAttributes
/Users/scpeters/ws/dome/src/sdformat/test/integration/plugin_attribute.cc:70: Failure
Expected: (std::string::npos) != (pluginToString.find("empty_attribute=''")), actual: 18446744073709551615 vs 18446744073709551615
<plugin name='example' filename='libexample.so'>
  <user attribute='attribute'/>
  <value attribute='attribute'>value</value>
</plugin>

[  FAILED  ] PluginAttribute.ParseAttributes (56 ms)

Output

@scpeters
Copy link
Member Author

As I noted in #1407 (comment), I don't have a good idea for how to fix this. I'm going to close this as "won't fix", but feel free to comment here if you have an idea and we can reconsider it.

@scpeters scpeters closed this as not planned Won't fix, can't repro, duplicate, stale May 20, 2024
@github-project-automation github-project-automation bot moved this from Inbox to Done in Core development May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

1 participant