Skip to content

Commit

Permalink
merge from main
Browse files Browse the repository at this point in the history
  • Loading branch information
adospace committed Dec 10, 2024
2 parents f462d1f + 8d1a8e0 commit 4635f1c
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"Profile 1": {
"commandName": "DebugRoslynComponent",
"targetProject": "..\\..\\samples\\ChartApp\\ChartApp.csproj"
"targetProject": "..\\..\\..\\mauireactor-integration\\DevExpress\\DevExpressIntApp\\DevExpressIntApp.csproj"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public ScaffoldTypeGenerator(
.Cast<IPropertySymbol>()
.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);

Expand All @@ -39,6 +39,7 @@ public ScaffoldTypeGenerator(
.Where(_ => _.Kind == SymbolKind.Field)
.Cast<IFieldSymbol>()
.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[_])
Expand Down Expand Up @@ -71,6 +72,7 @@ public ScaffoldTypeGenerator(
Events = typeToScaffold.GetMembers()
.Where(_ => _.Kind == SymbolKind.Event)
.Cast<IEventSymbol>()
.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())
Expand Down Expand Up @@ -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<IPropertySymbol>()
.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; }
Expand Down
2 changes: 1 addition & 1 deletion src/MauiReactor.ScaffoldGenerator/ScaffoldTypeGenerator.tt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 19 additions & 7 deletions src/MauiReactor/ContentPage.partial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/MauiReactor/HotReload/LocalTypeLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal class LocalTypeLoader : ITypeLoader
#pragma warning disable CS0067
public WeakProducer<ITypeLoaderEventConsumer>? AssemblyChangedEvent { get; }
public Assembly? LastLoadedAssembly { get; }
#pragma warning restore CS0067
#pragma warning restore CS0067

public T LoadObject<T>(Type type)
{
Expand Down
9 changes: 9 additions & 0 deletions src/MauiReactor/Internals/ComponentServicesAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace MauiReactor.HotReload;

/// <summary>
/// Attribute to mark a method as a component service method: the method is called to register services when the assembly is hot-reloaded.
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public class ComponentServicesAttribute : Attribute
{
}
2 changes: 1 addition & 1 deletion src/MauiReactor/Internals/ServiceCollectionProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public ServiceContext(IServiceProvider serviceProvider)
}

public ServiceContext(Action<ServiceCollection> serviceCollectionSetupAction)
: this( SetupServiceProvider(serviceCollectionSetupAction))
: this(SetupServiceProvider(serviceCollectionSetupAction))
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/MauiReactor/ReactorApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 4635f1c

Please sign in to comment.