Skip to content

Xml - don't automatically encode attribute values #1610

Closed

Description

@belav

Currently xml attributes are encoded when run through CSharpier, which results in them being less readable.

Input

<Target Name="Transform" BeforeTargets="Build">
  <Message Importance="high" Text="@(MyItems->'MyItems has %(Identity)', ', ')" />
</Target>

Output

<Target Name="Transform" BeforeTargets="Build">
  <Message Importance="high" Text="@(MyItems-&gt;'MyItems has %(Identity)', ', ')" />
</Target>

This happens automatically with XAttribute but the code does make use of that along with the associated XmlAttribute to keep the original new lines in attribute values. Does using only XmlAttribute cause some other issue? Can the code figure out how to keep unencoded values for everything?

Activity

  1. added this to the 1.1.0 milestone on May 20, 2025
  2. belav commented on Jul 13, 2025

    @belav
    OwnerAuthor

    XmlAttribute always gives the unencoded value.
    XAttrbitue always gives the encoded value.

    This may require deciding which values should be encoded. This is a test to ensure we keep encoded values.

    <Project>
      <Element AttributeLineEndingDecimal="@('', '&#xA;')" />
      <Element AttributeLineEndingHexidecimal="@('', '&#xA;')" />
      <Element Attribute="&quot;&quot; &amp;&amp;" />
    </Project>

    Ideally the original file would be taken into account. Keeping values encoded if they were encoded there.

  3. modified the milestones: 1.1.0, 1.2.0 on Jul 19, 2025
  4. added 4 commits that reference this issue on Aug 11, 2025
    677ab61
    1d757f5
    d7d09dc
    431e735
  5. added a commit that references this issue on Aug 31, 2025
    0a90816
  6. added a commit that references this issue on Nov 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions