Repository navigation
Description
Background
#4955 (for #3347 and #4956) makes Csla.dll trim and NativeAOT clean, with the trim/AOT analyzers enabled and no suppressed IL warnings. Csla.csproj is the only project that runs those analyzers. The other framework assemblies have never been analyzed.
In #4955 the late-bound reflection APIs became [RequiresUnreferencedCode] instead of suppressing their warnings:
MethodCaller:CallPropertyGetter,CallPropertySetter,CallMethod,CallMethodIfImplemented,IsMethodImplemented,CallMethodTryAsync,IsAsyncMethod,GetType(string[, bool])ServiceProviderMethodCaller.FindDataPortalMethod<T>(object, ...)LateBoundObjectUtilities.CallByName
CSLA's own code in Csla.dll calls internal *Core variants that keep the suppressions. Several other CSLA assemblies call the public APIs, so a trimmed or NativeAOT app that uses them will now get trim warnings attributed to those assemblies.
Assemblies to review
In rough priority order, by how often each is trimmed or AOT compiled:
- Csla.Blazor / Csla.Blazor.WebAssembly. Blazor WebAssembly always trims.
PropertyInfocallsUtilities.CallByName(Model, ...).Modelis typedobjectbut is normally a business object, so the internal*Coremethods may fit. Csla.Blazor already hasInternalsVisibleTo. - Csla.Xaml.Maui (and the shared
Csla.Xaml.Sharedcode). MAUI trims on iOS and Android and may use NativeAOT.PropertyInfowalks arbitrary binding paths withCallPropertyGetter/CallPropertySetter, so the warning may be correct. Options are annotations,[RequiresUnreferencedCode]plus documentation, or a narrower path for business objects. - Csla.AspNetCore (the shared
Csla.Web.Mvc.Sharedcode).HttpPortalresolves client-supplied type names withMethodCaller.GetType. A server-only app may not reference those types, so the warning may be correct. A policy decision is needed (see below). - Csla.Channels.Grpc / Csla.Channels.RabbitMq (and Csla.Channels.Wcf). Same
GetTypepattern asHttpPortal. - Lower priority: the MVC tag helpers (
CslaErrorsTagHelperetc.) andCslaModelBinder. ASP.NET Core MVC/Razor isn't trim compatible anyway.
Work
- Enable the trim/AOT analyzers (
IsTrimmable/IsAotCompatible) on the net10+ targets of each assembly, and list the warnings. - For each warning, choose one: annotate (
DynamicallyAccessedMembers), call an internal*Corevariant (which may need newInternalsVisibleToentries), or surface it with[RequiresUnreferencedCode]and document the requirement. Keep messages and justifications inTrimmingMessages, following the pattern in CLAUDE.md. - Decide how the data portal hosts resolve type names: surface the warning and document that apps must preserve their business types, or resolve names through something with a preservation contract.
- Consider extending
Source/tests/Csla.AotSmokeTest, or adding a sibling, with a host scenario such as a NativeAOT ASP.NET Core data portal server or a trimmed Blazor WebAssembly client.
Related leftover in Csla.dll
The Type overloads of ServiceProviderMethodCaller.FindDataPortalMethod<T> and TryFindDataPortalMethod<T> annotate targetType with only DynamicallyAccessedMemberTypes.PublicConstructors, but they reflect over the type's methods. They rely on BusinessTypeJustification, which holds because the CSLA base classes are annotated DynamicallyAccessedMembers.All. To make the contract match, require All there and carry it through the callers (DataPortal<T>, FactoryDataPortal, ServiceProviderMethodCallerExtensions).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
#4962 Strong-name Csla.Xaml for MAUI
#4962 Document trimming requirements for hand-written policies and Pr…
MarimerLLC#4962 Resolve trim and NativeAOT warnings in the other CSLA…