Browse Source

Changes to control AOT Trimming in iOS
Replaced Newtonsoft.Json with System.Text.Json

Frank van den Bos 3 weeks ago
parent
commit
97d2d36601

+ 1 - 1
PRS.Avalonia/.run/PRS.Avalonia.iOS.run.xml

@@ -1,6 +1,6 @@
 <component name="ProjectRunConfigurationManager">
   <configuration default="false" name="PRS.Avalonia.iOS" type="XamarinIOSProject" factoryName="Xamarin.iOS">
-    <option name="PROJECT_PATH" value="$PROJECT_DIR$/PRS.Avalonia.iOS/PRS.Avalonia.iOS.csproj" />
+    <option name="PROJECT_PATH" value="$PROJECT_DIR$/../../inabox/InABox.Avalonia.Platform.iOS/InABox.Avalonia.Platform.iOS.csproj" />
     <option name="PROGRAM_PARAMETERS" value="" />
     <option name="IS_PASS_PARENT_ENVS" value="false" />
     <option name="EXTRA_MLAUNCH_PARAMETERS" value="" />

+ 1 - 1
PRS.Avalonia/PRS.Avalonia.iOS/AppDelegate.cs

@@ -28,7 +28,7 @@ public partial class AppDelegate : AvaloniaAppDelegate<App>
         result = result.UseSkia();
         result = result.WithInterFont();
         
-        if (Runtime.Arch == Arch.SIMULATOR)
+        //if (Runtime.Arch == Arch.SIMULATOR)
             result = result.With(new iOSPlatformOptions { RenderingMode = [iOSRenderingMode.OpenGl] });
         
         return result;

+ 2 - 2
PRS.Avalonia/PRS.Avalonia.iOS/Info.plist

@@ -7,9 +7,9 @@
 	<key>CFBundleIdentifier</key>
 	<string>com.prs.avalonia</string>
 	<key>CFBundleShortVersionString</key>
-	<string>1.9</string>
+	<string>1.12</string>
 	<key>CFBundleVersion</key>
-	<string>1.9</string>
+	<string>1.12</string>
 	<key>LSRequiresIPhoneOS</key>
 	<false/>
 	<key>MinimumOSVersion</key>

+ 47 - 20
PRS.Avalonia/PRS.Avalonia.iOS/PRS.Avalonia.iOS.csproj

@@ -6,29 +6,13 @@
         <Nullable>enable</Nullable>
         <Configurations>Debug;Release;Publish</Configurations>
         <Platforms>AnyCPU</Platforms>
-<!--        <IsAotCompatible>false</IsAotCompatible>-->
-<!--        <EnableNativeAOT>false</EnableNativeAOT>-->
-<!--        <PublishAot>false</PublishAot>-->
-<!--        <PublishAotUsingRuntimePack>false</PublishAotUsingRuntimePack>-->
-<!--        <MtouchUseLlvm>false</MtouchUseLlvm>-->
+        <PublishAot>false</PublishAot>
     </PropertyGroup>
     
-<!--     Forces the use of the iOS interpreter during builds -->
-<!--    <PropertyGroup Condition="$(TargetFramework.Contains('-ios'))">-->
-<!--        <UseInterpreter>true</UseInterpreter>-->
-<!--    </PropertyGroup>-->
-
-<!--     Disables the new "managed-static" registrar. Could cause the app's size to be slightly larger. May enable in the future  See : https://github.com/xamarin/xamarin-macios/wiki/.NET-9-release-notes#type-registrar-managed-static-as-the-new-default -->
-<!--    <Target Name="SelectStaticRegistrar" AfterTargets="SelectRegistrar">-->
-<!--        <PropertyGroup Condition="'$(Registrar)' == 'managed-static'">-->
-<!--            <Registrar>static</Registrar>-->
-<!--        </PropertyGroup>-->
-<!--    </Target>-->
+
     
     <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
       <CodesignKey>iPhone Developer</CodesignKey>
-<!--      <MtouchDebug>true</MtouchDebug>-->
-<!--      <IOSDebugOverWiFi>true</IOSDebugOverWiFi>-->
       <CodesignProvision>Development (com.prs.avalonia)</CodesignProvision>
     </PropertyGroup>
     
@@ -49,12 +33,55 @@
     </ItemGroup>
 
     <ItemGroup>
-      <PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.2" />
-      <PackageReference Include="Avalonia.iOS" Version="11.2.2" />
+      <PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.2" />
+      <PackageReference Include="Avalonia.iOS" Version="11.3.2" />
     </ItemGroup>
 
     <ItemGroup>
       <Folder Include="Assets.xcassets\" />
     </ItemGroup>
