Skip to content

Commit

Permalink
fix: Misc fixes for hot-reload testing
Browse files Browse the repository at this point in the history
  • Loading branch information
dr1rrb committed Nov 9, 2023
1 parent 11deccb commit 1a20f3d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
<CompilerVisibleProperty Include="BuildingInsideVisualStudio" />
<CompilerVisibleProperty Include="IsHotReloadHost" />
<CompilerVisibleProperty Include="UnoForceHotReloadCodeGen" />
<CompilerVisibleProperty Include="UnoForceIncludeProjectConfiguration" />
<CompilerVisibleProperty Include="UnoForceIncludeServerProcessorsConfiguration" />
<CompilerVisibleProperty Include="IsUnoHead" />
<CompilerVisibleProperty Include="UnoDisableHotRestartHelperGeneration" />
<CompilerVisibleProperty Include="RuntimeIdentifier" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public void Initialize(GeneratorInitializationContext context)

public void Execute(GeneratorExecutionContext context)
{
var isProjectConfigEnabled = IsMSBuildPropertyTrue("UnoDevServer_IncludeProjectConfiguration");
var isServerProcessorsConfigEnabled = IsMSBuildPropertyTrue("UnoDevServer_IncludeServerProcessorsConfiguration");
var isProjectConfigEnabled = IsMSBuildPropertyTrue("UnoForceIncludeProjectConfiguration");
var isServerProcessorsConfigEnabled = IsMSBuildPropertyTrue("UnoForceIncludeServerProcessorsConfiguration");

if (!DesignTimeHelper.IsDesignTime(context)
&& context.GetMSBuildPropertyValue("Configuration") == "Debug")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ public void Initialize(GeneratorInitializationContext context)

public void Execute(GeneratorExecutionContext context)
{
// No initialization required for this one
//if (!Process.GetCurrentProcess().ProcessName.Equals("omnisharp.exe", StringComparison.OrdinalIgnoreCase))
//var process = Process.GetCurrentProcess().ProcessName;
//if (process.IndexOf("VBCSCompiler", StringComparison.OrdinalIgnoreCase) is not -1
// || process.IndexOf("csc", StringComparison.OrdinalIgnoreCase) is not -1)
//{
// Debugger.Launch();
//}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,31 @@ static async void CreateProject(
}
}

var workspace = MSBuildWorkspace.Create(globalProperties);

workspace.WorkspaceFailed += (_sender, diag) =>
MSBuildWorkspace workspace = null!;
for (var i = 3; i > 0; i--)
{
// In some cases, load failures may be incorrectly reported such as this one:
// https://github.com/dotnet/roslyn/blob/fd45aeb5fbc97d09d4043cef9c9c5142f7638e5c/src/Workspaces/Core/MSBuild/MSBuild/MSBuildProjectLoader.Worker.cs#L245-L259
// Since the text may be localized we cannot rely on it, so we never fail the project loading for now.
reporter.Verbose($"MSBuildWorkspace {diag.Diagnostic}");
};
try
{
workspace = MSBuildWorkspace.Create(globalProperties);

await workspace.OpenProjectAsync(projectPath, cancellationToken: cancellationToken);
workspace.WorkspaceFailed += (_sender, diag) =>
{
// In some cases, load failures may be incorrectly reported such as this one:
// https://github.com/dotnet/roslyn/blob/fd45aeb5fbc97d09d4043cef9c9c5142f7638e5c/src/Workspaces/Core/MSBuild/MSBuild/MSBuildProjectLoader.Worker.cs#L245-L259
// Since the text may be localized we cannot rely on it, so we never fail the project loading for now.
reporter.Verbose($"MSBuildWorkspace {diag.Diagnostic}");
};

await workspace.OpenProjectAsync(projectPath, cancellationToken: cancellationToken);
break;
}
catch (InvalidOperationException) when (i > 1)
{
// When we load the work space right after the app was started, it happens that it "app build" is not yet completed, preventing us to open the project.
// We retry a few times to let the build complete.
await Task.Delay(5_000, cancellationToken);
}
}
var currentSolution = workspace.CurrentSolution;
var hotReloadService = new WatchHotReloadService(workspace.Services, metadataUpdateCapabilities);
await hotReloadService.StartSessionAsync(currentSolution, cancellationToken);
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UI.RemoteControl/RemoteControlClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ private void StartKeepAliveTimer()

private async Task InitializeServerProcessors()
{
if (AppType.Assembly.GetCustomAttributes(typeof(ServerProcessorsConfigurationAttribute), false) is ServerProcessorsConfigurationAttribute[] configs)
if (AppType.Assembly.GetCustomAttributes(typeof(ServerProcessorsConfigurationAttribute), false) is ServerProcessorsConfigurationAttribute[] { Length: > 0 } configs)
{
var config = configs.First();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
<UnoRuntimeEnabledPackage Include="Uno.WinUI.DevServer" PackageBasePath="$(MSBuildThisFileDirectory)" Condition="'$(MSBuildThisFile)'=='uno.winui.devserver.targets'" />
</ItemGroup>

<ItemGroup>
<CompilerVisibleProperty Include="UnoDevServer_IncludeProjectConfiguration" />
<CompilerVisibleProperty Include="UnoDevServer_IncludeServerProcessorsConfiguration" />
</ItemGroup>

<PropertyGroup>
<!-- Keep the inner path with '/' separator -->
<UnoRemoteControlProcessorsPath Condition="'$(SolutionFileName)'!='Uno.UI.sln'">$(MSBuildThisFileDirectory)../tools/rc/processors</UnoRemoteControlProcessorsPath>
Expand Down

0 comments on commit 1a20f3d

Please sign in to comment.