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

WPF Project BAML Resource path include Space . save project error. #3315

Open
Tearies opened this issue Oct 28, 2024 · 14 comments
Open

WPF Project BAML Resource path include Space . save project error. #3315

Tearies opened this issue Oct 28, 2024 · 14 comments
Labels

Comments

@Tearies
Copy link

Tearies commented Oct 28, 2024

Steps to reproduce

1.New WPF Project Whith a Dir Name Include ' ' . eg:Resource Test
2.Add Control reference the source
3.Decompile the WPF Project out put dll.

Error message shown

resource dir name is Resource%20Test

Details

  • Product in use: e.g. ILSpy
  • Version in use: e.g. 9.0.0 preview 3
  • Any other relevant information to the issue, or your interest in contributing a fix.
@Tearies Tearies added the Bug label Oct 28, 2024
@Tearies Tearies changed the title WPF Project BMAL resrouce path include Space . save project error. WPF Project BAML Resource path include Space . save project error. Oct 28, 2024
@Tearies
Copy link
Author

Tearies commented Oct 29, 2024

replace the new assembly and run again
and raise exception can't find resource "Resource%20Test\logo.png"

@greenozon
Copy link

do you mean the issue is %20 and should be just space?

@Tearies
Copy link
Author

Tearies commented Oct 29, 2024

Yes

@greenozon
Copy link

@siegfriedpammer I guess I've bothered you in the past with similar issues!
could you please fix the space issue pls :)

@siegfriedpammer
Copy link
Member

Can you please provide an example binary? I have tried to reproduce this, but I am unable to recreate the exact test case in VS... VS keeps escaping/replacing my spaces :(

Thanks a lot!

@Tearies
Copy link
Author

Tearies commented Nov 2, 2024

Source
image

Error
image

@Tearies
Copy link
Author

Tearies commented Nov 2, 2024

SpaceBamlDecompile.zip

Assembly

@greenozon
Copy link

dnSpyEx shows as follows:
image

@siegfriedpammer
Copy link
Member

siegfriedpammer commented Nov 2, 2024

Seems URI encoding/decoding is specific to ".resources" files... I will add this to the project export only... So upon invoking "Save Code", "a%20b" is turned into "a b", which our filename sanitizer will turn into "a-b"... I hope that this is an acceptable solution. Thanks!

@Tearies
Copy link
Author

Tearies commented Nov 2, 2024

Xaml compiles to encode spaces. If the Uri reference is not synchronized, it is better to restore it to spaces.

@Tearies
Copy link
Author

Tearies commented Nov 2, 2024

dnSpyEx shows as follows: image

It should be like this

@siegfriedpammer
Copy link
Member

We escape spaces in filenames/paths because they usually only cause trouble and if you are going to try to recompile something after exporting it as a project, I think fixing up the names of resources is the least of your problems - especially if the assemblies are obfuscated.

@Tearies
Copy link
Author

Tearies commented Nov 3, 2024

It is because I need to export it and compile it again. The path of the resource file will be encoded again. The "%20" character will be re-encoded as the original character. Then the place where I reference this resource will not find the corresponding resource, resulting in a program error. So I will pay more attention to this problem. Of course, if I just want to take a look at the implementation logic, then I don't need to care too much about this problem.

@Tearies
Copy link
Author

Tearies commented Nov 3, 2024

The problem of assembly obfuscation is indeed something I have not considered. But if the obfuscated place uses this resource, it will also use the obfuscated one. If we recompile, there will still be problems in use. Just like dnSpy. They should have considered this situation. Otherwise, they will also have %20. dotPeek outputs _25020, and I will do a lot of resource searches and modifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants