Repository navigation
Update the MAUI sample to CSLA 11 with trimming and NativeAOT - #4973
Draft
rockfordlhotka wants to merge 7 commits into
Draft
rockfordlhotka wants to merge 7 commits into
rockfordlhotka wants to merge 7 commits into
Conversation
- Reference the Csla and Csla.Maui 11.0.0-alpha.1 packages and drop the retired AutoImplementProperties generator package - Declare PersonList partial and replace DataMapper.Map with explicit property assignments in PersonEdit - Publish with TrimMode=full on Android and iOS and NativeAOT on iOS and Mac Catalyst; set TrimmerSingleWarn=false and IsAotCompatible on the libraries; remove the stale net9.0 property groups - Suppress the csla:PropertyInfo IL2026 on PersonEditPage's generated InitializeComponent, and use the trim safe OnPlatform element in Styles.xaml - Use the non-generic RefreshAsync (MAUI part of #4961) - Add a readme covering the settings and CSLA rules Csla.Xaml (MAUI): suppress IL2112 on PropertyInfo.BrokenRulesProperty. The class-level RequiresUnreferencedCode covers the static field, which MAUI's VisualElement [DynamicallyAccessedMembers] reaches; its initializer doesn't walk a binding path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove before merging. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lator in the temp workflow NativeAOT links every assembly and the iOS SDK warns when TrimMode is set with it. dotnet publish rejects simulator RIDs, so the temporary workflow builds with _IsPublishing=true and checks the bundles have no managed assemblies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
@Bowman74 can you help me test this? My new PC has an arm64 processor and so apparently can't run android emulators, and I've never been able to run iOS stuff - but hopefully this PR enables AOT trimming for MAUI. |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new constant reference is missing from MAUI’s Csla 11.0.0-alpha.1 dependency, breaking MAUI Release builds and blocking Csla.Maui packaging.
1 open issue
What changed in this PR
Updates the MAUI sample to CSLA 11 and demonstrates full trimming on Android and NativeAOT on Apple platforms. It also adds a targeted suppression for the framework’s MAUI PropertyInfo trimming warning.
Changes:
- Updates dependencies and business classes for CSLA 11.
- Enables trimming/AOT settings, replaces reflection-based mapping, and documents publishing.
- Adds a temporary macOS workflow to verify NativeAOT output and check for IL warnings.
| File | Description |
|---|---|
| Source/Csla/Core/TrimmingMessages.cs | Adds the bindable-field suppression justification. |
| Source/Csla.Xaml.Shared/PropertyInfo.cs | Suppresses MAUI-specific IL2112 on BrokenRulesProperty. |
| Samples/MauiExample/readme.md | Documents trimming rules and publish commands. |
| Samples/MauiExample/MauiExample/Resources/Styles/Styles.xaml | Uses the trim-safe OnPlatform element. |
| Samples/MauiExample/MauiExample/Pages/PersonListPage.xaml.cs | Uses non-generic RefreshAsync. |
| Samples/MauiExample/MauiExample/Pages/PersonEditPage.xaml.cs | Updates refresh calls and scopes the XAML warning suppression. |
| Samples/MauiExample/MauiExample/MauiExample.csproj | Updates packages and enables platform-specific trimming/AOT. |
| Samples/MauiExample/DataAccess/DataAccess.csproj | Enables trim and AOT analysis. |
| Samples/MauiExample/BusinessLibrary/PersonList.cs | Makes the list partial for operation generation. |
| Samples/MauiExample/BusinessLibrary/PersonEdit.cs | Replaces reflective mapping with explicit assignments. |
| Samples/MauiExample/BusinessLibrary/BusinessLibrary.csproj | Updates CSLA, removes the retired generator, and enables AOT analysis. |
| .github/workflows/maui-sample-aot.yaml | Adds temporary Apple NativeAOT verification. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Moves
Samples/MauiExampleto CSLA 11 and sets it up to publish with full trimming on Android and NativeAOT on iOS and Mac Catalyst, with no IL warnings. It also fixes an IL2112 thatCsla.Xaml(MAUI) causes in any trimmed app that usescsla:PropertyInfo.Sample changes
CslaandCsla.Maui11.0.0-alpha.1 and remove the retiredCsla.Generator.AutoImplementProperties.CSharppackageMicrosoft.Maui.Controlsto 10.0.120 andMicrosoft.Extensions.Logging.Debugto 10.0.14, the minimumsCsla.Maui11.0.0-alpha.1 requires (older pins fail restore with NU1605)PersonListispartial(CSLA0024);PersonEdit.FetchassignsIdandNameinstead of callingDataMapper.Map, which is[RequiresUnreferencedCode]TrimMode=fullon Android,PublishAot=trueon iOS and Mac Catalyst (NativeAOT already trims every assembly, and the iOS SDK warns ifTrimModeis set with it),TrimmerSingleWarn=false, andIsAotCompatibleonBusinessLibraryandDataAccess; the stalenet9.0property groups are removedcsla:PropertyInfo, with one justified IL2026 suppression scoped toPersonEditPage.InitializeComponent. That method is generated from the XAML, so the suppression is declared at assembly level with aTargetStyles.xamluses the<OnPlatform>element; the template's{OnPlatform}markup extension caused an IL2026 on itsDefaultRefreshAsync(the MAUI part of Use non-generic RefreshAsync in samples when they move to CSLA 11 #4961; theSaveAsync/ManageObjectLifetimebehavior review stays there)readme.mdcovering the settings, the CSLA trimming rules the sample follows, and how to publish each platformFramework fix: IL2112 in Csla.Xaml (MAUI)
PropertyInfohas a class-level[RequiresUnreferencedCode], which also covers its staticBrokenRulesPropertyfield. MAUI'sVisualElementhas[DynamicallyAccessedMembers(PublicFields | NonPublicFields)], which reaches that field, so the trimmer reports IL2112 againstCsla.Xamlin every trimmed app that uses the control. The field now has anUnconditionalSuppressMessagefor IL2112: its static initializer only creates theBindablePropertyand doesn't walk a binding path. The justification is inTrimmingMessages.cs. Avalonia's base types have no such annotation, so only MAUI is affected.Release note:
Csla.Xaml.MauiRelease builds against the publishedCslapackage, and 11.0.0-alpha.1 doesn't have the newTrimmingMessagesconstant. So theCsla.MauiRelease build won't compile until the next Csla prerelease ships and the Release reference is bumped to it, the same order used for 11.0.0-alpha.1 (#4971). CI builds MAUI in Debug, so it isn't affected. Until that release, the sample, which references alpha.1, reports this one IL2112 on Android publish; the readme says so.Testing
dotnet build Samples/MauiExample/MauiExample.sln -c Debug: 0 errors. The only warnings are the iOS/Mac Catalyst "no connection to a Mac" messages (no CS0618, CSLA0024 or IL warnings)dotnet build Source/csla.build.slnandSource/csla.maui.build.sln: no CS or IL warnings (csla.build has its existing MSB3277/NU19xx/NU1510 restore and reference warnings only)Csla/Csla.Mauipacked from this branch: 0 IL warnings. Confirmed trimming ran (PropertyInfoandViewModelBasekept, unusedPropertyStatusremoved). Against published alpha.1: only the IL2112 fixed here_IsPublishing=true, becausedotnet publishonly accepts device RIDs, and it uses Xcode 26.5 withValidateXcodeVersion=falsebecause this runner image has no simulator runtime for Xcode 26.0Closes #4970
Partially addresses #4961 (MAUI
RefreshAsynccalls)🤖 Generated with Claude Code