Open yueyinqiu opened 1 month ago
@yueyinqiu thanks for contacting us.
I'm not sure what the right thing to do here is. From what I know, I believe that both are required. The challenge with DynamicallyAccessedMembers
is that it only "preserves" the first level, and not the entire "object graph".
You could say that DynamicallyAccessedMembers
is then not enough to tell the linker what it needs to preserve, and it also only affects the return value itself, and not any other parameter that gets passed in.
RequiresUnreferencedCode
provides a broader warning that when calling that API, you might need to ensure other types are preserved.
Based on that, I think the right thing to do would be to annotate the other APIs with [RequiresUnreferencedCode]
too. I'm not sure why it wasn't done.
Hello, I have recently found that
IJSInProcessObjectReference.Invoke<TValue>
is attributed under[RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed.")]
here.However we have add
[DynamicallyAccessedMembers(JsonSerialized)]
for itsTValue
, so it seems unnecessary to useRequiresUnreferencedCode
?And we didn't do that in
IJSObjectReference
, so I believe it should be a mistake.