bflattened / bflat

C# as you know it but with Go-inspired tooling (small, selfcontained, and native executables)
GNU Affero General Public License v3.0
3.56k stars 102 forks source link

The runtime directive ( .rd.xml) solution seems not working for Json.Net with bflat? #93

Closed xiaoyuvax closed 1 year ago

xiaoyuvax commented 1 year ago

don't know if bflat processes the embeded .rd.xml, as for my own experiment, it doesn't make any difference by adding *.rd.xml. and this dotnet issue is relevant: https://github.com/dotnet/runtimelab/issues/635

contents of affected .rd.xml file:

<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
    <Application>
        <Assembly Name="MyConfig" Serialize="Required Public"
                  Browse="All" Activate="PublicAndInternal"
                  Dynamic="Public"  />
    </Application>  
</Directives>

Exception Message: Unable to find a constructor to use for type MyConfig.Config. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute. Path 'Note', line 2, position 9.

MichalStrehovsky commented 1 year ago

Bflat doesn't support rd.xml, embedded or not and there's no plans to add it - #19.

It will respect an embedded root descriptors: https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options?pivots=dotnet-7-0#root-descriptors

It needs to be an embedded resource with name ILLink.Descriptors.xml.