Skip to content

Conversation

@joperezr
Copy link
Member

@joperezr joperezr commented Aug 6, 2021

Fixes #52083

I tried running these tests locally now that DCS has been annotated to ensure that this annotation is fixing the issue:

private void SetKeyValuePairAdapterFlags(
[DynamicallyAccessedMembers(DataContractPreserveMemberTypes)]
Type type)

But I wasn't able to run the tests locally. Will use CI to validate that the test still passes.

@joperezr joperezr requested review from eerhardt and radical August 6, 2021 22:52
@ghost ghost added linkable-framework Issues associated with delivering a linker friendly framework area-Infrastructure-libraries labels Aug 6, 2021
@ghost
Copy link

ghost commented Aug 6, 2021

Tagging subscribers to 'linkable-framework': @eerhardt, @vitek-karas, @LakshanF, @sbomer, @joperezr
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #52083

I tried running these tests locally now that DCS has been annotated to ensure that this annotation is fixing the issue:

private void SetKeyValuePairAdapterFlags(
[DynamicallyAccessedMembers(DataContractPreserveMemberTypes)]
Type type)

But I wasn't able to run the tests locally. Will use CI to validate that the test still passes.

Author: joperezr
Assignees: -
Labels:

linkable-framework

Milestone: -

@eerhardt
Copy link
Member

eerhardt commented Aug 7, 2021

@joperezr - the tests appear to be failing now.

@joperezr
Copy link
Member Author

joperezr commented Aug 9, 2021

Yup, I noticed that, seems like we missed that specific annotation, my latest commit is adding it.

Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

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

As long as its green. This looks great.

Thanks @joperezr.

@joperezr
Copy link
Member Author

joperezr commented Aug 9, 2021

For some reason CI status is not updating in the PR, but the jobs did get queued: https://dev.azure.com/dnceng/public/_build/results?buildId=1284257&view=results.

I'll follow up with the results there and won't merge until it's green.

@ghost
Copy link

ghost commented Aug 10, 2021

Hello @joperezr!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

{
private static Type[]? s_serInfoCtorArgs;
private static readonly MethodInfo s_getKeyValuePairMethod = typeof(KeyValuePairAdapter<,>).GetMethod("GetKeyValuePair", Globals.ScanAllMembers)!;
private static readonly ConstructorInfo s_ctorGenericMethod = typeof(KeyValuePairAdapter<,>).GetConstructor(Globals.ScanAllMembers, new Type[] { typeof(KeyValuePair<,>).MakeGenericType(typeof(KeyValuePairAdapter<,>).GetGenericArguments()) })!;
Copy link
Member

Choose a reason for hiding this comment

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

@steveharter @GrabYourPitchforks @MichalStrehovsky - do any of you know an easier way to express this in reflection?

We are trying to find this constructor:

internal sealed class KeyValuePairAdapter<K, T> : IKeyValuePairAdapter
{
private K _kvpKey;
private T _kvpValue;
public KeyValuePairAdapter(KeyValuePair<K, T> kvPair)
{
_kvpKey = kvPair.Key;
_kvpValue = kvPair.Value;
}

Copy link
Member

Choose a reason for hiding this comment

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

I'm not immediately aware of any other way to write this that might play well with trimming. There are some tricks you can pull to save intermediate allocations, but since this is being placed into a readonly static, I don't know how much it would save in practice.

Copy link
Member

Choose a reason for hiding this comment

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

There's no better thing that I know of. There was a proposal somewhere to complement Type.MakeGenericMethodParameter(Int32) with another API that would work for type generic parameters, but that didn't materialize.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the verification.

@eerhardt eerhardt merged commit ffa6aae into dotnet:main Aug 11, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Sep 10, 2021
@joperezr joperezr deleted the RemoveDCSrdxml branch April 6, 2022 16:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-Infrastructure-libraries linkable-framework Issues associated with delivering a linker friendly framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Serializing a KeyValuePair in DCS doesn't work in a trimmed app

4 participants