To repro:
Update repro program - add a const int SomeField = 123; somewhere. You'll need to make sure the field is rooted by following similar steps as in #5. Notice that after trimming, the default value is missing.
To fix:
Introduce a new node to represent entry in the Constant table.
In the implementation of the constant node, don't worry about the contents of the blob - just copy the byte[] over as we do for e.g. the field's signatureBlob.
In the field definition dependency node, if fieldDef.Attributes & System.Reflection.FieldAttributes.Literal, this is a literal (const in C#) field.
If this is a literal field, the field also depends on the node representing the Constant value. fieldDef.GetDefaultValue will give you the token of the constant value. Add a dependency on the new node.
To repro: Update repro program - add a
const int SomeField = 123;
somewhere. You'll need to make sure the field is rooted by following similar steps as in #5. Notice that after trimming, the default value is missing.To fix:
signatureBlob
.fieldDef.Attributes & System.Reflection.FieldAttributes.Literal
, this is a literal (const
in C#) field.fieldDef.GetDefaultValue
will give you the token of the constant value. Add a dependency on the new node.