diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index e715df8..0ec96f9 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -16,7 +16,7 @@ jobs: Solution_Name: ./src/MauiReactor.Build.sln Test_Project: ./samples/UnitTests/UnitTests.csproj TemplatePack_Name: ./src/MauiReactor.TemplatePack/MauiReactor.TemplatePack.csproj - Version: 2.0.55 + Version: 2.0.59 steps: - name: Checkout diff --git a/src/MauiReactor.ScaffoldGenerator/Properties/launchSettings.json b/src/MauiReactor.ScaffoldGenerator/Properties/launchSettings.json index 8141141..26683b5 100644 --- a/src/MauiReactor.ScaffoldGenerator/Properties/launchSettings.json +++ b/src/MauiReactor.ScaffoldGenerator/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "Profile 1": { "commandName": "DebugRoslynComponent", - "targetProject": "..\\..\\samples\\ChartApp\\ChartApp.csproj" + "targetProject": "..\\..\\..\\mauireactor-integration\\DevExpress\\DevExpressIntApp\\DevExpressIntApp.csproj" } } } \ No newline at end of file diff --git a/src/MauiReactor.ScaffoldGenerator/ScaffoldTypeGenerator.partial.cs b/src/MauiReactor.ScaffoldGenerator/ScaffoldTypeGenerator.partial.cs index 9a55766..25c853c 100644 --- a/src/MauiReactor.ScaffoldGenerator/ScaffoldTypeGenerator.partial.cs +++ b/src/MauiReactor.ScaffoldGenerator/ScaffoldTypeGenerator.partial.cs @@ -30,7 +30,7 @@ public ScaffoldTypeGenerator( .Cast() .Where(_ => !_.IsReadOnly && !_.IsWriteOnly) .Where(_ => (_.ContainingType is INamedTypeSymbol namedTypeSymbol) && namedTypeSymbol.GetFullyQualifiedName() == typeToScaffold.GetFullyQualifiedName()) - //.Where(_ => !((INamedTypeSymbol)_.Type).IsGenericType) + .Where(_ => _.DeclaredAccessibility == Accessibility.Public) // Check if the property is public .GroupBy(p => p.Name, StringComparer.OrdinalIgnoreCase) .ToDictionary(g => g.Key, g => g.First(), StringComparer.OrdinalIgnoreCase); @@ -39,6 +39,7 @@ public ScaffoldTypeGenerator( .Where(_ => _.Kind == SymbolKind.Field) .Cast() .Where(_ => _.Type.Equals(bindablePropertyType, SymbolEqualityComparer.Default)) + .Where(_ => _.DeclaredAccessibility == Accessibility.Public) // Check if the field is public .Select(_ => _.Name.Substring(0, _.Name.Length - "Property".Length)) .Where(_ => propertiesMap.ContainsKey(_)) .Select(_ => propertiesMap[_]) @@ -71,6 +72,7 @@ public ScaffoldTypeGenerator( Events = typeToScaffold.GetMembers() .Where(_ => _.Kind == SymbolKind.Event) .Cast() + .Where(_ => _.DeclaredAccessibility == Accessibility.Public) // Check if the field is public .Where(_ => _.Type.Name != "Func") .Where(_ => !_.Name.Contains('.')) .Where(_ => (_.ContainingType is INamedTypeSymbol namedTypeSymbol) && namedTypeSymbol.GetFullyQualifiedName() == typeToScaffold.GetFullyQualifiedName()) @@ -119,18 +121,19 @@ public ScaffoldTypeGenerator( .ToArray(); SupportItemTemplate = implementItemTemplateFlag && typeToScaffold.GetMembers().Count(_ => _.Name == "ItemsSource" || _.Name == "ItemTemplate") == 2; - ItemSourceIsIList = SupportItemTemplate && typeToScaffold + ItemsSourceFullyQualifiedName = (SupportItemTemplate) ? + typeToScaffold .GetMembers("ItemsSource") .Cast() .First() .Type - .GetFullyQualifiedName() == "System.Collections.IList"; + .GetFullyQualifiedName() : string.Empty; } private IPropertySymbol[] Properties { get; } private IPropertySymbol[] AnimatableProperties { get; } - public bool SupportItemTemplate { get; } - public bool ItemSourceIsIList { get; } + public bool SupportItemTemplate { get; } + private string ItemsSourceFullyQualifiedName { get; } private IEventSymbol[] Events { get; } private string Namespace { get; } private string TypeName { get; } diff --git a/src/MauiReactor.ScaffoldGenerator/ScaffoldTypeGenerator.tt b/src/MauiReactor.ScaffoldGenerator/ScaffoldTypeGenerator.tt index 470a8d7..a950d26 100644 --- a/src/MauiReactor.ScaffoldGenerator/ScaffoldTypeGenerator.tt +++ b/src/MauiReactor.ScaffoldGenerator/ScaffoldTypeGenerator.tt @@ -272,7 +272,7 @@ namespace <#= Namespace #> else if (thisAs<#= InterfaceName #>.ItemsSource != null) { _customDataTemplate = new CustomDataTemplate(this); - NativeControl.ItemsSource = thisAs<#= InterfaceName #>.ItemsSource; + NativeControl.ItemsSource = (<#= ItemsSourceFullyQualifiedName #>)thisAs<#= InterfaceName #>.ItemsSource; NativeControl.ItemTemplate = _customDataTemplate.DataTemplate; } else diff --git a/src/MauiReactor/ContentPage.partial.cs b/src/MauiReactor/ContentPage.partial.cs index 45ff7d1..4d653c2 100644 --- a/src/MauiReactor/ContentPage.partial.cs +++ b/src/MauiReactor/ContentPage.partial.cs @@ -35,17 +35,28 @@ protected override void OnRemoveChild(VisualNode widget, BindableObject childCon } } + public partial class ContentPage { partial class ContentPageWithBackButtonPressedOverriden : Microsoft.Maui.Controls.ContentPage { protected override bool OnBackButtonPressed() { - return true; - //return base.OnBackButtonPressed(); + var backButtonBehavior = (BackButtonBehavior?)this.GetValue(Microsoft.Maui.Controls.Shell.BackButtonBehaviorProperty); + + if (backButtonBehavior != null && + backButtonBehavior.Command != null && + backButtonBehavior.Command.CanExecute(null)) + { + //we want to handle back button pressed event (including physical button on Android) + backButtonBehavior.Command.Execute(null); + return true; + } + + return false; } - } - + } + public ContentPage(string title) : base(title) { @@ -57,16 +68,17 @@ public ContentPage(VisualNode content) _internalChildren.Add(content); } - + protected override void OnMount() { _nativeControl ??= new ContentPageWithBackButtonPressedOverriden(); base.OnMount(); - } - + } + } + public partial class Component { public static ContentPage ContentPage(string title) diff --git a/src/MauiReactor/HotReload/LocalTypeLoader.cs b/src/MauiReactor/HotReload/LocalTypeLoader.cs index 9c06a91..78ceaa4 100644 --- a/src/MauiReactor/HotReload/LocalTypeLoader.cs +++ b/src/MauiReactor/HotReload/LocalTypeLoader.cs @@ -11,7 +11,7 @@ internal class LocalTypeLoader : ITypeLoader #pragma warning disable CS0067 public WeakProducer? AssemblyChangedEvent { get; } public Assembly? LastLoadedAssembly { get; } -#pragma warning restore CS0067 +#pragma warning restore CS0067 public T LoadObject(Type type) { diff --git a/src/MauiReactor/Internals/ComponentServicesAttribute.cs b/src/MauiReactor/Internals/ComponentServicesAttribute.cs new file mode 100644 index 0000000..611dddb --- /dev/null +++ b/src/MauiReactor/Internals/ComponentServicesAttribute.cs @@ -0,0 +1,9 @@ +namespace MauiReactor.HotReload; + +/// +/// Attribute to mark a method as a component service method: the method is called to register services when the assembly is hot-reloaded. +/// +[AttributeUsage(AttributeTargets.Method)] +public class ComponentServicesAttribute : Attribute +{ +} \ No newline at end of file diff --git a/src/MauiReactor/Internals/ServiceCollectionProvider.cs b/src/MauiReactor/Internals/ServiceCollectionProvider.cs index 56317d1..075167f 100644 --- a/src/MauiReactor/Internals/ServiceCollectionProvider.cs +++ b/src/MauiReactor/Internals/ServiceCollectionProvider.cs @@ -134,7 +134,7 @@ public ServiceContext(IServiceProvider serviceProvider) } public ServiceContext(Action serviceCollectionSetupAction) - : this( SetupServiceProvider(serviceCollectionSetupAction)) + : this(SetupServiceProvider(serviceCollectionSetupAction)) { } diff --git a/src/MauiReactor/ReactorApplication.cs b/src/MauiReactor/ReactorApplication.cs index de2684a..09d1382 100644 --- a/src/MauiReactor/ReactorApplication.cs +++ b/src/MauiReactor/ReactorApplication.cs @@ -370,7 +370,7 @@ public static MauiAppBuilder EnableMauiReactorHotReload(this MauiAppBuilder appB { TypeLoader.UseRemoteLoader = true; TypeLoader.OnHotReloadCompleted = onHotReloadCompleted; - ServiceCollectionProvider.EnableHotReload = true; + ServiceCollectionProvider.EnableHotReload = true; return appBuilder; }