in ILRepack/Steps/ResourceProcessing/BamlGenerator.cs [87:126]
public void AddMergedDictionaries(
BamlDocument document, IEnumerable<string> importedFiles)
{
BamlRecord mergedDictionaryRecord = document.FirstOrDefault(IsMergedDictionaryAttribute);
if (mergedDictionaryRecord != null)
{
HandleMergedDictionary(document, importedFiles, mergedDictionaryRecord as AttributeInfoRecord);
}
else
{
if (document.FindIndex(IsResourceDictionaryElementStart) == -1)
{
//TODO: throw? (Let's hope people read the logs ^_^)
_logger.Error(string.Format(
"Existing 'Themes/generic.xaml' in {0} is *not* a ResourceDictionary. " +
"This will prevent proper WPF application merging.", _mainAssemblyName));
return;
}
int attributeInfosStartIndex = document.FindLastIndex(r => r is AssemblyInfoRecord);
if (attributeInfosStartIndex == -1)
{
_logger.Error("Invalid BAML detected. (no AssemblyInfoRecord)");
return;
}
var extraAttributes = GetMergedDictionariesAttributes().ToList();
AdjustAttributeIds(document, (ushort)extraAttributes.Count);
document.InsertRange(attributeInfosStartIndex + 1, extraAttributes);
int defferableRecordIndex = document.FindIndex(r => r is DeferableContentStartRecord);
if (attributeInfosStartIndex == -1)
{
_logger.Error("Invalid BAML detected. (No DeferableContentStartRecord)");
}
document.InsertRange(defferableRecordIndex, GetDictionariesList(importedFiles));
}
}