-
Notifications
You must be signed in to change notification settings - Fork 127
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
Conversation
src/ILLink.RoslynAnalyzer/DynamicallyAccessedMembersAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/ILLink.RoslynAnalyzer/DynamicallyAccessedMembersAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/ILLink.RoslynAnalyzer/DynamicallyAccessedMembersAnalyzer.cs
Outdated
Show resolved
Hide resolved
@@ -678,6 +678,43 @@ private void M1() | |||
.WithArguments ("type", "System.C.M2(System.Type)", "System.C.M1()", "'DynamicallyAccessedMemberTypes.PublicMethods'")); | |||
} | |||
|
|||
[Fact] | |||
public Task ConversionOperation () |
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.
Shouldn't this be in the shared tests?
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.
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.
test/ILLink.RoslynAnalyzer.Tests/DynamicallyAccessedMembersAnalyzerTests.cs
Show resolved
Hide resolved
- Take Location in helper instead of originOperation - Avoid optional parameters - Add test with DAM on conversion return type
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.
Much cleaner/clearer! Thanks!
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.
LGTM
test/ILLink.RoslynAnalyzer.Tests/DynamicallyAccessedMembersAnalyzerTests.cs
Show resolved
Hide resolved
If there's still outstanding work for the test integration it would be good to have an issue to track that |
* 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
@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#L125so 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.