From b273167e5507f1050c29c7a71f4cc8b185f18288 Mon Sep 17 00:00:00 2001 From: Julien Lebosquain Date: Sat, 28 Feb 2026 08:13:16 +0000 Subject: [PATCH] Make RemoteServer/RemoteWidget internal (#20767) * Make RemoteServer/RemoteWidget internal * Remote Previewer and RemoteDemo projects * Update API suppressions --- Avalonia.sln | 14 ---- api/Avalonia.nupkg.xml | 28 ++++++- samples/Previewer/App.xaml | 5 -- samples/Previewer/App.xaml.cs | 22 ----- samples/Previewer/Center.cs | 19 ----- samples/Previewer/MainWindow.xaml | 12 --- samples/Previewer/MainWindow.xaml.cs | 86 -------------------- samples/Previewer/Previewer.csproj | 22 ----- samples/Previewer/Program.cs | 14 ---- samples/RemoteDemo/Program.cs | 53 ------------ samples/RemoteDemo/RemoteDemo.csproj | 12 --- src/Avalonia.Controls/Remote/RemoteServer.cs | 3 +- src/Avalonia.Controls/Remote/RemoteWidget.cs | 2 +- 13 files changed, 28 insertions(+), 264 deletions(-) delete mode 100644 samples/Previewer/App.xaml delete mode 100644 samples/Previewer/App.xaml.cs delete mode 100644 samples/Previewer/Center.cs delete mode 100644 samples/Previewer/MainWindow.xaml delete mode 100644 samples/Previewer/MainWindow.xaml.cs delete mode 100644 samples/Previewer/Previewer.csproj delete mode 100644 samples/Previewer/Program.cs delete mode 100644 samples/RemoteDemo/Program.cs delete mode 100644 samples/RemoteDemo/RemoteDemo.csproj diff --git a/Avalonia.sln b/Avalonia.sln index b4b89de2a3..4caeb66cf8 100644 --- a/Avalonia.sln +++ b/Avalonia.sln @@ -118,14 +118,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Skia.RenderTests", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Remote.Protocol", "src\Avalonia.Remote.Protocol\Avalonia.Remote.Protocol.csproj", "{D78A720C-C0C6-478B-8564-F167F9BDD01B}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RemoteDemo", "samples\RemoteDemo\RemoteDemo.csproj", "{E2999E4A-9086-401F-898C-AEB0AD38E676}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{4ED8B739-6F4E-4CD4-B993-545E6B5CE637}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Designer.HostApp", "src\tools\Avalonia.Designer.HostApp\Avalonia.Designer.HostApp.csproj", "{050CC912-FF49-4A8B-B534-9544017446DD}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Previewer", "samples\Previewer\Previewer.csproj", "{F40FC0A2-1BC3-401C-BFC1-928EC4D4A9CE}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Skia.UnitTests", "tests\Avalonia.Skia.UnitTests\Avalonia.Skia.UnitTests.csproj", "{E1240B49-7B4B-4371-A00E-068778C5CF0B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.OpenGL", "src\Avalonia.OpenGL\Avalonia.OpenGL.csproj", "{7CCAEFC4-135D-401D-BDDD-896B9B7D3569}" @@ -407,18 +403,10 @@ Global {D78A720C-C0C6-478B-8564-F167F9BDD01B}.Debug|Any CPU.Build.0 = Debug|Any CPU {D78A720C-C0C6-478B-8564-F167F9BDD01B}.Release|Any CPU.ActiveCfg = Release|Any CPU {D78A720C-C0C6-478B-8564-F167F9BDD01B}.Release|Any CPU.Build.0 = Release|Any CPU - {E2999E4A-9086-401F-898C-AEB0AD38E676}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E2999E4A-9086-401F-898C-AEB0AD38E676}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E2999E4A-9086-401F-898C-AEB0AD38E676}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E2999E4A-9086-401F-898C-AEB0AD38E676}.Release|Any CPU.Build.0 = Release|Any CPU {050CC912-FF49-4A8B-B534-9544017446DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {050CC912-FF49-4A8B-B534-9544017446DD}.Debug|Any CPU.Build.0 = Debug|Any CPU {050CC912-FF49-4A8B-B534-9544017446DD}.Release|Any CPU.ActiveCfg = Release|Any CPU {050CC912-FF49-4A8B-B534-9544017446DD}.Release|Any CPU.Build.0 = Release|Any CPU - {F40FC0A2-1BC3-401C-BFC1-928EC4D4A9CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F40FC0A2-1BC3-401C-BFC1-928EC4D4A9CE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F40FC0A2-1BC3-401C-BFC1-928EC4D4A9CE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F40FC0A2-1BC3-401C-BFC1-928EC4D4A9CE}.Release|Any CPU.Build.0 = Release|Any CPU {E1240B49-7B4B-4371-A00E-068778C5CF0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E1240B49-7B4B-4371-A00E-068778C5CF0B}.Debug|Any CPU.Build.0 = Debug|Any CPU {E1240B49-7B4B-4371-A00E-068778C5CF0B}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -710,9 +698,7 @@ Global {854568D5-13D1-4B4F-B50D-534DC7EFD3C9} = {86C53C40-57AA-45B8-AD42-FAE0EFDF0F2B} {CBC4FF2F-92D4-420B-BE21-9FE0B930B04E} = {B39A8919-9F95-48FE-AD7B-76E08B509888} {E1582370-37B3-403C-917F-8209551B1634} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B} - {E2999E4A-9086-401F-898C-AEB0AD38E676} = {9B9E3891-2366-4253-A952-D08BCEB71098} {050CC912-FF49-4A8B-B534-9544017446DD} = {4ED8B739-6F4E-4CD4-B993-545E6B5CE637} - {F40FC0A2-1BC3-401C-BFC1-928EC4D4A9CE} = {9B9E3891-2366-4253-A952-D08BCEB71098} {E1240B49-7B4B-4371-A00E-068778C5CF0B} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B} {D49233F8-F29C-47DD-9975-C4C9E4502720} = {E870DCD7-F46A-498D-83FC-D0FD13E0A11C} {3C471044-3640-45E3-B1B2-16D2FF8399EE} = {E870DCD7-F46A-498D-83FC-D0FD13E0A11C} diff --git a/api/Avalonia.nupkg.xml b/api/Avalonia.nupkg.xml index aee61ea399..bf32b82d3e 100644 --- a/api/Avalonia.nupkg.xml +++ b/api/Avalonia.nupkg.xml @@ -1,4 +1,4 @@ - + @@ -331,6 +331,18 @@ baseline/Avalonia/lib/net10.0/Avalonia.Controls.dll current/Avalonia/lib/net10.0/Avalonia.Controls.dll + + CP0001 + T:Avalonia.Controls.Remote.RemoteServer + baseline/Avalonia/lib/net10.0/Avalonia.Controls.dll + current/Avalonia/lib/net10.0/Avalonia.Controls.dll + + + CP0001 + T:Avalonia.Controls.Remote.RemoteWidget + baseline/Avalonia/lib/net10.0/Avalonia.Controls.dll + current/Avalonia/lib/net10.0/Avalonia.Controls.dll + CP0001 T:Avalonia.Controls.SaveFileDialog @@ -703,6 +715,18 @@ baseline/Avalonia/lib/net8.0/Avalonia.Controls.dll current/Avalonia/lib/net8.0/Avalonia.Controls.dll + + CP0001 + T:Avalonia.Controls.Remote.RemoteServer + baseline/Avalonia/lib/net8.0/Avalonia.Controls.dll + current/Avalonia/lib/net8.0/Avalonia.Controls.dll + + + CP0001 + T:Avalonia.Controls.Remote.RemoteWidget + baseline/Avalonia/lib/net8.0/Avalonia.Controls.dll + current/Avalonia/lib/net8.0/Avalonia.Controls.dll + CP0001 T:Avalonia.Controls.SaveFileDialog @@ -3937,4 +3961,4 @@ baseline/Avalonia/lib/netstandard2.0/Avalonia.Base.dll current/Avalonia/lib/netstandard2.0/Avalonia.Base.dll - \ No newline at end of file + diff --git a/samples/Previewer/App.xaml b/samples/Previewer/App.xaml deleted file mode 100644 index 817142fefd..0000000000 --- a/samples/Previewer/App.xaml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/samples/Previewer/App.xaml.cs b/samples/Previewer/App.xaml.cs deleted file mode 100644 index ab83d45cd3..0000000000 --- a/samples/Previewer/App.xaml.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Avalonia; -using Avalonia.Controls.ApplicationLifetimes; -using Avalonia.Markup.Xaml; - -namespace Previewer -{ - public class App : Application - { - public override void Initialize() - { - AvaloniaXamlLoader.Load(this); - } - - public override void OnFrameworkInitializationCompleted() - { - if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) - desktop.MainWindow = new MainWindow(); - base.OnFrameworkInitializationCompleted(); - } - } - -} diff --git a/samples/Previewer/Center.cs b/samples/Previewer/Center.cs deleted file mode 100644 index 7a28827d61..0000000000 --- a/samples/Previewer/Center.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Avalonia; -using Avalonia.Controls; - -namespace Previewer -{ - public class Center : Decorator - { - protected override Size ArrangeOverride(Size finalSize) - { - if (Child != null) - { - var desired = Child.DesiredSize; - Child.Arrange(new Rect((finalSize.Width - desired.Width) / 2, (finalSize.Height - desired.Height) / 2, - desired.Width, desired.Height)); - } - return finalSize; - } - } -} \ No newline at end of file diff --git a/samples/Previewer/MainWindow.xaml b/samples/Previewer/MainWindow.xaml deleted file mode 100644 index eb612303f2..0000000000 --- a/samples/Previewer/MainWindow.xaml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/samples/Previewer/MainWindow.xaml.cs b/samples/Previewer/MainWindow.xaml.cs deleted file mode 100644 index dabf90f5d0..0000000000 --- a/samples/Previewer/MainWindow.xaml.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Net; -using Avalonia; -using Avalonia.Controls; -using Avalonia.Controls.Remote; -using Avalonia.Markup.Xaml; -using Avalonia.Remote.Protocol; -using Avalonia.Remote.Protocol.Designer; -using Avalonia.Remote.Protocol.Viewport; -using Avalonia.Threading; - -namespace Previewer -{ - public class MainWindow : Window - { - private const string InitialXaml = @" - Hello world! - - "; - private IAvaloniaRemoteTransportConnection? _connection; - private Control _errorsContainer; - private TextBlock _errors; - private RemoteWidget? _remote; - - - public MainWindow() - { - this.InitializeComponent(); - var tb = this.GetControl("Xaml"); - tb.Text = InitialXaml; - var scroll = this.GetControl("Remote"); - var rem = new Center(); - scroll.Content = rem; - _errorsContainer = this.GetControl("ErrorsContainer"); - _errors = this.GetControl("Errors"); - tb.GetObservable(TextBox.TextProperty).Subscribe(text => _connection?.Send(new UpdateXamlMessage - { - Xaml = text - })); - new BsonTcpTransport().Listen(IPAddress.Loopback, 25000, t => - { - Dispatcher.UIThread.Post(() => - { - if (_connection != null) - { - _connection.Dispose(); - _connection.OnMessage -= OnMessage; - } - _connection = t; - rem.Child = _remote = new RemoteWidget(t); - t.Send(new UpdateXamlMessage - { - Xaml = tb.Text - }); - - t.OnMessage += OnMessage; - }); - }); - Title = "Listening on 127.0.0.1:25000"; - } - - private void OnMessage(IAvaloniaRemoteTransportConnection transport, object obj) - { - Dispatcher.UIThread.Post(() => - { - if (transport != _connection) - return; - if (obj is UpdateXamlResultMessage result) - { - _errorsContainer.IsVisible = result.Error != null; - _errors.Text = result.Error ?? ""; - } - if (obj is RequestViewportResizeMessage resize && _remote is not null) - { - _remote.Width = Math.Min(4096, Math.Max(resize.Width, 1)); - _remote.Height = Math.Min(4096, Math.Max(resize.Height, 1)); - } - }); - } - - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } - } -} diff --git a/samples/Previewer/Previewer.csproj b/samples/Previewer/Previewer.csproj deleted file mode 100644 index e894108c0f..0000000000 --- a/samples/Previewer/Previewer.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - Exe - $(AvsCurrentTargetFramework) - - - - %(Filename) - - - - - - - - - - - - - - diff --git a/samples/Previewer/Program.cs b/samples/Previewer/Program.cs deleted file mode 100644 index b12b93974a..0000000000 --- a/samples/Previewer/Program.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Avalonia; - -namespace Previewer -{ - class Program - { - public static AppBuilder BuildAvaloniaApp() - => AppBuilder.Configure() - .UsePlatformDetect(); - - public static int Main(string[] args) - => BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); - } -} diff --git a/samples/RemoteDemo/Program.cs b/samples/RemoteDemo/Program.cs deleted file mode 100644 index 0565b676fb..0000000000 --- a/samples/RemoteDemo/Program.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Net; -using System.Net.Sockets; -using System.Threading; -using Avalonia; -using Avalonia.Controls; -using Avalonia.Controls.Remote; -using Avalonia.Remote.Protocol; -using Avalonia.Threading; -using ControlCatalog; - -namespace RemoteDemo -{ - class Program - { - static void Main(string[] args) - { - AppBuilder.Configure().UsePlatformDetect().SetupWithoutStarting(); - - var l = new TcpListener(IPAddress.Loopback, 0); - l.Start(); - var port = ((IPEndPoint) l.LocalEndpoint).Port; - l.Stop(); - - var transport = new BsonTcpTransport(); - transport.Listen(IPAddress.Loopback, port, sc => - { - Dispatcher.UIThread.Post(() => - { - new RemoteServer(sc).Content = new MainView(); - }); - }); - - var cts = new CancellationTokenSource(); - transport.Connect(IPAddress.Loopback, port).ContinueWith(t => - { - Dispatcher.UIThread.Post(() => - { - var window = new Window() - { - Content = new RemoteWidget(t.Result) - }; - window.Closed += delegate { cts.Cancel(); }; - window.Show(); - }); - }); - Dispatcher.UIThread.MainLoop(cts.Token); - - - - } - } -} diff --git a/samples/RemoteDemo/RemoteDemo.csproj b/samples/RemoteDemo/RemoteDemo.csproj deleted file mode 100644 index 8c479b1093..0000000000 --- a/samples/RemoteDemo/RemoteDemo.csproj +++ /dev/null @@ -1,12 +0,0 @@ - - - Exe - $(AvsCurrentTargetFramework) - - - - - - - - diff --git a/src/Avalonia.Controls/Remote/RemoteServer.cs b/src/Avalonia.Controls/Remote/RemoteServer.cs index 7d036f9b9f..4a08e0b079 100644 --- a/src/Avalonia.Controls/Remote/RemoteServer.cs +++ b/src/Avalonia.Controls/Remote/RemoteServer.cs @@ -6,8 +6,7 @@ using Avalonia.Remote.Protocol; namespace Avalonia.Controls.Remote { - [Unstable] - public class RemoteServer : IDisposable + internal class RemoteServer : IDisposable { private EmbeddableControlRoot _topLevel; diff --git a/src/Avalonia.Controls/Remote/RemoteWidget.cs b/src/Avalonia.Controls/Remote/RemoteWidget.cs index 11eb53ceb5..e2d1a440ad 100644 --- a/src/Avalonia.Controls/Remote/RemoteWidget.cs +++ b/src/Avalonia.Controls/Remote/RemoteWidget.cs @@ -10,7 +10,7 @@ using PixelFormat = Avalonia.Platform.PixelFormat; namespace Avalonia.Controls.Remote { - public class RemoteWidget : Control + internal class RemoteWidget : Control { public enum SizingMode {