Skip to content

Commit

Permalink
fix(remotecontrol): Fixed annoying "Uri format" parsing error while l…
Browse files Browse the repository at this point in the history
…aunching apps with RemoteControl activated.
  • Loading branch information
carldebilly authored and dr1rrb committed Jun 1, 2021
1 parent ec1c39f commit cf88024
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.CodeAnalysis;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
Expand Down Expand Up @@ -110,11 +111,24 @@ private static void BuildEndPointAttribute(GeneratorExecutionContext context, In
{
var addresses = NetworkInterface.GetAllNetworkInterfaces()
.SelectMany(x => x.GetIPProperties().UnicastAddresses)
.Where(x => !IPAddress.IsLoopback(x.Address));
.Where(x => !IPAddress.IsLoopback(x.Address))
.Where(x => x.DuplicateAddressDetectionState == DuplicateAddressDetectionState.Preferred);

foreach (var addressInfo in addresses)
{
sb.AppendLineInvariant($"[assembly: global::Uno.UI.RemoteControl.ServerEndpointAttribute(\"{addressInfo.Address}\", {unoRemoteControlPort})]");
var address = addressInfo.Address;

string addressStr;
if(address.AddressFamily == AddressFamily.InterNetworkV6)
{
address.ScopeId = 0; // remove annoying "%xx" on IPv6 addresses
addressStr = $"[{address}]";
}
else
{
addressStr = address.ToString();
}
sb.AppendLineInvariant($"[assembly: global::Uno.UI.RemoteControl.ServerEndpointAttribute(\"{addressStr}\", {unoRemoteControlPort})]");
}
}
else
Expand Down

0 comments on commit cf88024

Please sign in to comment.