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

TypeRefHash Questions/Inconsistencies #219

Open
ddash-ct opened this issue Nov 23, 2021 · 1 comment
Open

TypeRefHash Questions/Inconsistencies #219

ddash-ct opened this issue Nov 23, 2021 · 1 comment

Comments

@ddash-ct
Copy link

While attempting to review and leverage the TypeRefHash, we came across a few issues we would like to bring up and hopefully resolve through discussion/implementation:

  • Could you explicitly state the sort order in the definition of TypeRefHash? It seems the sort order is the default C# sort order, which may cause some problems as stated in subsequent bullets:
  • Since the C# default sort order is leveraged, the generated TypeRefHash may change based upon locality/language. For example, if the default language setting for a user is French, the generated TypeRefHash may be different than if the default language setting is English.
  • The C# default sort order treats some characters differently than, say, Python. Having a sorter which is language agnostic will better enable portability and implementation in other languages/environments.
  • The sort order is case-insensitive, while the hash is case-sensitive. The TypeRefHash can be defeated by altering the case of some of the strings. In comparison, an ImportHash converts all names to lower-case before both comparing and hashing.
@secana
Copy link
Owner

secana commented Nov 26, 2021

Hi @ddash-ct the topic came up a few times already. It is definitely a design flaw that we haven't on our minds when we created the TRH.

As far as I can see, the best would be to bring out a TRH 2.0, with a defined sort order that is easy to port to other languages.

For the case argument, I'm not sure if that is an issue, as .NET TypeRefs are case-sensitive as well, e.g. System.Text.Json is not the same as system.Text.Json. In that case it differs from the PE import table. If I'm wrong on that, please let me know.

I'll discuss the problem with the co-creators of the hash. As it is a breaking change, we need some time to figure out how to do it without creating too much friction.

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

No branches or pull requests

2 participants