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 parsing of type names with generic array parameter #8337

Conversation

ReubenBond
Copy link
Member

@ReubenBond ReubenBond commented Mar 6, 2023

Fixes #8330

This is a generics corner case which was stumping the type parser when parsing a formatted unconstructed generic type.
For example, this type would not round-trip successfully:
typeof(List<>).MakeGenericType(typeof(Inner<>.Middle).MakeArrayType())

Concretely, this behavior was being hit when compiling the grain manifest for a type like IGenericArrayRegisterGrain<T>, since the manifest would contain the implemented interfaces, which contains IGenericRegisterGrain<T[]> (with no concrete T):

public interface IGenericRegisterGrain<T> : IGrainWithIntegerKey
{
  Task Set(T value);
  Task<T> Get();
}

public interface IGenericArrayRegisterGrain<T> : IGenericRegisterGrain<T[]>
{
}

The fix is to check that we are indeed looking at a formatted generic type, versus an array, by reading ahead for the presence of [[ (indicating a generic parameter list) rather than just [ (ambiguous between an array specification or generic parameter list)

Microsoft Reviewers: Open in CodeFlow

@ReubenBond ReubenBond added this to the 7.1.1 milestone Mar 6, 2023
@ReubenBond ReubenBond merged commit f2890ce into dotnet:main Mar 7, 2023
@ReubenBond ReubenBond deleted the fix/type-encoding-for-generic-array-parameters branch March 7, 2023 23:27
@github-actions github-actions bot locked and limited conversation to collaborators Dec 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Orleans 7] Orleans runtime fails to start when grain interface contains generic array constraint
1 participant