Implements correct handling of RequiresAssemblyFiles on properties and events (#83195)
authorVitek Karas <10670590+vitek-karas@users.noreply.github.com>
Fri, 10 Mar 2023 09:50:30 +0000 (01:50 -0800)
committerGitHub <noreply@github.com>
Fri, 10 Mar 2023 09:50:30 +0000 (01:50 -0800)
commit0d7578ce25367d009555e9d15895a9a0e787d9ce
treec3951a16cb3f7205e1e7269f03a21750c522bd58
parent1d5c424487c476831d9f98b1ca78b4fda6d18066
Implements correct handling of RequiresAssemblyFiles on properties and events (#83195)

The `RequiresAssemblyFiles` attribute can be present on property or event (in which case it applies to all accessors). The analyzer already handles this case, but the NativeAOT compiler didn't. This change implements the correct behavior in NativeAOT as well.

The implementation actually handles all Requires attributes this way now, but the other two are not allowed on properties or event (yet).

Had to add an optimization to the `GetPropertyForAccessor`/`GetEventForAccessor` as these are now called very frequently and they can be really slow.

Implements a new behavior with regard to IL3003 as described in the comment in the code as well as: #83235

Fixes https://github.com/dotnet/runtime/issues/71985.
src/coreclr/tools/Common/Compiler/PseudoDescExtensions.cs
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/DiagnosticUtilities.cs
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedMetadataManager.cs
src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/BasicRequires.cs
src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresAttributeMismatch.cs