+
+    <PropertyGroup>
+        <PublishAot>false</PublishAot>
+        <!-- Recommended Avalonia trimming settings for Native AOT -->
+        <BuiltInComInteropSupport>false</BuiltInComInteropSupport>
+        <TrimMode>link</TrimMode>
+    </PropertyGroup>
+
+    <ItemGroup>
+        <TrimmerRootDescriptor Include="TrimmerRoots.xml" />
+    </ItemGroup>
+    
+    <ItemGroup>
+        <!-- Preserve Avalonia types for reflection -->
+        <TrimmerRootAssembly Include="Avalonia.Themes.Fluent" />
+        <TrimmerRootAssembly Include="Autofac" />
+        <TrimmerRootAssembly Include="Avalonia.Controls" />
+
+        <TrimmerRootAssembly Include="InABox.Avalonia" />
+        <TrimmerRootAssembly Include="InABox.Avalonia.Platform" />
+        <TrimmerRootAssembly Include="InABox.Avalonia.Platform.iOS" />
+        <TrimmerRootAssembly Include="InABox.Client.RPC" />
+        <TrimmerRootAssembly Include="PRS.Avalonia" />
+        <TrimmerRootAssembly Include="PRSClasses" />
+        <TrimmerRootAssembly Include="InABox.Core" />
+        <TrimmerRootAssembly Include="InABox.Formatters.Core" />
+        <TrimmerRootAssembly Include="InABox.Integration" />
+        <TrimmerRootAssembly Include="InABox.Logging.Shared" />
+        <TrimmerRootAssembly Include="InABox.RPC.Shared" />
+    </ItemGroup>
+
+    <!-- Forces the use of the iOS interpreter during builds -->
+    <PropertyGroup Condition="$(TargetFramework.Contains('-ios'))">
+        <UseInterpreter>true</UseInterpreter>
+    </PropertyGroup>
+
+    <!-- Disables the new "managed-static" registrar. Could cause the app's size to be slightly larger. 
+    May enable in the future  See : https://github.com/xamarin/xamarin-macios/wiki/.NET-9-release-notes#type-registrar-managed-static-as-the-new-default -->
+    <Target Name="SelectStaticRegistrar" AfterTargets="SelectRegistrar">
+        <PropertyGroup Condition="'$(Registrar)' == 'managed-static'">
+            <Registrar>static</Registrar>
+        </PropertyGroup>
+    </Target>
     
 </Project>

+ 19 - 0
PRS.Avalonia/PRS.Avalonia.iOS/TrimmerRoots.xml

@@ -0,0 +1,19 @@
+<linker>
+    <assembly fullname="Avalonia.Themes.Fluent" preserve="All" />
+    <assembly fullname="Autofac" preserve="All" />
+    <assembly fullname="Avalonia.Controls" preserve="All" />
+    
+    <assembly fullname="InABox.Avalonia" preserve="All" />
+    <assembly fullname="InABox.Avalonia.Platform" preserve="All" />
+    <assembly fullname="InABox.Avalonia.Platform.iOS" preserve="All" />
+    <assembly fullname="InABox.Client.RPC" preserve="All" />
+    <assembly fullname="InABox.Core" preserve="All" />
+    <assembly fullname="InABox.Formatters.Core" preserve="All" />
+    <assembly fullname="InABox.Integration" preserve="All" />
+    <assembly fullname="InABox.Logging.Shared" preserve="All" />
+    <assembly fullname="InABox.RPC.Shared" preserve="All" />
+
+    <assembly fullname="PRSClasses" preserve="All" />
+    <assembly fullname="PRS.Avalonia" preserve="All" />
+    <assembly fullname="PRS.Avalonia.iOS" preserve="All" />
+</linker>

+ 5 - 0
PRS.Avalonia/PRS.Avalonia/App.axaml.cs

@@ -9,6 +9,7 @@ using Avalonia.Markup.Xaml;
 using Comal.Classes;
 using InABox.Avalonia;
 using InABox.Core;
+using PRS.Avalonia.Login;
 using PRS.Avalonia.Modules;
 using GeoFence = Comal.Classes.GeoFence;
 
