Make RDG handle names that are escaped keywords
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
When we generate code containing user-defined names (e.g. using `typeof` on the type of a parameter), we need to be careful to generate syntactically valid code in the presence of escaped keywords like `@class`.
> Ah! I misinterpreted your comment a little bit. I thought your inquiry was around the use of the `@` prefix on class names in general (which ends up producing something like `typeof(MyClass)` which is valid) but you were referring to the literal use of `class @class`.
>
> My initial reaction to this is that it's the kind of edge case that I'd be comfortable not addressing specifically in RDG.
>
> My second reaction is to explore what the implementation complexity would look like with this and see if it is worth pursuing given cost/reward. It might very well be we have to pass a formatter to `ToDisplayString` here to get the desired behavior.
>
> My third reaction is wondering if the current behavior (compiler errors on generated code) is a valid experience for users who run into these kinds of buggy experiences.
>
> In any case, this is worth tracking in a follow-up issue if you'd like to file one?
_Originally posted by @captainsafia in https://github.com/dotnet/aspnetcore/pull/47914#discussion_r1194173902_
Contributor guide
Assessment
This issue has not been assessed yet.