Rd.xml in CoreRT

<Directives xmlns=”http://schemas.microsoft.com/netfx/2013/01/metadata">
<Application>
<Assembly Name=”mscorlib” />
</Application>
</Directives>

Assembly directive

  • Module metadata only,
  • All types,
  • Module metadata and selected types.
<Directives xmlns=http://schemas.microsoft.com/netfx/2013/01/metadata">
<Application>
<Assembly Name="mscorlib" />
</Application>
</Directives>
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
<Application>
<Assembly Name="mscorlib" Dynamic="Required All" />
</Application>
</Directives>
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
<Application>
<Assembly Name="MonoGame.Framework">
<Type Name="Microsoft.Xna.Framework.Content.ListReader`1[[System.Char,mscorlib]]" Dynamic="Required All" />
</Assembly>
</Application>
</Directives>

Types directives.

  • Take all type methods,
  • Select which methods should be rooted.
<Type Name="Microsoft.Xna.Framework.Content.ListReader`1[[System.Char,mscorlib]]" Dynamic="Required All" />
// just int
System.Int32
// string[]
System.String[]
// string[][]
System.String[][]
// string[,]
System.String[,]
// List<int>
System.Collections.Generic.List`1[[System.Int32,System.Private.CoreLib]]
// Dictionary<int, string>.KeyCollection
System.Collections.Generic.Dictionary`2[[System.Int32,System.Private.CoreLib],[System.String,System.Private.CoreLib]]+KeyCollection
// List<T>
System.Collections.Generic.List`1
<Type Name="System.Collections.Generic.Dictionary`2[[System.Int32,System.Private.CoreLib],[System.String,System.Private.CoreLib]]">
<Method Name="EnsureCapacity">
<Parameter Name="System.Int32, System.Private.CoreLib" />
</Method>
</Type>
<Type Name="System.Array">
<Method Name="Empty">
<GenericArgument Name="System.Int32, System.Private.CoreLib" />
</Method>
</Type>

Excercises

public class WeatherForecast
{
public DateTimeOffset Date { get; set; }
public int TemperatureCelsius { get; set; }
public string Summary { get; set; }
}
static void SerializeNonNullableProperties()
{
var weatherForecast = new WeatherForecast()
{
TemperatureCelsius = 15,
Summary = "Hot",
Date = DateTimeOffset.UtcNow,
};
string jsonString;
jsonString = JsonSerializer.Serialize(weatherForecast);
Console.WriteLine(jsonString);
}
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
<Application>
<Assembly Name="System.Text.Json">
<!-- for serialization of WeatherForecast -->
<Type Name="System.Text.Json.JsonPropertyInfoNotNullable`4[[CoreRtRdXmlExamples.WeatherForecast,CoreRtRdXmlExamples],[System.DateTimeOffset,System.Private.CoreLib],[System.DateTimeOffset,System.Private.CoreLib],[System.DateTimeOffset,System.Private.CoreLib]]" Dynamic="Required All" />
<Type Name="System.Text.Json.JsonPropertyInfoNotNullable`4[[CoreRtRdXmlExamples.WeatherForecast,CoreRtRdXmlExamples],[System.Int32,System.Private.CoreLib],[System.Int32,System.Private.CoreLib],[System.Int32,System.Private.CoreLib]]" Dynamic="Required All" />
</Assembly>
</Application>
</Directives>
Unhandled Exception: System.Reflection.MissingMetadataException: 'System.Text.Json.JsonPropertyInfoNotNullable<CoreRtRdXmlExamples.WeatherForecast,System.DateTimeOffset,System.DateTimeOffset,System.DateTimeOffset>' is missing metadata. For more information, please visit http://go.microsoft.com/fwlink/?LinkID=392859
<Type Name="System.Text.Json.JsonPropertyInfoNotNullable`4[[CoreRtRdXmlExamples.WeatherForecast,CoreRtRdXmlExamples],[System.DateTimeOffset,System.Private.CoreLib],[System.DateTimeOffset,System.Private.CoreLib],[System.DateTimeOffset,System.Private.CoreLib]]" Dynamic="Required All" />

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store