-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Closed
Closed
Copy link
Labels
area-Tools-ILLink.NET linker development as well as trimming analyzers.NET linker development as well as trimming analyzersquestionAnswer questions and provide assistance, not an issue with source code or documentation.Answer questions and provide assistance, not an issue with source code or documentation.
Description
Consider the following application:
using System.Diagnostics.CodeAnalysis;
Test(typeof(MyPoco));
static void Test(Type type) => Activator.CreateInstance(type);
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
class MyPoco;
I would have expected that this would instruct the linker to preserve the default constructor for MyPoco
, however when I publish to AOT I get the error:
Unhandled exception. System.MissingMethodException: No parameterless constructor defined for type 'MyPoco'.
at System.ActivatorImplementation.CreateInstance(Type, Boolean) + 0x198
at Program.<Main>$(String[] args) + 0x2c
Metadata
Metadata
Assignees
Labels
area-Tools-ILLink.NET linker development as well as trimming analyzers.NET linker development as well as trimming analyzersquestionAnswer questions and provide assistance, not an issue with source code or documentation.Answer questions and provide assistance, not an issue with source code or documentation.
Type
Projects
Status
No status