ReloadPreview 3.0.6
See the version list below for details.
dotnet add package ReloadPreview --version 3.0.6
NuGet\Install-Package ReloadPreview -Version 3.0.6
<PackageReference Include="ReloadPreview" Version="3.0.6" />
paket add ReloadPreview --version 3.0.6
#r "nuget: ReloadPreview, 3.0.6"
// Install ReloadPreview as a Cake Addin #addin nuget:?package=ReloadPreview&version=3.0.6 // Install ReloadPreview as a Cake Tool #tool nuget:?package=ReloadPreview&version=3.0.6
ReloadPreview
What is ReloadPreview
We know we can preview the ui when use xaml,xml,storyboard,swiftui, but if you want use C# code to write ui, no preview? Now, you can use this library to do it. It not only preview, because it need run app, that mean you can show data and load service, and debug by print info.
Support platform
- net6.0-android (tested)
- net6.0-ios (tested, can't directly reload object that extend object-c)
- new6.0 and netstandard (such as maui-windows,or avalonia,need load ReloadClass< Control > in UI thread)
Need other platform? Invoke UI thread when change ui at Reload event, or override InvokeInMainThread
method.
How it work
After code changed, Command Line Server use msbuild to create new dll, then use socket send the .dll to android or ios app, app can use reflection to create instance from dll. So, you can remove old view form window, and use this instance of new view to do something.
Notice: you must let reloaded class is public, because it is reload another assembly.
How to use
Install and Run Command Line Server , input proj and target, such as D:/RelodPreview/ReloadPreview.csproj -t=android
.
Them install nuget, use it, such as at MAUI app:
public App()
{
HotReload.Instance.Init("192.168.0.108");
InitializeComponent();
HotReload.Instance.Reload += () =>
{
var view = HotReload.Instance.ReloadClass<MainPage>() as Page;
Console.WriteLine(view is null);
MainPage = view;
};
MainPage = new MainPage();
}
At ios platform,you can't reload class that extend from native object-c class, such as UIView,UIViewController,you can reload view like this:
public MainController(UIWindow window)
{
HotReload.Instance.Init("192.168.0.108");
HotReload.Instance.Reload += () =>
{
dynamic view = HotReload.Instance.ReloadClass<MainPage>(window!.Frame);
this.View = view.Get() as UIView;
};
this.View = new MainPage(window!.Frame).Page;
}
public class MainPage
{
public UIView Page;
public MainPage(CGRect frame)
{
Page = new UILabel(frame)
{
BackgroundColor = UIColor.Red,
TextAlignment = UITextAlignment.Center,
Text = "Hello,net6-ios!"
};
}
public UIView Get()
{
return Page;
}
}
At not Android and iOS, maybe you need load ReloadClass< T > in UI thread,such as at Avalonia:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
#if DEBUG
HotReload.Instance.Reload += () =>
{
Dispatcher.UIThread.Post(() =>
{
var view = HotReload.Instance.ReloadClass<MainPage>();
this.Content = view;
});
};
HotReload.Instance.Init("192.168.0.108");
#endif
}
}
Tips
2021.10.21
I found when you close "Edit and Continue" at Visual Studio 2022, you can use "Apply Changes" of Visual Studio to continue simple debug Android, At Android, "Apply Changes" will kill current Activity, and reload the Activity in apk, it can't let app auto load the new dll, so ReloadPreview can help you reload all the things of the activity. Limit is you just can use old breakpoint.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-android31.0 is compatible. net6.0-ios was computed. net6.0-ios15.2 is compatible. net6.0-maccatalyst was computed. net6.0-maccatalyst15.2 is compatible. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Text.Json (>= 6.0.2)
-
net6.0
- System.Text.Json (>= 6.0.2)
-
net6.0-android31.0
- System.Text.Json (>= 6.0.2)
-
net6.0-ios15.2
- System.Text.Json (>= 6.0.2)
-
net6.0-maccatalyst15.2
- System.Text.Json (>= 6.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
3.0.7 | 575 | 7/12/2022 | |
3.0.6 | 549 | 4/21/2022 | |
3.0.5 | 450 | 3/3/2022 | |
3.0.4 | 441 | 2/27/2022 | |
3.0.3 | 461 | 2/27/2022 | |
3.0.2 | 464 | 2/27/2022 | |
2.1.8 | 318 | 12/22/2021 | |
2.1.7 | 289 | 12/22/2021 | |
2.1.6 | 311 | 12/14/2021 | |
2.1.5 | 362 | 12/14/2021 | |
2.1.4 | 522 | 12/11/2021 | |
2.1.3 | 1,326 | 12/3/2021 | |
2.1.2 | 728 | 12/3/2021 | |
2.1.1 | 306 | 12/3/2021 | |
2.1.0 | 317 | 12/2/2021 | |
2.0.0 | 1,610 | 12/1/2021 | |
1.2.0 | 318 | 11/28/2021 | |
1.0.0 | 379 | 10/13/2021 |
created for maui single project