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

Fix type name parsing in NativeAOT #79963

Merged
merged 1 commit into from
Dec 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static bool ResolveType(string name, ModuleDesc callingModule, TypeSystem
StringBuilder typeName = new StringBuilder();
StringBuilder typeNamespace = new StringBuilder();
string containingTypeName = null;
while (i < name.Length && (char.IsLetterOrDigit(name[i]) || name[i] == '.' || name[i] == '`' || name[i] == '+'))
while (i < name.Length && (char.IsLetterOrDigit(name[i]) || name[i] == '.' || name[i] == '_' || name[i] == '`' || name[i] == '+'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what the style conventions are in the compiler, but you could simplify this with a pattern if that's allowed?

Suggested change
while (i < name.Length && (char.IsLetterOrDigit(name[i]) || name[i] == '.' || name[i] == '_' || name[i] == '`' || name[i] == '+'))
while (i < name.Length && (char.IsLetterOrDigit(name[i]) || name[i] is '.' or '_' or '`' or '+'))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to polish this; this file will be nuked from orbit with #72833. This parser is kind of garbage. It's from a time when this being a heuristic was enough, as the comment above says. That time has passed.

{
if (name[i] == '.')
{
Expand Down Expand Up @@ -59,7 +59,7 @@ public static bool ResolveType(string name, ModuleDesc callingModule, TypeSystem

// Consume assembly name
StringBuilder assemblyName = new StringBuilder();
while (i < name.Length && (char.IsLetterOrDigit(name[i]) || name[i] == '.'))
while (i < name.Length && (char.IsLetterOrDigit(name[i]) || name[i] == '.' || name[i] == '_'))
{
assemblyName.Append(name[i]);
i++;
Expand Down