-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restrict embedded XML #1675
Restrict embedded XML #1675
Conversation
Embedded attributes and substitutions may only modify the containing assembly.
In the test infrastructure.
I think we will need a an exceptions to the rule:
|
Actually it's not entirely clear to me why we need this. Is it to support removing an attribute whose definition is compiled into multiple assemblies? Could we just recommend embedding a duplicate attribute XML into such assemblies? |
This is needed for compiler inserted attributes. It's not really viable to insert the same XML into all assemblies produced by C# compiler. We could try to convert that section of XML into XML file argument descriptor as specializing this case will be a pain, we could be in the situation where SPC is not known till later and to ensure we don't have a hole somewhere which would mark attributes before they we read SPC xml. |
```XML | ||
<!-- IL2101: Embedded XML in assembly 'ContainingAssembly' may not modify other assembly 'OtherAssembly' --> | ||
<linker> | ||
<assembly fullname="OtherAssembly"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fullname is now redundant for embedded XML format, should we just remove/ignore it instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's good to warn when it's used incorrectly in the embedded XML, otherwise people might try to embed existing XML and wonder why it doesn't work.
Since the assembly is redundant for embedded XML, I made it so that you can leave out the assembly
entirely:
<linker>
<type fullname="..." />
</linker>
I kept support for <assembly fullname="ThisAssembly>"
since I think it will be easier to reuse existing XML this way, but I could force the embedded XML not to name the assembly if you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I think this is more wording issue than anything else. Your "It is invalid to use these embedded XML files to modify other assemblies." seems to suggest this will be error where in reality this is a warning. Maybe we could go with even simple mode and merge 2100 and 2101 under the simple warning that warns that fullname
value is ignored for embedded XML files (just suggestion)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reworded the warnings - hopefully this is better. I'd like to keep them separate because the wildcard can produce a warning for non-embedded XML too.
Does the compiler inject attribute type definitions into assemblies, or only attribute instances? This approach still allows specifying RemoveAttributeInstances in embedded XML for the assembly that defines the attribute type, and it will remove instances of the attribute everywhere.
The lazy loading change will ensure that attribute XML from the resolved attribute type's assembly is processed before we mark attribute instances. |
Yes - Roslyn adds attribute definitions into each assembly it needs it in. That's the problem - that's the reason we have the |
I see, thank you. So it sounds like there are a few options:
|
- Allow '*' in corelib embedded attribute XML - Reword warning messages - Avoid calling virtual method from ctor
Macking the core library causes problems for PEVerify: - Removed reference to corelib creates invalid typerefs - System types like Object aren't found
Avoids modifying other assemblies in embedded XML, in response to dotnet/linker#1675. This will unblock dependency flow in dotnet#14925.
Avoids modifying other assemblies in embedded XML, in response to dotnet/linker#1675. This will unblock dependency flow in dotnet#14925.
* Fix illink test Avoids modifying other assemblies in embedded XML, in response to dotnet/linker#1675. This will unblock dependency flow in #14925. * Avoid deconstructing KeyValuePair Not implemented in .NET Framework
* Restrict embedded XML Embedded attributes and substitutions may only modify the containing assembly. * Allow specifying resource name in referenced assembly In the test infrastructure. * Fix formatting * PR feedback - Allow '*' in corelib embedded attribute XML - Reword warning messages - Avoid calling virtual method from ctor * Fix test on mono Macking the core library causes problems for PEVerify: - Removed reference to corelib creates invalid typerefs - System types like Object aren't found * PR feedback * PR feedback
* Restrict embedded XML Embedded attributes and substitutions may only modify the containing assembly. * Allow specifying resource name in referenced assembly In the test infrastructure. * Fix formatting * PR feedback - Allow '*' in corelib embedded attribute XML - Reword warning messages - Avoid calling virtual method from ctor * Fix test on mono Macking the core library causes problems for PEVerify: - Removed reference to corelib creates invalid typerefs - System types like Object aren't found * PR feedback * PR feedback Commit migrated from dotnet/linker@9c88abd
This restricts the embedded XML to prevent modification of assemblies other than the containing assembly. Specifically:
assemby
tag, instead specifying types of the containing assembly directly under<linker>
(I'm separating the XML changes out from the rest of #1666.)