Skip to content

Embedded XML not processed for assemblies referenced only via PreserveDependency attribute #843

@vitek-karas

Description

@vitek-karas

PreserveDependency attributes are processed in PreserveDependencyLookupStep which runs after BlacklistStep. As such any assemblies referenced only via PreserveDependency attributes are not processed by the BlacklistStep and thus any embedded XML in those assemblies is not processed.

This was obviously an intentional "omission" as per comment on the relevant test: https://github.com/mono/linker/blob/ab427fd29fd1ecfac81b878abd1043a0ae61f0de/test/Mono.Linker.Tests.Cases/PreserveDependencies/PreserveDependencyMethodInNonReferencedAssemblyWithEmbeddedXml.cs#L8

Unfortunately fixing this is not simple. A related desired behavior is that if the PreserveDependency attribute is not actually used (that is the item it's on is trimmed), the embedded XML of its referenced assembly should not be processed (or rather applied). This is shown in test https://github.com/mono/linker/blob/ab427fd29fd1ecfac81b878abd1043a0ae61f0de/test/Mono.Linker.Tests.Cases/PreserveDependencies/PreserveDependencyOnUnusedMethodInNonReferencedAssemblyWithEmbeddedXml.cs#L8

Real fix would have to be able to either add assemblies to the closure later on (during MarkStep), or delay application of embedded XML to that point (during MarkStep). Both approaches are rather tricky to handle correctly as they break assumptions made by existing code in the linker.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions