Conversation
|
Can we add a test somewhere to verify the warning experience, i.e. a trimmed app test that references a type that fails to deserialize? |
|
Testing trimming is difficult because you need to build a new app, publish it, then run it. However, I can add a test that verifies a type that can't be found throws the friendly error message. |
| else if (type == typeof(CngCbcAuthenticatedEncryptorDescriptorDeserializer)) | ||
| else if (type == typeof(CngCbcAuthenticatedEncryptorDescriptorDeserializer) && RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||
| { | ||
| return _activator.CreateInstance<CngCbcAuthenticatedEncryptorDescriptorDeserializer>(descriptorDeserializerTypeName); | ||
| } | ||
| else if (type == typeof(CngGcmAuthenticatedEncryptorDescriptorDeserializer)) | ||
| else if (type == typeof(CngGcmAuthenticatedEncryptorDescriptorDeserializer) && RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) |
There was a problem hiding this comment.
Is this netstandard 2.0? These APIs aren't trim friendly.
There was a problem hiding this comment.
Yes, it targets netstandard2.0.
What specifically isn't trim-friendly? No warnings are coming from the linker.
There was a problem hiding this comment.
My bad, I meant that RuntimeInformation.IsOSPlatform(OSPlatform.Windows) isn't recognized by the trimmer. Those branches will exist when this is trimmed and we're targeting linux.
There was a problem hiding this comment.
Got it. I added IsOSPlatform to suppress errors from build, not for trimming.
A couple of types won't matter. I don't think introducing a net6-window target is worth it.
|
This might still fail in weird ways. Even if the external type is loaded, it would be missing things that it depends on that weren't preserved. We're going to let that fail randomly in that case right? (TBH, nothing can be done about that...) |
|
Agreed. Nice thing is these changes are internal and conservative. If people run into problems we can't revisit them in the future. |
|
Hey @JamesNK! 👋🏻 I'm pretty sure these changes broke cross-version forwarding when using The code in Since the old version of the decryptor cannot be found. I'd send a PR to fix this, but I'm not 100% sure what the intention of the change in this PR was and how to work around it. |
|
Hi Create an issue with what you just said. PR welcome. @amcasey is working on data protection recently. Include both of us on the issue and PR. |
Fixes #41411
Fixes #24705
Result of the discussion with Levi and Hao about how DataProtection is used:
Since custom type names are rare, this PR removes build warnings. It's possible to get runtime errors, but this change tries to make them useful.
This PR: