Skip to content

Conversation

@dvoituron
Copy link
Collaborator

[DialogService] Add a fake instance of DialogEventArgs #280

Add this line to prevent the Trimming process from deleting this class?

_ = new DialogEventArgs() { Id = "0", Reason = "Unknown" };

@dvoituron dvoituron requested a review from vnbaaij December 27, 2023 12:41
@github-actions
Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://black-pebble-0dc79cb03-1223.westeurope.3.azurestaticapps.net

@vnbaaij
Copy link
Collaborator

vnbaaij commented Dec 27, 2023

Should we not use a DynamicDependencyAttribute for this:
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(DialogEventArgs))]

See recommendations under https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/prepare-libraries-for-trimming?pivots=dotnet-8-0

@dvoituron
Copy link
Collaborator Author

Should we not use a DynamicDependencyAttribute for this: [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(DialogEventArgs))]

See recommendations under https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/prepare-libraries-for-trimming?pivots=dotnet-8-0

I don't think so, but maybe I'm wrong. In my opinion, this feature is useful when calling a method that uses reflection. It adds a warning at compile time to inform the developer. Here, we're not using reflection with this class. However, adding this tiny class to the lib should correct this problem.

@dvoituron
Copy link
Collaborator Author

@vnbaaij You're probably right, this code is probably cleaner. I'll update it

[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(DialogEventArgs))]
public partial class DialogService : IDialogService
{
}

@vnbaaij vnbaaij merged commit 522707c into dev Dec 28, 2023
@vnbaaij vnbaaij deleted the users/dvoituron/fix-dialogeventargs-trimmed branch December 28, 2023 07:57
@github-actions
Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://black-pebble-0dc79cb03-1223.westeurope.3.azurestaticapps.net

1 similar comment
@github-actions
Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://black-pebble-0dc79cb03-1223.westeurope.3.azurestaticapps.net

vnbaaij added a commit that referenced this pull request Dec 28, 2023
* Add a fake instance of DialogEventArgs

* Update DialogService.cs

Add DynamicDependencyAttribute

---------

Co-authored-by: Vincent Baaij <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants