From: Michal Strehovský Date: Wed, 1 Feb 2023 21:28:43 +0000 (+0900) Subject: Do not strip resource messages if EventSource would use it (#81466) X-Git-Tag: accepted/tizen/unified/riscv/20231226.055536~4285 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eadf678c8e9749938f6c11830288bc061c0b8030;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Do not strip resource messages if EventSource would use it (#81466) Works around #81459. --- 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 77b41a5..92b2925 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeBasedDependencyAlgorithm.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeBasedDependencyAlgorithm.cs @@ -137,6 +137,21 @@ namespace ILCompiler.DependencyAnalysis dependencies.AddRange(caDependencies); dependencies.Add(factory.CustomAttributeMetadata(new ReflectableCustomAttribute(module, caHandle)), "Attribute metadata"); } + + // Works around https://github.com/dotnet/runtime/issues/81459 + if (constructor.OwningType is MetadataType { Name: "EventSourceAttribute" } eventSourceAttributeType) + { + foreach (var namedArg in decodedValue.NamedArguments) + { + if (namedArg.Name == "LocalizationResources" && namedArg.Value is string resName + && InlineableStringsResourceNode.IsInlineableStringsResource(module, resName + ".resources")) + { + dependencies ??= new DependencyList(); + dependencies.Add(factory.InlineableStringResource(module), "EventSource used resource"); + } + } + } + // End of workaround for https://github.com/dotnet/runtime/issues/81459 } catch (TypeSystemException) {