-
Notifications
You must be signed in to change notification settings - Fork 127
Create a schema for the LinkAttribute XML files #2500
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
Merged
Merged
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
8cc539b
Initial Schema work
jtschuster abac411
Finalize schema so all test xml is valid
jtschuster 5f3bdad
Add restrictions on some attributes and change uses of "nothing" to
jtschuster 79ae2c2
Initial Schema work
jtschuster ed7b9e9
Finalize schema so all test xml is valid
jtschuster f837645
Add restrictions on some attributes and change uses of "nothing" to
jtschuster 437f5cd
Remove schema reference in generated file expectation
jtschuster 3ebd1fb
merge with main
jtschuster b142870
Adds a more restrictive schema for LinkAttributes and updates paths for
jtschuster 8f200b1
Update docs to use 'none' instead of 'nothing'
jtschuster 6838288
remove schema from xml expectation file
jtschuster 6f5eb8f
remove namespace from xml schema location
jtschuster a1c1033
rename 'typechild' and allow multiple nested types
jtschuster c8e9f4b
remove <type> option from <linker> in LinkAttributes
jtschuster 4c0cb95
Remove ILLink.xsd
jtschuster f70da3d
Add more restraints on xml schema
jtschuster fe36b38
Rename "none" to "nothing" in CreateRuntimeRootILLinkDescriptorFile
jtschuster 9637260
change docs back to using preserve='nothing'
jtschuster 504e4a2
Merge branch 'main' into XmlSchema
jtschuster File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <xsd:schema attributeFormDefault="unqualified" | ||
| elementFormDefault="unqualified" | ||
| xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | ||
|
|
||
| <xsd:complexType name="membertype"> | ||
| <xsd:choice maxOccurs="unbounded" minOccurs="0"> | ||
| <xsd:element name="attribute" type="attribute" /> | ||
| </xsd:choice> | ||
| <xsd:attribute name="feature" /> | ||
| <xsd:attribute name="featurevalue" type="xsd:boolean" /> | ||
| <xsd:attribute name="featuredefault" type="xsd:boolean" /> | ||
| <xsd:attribute name="name" /> | ||
| <xsd:attribute name="signature" /> | ||
| </xsd:complexType> | ||
|
|
||
| <xsd:complexType name="method"> | ||
| <xsd:complexContent> | ||
| <xsd:extension base="membertype"> | ||
| <xsd:choice maxOccurs="unbounded" minOccurs="0"> | ||
| <xsd:choice maxOccurs="unbounded" minOccurs="0"> | ||
| <xsd:element name="parameter"> | ||
| <xsd:complexType> | ||
| <xsd:choice maxOccurs="unbounded" minOccurs="0"> | ||
| <xsd:element name="attribute" type="attribute" /> | ||
| </xsd:choice> | ||
| <xsd:attribute name="name" use="required" /> | ||
| </xsd:complexType> | ||
| </xsd:element> | ||
| </xsd:choice> | ||
| <xsd:choice maxOccurs="1" minOccurs="0"> | ||
| <xsd:element name="return"> | ||
| <xsd:complexType> | ||
| <xsd:choice maxOccurs="unbounded" minOccurs="0"> | ||
| <xsd:element name="attribute" type="attribute" /> | ||
| </xsd:choice> | ||
| </xsd:complexType> | ||
| </xsd:element> | ||
| </xsd:choice> | ||
| </xsd:choice> | ||
| </xsd:extension> | ||
| </xsd:complexContent> | ||
| </xsd:complexType> | ||
|
|
||
| <xsd:complexType name="argument" mixed="true"> | ||
| <xsd:choice minOccurs="0" maxOccurs="1"> | ||
| <xsd:element name="argument"> | ||
| <xsd:complexType> | ||
| <xsd:simpleContent> | ||
| <xsd:extension base="xsd:string"> | ||
| <xsd:attribute name="type" /> | ||
| </xsd:extension> | ||
| </xsd:simpleContent> | ||
| </xsd:complexType> | ||
| </xsd:element> | ||
| </xsd:choice> | ||
| <xsd:attribute name="type" /> | ||
| </xsd:complexType> | ||
|
|
||
| <xsd:complexType name="attribute"> | ||
| <xsd:choice maxOccurs="unbounded" minOccurs="0"> | ||
| <xsd:element name="argument" type="argument" /> | ||
| <xsd:element name="property"> | ||
| <xsd:complexType mixed="true"> | ||
| <xsd:attribute name="name" use="required" /> | ||
| </xsd:complexType> | ||
| </xsd:element> | ||
| </xsd:choice> | ||
| <xsd:attribute name="internal" /> | ||
| <xsd:attribute name="fullname" /> | ||
| <xsd:attribute name="assembly" /> | ||
| </xsd:complexType> | ||
|
|
||
| <xsd:complexType name="assembly"> | ||
| <xsd:choice maxOccurs="unbounded" minOccurs="0"> | ||
| <xsd:element name="attribute" type="attribute" /> | ||
| <xsd:element name="type" type="type" /> | ||
| </xsd:choice> | ||
| <xsd:attribute name="fullname" use="required" /> | ||
| <xsd:attribute name="feature" /> | ||
| <xsd:attribute name="featurevalue" type="xsd:boolean" /> | ||
| <xsd:attribute name="featuredefault" type="xsd:boolean" /> | ||
| </xsd:complexType> | ||
|
|
||
| <xsd:complexType name ="nestedtype"> | ||
| <xsd:choice minOccurs="0" maxOccurs="unbounded"> | ||
| <xsd:element name="event" type="membertype" /> | ||
| <xsd:element name="method" type="method" /> | ||
| <xsd:element name="field" type="membertype" /> | ||
| <xsd:element name="property" type="membertype" /> | ||
| <xsd:element name="attribute" type="attribute" /> | ||
| <xsd:element name="type" type="nestedtype" /> | ||
| </xsd:choice> | ||
| <xsd:attribute name="name" use="required"/> | ||
| <xsd:attribute name="feature" /> | ||
| <xsd:attribute name="featurevalue" type="xsd:boolean" /> | ||
| <xsd:attribute name="featuredefault" type="xsd:boolean" /> | ||
| </xsd:complexType> | ||
|
|
||
| <xsd:complexType name="type"> | ||
| <xsd:choice maxOccurs="unbounded" minOccurs="0"> | ||
| <xsd:element name="attribute" type="attribute" /> | ||
| <xsd:element name="event" type="membertype" /> | ||
| <xsd:element name="method" type="method" /> | ||
| <xsd:element name="field" type="membertype" /> | ||
| <xsd:element name="property" type="membertype" /> | ||
| <xsd:element name="type" type="nestedtype"/> | ||
| </xsd:choice> | ||
| <xsd:attribute name="feature" /> | ||
| <xsd:attribute name="featurevalue" type="xsd:boolean" /> | ||
| <xsd:attribute name="featuredefault" type="xsd:boolean" /> | ||
| <xsd:attribute name="fullname" use="required"/> | ||
| </xsd:complexType> | ||
|
|
||
| <xsd:element name="linker"> | ||
| <xsd:complexType> | ||
| <xsd:choice maxOccurs="unbounded" minOccurs="0"> | ||
| <xsd:element name="assembly" type="assembly" /> | ||
| <xsd:element name="type" type="type" /> | ||
| </xsd:choice> | ||
| </xsd:complexType> | ||
| </xsd:element> | ||
|
|
||
| </xsd:schema> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...o.Linker.Tests.Cases/Attributes/OnlyKeepUsed/UnusedAttributePreservedViaLinkXmlIsKept.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| <linker> | ||
| <linker> | ||
| <assembly fullname="test, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> | ||
| <type fullname="Mono.Linker.Tests.Cases.Attributes.OnlyKeepUsed.UnusedAttributePreservedViaLinkXmlIsKept/FooAttribute" preserve="all"> | ||
| </type> | ||
| </assembly> | ||
| </linker> | ||
| </linker> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 66 additions & 66 deletions
132
test/Mono.Linker.Tests.Cases/DataFlow/XmlAnnotations.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,66 +1,66 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <linker> | ||
| <assembly fullname="Test"> | ||
| <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute"> | ||
| <argument>ILLink</argument> | ||
| <argument>IL2067</argument> | ||
| <property name="Scope">member</property> | ||
| <property name="Target">M:Mono.Linker.Tests.Cases.DataFlow.XmlAnnotations.ReadFromInstanceField</property> | ||
| </attribute> | ||
| <type fullname="Mono.Linker.Tests.Cases.DataFlow.XmlAnnotations"> | ||
| <field name="_typeWithPublicParameterlessConstructor"> | ||
| <attribute fullname="System.DoesNotExistAttribute" assembly="Mono.Linker.Tests.Cases.Expectations"> | ||
| <argument>0</argument> | ||
| </attribute> | ||
| <attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute"> | ||
| <argument type="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes">PublicParameterlessConstructor</argument> | ||
| </attribute> | ||
| </field> | ||
| <method signature="System.Void TwoAnnotatedParameters(System.Type,System.Type)"> | ||
| <parameter name="type"> | ||
| <attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute"> | ||
| <argument type="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes">PublicParameterlessConstructor</argument> | ||
| </attribute> | ||
| </parameter> | ||
| <parameter name="type2"> | ||
| <attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute"> | ||
| <argument type="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes">PublicConstructors</argument> | ||
| </attribute> | ||
| </parameter> | ||
| </method> | ||
| <method signature="SpacesBetweenParametersWrongArgument (System.Type, System.Boolean)"> | ||
| <parameter name="type"> | ||
| <attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute"> | ||
| <argument type="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes">0</argument> | ||
| </attribute> | ||
| </parameter> | ||
| </method> | ||
| <method signature="GenericMethod<T>(T,System.Type)"> | ||
| <parameter name="type"> | ||
| <attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute"> | ||
| <argument type="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes">PublicParameterlessConstructor</argument> | ||
| </attribute> | ||
| </parameter> | ||
| </method> | ||
| <method name="ReturnConstructorsFailure"> | ||
| <return> | ||
| <attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute"> | ||
| <argument type="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes">PublicParameterlessConstructor</argument> | ||
| </attribute> | ||
| </return> | ||
| </method> | ||
| <property name="PropertyWithPublicParameterlessConstructor"> | ||
| <attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute"> | ||
| <argument type="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes">PublicParameterlessConstructor</argument> | ||
| </attribute> | ||
| </property> | ||
| <type name="NestedType"> | ||
| <field name="_typeWithPublicParameterlessConstructor"> | ||
| <attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute"> | ||
| <argument type="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes">PublicParameterlessConstructor</argument> | ||
| </attribute> | ||
| </field> | ||
| </type> | ||
| </type> | ||
| </assembly> | ||
| </linker> | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <linker xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../src/ILLink.Shared/ILLink.LinkAttributes.xsd"> | ||
| <assembly fullname="Test"> | ||
| <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute"> | ||
| <argument>ILLink</argument> | ||
| <argument>IL2067</argument> | ||
| <property name="Scope">member</property> | ||
| <property name="Target">M:Mono.Linker.Tests.Cases.DataFlow.XmlAnnotations.ReadFromInstanceField</property> | ||
| </attribute> | ||
| <type fullname="Mono.Linker.Tests.Cases.DataFlow.XmlAnnotations"> | ||
| <field name="_typeWithPublicParameterlessConstructor"> | ||
| <attribute fullname="System.DoesNotExistAttribute" assembly="Mono.Linker.Tests.Cases.Expectations"> | ||
| <argument>0</argument> | ||
| </attribute> | ||
| <attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute"> | ||
| <argument type="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes">PublicParameterlessConstructor</argument> | ||
| </attribute> | ||
| </field> | ||
| <method signature="System.Void TwoAnnotatedParameters(System.Type,System.Type)"> | ||
| <parameter name="type"> | ||
| <attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute"> | ||
| <argument type="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes">PublicParameterlessConstructor</argument> | ||
| </attribute> | ||
| </parameter> | ||
| <parameter name="type2"> | ||
| <attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute"> | ||
| <argument type="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes">PublicConstructors</argument> | ||
| </attribute> | ||
| </parameter> | ||
| </method> | ||
| <method signature="SpacesBetweenParametersWrongArgument (System.Type, System.Boolean)"> | ||
| <parameter name="type"> | ||
| <attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute"> | ||
| <argument type="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes">0</argument> | ||
| </attribute> | ||
| </parameter> | ||
| </method> | ||
| <method signature="GenericMethod<T>(T,System.Type)"> | ||
| <parameter name="type"> | ||
| <attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute"> | ||
| <argument type="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes">PublicParameterlessConstructor</argument> | ||
| </attribute> | ||
| </parameter> | ||
| </method> | ||
| <method name="ReturnConstructorsFailure"> | ||
| <return> | ||
| <attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute"> | ||
| <argument type="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes">PublicParameterlessConstructor</argument> | ||
| </attribute> | ||
| </return> | ||
| </method> | ||
| <property name="PropertyWithPublicParameterlessConstructor"> | ||
| <attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute"> | ||
| <argument type="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes">PublicParameterlessConstructor</argument> | ||
| </attribute> | ||
| </property> | ||
| <type name="NestedType"> | ||
| <field name="_typeWithPublicParameterlessConstructor"> | ||
| <attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute"> | ||
| <argument type="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes">PublicParameterlessConstructor</argument> | ||
| </attribute> | ||
| </field> | ||
| </type> | ||
| </type> | ||
| </assembly> | ||
| </linker> |
4 changes: 2 additions & 2 deletions
4
...ynamicDependencies/Dependencies/DynamicDependencyMethodInNonReferencedAssemblyLibrary.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| <linker> | ||
| <linker> | ||
| <assembly fullname="DynamicDependencyMethodInNonReferencedAssemblyLibrary, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> | ||
| <type fullname="Mono.Linker.Tests.Cases.DynamicDependencies.Dependencies.DynamicDependencyMethodInNonReferencedAssemblyLibrary" preserve="all" /> | ||
| </assembly> | ||
| </linker> | ||
| </linker> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
It's correct to have only one between the two, but just be aware that seems like runtime is using the 'nothing' notation since is what it was documented. See file.
The way I see it we either agreed on 'nothing' (and change only some linker tests) or agreed on 'none' and have to change other files outside the linker repo who may have used 'nothing' already
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 the guiding force should be what the linker actually recognizes - if it's both, then we should allow both in the schema as well.
Uh oh!
There was an error while loading. Please reload this page.
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.
Seems like the code is looking for Nothing and if an invalid value is passed then it defaults to Nothing
https://github.com/dotnet/linker/blob/main/src/linker/Linker.Steps/DescriptorMarker.cs#L137-L146