@@ -20,6 +21,10 @@ public class App : Application
 
     public override void Initialize()
     {
+
+        //ViewLocator.Register<MainViewModel,MainView>();
+        //ViewLocator.Register<LoginViewModel, LoginView>();
+        
         TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
         MobileLogging.LogException += MobileLogging_LogException;
 

+ 1 - 1
PRS.Avalonia/PRS.Avalonia/Login/LoginViewModel.cs

@@ -10,7 +10,7 @@ namespace PRS.Avalonia.Login;
 
 public partial class LoginViewModel : ViewModelBase
 {
-    [ObservableProperty] private string _status;
+    [ObservableProperty] private string _status = "";
 
 
     public LoginViewModel()

+ 8 - 14
PRS.Avalonia/PRS.Avalonia/PRS.Avalonia.csproj

@@ -304,19 +304,18 @@
 
     <ItemGroup>
         
-        <PackageReference Include="Avalonia.Skia" Version="11.2.2" />
-        
-        <PackageReference Include="Avalonia.Svg.Skia" Version="11.2.0.2" />
-        <PackageReference Include="Avalonia.Controls.ColorPicker" Version="11.2.2" />
-        <PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.2" />
+        <PackageReference Include="Avalonia.Skia" Version="11.3.2" />
+        <PackageReference Include="Avalonia.Controls.ColorPicker" Version="11.3.2" />
+        <PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.2" />
         <PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
         <PackageReference Include="Deadpikle.AvaloniaProgressRing" Version="0.10.10" />
-        <PackageReference Include="Mapsui.Avalonia" Version="4.1.9" />
-        <PackageReference Include="Microsoft.Maui.Essentials" Version="9.0.71" />
+        <PackageReference Include="Mapsui.Avalonia" Version="5.0.0-beta.19" />
+        <PackageReference Include="Microsoft.Maui.Essentials" Version="9.0.90" />
         
         <!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
 		<PackageReference Condition="'$(Configuration)' == 'DebugDev'" Include="Avalonia.Diagnostics" Version="11.2.2"/>
-		<PackageReference Include="ReactiveUI" Version="20.3.1" />
+		<PackageReference Include="ReactiveUI" Version="20.4.1" />
+		<PackageReference Include="Svg.Controls.Skia.Avalonia" Version="11.3.0.3" />
     
     </ItemGroup>
 
@@ -445,10 +444,5 @@
         <UpToDateCheckInput Remove="Components\ModuleList\Resources.axaml" />
         <UpToDateCheckInput Remove="Components\ModuleList\Styles.axaml" />
     </ItemGroup>
-
-    <ItemGroup>
-      <Reference Include="Avalonia.Controls.DataGrid">
-        <HintPath>..\..\..\..\.nuget\packages\avalonia.controls.datagrid\11.2.5\lib\net8.0\Avalonia.Controls.DataGrid.dll</HintPath>
-      </Reference>
-    </ItemGroup>
+    
 </Project>

+ 22 - 3
PRS.Avalonia/PRS.Avalonia/ViewLocator.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Collections.Generic;
 using Avalonia.Controls;
 using Avalonia.Controls.Templates;
 using InABox.Avalonia;
@@ -7,11 +8,28 @@ namespace PRS.Avalonia;
 
 public class ViewLocator : IDataTemplate
 {
+    
+    // private static Dictionary<Type,Func<Control>> _views = new Dictionary<Type, Func<Control>>();
+    
+    // public static void Register<TViewModel,TView>() 
+    //     where TViewModel:IViewModelBase, new()
+    //     where TView : Control, new()
+    // {
+    //     Navigation.Register<TViewModel>(() => new TViewModel());
+    //     _views[typeof(TViewModel)] = () => new TView();
+    // }
+    
     public Control? Build(object? param)
     {
         if (param is null)
             return null;
 
+        // if (_views.TryGetValue(param.GetType(), out var create))
+        // {
+        //     var result = create();
+        //     return result;
+        // }
+        
         var name = param.GetType().AssemblyQualifiedName;
         var index = name.IndexOf('`'); // Allow for generic names.
         if(index != -1)
@@ -19,10 +37,11 @@ public class ViewLocator : IDataTemplate
             name = name.Substring(0, index);
         }
         name = name.Replace("ViewModel", "View", StringComparison.Ordinal);
-
+        
         var type = Type.GetType(name);
-
-        if (type != null) return (Control)Activator.CreateInstance(type)!;
+        
+        if (type != null) 
+            return (Control)Activator.CreateInstance(type)!;
 
         return new TextBlock { Text = "Not Found: " + name };
     }

+ 2 - 2
PRS.DigitalKey/PRS.DigitalKey.iOS/PRS.DigitalKey.iOS.csproj

@@ -44,7 +44,7 @@
     </ItemGroup>
 
     <ItemGroup>
-      <PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.2" />
-      <PackageReference Include="Avalonia.iOS" Version="11.2.2" />
+      <PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.2" />
+      <PackageReference Include="Avalonia.iOS" Version="11.3.2" />
     </ItemGroup>
 </Project>

+ 2 - 2
PRS.DigitalKey/PRS.DigitalKey/PRS.DigitalKey.csproj

@@ -28,9 +28,9 @@
     </ItemGroup>
 
     <ItemGroup>
-        <PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.2" />
+        <PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.2" />
         <PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
-        <PackageReference Include="Microsoft.Maui.Essentials" Version="9.0.71" />
+        <PackageReference Include="Microsoft.Maui.Essentials" Version="9.0.90" />
         
         <!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
     

+ 0 - 1
prs.classes/EnclosedEntities/ActivityCharge/ActivityCharge.cs

@@ -1,6 +1,5 @@
 using System;
 using InABox.Core;
-using Newtonsoft.Json.Serialization;
 
 namespace Comal.Classes
 {

+ 0 - 1
prs.classes/Entities/Job/JobStage.cs

@@ -3,7 +3,6 @@ using System.Collections.Generic;
 using System.ComponentModel;
 using System.Linq;
 using InABox.Core;
-using Newtonsoft.Json;
 
 namespace Comal.Classes
 {

+ 0 - 4
prs.classes/Entities/Staging/Component/StagingSetoutComponent.cs

@@ -1,10 +1,6 @@
 using InABox.Core;
-using Newtonsoft.Json.Linq;
 using System;
-using System.Collections;
 using System.Collections.Generic;
-using System.Linq;
-using System.Text;
 
 namespace Comal.Classes
 {