From 3efe6f45417a433f2bac57bbfdb4f81cf4003ee1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Strehovsk=C3=BD?= Date: Tue, 7 Feb 2023 08:54:55 +0900 Subject: [PATCH] Adjust workaround for event source resource stripping (#81528) 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. --- .../DependencyAnalysis/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 92b2925..ef0035d 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 @@ namespace ILCompiler.DependencyAnalysis && 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"); } } } -- 2.7.4