Get the normal event accessors generated (#89441)
authorMike Voorhees <mrvoorhe@users.noreply.github.com>
Tue, 25 Jul 2023 17:50:53 +0000 (13:50 -0400)
committerGitHub <noreply@github.com>
Tue, 25 Jul 2023 17:50:53 +0000 (10:50 -0700)
commite7984e4f9ab408be297d2e2d0df921097f18112a
tree5b76e198af704e90cad5155408da11da92401992
parent821d6cc86e1bcd22f4d35ce470645b5bbe34b923
Get the normal event accessors generated (#89441)

Because System.Threading.dll was not referenced, this led to Roslyn generating the Delegate.Combine based accessor which does not have any locals.  https://github.com/dotnet/roslyn/blob/520e2f10078ab0e5f85c78fdd95d786d78b9676a/src/Compilers/CSharp/Portable/Compiler/MethodBodySynthesizer.cs#L323-L520

In our UnityLinker test framework we have 2 cases currently.  Mono, which will reference mscorlib.dll, and Roslyn will find `System.Threading.Interlocked.CompareExchange` and use the normal approach.

And currently I have our coreclr tests referencing System.Threading.dll for no great reason.  This is how I stumbled on this.

While this change isn't strictly necessary, I think it's better to have coverage on the `System.Threading.Interlocked.CompareExchange` approach because that's what would normally be generated.  It's also the more complex case for the linker to handle since it has to clear the locals.
src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/MemberTypes.cs
src/tools/illink/test/Mono.Linker.Tests.Cases/DynamicDependencies/DynamicDependencyMemberTypes.cs
src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/EventUsedViaReflection.cs
src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/RuntimeReflectionExtensionsCalls.cs
src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TestCaseCompilationMetadataProvider.cs