Skip to content

Rename confusion breaks data contract serialization #147

Open

Description

@semenenkov

1.3.1 serialization.zip
Please check the attached zip
Solution attached, bin contains unconfused and confused exes and xml files produced by them.
Wpf form with two buttons, first saves xml in app folder, second reads file and shows value from file.
Issue is that nested classes not marked as data contract are exported incorrectly, confused version is not compatible with unconfused (but compatible with itself)
Unconfused exports as

  <Inner1Item xmlns:d2p1="http://schemas.datacontract.org/2004/07/WpfApp1">
    <d2p1:Inner2List>

Confused as

  <Inner1Item xmlns:d2p1="http://schemas.datacontract.org/2004/07/">
    <d2p1:_x202E__x206E__x206E__x202D__x200C__x206A__x206F__x206F__x206B__x206C__x200D__x200F__x206D__x200E__x200F__x200B__x202B__x200D__x206E__x206F__x200F__x202D__x202B__x206B__x200E__x202A__x202C__x200C__x206F__x200B__x202D__x206E__x206C__x206A__x206D__x206D__x202B__x206A__x202C__x200D__x202E_>

Inner2List is a public member which to my understanding should not be confused, isn't it?

Activity

  1. mkaring commented on Jun 2, 2020

    @mkaring
    Owner

    You are correct. What happens here is clearly wrong. Renaming the members is correct, because you are obfuscating an executable and ConfuserEx treats all the types in an executable as internal. However, you did set the DataMember, and that should keep the naming in the serialized output the same.

    There are a couple of issues surrounding properties and attributes on properties that were found in issue #123. This issue may be related to one of them.

  2. added this to the 1.4 milestone on Jun 2, 2020
  3. semenenkov commented on Jun 2, 2020

    @semenenkov
    Author

    @mkaring thanks for reply,
    you are obfuscating an executable and ConfuserEx treats all the types in an executable as internal
    I think this is arguable but from some point of view make sense.
    From the point of normal human logic - yes, but from the point of .net it is still an assembly and its public members in theory can be requested from outside. I think some old confuser versions did not rename public members and I was relying on that, making logic-sensitive members internal and others, especially performance-sensitive or confuser-buggy - public. I don't mind of this new approach, just will have to change my habits and some code to use [Obfuscation] attribute instead of public access modifier.

  4. mkaring commented on Jun 2, 2020

    @mkaring
    Owner

    ConfuerEx always handled the types in executables like this. Not sure what the old Confuser did.

    There is a way however, to enforce that the public members remain untouched. You have to add the renPublic parameter of the rename protection with the value false. This way you can disable the automatic selection of this parameter based on the assembly type.

    <project outputDir=".\Confused" baseDir="." xmlns="http://confuser.codeplex.com">
      <rule pattern="true" inherit="false">
        <protection id="rename">
          <argument name="renPublic" value="false" />
        </protection>
      </rule>
      <module path="WpfApp1.exe" />
    </project>
  5. semenenkov commented on Jun 2, 2020

    @semenenkov
    Author

    @mkaring thanks a lot for the tip!
    Previous version I am still using was released many years ago, it is even not Ex yet, and I am pretty sure public members were not confused, I can't check it with disassembler but I see it from exception stack traces.

  6. removed this from the 1.4 milestone on Jul 1, 2020
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

    bugSomething isn't workingenhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions