-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Implement more validation for inline array element access and conversion scenarios #68146
Implement more validation for inline array element access and conversion scenarios #68146
Conversation
@cston, @dotnet/roslyn-compiler For the second review |
1 similar comment
@cston, @dotnet/roslyn-compiler For the second review |
{ | ||
var buffer = m.GlobalNamespace.GetTypeMember("Buffer"); | ||
|
||
Assert.True(buffer.HasInlineArrayAttribute(out int length)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the type with two fields recognized as a valid inline array type?
It is not. This API is not determining whether the type is a valid inline array type. It only indicates whether it has a valid attribute. The final check is performed by TryGetInlineArrayElementField
, which returns the only field
} | ||
} | ||
} | ||
} | ||
|
||
return elementType; | ||
if (elementField is not null && elementField.ContainingType.IsGenericType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we testing nested types, with and without generic type parameters?
We are not at the moment, but IsGenericType
check covers the scenario. I will add a test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added tests.
{ | ||
private T _element0; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using this type:
var c = new C();
c.F[2] = 1;
Console.WriteLine(c.F[2]);
class C
{
Enclosing<int>.Buffer<string> F;
}
``` #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using this type: ...
Done
Relates to test plan #67826