Skip to content

[feature/damAnalyzer] Merge from main #2298

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

Merged
merged 32 commits into from
Sep 30, 2021

Conversation

sbomer
Copy link
Member

@sbomer sbomer commented Sep 29, 2021

Picking up recent test infra changes from main so we can use them in the DAM analyzer.

As part of the merge I moved GetMissingMemberTypes from ReflectionMethodBodyScanner.cs into the shared Annotations.cs and replaced the older logic in SourceHasRequiredAnnotations.

mrvoorhe and others added 30 commits September 2, 2021 09:25
* Nullable annotations part 1

Enable nullable annotations for LinkContext and the XML processing classes.
…0906.1 (dotnet#2262)

[main] Update dependencies from dotnet/runtime
[main] Update dependencies from dotnet/arcade


 - Workaround crashing analyzer
This uncovers a null ref in sweepstep.
The test is order dependent:
- Assembly (librarywithnonemtpy) has a virtual method which referes to type from second library (library). This processes the type reference.
- The type is removed from library
- The virtual method is re-processed again -> hits a type def which does not belong to any assembly/scope

For this to happen the virtual method must be processed after the type has been removed.
This also requires the method to be meant for removal later on (the body will be rewritten to throw), since otherwise the type would have been marked.
This also requires the library with the removed type to be kept (so something else in it must be kept).
Basically a workaround for dotnet#2260. This simply goes back to using the `Resolve` method and avoid the cache for now.
…lyzer (dotnet#2254)

* Add support in RUC analyzer for new() constraint on generics

* Support `new()` constraint on types

* Use SyntaxNodeAnalysisContext for constructor constraints

* Lint

* Update justification
* Add MakeGenericMethod and MakeGenericType to the special incompatible members of the RUC analyzer.

* Don't produce diagnostics for MakeGenericMethod/MakeGenericType

* Add comment

* Lint
* Warn on usage of attributes with annotated ctors

* PR feedback
Add ProducedBy from Test Restructure
Add support for SetupCompileBefore in the analyzer
Run analyzer tests on all members (not only methods)
Move tests to RequiresCapability

* Enable analyzer tests for attributes which use RUC annotated properties

* Lint

* Rename CheckAttributeCtor
Check for instantiations that set annotated properties

* Apply suggestions from code review

Co-authored-by: Andy Gocke <angocke@microsoft.com>

* Update comment
Rename Linker => Trimmer in ProducedBy

* Fix applied suggestions

* Lint

Co-authored-by: Andy Gocke <angocke@microsoft.com>
Enable nullable on Annotations.cs
Check for null after TryResolve using 'is' keyword in MarkStep()
…916.4 (dotnet#2283)

[main] Update dependencies from dotnet/arcade
…0920.1 (dotnet#2284)

[main] Update dependencies from dotnet/runtime
* Build testcases against reference assemblies

* Reproduce issue in testcase

* Add TypeReferenceMarker

* Update one more testcase

* Don't mark forwarders in TypeReferenceMarker

Leave the logic as before and mark them from MarkStep.

* PR feedback

- Use ref assemblies for ReferenceAttribute
- Avoid adding to common references unless needed by test dependencies
* Nullable annotations part 3

* Fix spelling
` GetDynamicallyAccessedMemberTypesFromBindingFlagsForXXX` would return `DynamicallyAccessedMembers.None` when the binding flags are null/unknown.

This fix is a bit more targeted so that we can potentially take it to 6.0.

In general, there's some duality in how BindingFlags are handled - there are places that call `BindingFlagsAreUnsupported` and avoid `GetDynamicallyAccessedMemberTypesFromBindingFlagsForXXX` for null that way. Others call into this API without checking whether the flags are supported first.

I'm unclear whether it would be more appropriate to check for `BindingFlagsAreUnsupported` in the code I'm adding. It's a valid option as well.
* Share logic for discovering typereferences

* PR feedback

- Add non-nullable property over "visited" hashset
- Hide construction/process pattern in static helpers
…924.2 (dotnet#2294)

[main] Update dependencies from dotnet/arcade
…0926.2 (dotnet#2295)

[main] Update dependencies from dotnet/runtime
`IgnorableBindingFlags` are all new - we wouldn't consider them supported in the past. I'm also adding `BindingFlags.ExactBinding` in the first group - that one was considered unsupported in the past but this flag just disallows implicit widening and similar things that don't affect our binding logic (I don't think we would ever want to go in that territory).
* Improve analyzer test checker

- When diagnostics are missing, display all missing diagnostics
- Show candidate diagnostics that didn't match any expected ones
- Adjust match criteria to match Roslyn strings
- Clean up nullable annotations in test infra
- Remove cctor warnings from analyzer to match linker
- Remove redundant attribute property setter warnings
- Fix location filtering for warnings that originate from types
@sbomer sbomer requested a review from marek-safar as a code owner September 29, 2021 15:40
@sbomer sbomer requested review from mateoatr and agocke September 29, 2021 15:40
@sbomer sbomer merged commit 83c51d4 into dotnet:feature/damAnalyzer Sep 30, 2021
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
[feature/damAnalyzer] Merge from main

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

7 participants