-
Couldn't load subscription status.
- Fork 5.2k
Description
Description
Structs cannot be annotated as RequiresUnreferencedCode. I'm trying to make a library AOT compatible, and we have multiple structs that are not compatible with trimming. In most cases, we can just annotate all incompatible methods with RequiresUnreferencedCode. However, we have 2 cases where we have an overload for ToString which is incompatible with trimming. Since we cannot annotate the method or struct the warning will never be resolved.
Reproduction Steps
internal struct Sample
{
public override string ToString()
{
// Reflection-based serialization code not compatible with trimming
}
}Expected behavior
Ability to annotate structs as RequiresUnreferencedCode
Actual behavior
Adding RequiresUnreferencedCode attribute to a struct results in CS0592
Regression?
No response
Known Workarounds
For the ToString() overload case, none. For the general case, every method must be annotated.
Configuration
No response
Other information
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status