Skip to content

Commit

Permalink
fix: Don't regenerate source for ResourceDictionary runs
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Nov 28, 2021
1 parent f26804a commit adbd48d
Showing 1 changed file with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,35 @@ private string InnerGenerateFile()
{
_isTopLevelDictionary = true;

BuildResourceDictionaryBackingClass(writer, topLevelControl);
BuildTopLevelResourceDictionary(writer, topLevelControl);
if (_generationRunFileInfo.RunInfo.Index == 0)
{
var componentBuilder = new IndentedStringBuilder();

using (componentBuilder.Indent(writer.CurrentLevel))
{
BuildResourceDictionaryBackingClass(componentBuilder, topLevelControl);
BuildTopLevelResourceDictionary(componentBuilder, topLevelControl);

_generationRunFileInfo.SetAppliedTypes(_xamlAppliedTypes);
_generationRunFileInfo.ComponentCode = componentBuilder.ToString();
}

writer.AppendLineInvariant("{0}", componentBuilder.ToString());
}
else
{
if (_generationRunFileInfo.RunInfo.Manager.PreviousRuns.FirstOrDefault(r => r.GetRunFileInfo(_fileUniqueId)?.ComponentCode != null) is { } runFileInfo)
{
var generationRunFileInfo = runFileInfo.GetRunFileInfo(_fileUniqueId);

writer.AppendLineInvariant("{0}", generationRunFileInfo.ComponentCode);

foreach (var type in generationRunFileInfo.AppliedTypes)
{
_xamlAppliedTypes.Add(type.Key, type.Value);
}
}
}
}
else
{
Expand Down

0 comments on commit adbd48d

Please sign in to comment.