Skip to content

Commit

Permalink
feat: Add ability to enable hot-reload in release (for automated test…
Browse files Browse the repository at this point in the history
…ing purposes only)
  • Loading branch information
dr1rrb committed Nov 8, 2023
1 parent 4f73003 commit 11deccb
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ private void BuildInitializeComponent(IndentedStringBuilder writer, XamlObjectDe
}
else
{
if (_isDebug)
if (_isHotReloadEnabled)
{
// Insert hot reload support
writer.AppendLineIndented($"var __resourceLocator = new global::System.Uri(\"file:///{_fileDefinition.FilePath.Replace("\\", "/")}\");");
Expand Down Expand Up @@ -656,7 +656,7 @@ private void InitializeRemoteControlClient(IndentedStringBuilder writer)
// a nuget package.
writer.AppendLineIndented($"// Automatic remote control startup is disabled");
}
else if (_isDebug)
else if (_isHotReloadEnabled)
{
if (_metadataHelper.FindTypeByFullName("Uno.UI.RemoteControl.RemoteControlClient") != null)
{
Expand Down Expand Up @@ -1306,7 +1306,7 @@ IDisposable WrapSingleton()

private void WriteMetadataNewTypeAttribute(IIndentedStringBuilder writer)
{
if (_isDebug)
if (_isHotReloadEnabled)
{
writer.AppendLineIndented("[global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate]");
}
Expand Down Expand Up @@ -2778,10 +2778,10 @@ private void BuildResourceDictionary(IIndentedStringBuilder writer, XamlMemberDe
{
// Some resources (such as material colors) are initialized upon creation and so can't be tracked this way,
// as can't add the `SetElementProperty` call in a getter.
if (!isInInitializer && _isDebug)
if (!isInInitializer && _isHotReloadEnabled)
{
// Track source location of resources by key as they may be lazily initialized.
// Attach the values to the named string for similarity with other places where this informatin is stored.
// Attach the values to the named string for similarity with other places where this information is stored.
writer.AppendLineIndented($"global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(\"ResourceSourceLocations\", \"{key}\", \"file:///{_fileDefinition.FilePath.Replace("\\", "/")}#L{resource.LineNumber}:{resource.LinePosition}\"){closingPunctuation}");
}

Expand Down Expand Up @@ -3622,7 +3622,7 @@ private void BuildExtendedProperties(IIndentedStringBuilder outerwriter, XamlObj

if (IsFrameworkElement(objectDefinition.Type))
{
if (_isDebug)
if (_isHotReloadEnabled)
{
writer.AppendLineIndented(
$"global::Uno.UI.FrameworkElementHelper.SetBaseUri(" +
Expand All @@ -3639,7 +3639,7 @@ private void BuildExtendedProperties(IIndentedStringBuilder outerwriter, XamlObj
}
}

if (IsNotFrameworkElementButNeedsSourceLocation(objectDefinition) && _isDebug)
if (IsNotFrameworkElementButNeedsSourceLocation(objectDefinition) && _isHotReloadEnabled)
{
writer.AppendLineIndented($"global::Uno.UI.Helpers.MarkupHelper.SetElementProperty({closureName}, \"OriginalSourceLocation\", \"file:///{_fileDefinition.FilePath.Replace("\\", "/")}#L{objectDefinition.LineNumber}:{objectDefinition.LinePosition}\");");
}
Expand Down

0 comments on commit 11deccb

Please sign in to comment.