Skip to content

Update linker and analyzer to handle DAM on indexable property parameters#3081

Merged
jtschuster merged 8 commits intodotnet:mainfrom
jtschuster:indexablePropsAnalyzer
Oct 25, 2022
Merged

Update linker and analyzer to handle DAM on indexable property parameters#3081
jtschuster merged 8 commits intodotnet:mainfrom
jtschuster:indexablePropsAnalyzer

Conversation

@jtschuster
Copy link
Member

In the analyzer, IPropertyReference's may be indexable, which have additional parameters that must be passed to HandleCallAction.

@jtschuster jtschuster requested a review from sbomer as a code owner October 24, 2022 22:42
@jtschuster jtschuster marked this pull request as draft October 24, 2022 22:43
@jtschuster jtschuster marked this pull request as ready for review October 25, 2022 03:34
@jtschuster jtschuster marked this pull request as draft October 25, 2022 03:34
@jtschuster jtschuster changed the title Update analyzer to handle indexable properties Update linker and analyzer to handle DAM on indexable properties Oct 25, 2022
@jtschuster jtschuster changed the title Update linker and analyzer to handle DAM on indexable properties Update linker and analyzer to handle DAM on indexable property parameters Oct 25, 2022
@jtschuster jtschuster marked this pull request as ready for review October 25, 2022 20:08
Copy link
Member

@sbomer sbomer left a comment

Choose a reason for hiding this comment

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

Thanks!

paramAnnotations[paramAnnotations.Length - 1] = annotation;
annotatedMethods.Add (new MethodAnnotations (setMethod, paramAnnotations, DynamicallyAccessedMemberTypes.None, null));
}
if (setterAnnotation is not null)
Copy link
Member

Choose a reason for hiding this comment

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

Can this logic be replaced with the following?

setterAnnotation?.ParameterAnnotations[^1] = annotation;

Copy link
Member Author

@jtschuster jtschuster Oct 25, 2022

Choose a reason for hiding this comment

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

I think we could, but that makes me wonder if we should actually make MethodAnnotations.ParameterAnnotations an ImmutableArray<DynamicallyAccessedMembers> instead of just a mutable array. The fields are already readonly, so I think the intent is that Annotations should be immutable data structures.

Copy link
Member

Choose a reason for hiding this comment

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

In this case I think it is still useful to be able to modify them in-place as we are building the annotations. The usual pattern is to have some kind of mutable builder, which produces an immutable output at the end. I think since MethodAnnotations is private to FlowAnnotations, this kind of does that - after building annotations, they should only be accessed (and never mutated) through FlowAnnotations.

But I agree that since the fields are readonly there's an inconsistency. I am fine with it either way - just a suggestion since I thought the mutating version was more readable here.

Co-authored-by: Sven Boemer <sbomer@gmail.com>
@jtschuster jtschuster merged commit 4db6ac9 into dotnet:main Oct 25, 2022
tlakollo pushed a commit to tlakollo/runtime that referenced this pull request Oct 27, 2022
…ters (dotnet/linker#3081)

Don't assume there is only one parameter for set and none for get. Allow DAM on the index parameters of properties.
Co-authored-by: vitek-karas <10670590+vitek-karas@users.noreply.github.com>
Co-authored-by: Sven Boemer <sbomer@gmail.com>

Commit migrated from dotnet/linker@4db6ac9
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
…ters (dotnet/linker#3081)

Don't assume there is only one parameter for set and none for get. Allow DAM on the index parameters of properties.
Co-authored-by: vitek-karas <10670590+vitek-karas@users.noreply.github.com>
Co-authored-by: Sven Boemer <sbomer@gmail.com>

Commit migrated from dotnet/linker@4db6ac9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants