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

FindTypeByName always roots ExpandoObject (and is also undefined behavior) #1434

Closed
Sergio0694 opened this issue Jan 10, 2024 · 0 comments · Fixed by #1435
Closed

FindTypeByName always roots ExpandoObject (and is also undefined behavior) #1434

Sergio0694 opened this issue Jan 10, 2024 · 0 comments · Fixed by #1435
Labels
AOT bug Something isn't working trimming
Milestone

Comments

@Sergio0694
Copy link
Member

Describe the bug

This code in TypeNameSupport.FindTypeByName unconditionally roots ExpandoObject:

public static (Type type, int remaining) FindTypeByName(ReadOnlySpan<char> runtimeClassName)
{
// Assume that anonymous types are expando objects, whether declared 'dynamic' or not.
// It may be necessary to detect otherwise and return System.Object.
if (runtimeClassName.StartsWith("<>f__AnonymousType".AsSpan(), StringComparison.Ordinal))
{
return (typeof(System.Dynamic.ExpandoObject), 0);
}

This shows up even in a minimal WinRT component with NAOT, not using anonymous/dynamic types at all:

image

Additionally, matching on "<>f__AnonymousType" is undefined behavior. The C# spec (nor Roslyn) guarantee that name prefix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AOT bug Something isn't working trimming
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants