Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with CSLA 9 preview #4417

Closed
Bowman74 opened this issue Dec 27, 2024 · 4 comments · Fixed by #4419
Closed

Issue with CSLA 9 preview #4417

Bowman74 opened this issue Dec 27, 2024 · 4 comments · Fixed by #4419
Assignees

Comments

@Bowman74
Copy link
Contributor

Describe the bug
When running iOS the following error occurs.:
'Generic implementation type 'Csla.DataPortal1' has a DynamicallyAccessedMembers attribute applied to a generic argument type, but the service type 'Csla.IDataPortal1' doesn't have a matching DynamicallyAccessedMembers attribute on its generic argument type.'

When looking at the Main branch we can see in DataPortalT.cs that it is decorated with the DynamicallyAccessedMembers attribute in several locations, however the matching IDataPortalT.cs interface is not similarly decorated.

For example, the DataPortalT.cs DoCreateAsync method has its generic decorated but if we look at methods that call it in the same class; the async Task<T> CreateAsync(params object[] criteria) is not decorated, the T Create(params object[] criteria) also is not but the object Create( is decorated. If we look at the IDataPortalT.cs, none of the method signatures for Create are decorated.

The DynamicallyAccessedMembers attribute is similar to adding the async keyword, once there it needs to flow up the stack. As Microsoft states:
"To fix this, we must "annotate and propagate" by applying annotations all the way up the call chain until we reach a statically known type (like System.DateTime or System.Tuple), or another annotated value. "
https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/fixing-warnings#dynamicallyaccessedmembers

Right now CSLA 9.0 may not fully work with full trimming because of this. Particularly with aggressive AOT compilation on platforms like iOS.

Version and Platform
CSLA version: 9.0.0-rc1-gb7b53fbc46
OS: iOS
Platform: MAUI

Code that Fails
Sample CSLA project updated to .NET 9, verified issue in CSLA codebase. Errors out before any relevant user code is executed. iOS is more particular with this type of issue.

Stack Trace or Exception Detail
0x38 in UIKit.UIApplication.xamarin_UIApplicationMain C#
0xF in UIKit.UIApplication.UIApplicationMain at /Users/builder/azdo/_work/5/s/xamarin-macios/src/UIKit/UIApplication.cs:61,5 C#
0x4A in UIKit.UIApplication.Main at /Users/builder/azdo/_work/5/s/xamarin-macios/src/UIKit/UIApplication.cs:96,4 C#

0xD in MauiExample.Program.Main at C:\Users\kevinford\source\repos\csla\Samples\MauiExample\MauiExample\Platforms\iOS\Program.cs:13,3 C#

Additional context
Add any other context about the problem here.

@Bowman74
Copy link
Contributor Author

Bowman74 commented Dec 27, 2024

Note, this is possibly fixed with:
#4363

The main generic for the interface is now decorated with that PR. I'm not sure if the decorations for the individual generic methods need to flow up as well. I've found I get warnings when I don't propagate those up the stack as well. However, that PR may resolve this issue.

@Bowman74
Copy link
Contributor Author

Re-opening as there is another issue revealed by fixing the first.

@Bowman74
Copy link
Contributor Author

Closing as complete with PR #4417

@Bowman74
Copy link
Contributor Author

Closing as complete with PR #4417

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants