[NativeAOT] Preserve all constructors instead of no members (#18903)

`None` seems to be equivalent to not having the attribute at all. The type will be stripped by ILLink and ILC. The `PublicConstructors | NonPublicConstructors` seems to be a better option to keep the type while making it possible to trim as much of its members as possible.

This change resolves two warnings:
```
ILLink : warning IL2037: <Module>..cctor(): No members were resolved for 'None' on type 'Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer.FrameView'.
ILC : warning IL2037: <Module>..cctor(): No members were resolved for '0' on type 'Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer.FrameView'. 
```
(Note: these warnings will still be present for _static_ classes which don't have a static constructor)

@rolfbjarne I believe we don't need https://github.com/dotnet/runtime/pull/90154 anymore


---------

Co-authored-by: Simon Rozsival <simon@rozsival.com>
This commit is contained in:
Šimon Rozsíval 2023-09-01 16:08:19 +02:00 коммит произвёл GitHub
Родитель 4f26004591
Коммит d7b97abe50
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 4 добавлений и 1 удалений

Просмотреть файл

@ -259,7 +259,10 @@ namespace Mono.Tuner {
abr.SetCurrentAssembly (type.Module.Assembly);
var moduleConstructor = GetOrCreateModuleConstructor (type.GetModule ());
var attrib = abr.CreateDynamicDependencyAttribute (allMembers ? DynamicallyAccessedMemberTypes.All : DynamicallyAccessedMemberTypes.None, type);
var members = allMembers
? DynamicallyAccessedMemberTypes.All
: DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors;
var attrib = abr.CreateDynamicDependencyAttribute (members, type);
moduleConstructor.CustomAttributes.Add (attrib);
abr.ClearCurrentAssembly ();