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

Simplify DAM analyzer and add conversion test #2297

Merged
merged 3 commits into from
Sep 29, 2021

Conversation

sbomer
Copy link
Member

@sbomer sbomer commented Sep 28, 2021

@mateoatr I was looking again at the analyzer and saw some opportunity to simplify. I didn't understand why we check for Conversion operations specifically at https://github.com/dotnet/linker/blob/feature/damAnalyzer/src/ILLink.RoslynAnalyzer/DynamicallyAccessedMembersAnalyzer.cs#L125
so I wrote a test that should show a case where we might want different behavior for a conversion operator.

For now this pipes the targetIsMethodReturn argument through a few helpers, but soon we should be able to get rid of it and have a uniform representation of the source/target values.

@@ -678,6 +678,43 @@ private void M1()
.WithArguments ("type", "System.C.M2(System.Type)", "System.C.M1()", "'DynamicallyAccessedMemberTypes.PublicMethods'"));
}

[Fact]
public Task ConversionOperation ()
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be in the shared tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

It should be, but I think there's still a little work left for us to confidently share tests, so I've put it here for now. I don't think it hurts to have a few analyzer-only tests as a sanity check, as long as we go back and make sure the shared tests have full coverage later.

- Take Location in helper instead of originOperation
- Avoid optional parameters
- Add test with DAM on conversion return type
Copy link
Contributor

@mateoatr mateoatr left a comment

Choose a reason for hiding this comment

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

Much cleaner/clearer! Thanks!

Copy link
Member

@agocke agocke left a comment

Choose a reason for hiding this comment

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

LGTM

@agocke
Copy link
Member

agocke commented Sep 29, 2021

If there's still outstanding work for the test integration it would be good to have an issue to track that

@sbomer
Copy link
Member Author

sbomer commented Sep 29, 2021

Tracking issue for test integration: #2299 (some of it moved out from #2273)

@sbomer sbomer merged commit 8e7b310 into dotnet:feature/damAnalyzer Sep 29, 2021
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
* Simplify DAM analyzer and add conversion test

* PR feedback
- Take Location in helper instead of originOperation
- Avoid optional parameters
- Add test with DAM on conversion return type

* Add success testcase

Commit migrated from dotnet/linker@8e7b310
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