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

Update to metadata that fixes the char* as ushort* problem #121

Closed
AArnott opened this issue Feb 17, 2021 · 2 comments · Fixed by #136
Closed

Update to metadata that fixes the char* as ushort* problem #121

AArnott opened this issue Feb 17, 2021 · 2 comments · Fixed by #136
Assignees
Labels
enhancement New feature or request

Comments

@AArnott
Copy link
Member

AArnott commented Feb 17, 2021

No description provided.

@tannergooding
Copy link
Member

This may not be a good idea. There is some discussion in dotnet/corefxlab#2350 about changing char to be UTF8 and therefore 1-byte, rather than 2 at an opt-in level which means that char* for a LPCWSTR would now be incorrect.

Likewise, while char* itself is just a pointer and therefore blittable. char, char[], and string are not and are only sometimes blittable (and generally require you to explicitly annotate that you want it handled as UnmanagedType.U2 or as CharSet.Unicode).

@AArnott
Copy link
Member Author

AArnott commented Feb 22, 2021

I am shocked to learn that char might be redefined as a 1-byte value. I can't imagine how much code that would break.
I'm not sure what you're saying isn't a good idea though. char* is how anyone and everyone can represent a UTF-16 string today. string can be pinned today as a char*. It cannot be pinned as a ushort*. So while I don't have a crystal ball to foresee what the CLR may do in the future, we're generating code that needs to work well with the code people have today, which for the time being is char*.

AArnott added a commit that referenced this issue Feb 22, 2021
AArnott added a commit that referenced this issue Feb 22, 2021
AArnott added a commit that referenced this issue Feb 22, 2021
AArnott added a commit that referenced this issue May 6, 2022
Update Nerdbank.GitVersioning to enable graph build and optimize perf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants