From e13b704852e9b1f0eb8d088ed7f84f1cb802fd3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Thu, 2 Feb 2023 15:06:47 +0900 Subject: [PATCH] Adjust workaround for event source resource stripping The used approach only worked in debug builds. `InlineableStringResource` is not one of the nodes that survives from scanning phase to compilation phase. Make the compiler think `GetResourceString` was reflected on instead. --- .../CustomAttributeBasedDependencyAlgorithm.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeBasedDependencyAlgorithm.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeBasedDependencyAlgorithm.cs index 92b2925a21b0ae..ef0035d12a7e2d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeBasedDependencyAlgorithm.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeBasedDependencyAlgorithm.cs @@ -147,7 +147,11 @@ private static void AddDependenciesDueToCustomAttributes(ref DependencyList depe && InlineableStringsResourceNode.IsInlineableStringsResource(module, resName + ".resources")) { dependencies ??= new DependencyList(); - dependencies.Add(factory.InlineableStringResource(module), "EventSource used resource"); + var accessorMethod = module.GetType( + InlineableStringsResourceNode.ResourceAccessorTypeNamespace, + InlineableStringsResourceNode.ResourceAccessorTypeName) + .GetMethod(InlineableStringsResourceNode.ResourceAccessorGetStringMethodName, null); + dependencies.Add(factory.ReflectedMethod(accessorMethod), "EventSource used resource"); } } }