Description
In short, unless the analysis requires IL analysis, the linker and the analyzer should produce the same warnings, and the analyzer should produce a strict subset of the total linker warnings.
At the high level, we need to confirm this as best we can using some complex repos. We should turn on the analyzer and verify that no more warnings are produced and that similar value is provided by the analyzer as by the linker. Repos:
- dotnet/runtime
- dotnet/aspnetcore
See #2580 for issues that additionally block integration of the feature branch.
- add DAM analyzer without dataflow (Add DynamicallyAccessedMembers analyzer #2184)
- add abstraction to represent dataflow value (hide this/methodreturn differences)
- allow analyzer test infra to share linker test attributes (tracking issue: Reuse linker tests in analyzer #2299)
- add basic dataflow analysis: [DAM analyzer] Add basic dataflow analysis #2360
- [DAM analyzer] support exceptional control flow #2415
- implement support for unknown values flowing into annotated locations (in first iteration should not warn) (IL2062-IL2066)
- ensure analyzer produces no extra warnings compared to linker (validate in test infra) (Analyzer test infra improvements #2292)
- [DAM analyzer] Report warnings for annotations on unsupported types #2409 (IL2097-IL2099, IL2106)
- generic argument validation ([DAM analyzer] Report DAM warnings for generics in all cases #2364) (IL2087-IL2091)
- [DAM analyzer] Warn about mismatching virtual annotations #2512 (IL2092-IL2095)
- Warn for reflection access to annotated members ([DAM analyzer] Port DAM binding logic to analyzer #2339)
I think these are the analyzers we are currently missing, together with the related warnings:
-
XmlAnalyzer: IL2001, IL2002, IL2007-IL2025, IL2029-IL2031, IL2038-IL2040, IL2044, IL2045, IL2048, IL2049, IL2051-IL2054- Decided not to implement this: [DAM analyzer] Add support for attribute warning suppressions #2579
- [ ] PreserveDependencyAlanyzer: IL2003, IL2004, IL2005, IL2033
- [ ] DynamicDependencyAttributeAnalyzer: IL2033, IL2034, IL2035, IL2036, IL2037,
- [ ] Misc.: IL2032, IL2057, IL2059
- Decided not to implement this: [DAM analyzer] Add support for attribute warning suppressions #2579
There are some that fit into analyzers we already have:
- [ ] IL2027: Multiple instances of a Requires* attribute (fits into Requires*Analyzer),
- @tlakollo noted: The only way we generate IL2027 is when we have RUC specified in an xml file and RUC specified in the member, so I think is a warning that I would put in the xml analyzer side.
- IL2041: DAM is not allowed on methods (fits into DAMAnalyzer),
- [ ] IL2042: Cannot determine backing field of a property (fits into DAMAnalyzer), - IL2043: DAM on property conflicts with the same attribute on its accessor method (fits into DAMAnalyzer),
- IL2050: Pinvoke method declares a parameter with COM marshalling (we must add an analyzer for this, although I don't see anything particularly difficult for supporting this warning),
- [ ] IL2056: Annotated a property which has its backing field already annotated (fits into DAMAnalyzer)
Finally, there are issues where we know the linker behavior needs to be fixed, and the analyzer work should be done in parallel:
- [ ] #2158
Compiler generated backing fields
- [ ] #2628
Arrays
- [ ] foreach
over arrays is complicated and analyzer doesn't see the array access -> the iterator variable is evaluated as TopValue which means it won't cause any warnings. Unlike linker which will see it as unannotated value which will cause warnings.