Skip to content

Conversation

@tlakollo
Copy link
Contributor

Reenable the AOT analyzer in System.Private.DataContractSerialization

Related to: #73337

@ghost
Copy link

ghost commented Aug 15, 2022

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

Copy link
Member

@MichalStrehovsky MichalStrehovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Member

@StephenMolloy StephenMolloy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a firm grasp on what RequiresDynamicCode is attempting to accomplish here. It obviously looks quite similar to and even mostly tags the same places as RequiresUnreferencedCode - so I assume its a similar idea but for IL/code we generate instead of code we reflect. It looks mostly like attributes going in, so I don't have a problem here so long as you guys are comfortable that you've got the right set of things attributed.

@danmoseley danmoseley closed this Aug 16, 2022
@danmoseley danmoseley reopened this Aug 16, 2022
@LakshanF
Copy link
Contributor

LakshanF commented Aug 16, 2022

I don't have a firm grasp on what RequiresDynamicCode is attempting to accomplish here. It obviously looks quite similar to and even mostly tags the same places as RequiresUnreferencedCode - so I assume its a similar idea but for IL/code we generate instead of code we reflect. It looks mostly like attributes going in, so I don't have a problem here so long as you guys are comfortable that you've got the right set of things attributed.

Yes, both attributes are related but RequiresUnreferencedCode (RUC) is used in trimming, where a static analysis of the full dependency closure by the compiler cannot determine correctness and warns the developer. Use of unbounded reflection is one such area where the compiler has problems. RequiresDynamicCode (RDC) is used to create NativeAOT applications and the attribute is used to warn the developer that runtime code generation is likely used by the application which is not supported in that deployment model. NativeAOT relies heavily on trimming and the RUC warnings as well and there are some overlaps (MakeGenericType for example, but for reasons described above)

@LakshanF
Copy link
Contributor

The tests shown as failing seems to be passing - for example, at least the test here, and the failure seems to be related to a cloud issue where upload test run result XML is failing.

@tlakollo
Copy link
Contributor Author

In the PR there are a couple of cases in which we suppress because the RuntimeFeature.IsDynamicCodeSupported flag is used, meaning the code has a way to execute the code when published using a tool that doesn't support DynamicCode. On the other hand RUC sometimes uses DynamicallyAccessedMembers to keep members around and making things safe which sometimes is not enough for DynamicCode purposes. The PR also annotates things that directly generate code dynamically (example) and that piece of code is completely safe for Trimming purposes

@tlakollo tlakollo merged commit e461b77 into dotnet:main Aug 16, 2022
@tlakollo tlakollo deleted the AnnotateSysPrivDataConSer branch August 16, 2022 19:09
@ghost ghost locked as resolved and limited conversation to collaborators Sep 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants