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

Unescaping f# method names #4972

Closed
nohwnd opened this issue Apr 9, 2024 · 4 comments
Closed

Unescaping f# method names #4972

nohwnd opened this issue Apr 9, 2024 · 4 comments
Labels

Comments

@nohwnd
Copy link
Member

nohwnd commented Apr 9, 2024

Fancy f# method names with `` `` are escaping according to some rules, and to make managed name full compatible we need to fully unescape. #4969 fixes the most painful problem that prevents discovering completely. But in ideal case the CIL name should be fully unescaped so it can be found through reflection.


I have run a few manual tests and here are the characters that gets transformed (not exhaustive list):

  • \ escaped as \\
  • ' escaped as \'
  • " escaped as \"
  • @ escaped as @5

I will look at more cases now.

Originally posted by @Evangelink in #4969 (comment)

AB#2020980

@testplatform-bot
Copy link
Collaborator

✅ Successfully linked to Azure Boards work item(s):

@nohwnd
Copy link
Member Author

nohwnd commented Apr 9, 2024

Spec says:
3.4 Identifiers and Keywords

Any sequence of characters that is enclosed in double-backtick marks ( ), excluding newlines,
tabs, and double-backtick pairs themselves, is treated as an identifier. Note that when an identifier is
used for the name of a types, union type case, module, or namespace, the following characters are
not allowed even inside double-backtick marks:
‘.', '+', '$', '&', '[', ']', '/', '\', '*', '"', '`'
All input files are currently assumed to be encoded as UTF-8. See the C# specification for a list of the
Unicode characters that are accepted for the Unicode character classes \Lu, \Li, \Lt, \Lm, \Lo, \Nl,
\Pc, \Mn, \Mc, and \Cf.

https://fsharp.org/specs/language-spec/4.1/[FSharpSpec-4.1-latest.pdf](https://fsharp.org/specs/language-spec/4.1/FSharpSpec-4.1-latest.pdf)

member this.`` . + - = $ & [ ] \ / * @ ' ` " % ( ) ^ `` () =
Experimenting with the chars above and few more only ` ' " \ look to be escaped for methods:

image

@Amaury how did you get @ to become @5?

@Amaury
Copy link

Amaury commented Apr 9, 2024

Not the right Amaury... Try again 😉

@nohwnd
Copy link
Member Author

nohwnd commented Apr 11, 2024

This is not an issue, I misinterpreted what the parser is doing. We only need to handle ' correctly, which we do in #4969

@nohwnd nohwnd closed this as completed Apr 11, 2024
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