Skip to content

Resolve trimming and NativeAOT warnings in the other CSLA assemblies #4962

Closed

Description

@rockfordlhotka

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, ...)
  • LateBoundObject
  • Utilities.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. PropertyInfo calls Utilities.CallByName(Model, ...). Model is typed object but is normally a business object, so the internal *Core methods may fit. Csla.Blazor already has InternalsVisibleTo.
  • Csla.Xaml.Maui (and the shared Csla.Xaml.Shared code). MAUI trims on iOS and Android and may use NativeAOT. PropertyInfo walks arbitrary binding paths with CallPropertyGetter/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.Shared code). HttpPortal resolves client-supplied type names with MethodCaller.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 GetType pattern as HttpPortal.
  • Lower priority: the MVC tag helpers (CslaErrorsTagHelper etc.) and CslaModelBinder. ASP.NET Core MVC/Razor isn't trim compatible anyway.

Work

  1. Enable the trim/AOT analyzers (IsTrimmable / IsAotCompatible) on the net10+ targets of each assembly, and list the warnings.
  2. For each warning, choose one: annotate (DynamicallyAccessedMembers), call an internal *Core variant (which may need new InternalsVisibleTo entries), or surface it with [RequiresUnreferencedCode] and document the requirement. Keep messages and justifications in TrimmingMessages, following the pattern in CLAUDE.md.
  3. 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.
  4. 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).

Activity

  1. moved this from Todo to In Progress in CSLA Version 11.0.0on Oct 28, 2026
  2. added 2 commits that reference this issue on Oct 28, 2026
  3. added a commit that references this issue on Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions