Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

[feature/damAnalyzer] Merge from main - #2298

Merged
sbomer merged 32 commits into
dotnet:feature/damAnalyzerfrom
sbomer:mergeIntoAnalyzer
Sep 30, 2021
Merged

sbomer merged 32 commits into
dotnet:feature/damAnalyzerfrom
sbomer:mergeIntoAnalyzer

Conversation

@sbomer

@sbomer sbomer commented Sep 29, 2021 •

Copy link
Copy Markdown
Member

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.
[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 <[email protected]>

* Update comment
Rename Linker => Trimmer in ProducedBy

* Fix applied suggestions

* Lint

Co-authored-by: Andy Gocke <[email protected]>
Enable nullable on Annotations.cs
Check for null after TryResolve using 'is' keyword in MarkStep()
* 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
`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 agocke and mateoatr 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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants