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

[DAM analyzer] Add support for properties and enable more tests #2390

Merged
merged 7 commits into from
Nov 30, 2021

Conversation

sbomer
Copy link
Member

@sbomer sbomer commented Nov 20, 2021

I enabled more of the dataflow tests for the analyzer and fixed one common bucket of failures due to properties not being supported in the analyzer. The IOperation tree represents properties as IPropertyReferenceOperation so we need to handle properties specially (whereas the linker sees calls to the getter/setter directly).

@sbomer sbomer changed the title Add support for properties and enable more tests [DAM analyzer] Add support for properties and enable more tests Nov 20, 2021
@sbomer sbomer marked this pull request as ready for review November 29, 2021 19:22
Comment on lines 43 to 45
// Trimmer and analyzer use different formats for ref parameters
[ExpectedWarning ("IL2077", nameof (ByRefDataflow) + "." + nameof (MethodWithRefParameter) + "(Type&)", ProducedBy = ProducedBy.Trimmer)]
[ExpectedWarning ("IL2077", nameof (ByRefDataflow) + "." + nameof (MethodWithRefParameter) + "(ref Type)", ProducedBy = ProducedBy.Analyzer)]
Copy link
Member

Choose a reason for hiding this comment

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

Could you add an issue for this. My understand is that we tried to match the C# formatting in warnings, so if there's a discrepancy, it should be treated as a bug in the linker.

Copy link
Member Author

Choose a reason for hiding this comment

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

Filed #2406

[UnrecognizedReflectionAccessPattern (typeof (ByRefDataflow), nameof (MethodWithRefParameter), new string[] { "Type&" }, messageCode: "IL2077")]
// Trimmer and analyzer use different formats for ref parameters
[ExpectedWarning ("IL2077", nameof (ByRefDataflow) + "." + nameof (MethodWithRefParameter) + "(Type&)", ProducedBy = ProducedBy.Trimmer)]
[ExpectedWarning ("IL2077", nameof (ByRefDataflow) + "." + nameof (MethodWithRefParameter) + "(ref Type)", ProducedBy = ProducedBy.Analyzer)]
public static void PassRefToField ()
{
MethodWithRefParameter (ref s_typeWithPublicParameterlessConstructor);
Copy link
Member

Choose a reason for hiding this comment

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

Just a general note - I know that linker has issues with ref/out parameters in some cases. We should add a work item to the analyzer about the same.
Basically it reverses data flow direction to a degree....

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is the issue you're referring to, right? #2158
I'll link to it from the analyzer tracking issue.

- Rename to 'thisParameter'
- Reference issue about ref parameter formatting
@sbomer sbomer closed this Nov 30, 2021
@sbomer sbomer reopened this Nov 30, 2021
@sbomer
Copy link
Member Author

sbomer commented Nov 30, 2021

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@sbomer sbomer merged commit d8170a8 into dotnet:feature/damAnalyzer Nov 30, 2021
@sbomer sbomer mentioned this pull request Jan 13, 2022
4 tasks
@sbomer sbomer deleted the propertySupport branch February 22, 2022 18:13
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
…et/linker#2390)

The IOperation tree represents properties as
IPropertyReferenceOperation, so we need to handle
properties specially (whereas the linker sees calls
to the getter/setter directly).

Commit migrated from dotnet/linker@d8170a8
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.

2 participants