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

[ NativeAot ] Improve support #3417

Open
FoggyFinder opened this issue Aug 11, 2023 · 3 comments
Open

[ NativeAot ] Improve support #3417

FoggyFinder opened this issue Aug 11, 2023 · 3 comments

Comments

@FoggyFinder
Copy link

FoggyFinder commented Aug 11, 2023

Problem

Currently attempt to use NativeAot leads to "Unhandled Exception: System.InvalidOperationException: No properties in Item, has linker stripped it?" exception. Expectedly, adding Preserve attribute has no effect in this case.

MCVE (RealmAot1)

csproj:

<Project Sdk="Microsoft.NET.Sdk">

	<PropertyGroup>
		<OutputType>Exe</OutputType>
		<TargetFramework>net7.0</TargetFramework>
		<ImplicitUsings>enable</ImplicitUsings>
		<Nullable>enable</Nullable>
		<PublishAot>true</PublishAot>
	</PropertyGroup>

	<ItemGroup>
		<PackageReference Include="Realm" Version="11.3.0" />
	</ItemGroup>
</Project>

cs:

using MongoDB.Bson;
using Realms;

var config = new RealmConfiguration("Realm1.realm")
{
    Schema = new[]
    {
        typeof(Item)
    }
};
var realm = Realm.GetInstance(config);
var id = new ObjectId("64bb9508e033d8cfa91e66d3");
var item = realm.Find<Item>(id);
if (item is null)
{
    var testItem = new Item
    {
        Id = id,
        Name = "Do this thing",
        Status = "Open",
        Assignee = "Aimee"
    };
    realm.Write(() =>
    {
        item = realm.Add(testItem);
        Console.WriteLine($"[ Added ] {item.Name} : {item.Status} > {item.Assignee}");
    });
}
else
{
    Console.WriteLine($"{item.Name} : {item.Status} > {item.Assignee}");
}

public partial class Item : IRealmObject
{
    [PrimaryKey]
    [MapTo("_id")]
    public ObjectId Id { get; set; } = ObjectId.GenerateNewId();
    [MapTo("assignee")]
    public string? Assignee { get; set; }
    [MapTo("name")]
    public string? Name { get; set; }
    [MapTo("status")]
    public string? Status { get; set; }
}

Workaround: add the assembly to custom rd

add to csproj

	<ItemGroup>
		<RdXmlFile Include="Custom.rd.xml" />
	</ItemGroup>

Custom.rd.xml

<Directives>
	<Application>
		<Assembly Name="RealmAot1" Dynamic="Required All" />
	</Application>
</Directives>

After that works good! But using rd is considered as bad practice, ideally it should just work.

Also, generating native code step produces some warnings:

  Generating native code
\realm\11.3.0\lib\net6.0\Realm.dll : warning IL2104: Assembly 'Realm' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries
\mongodb.bson\2.19.1\lib\netstandard2.1\MongoDB.Bson.dll : warning IL3053: Assembly 'MongoDB.Bson' produced AOT analysis warnings.
\mongodb.bson\2.19.1\lib\netstandard2.1\MongoDB.Bson.dll : warning IL2104: Assembly 'MongoDB.Bson' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries
\runtime.win-x64.microsoft.dotnet.ilcompiler\7.0.8\framework\System.Linq.Expressions.dll : warning IL3053: Assembly 'System.Linq.Expressions' produced AOT analysis warnings.

How important is this improvement for you?

Would be a major improvement

Feature would mainly be used with

Local Database only

@charlesroddie
Copy link

charlesroddie commented Jan 20, 2024

We get these trim warnings from Realm:

2024-01-15T21:50:29.4408650Z ILC : Trim analysis warning IL2094: Realms.DataBinding.RealmObjectTypeDelegator.GetPropertyImpl(String,BindingFlags,Binder,Type,Type[],ParameterModifier[]): 'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the implicit 'this' parameter of method 'Realms.DataBinding.RealmObjectTypeDelegator.GetPropertyImpl(String,BindingFlags,Binder,Type,Type[],ParameterModifier[])' don't match overridden implicit 'this' parameter of method 'System.Type.GetPropertyImpl(String,BindingFlags,Binder,Type,Type[],ParameterModifier[])'. All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.
2024-01-15T21:50:30.1981240Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Extensions\ReflectionExtensions.cs(71): AOT analysis warning IL3050: Realms.ReflectionExtensions.GetEnumValues<T>(): Using member 'System.Enum.GetValues(Type)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. It might not be possible to create an array of the enum type at runtime. Use the GetValues<TEnum> overload or the GetValuesAsUnderlyingType method instead.
2024-01-15T21:50:30.2172320Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\InteropConfig.cs(135): Trim analysis warning IL2075: Realms.InteropConfig.<>c.<TryGetUWPFolder>b__11_0(): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String,BindingFlags)'. The return value of method 'System.Reflection.PropertyInfo.PropertyType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:30.2192080Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\InteropConfig.cs(105): Trim analysis warning IL2057: Realms.InteropConfig.TryInitializeUnity(): Unrecognized value passed to the parameter 'typeName' of method 'System.Type.GetType(String)'. It's not possible to guarantee the availability of the target type.
2024-01-15T21:50:30.2202740Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Linq\RealmResultsProvider.cs(54): AOT analysis warning IL3050: Realms.RealmResultsProvider.CreateQuery(Expression): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:30.2407570Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Linq\TypeSystem.cs(47): AOT analysis warning IL3050: Realms.TypeSystem.FindIEnumerable(Type): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:30.2411340Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Linq\TypeSystem.cs(62): Trim analysis warning IL2070: Realms.TypeSystem.FindIEnumerable(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The parameter 'seqType' of method 'Realms.TypeSystem.FindIEnumerable(Type)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:30.2415910Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Linq\TypeSystem.cs(53): AOT analysis warning IL3050: Realms.TypeSystem.<>c.<FindIEnumerable>b__1_1(Type): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:30.2741390Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Realm.cs(337): Trim analysis warning IL2072: Realms.Realm.CreateRealmObjectMetadata(ObjectSchema): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Activator.CreateInstance(Type)'. The return value of method 'Realms.WovenAttribute.HelperType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:30.2834790Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Schema\ObjectSchema.cs(261): Trim analysis warning IL2070: Realms.Schema.ObjectSchema.Builder.Builder(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields' in call to 'System.Type.GetField(String,BindingFlags)'. The parameter '#0' of method 'Realms.Schema.ObjectSchema.Builder.Builder(Type)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:30.2839130Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Schema\ObjectSchema.cs(275): Trim analysis warning IL2070: Realms.Schema.ObjectSchema.Builder.Builder(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Reflection.TypeInfo.DeclaredProperties.get'. The parameter '#0' of method 'Realms.Schema.ObjectSchema.Builder.Builder(Type)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:30.3046230Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Schema\Property.cs(422): Trim analysis warning IL2075: Realms.Schema.Property.FromPropertyInfo(PropertyInfo): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String)'. The return value of method 'System.Linq.Enumerable.Single<Type>(IEnumerable`1<Type>)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:30.3104310Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Schema\RealmSchema.cs(53): Trim analysis warning IL2026: Realms.Schema.RealmSchema.<>c.<.cctor>b__25_1(Assembly): Using member 'System.Reflection.Assembly.GetType(String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types might be removed.
2024-01-15T21:50:30.3108420Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Schema\RealmSchema.cs(53): Trim analysis warning IL2075: Realms.Schema.RealmSchema.<>c.<.cctor>b__25_1(Assembly): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'. The return value of method 'System.Reflection.Assembly.GetType(String)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:30.3553560Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Helpers\Argument.cs(55): Trim analysis warning IL2087: Realms.Helpers.Argument.Ensure<T>(Boolean,String): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'System.Activator.CreateInstance(Type,Object[])'. The generic parameter 'T' of 'Realms.Helpers.Argument.Ensure<T>(Boolean,String)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:30.3950540Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Dynamic\MetaRealmList.cs(40): Trim analysis warning IL2075: Realms.Dynamic.MetaRealmList.BindGetIndex(GetIndexBinder,DynamicMetaObject[]): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String)'. The return value of method 'System.Dynamic.DynamicMetaObject.LimitType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:30.4104130Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Dynamic\MetaRealmObject.cs(44): Trim analysis warning IL2060: Realms.Dynamic.MetaRealmObject..cctor(): Call to 'System.Reflection.MethodInfo.MakeGenericMethod(Type[])' can not be statically analyzed. It's not possible to guarantee the availability of requirements of the generic method.
2024-01-15T21:50:30.4105760Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Dynamic\MetaRealmObject.cs(44): AOT analysis warning IL3050: Realms.Dynamic.MetaRealmObject..cctor(): Using member 'System.Reflection.MethodInfo.MakeGenericMethod(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:30.4107140Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Dynamic\MetaRealmObject.cs(47): Trim analysis warning IL2060: Realms.Dynamic.MetaRealmObject..cctor(): Call to 'System.Reflection.MethodInfo.MakeGenericMethod(Type[])' can not be statically analyzed. It's not possible to guarantee the availability of requirements of the generic method.
2024-01-15T21:50:30.4108500Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Dynamic\MetaRealmObject.cs(47): AOT analysis warning IL3050: Realms.Dynamic.MetaRealmObject..cctor(): Using member 'System.Reflection.MethodInfo.MakeGenericMethod(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:30.8759840Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Dynamic\MetaRealmObject.cs(181): Trim analysis warning IL2060: Realms.Dynamic.MetaRealmObject.BindGetMember(GetMemberBinder): Call to 'System.Reflection.MethodInfo.MakeGenericMethod(Type[])' can not be statically analyzed. It's not possible to guarantee the availability of requirements of the generic method.
2024-01-15T21:50:30.8831220Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Dynamic\MetaRealmObject.cs(181): AOT analysis warning IL3050: Realms.Dynamic.MetaRealmObject.BindGetMember(GetMemberBinder): Using member 'System.Reflection.MethodInfo.MakeGenericMethod(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:30.8864980Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Dynamic\MetaRealmObject.cs(210): Trim analysis warning IL2060: Realms.Dynamic.MetaRealmObject.BindSetMember(SetMemberBinder,DynamicMetaObject): Call to 'System.Reflection.MethodInfo.MakeGenericMethod(Type[])' can not be statically analyzed. It's not possible to guarantee the availability of requirements of the generic method.
2024-01-15T21:50:30.8887790Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Dynamic\MetaRealmObject.cs(210): AOT analysis warning IL3050: Realms.Dynamic.MetaRealmObject.BindSetMember(SetMemberBinder,DynamicMetaObject): Using member 'System.Reflection.MethodInfo.MakeGenericMethod(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:30.8935120Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Dynamic\MetaRealmObject.cs(232): Trim analysis warning IL2103: Realms.Dynamic.MetaRealmObject.GetBindingRestrictions(Expression): Value passed to the '#1' parameter of method 'System.Linq.Expressions.Expression.Property(Expression,MethodInfo)' cannot be statically determined as a property accessor.
2024-01-15T21:50:31.1185290Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\DataBinding\RealmObjectTypeDelegator.cs(41): Trim analysis warning IL2085: Realms.DataBinding.RealmObjectTypeDelegator.GetPropertyImpl(String,BindingFlags,Binder,Type,Type[],ParameterModifier[]): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Reflection.TypeDelegator.GetPropertyImpl(String,BindingFlags,Binder,Type,Type[],ParameterModifier[])'. The implicit 'this' argument of method 'Realms.DataBinding.RealmObjectTypeDelegator.GetPropertyImpl(String,BindingFlags,Binder,Type,Type[],ParameterModifier[])' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:31.1237500Z D:\a\realm-dotnet\realm-dotnet\Realm\Realm\DataBinding\WovenGetterMethodInfo.cs(67): Trim analysis warning IL2072: Realms.DataBinding.WovenGetterMethodInfo.Invoke(Object,BindingFlags,Binder,Object[],CultureInfo): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Activator.CreateInstance(Type)'. The return value of method 'System.Reflection.MethodInfo.ReturnType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:34.8845340Z ILC : Trim analysis warning IL2090: MongoDB.Bson.Serialization.Serializers.EnumerableInterfaceImplementerSerializer`2.FinalizeResult(Object): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'System.Type.GetConstructors()'. The generic parameter 'TValue' of 'MongoDB.Bson.Serialization.Serializers.EnumerableInterfaceImplementerSerializer`2' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:34.8847870Z ILC : Trim analysis warning IL2090: MongoDB.Bson.Serialization.Serializers.EnumerableInterfaceImplementerSerializer`2.FinalizeResult(Object): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Type.GetConstructor(Type[])'. The generic parameter 'TValue' of 'MongoDB.Bson.Serialization.Serializers.EnumerableInterfaceImplementerSerializer`2' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:34.8849730Z ILC : Trim analysis warning IL2090: MongoDB.Bson.Serialization.Serializers.EnumerableInterfaceImplementerSerializer`2.FinalizeResult(Object): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String,Type[])'. The generic parameter 'TValue' of 'MongoDB.Bson.Serialization.Serializers.EnumerableInterfaceImplementerSerializer`2' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:35.0429230Z ILC : AOT analysis warning IL3050: MongoDB.Bson.Serialization.BsonClassMapSerializationProvider.GetSerializer(Type,IBsonSerializerRegistry): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:37.1139880Z ILC : Trim analysis warning IL2070: MongoDB.Bson.Serialization.BsonSerializationProviderBase.CreateSerializer(Type,IBsonSerializerRegistry): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'System.Type.GetConstructor(Type[])'. The parameter '#0' of method 'MongoDB.Bson.Serialization.BsonSerializationProviderBase.CreateSerializer(Type,IBsonSerializerRegistry)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:37.1143360Z ILC : Trim analysis warning IL2070: MongoDB.Bson.Serialization.BsonSerializationProviderBase.CreateSerializer(Type,IBsonSerializerRegistry): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Type.GetConstructor(Type[])'. The parameter '#0' of method 'MongoDB.Bson.Serialization.BsonSerializationProviderBase.CreateSerializer(Type,IBsonSerializerRegistry)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:37.1145380Z ILC : Trim analysis warning IL2055: MongoDB.Bson.Serialization.BsonSerializationProviderBase.CreateGenericSerializer(Type,Type[],IBsonSerializerRegistry): Call to 'System.Type.MakeGenericType(Type[])' can not be statically analyzed. It's not possible to guarantee the availability of requirements of the generic type.
2024-01-15T21:50:37.1147150Z ILC : AOT analysis warning IL3050: MongoDB.Bson.Serialization.BsonSerializationProviderBase.CreateGenericSerializer(Type,Type[],IBsonSerializerRegistry): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:37.1150890Z ILC : AOT analysis warning IL3050: MongoDB.Bson.Serialization.BsonClassMap.LookupClassMap(Type): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:37.1152830Z ILC : AOT analysis warning IL3050: MongoDB.Bson.Serialization.Serializers.IOrderedEnumerableSerializer.Create(IBsonSerializer,String): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:37.1155150Z ILC : AOT analysis warning IL3050: MongoDB.Bson.Serialization.CollectionsSerializationProvider.GetReadOnlyDictionarySerializer(Type,IBsonSerializerRegistry): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:37.1162420Z ILC : AOT analysis warning IL3050: MongoDB.Bson.Serialization.CollectionsSerializationProvider.GetReadOnlyDictionarySerializer(Type,IBsonSerializerRegistry): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:37.1168180Z ILC : AOT analysis warning IL3050: MongoDB.Bson.Serialization.CollectionsSerializationProvider.GetReadOnlyDictionarySerializer(Type,IBsonSerializerRegistry): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:37.1173130Z ILC : Trim analysis warning IL2070: MongoDB.Bson.Serialization.CollectionsSerializationProvider.GetCollectionSerializer(Type,IBsonSerializerRegistry): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The parameter '#0' of method 'MongoDB.Bson.Serialization.CollectionsSerializationProvider.GetCollectionSerializer(Type,IBsonSerializerRegistry)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:37.1177710Z ILC : AOT analysis warning IL3050: MongoDB.Bson.Serialization.CollectionsSerializationProvider.GetCollectionSerializer(Type,IBsonSerializerRegistry): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:37.1181930Z ILC : AOT analysis warning IL3050: MongoDB.Bson.Serialization.CollectionsSerializationProvider.GetCollectionSerializer(Type,IBsonSerializerRegistry): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:37.1187170Z ILC : AOT analysis warning IL3050: MongoDB.Bson.Serialization.CollectionsSerializationProvider.GetCollectionSerializer(Type,IBsonSerializerRegistry): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:37.1192660Z ILC : AOT analysis warning IL3050: MongoDB.Bson.Serialization.CollectionsSerializationProvider.GetCollectionSerializer(Type,IBsonSerializerRegistry): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:37.1198050Z ILC : AOT analysis warning IL3050: MongoDB.Bson.Serialization.CollectionsSerializationProvider.GetCollectionSerializer(Type,IBsonSerializerRegistry): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:37.1203940Z ILC : Trim analysis warning IL2055: MongoDB.Bson.Serialization.Attributes.BsonSerializerAttribute.CreateSerializer(Type): Call to 'System.Type.MakeGenericType(Type[])' can not be statically analyzed. It's not possible to guarantee the availability of requirements of the generic type.
2024-01-15T21:50:37.1208040Z ILC : AOT analysis warning IL3050: MongoDB.Bson.Serialization.Attributes.BsonSerializerAttribute.CreateSerializer(Type): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:37.1212510Z ILC : Trim analysis warning IL2077: MongoDB.Bson.Serialization.Attributes.BsonSerializerAttribute.CreateSerializer(Type): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Activator.CreateInstance(Type)'. The field 'MongoDB.Bson.Serialization.Attributes.BsonSerializerAttribute._serializerType' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:37.1216200Z ILC : Trim analysis warning IL2077: MongoDB.Bson.Serialization.Attributes.BsonSerializerAttribute.CreateSerializer(Type): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Activator.CreateInstance(Type)'. The field 'MongoDB.Bson.Serialization.Attributes.BsonSerializerAttribute._serializerType' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:37.3267130Z ILC : Trim analysis warning IL2057: MongoDB.Bson.Serialization.TypeNameDiscriminator.GetActualType(String): Unrecognized value passed to the parameter 'typeName' of method 'System.Type.GetType(String)'. It's not possible to guarantee the availability of the target type.
2024-01-15T21:50:37.3268440Z ILC : Trim analysis warning IL2026: MongoDB.Bson.Serialization.TypeNameDiscriminator.GetActualType(String): Using member 'System.Reflection.Assembly.GetType(String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types might be removed.
2024-01-15T21:50:37.3269620Z ILC : Trim analysis warning IL2055: MongoDB.Bson.Serialization.TypeNameDiscriminator.GetActualType(String): Call to 'System.Type.MakeGenericType(Type[])' can not be statically analyzed. It's not possible to guarantee the availability of requirements of the generic type.
2024-01-15T21:50:37.3270990Z ILC : AOT analysis warning IL3050: MongoDB.Bson.Serialization.TypeNameDiscriminator.GetActualType(String): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:37.3308720Z ILC : Trim analysis warning IL2070: MongoDB.Bson.Serialization.CollectionsSerializationProvider.GetImplementedInterfaces(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The parameter '#0' of method 'MongoDB.Bson.Serialization.CollectionsSerializationProvider.GetImplementedInterfaces(Type)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:37.3311460Z ILC : Trim analysis warning IL2070: MongoDB.Bson.Serialization.CollectionsSerializationProvider.GetImplementedInterfaces(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The parameter '#0' of method 'MongoDB.Bson.Serialization.CollectionsSerializationProvider.GetImplementedInterfaces(Type)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:38.9953160Z ILC : Trim analysis warning IL2072: MongoDB.Bson.Serialization.BsonClassMapSerializer`1.DeserializeExtraElementMember(BsonDeserializationContext,Object,String,BsonMemberMap): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Activator.CreateInstance(Type)'. The return value of method 'MongoDB.Bson.Serialization.BsonMemberMap.MemberType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:38.9956000Z ILC : Trim analysis warning IL2072: MongoDB.Bson.Serialization.BsonClassMapSerializer`1.DeserializeExtraElementValue(BsonDeserializationContext,Dictionary`2<String,Object>,String,BsonMemberMap): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Activator.CreateInstance(Type)'. The return value of method 'MongoDB.Bson.Serialization.BsonMemberMap.MemberType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:39.2419070Z ILC : Trim analysis warning IL2080: MongoDB.Bson.Serialization.BsonClassMap.GetCreator(): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Type.GetConstructors(BindingFlags)'. The field 'MongoDB.Bson.Serialization.BsonClassMap._classType' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:39.2421210Z ILC : Trim analysis warning IL2077: MongoDB.Bson.Serialization.BsonClassMap.<GetCreator>b__118_2(): '' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Runtime.Serialization.FormatterServices.GetUninitializedObject(Type)'. The field 'MongoDB.Bson.Serialization.BsonClassMap._classType' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:39.2423220Z ILC : AOT analysis warning IL3050: MongoDB.Bson.Serialization.BsonMemberMap.GetSerializer(): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:40.9721270Z /Users/runner/work/1/s/LocalDbTypesQueries/QueriesActivities.cs(84): Trim analysis warning IL2103: LocalDbTypesQueries.Activities.GetActivity(Activity): Value passed to the '#1' parameter of method 'System.Linq.Expressions.Expression.Property(Expression,MethodInfo)' cannot be statically determined as a property accessor.
2024-01-15T21:50:40.9722980Z /Users/runner/work/1/s/LocalDbTypesQueries/QueriesActivities.cs(89): Trim analysis warning IL2103: LocalDbTypesQueries.Activities.GetActivity(Activity): Value passed to the '#1' parameter of method 'System.Linq.Expressions.Expression.Property(Expression,MethodInfo)' cannot be statically determined as a property accessor.
2024-01-15T21:50:40.9724290Z /Users/runner/work/1/s/LocalDbTypesQueries/QueriesActivities.cs(89): Trim analysis warning IL2103: LocalDbTypesQueries.Activities.GetActivity(Activity): Value passed to the '#1' parameter of method 'System.Linq.Expressions.Expression.Property(Expression,MethodInfo)' cannot be statically determined as a property accessor.
2024-01-15T21:50:40.9725590Z /Users/runner/work/1/s/LocalDbTypesQueries/QueriesActivities.cs(94): Trim analysis warning IL2103: LocalDbTypesQueries.Activities.GetActivity(Activity): Value passed to the '#1' parameter of method 'System.Linq.Expressions.Expression.Property(Expression,MethodInfo)' cannot be statically determined as a property accessor.
2024-01-15T21:50:40.9726860Z /Users/runner/work/1/s/LocalDbTypesQueries/QueriesActivities.cs(94): Trim analysis warning IL2103: LocalDbTypesQueries.Activities.GetActivity(Activity): Value passed to the '#1' parameter of method 'System.Linq.Expressions.Expression.Property(Expression,MethodInfo)' cannot be statically determined as a property accessor.
2024-01-15T21:50:43.1155220Z ILC : Trim analysis warning IL2080: MongoDB.Bson.Serialization.BsonClassMap.GetShouldSerializeMethod(MemberInfo): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String,Type[])'. The field 'MongoDB.Bson.Serialization.BsonClassMap._classType' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:43.1342770Z ILC : Trim analysis warning IL2072: MongoDB.Bson.BsonTypeMapper.MapToDotNetValue(BsonValue,BsonTypeMapperOptions): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Activator.CreateInstance(Type)'. The return value of method 'MongoDB.Bson.BsonTypeMapperOptions.MapBsonArrayTo.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:43.1347040Z ILC : Trim analysis warning IL2072: MongoDB.Bson.BsonTypeMapper.MapToDotNetValue(BsonValue,BsonTypeMapperOptions): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Activator.CreateInstance(Type)'. The return value of method 'MongoDB.Bson.BsonTypeMapperOptions.MapBsonArrayTo.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:43.1350010Z ILC : Trim analysis warning IL2072: MongoDB.Bson.BsonTypeMapper.MapToDotNetValue(BsonValue,BsonTypeMapperOptions): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Activator.CreateInstance(Type)'. The return value of method 'MongoDB.Bson.BsonTypeMapperOptions.MapBsonDocumentTo.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:43.1352940Z ILC : Trim analysis warning IL2072: MongoDB.Bson.BsonTypeMapper.MapToDotNetValue(BsonValue,BsonTypeMapperOptions): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Activator.CreateInstance(Type)'. The return value of method 'MongoDB.Bson.BsonTypeMapperOptions.MapBsonDocumentTo.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:49.2522500Z ILC : Trim analysis warning IL2075: MongoDB.Bson.Serialization.Conventions.ReadWriteMemberFinderConvention.Apply(BsonClassMap): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetFields(BindingFlags)'. The return value of method 'MongoDB.Bson.Serialization.BsonClassMap.ClassType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:49.2525720Z ILC : Trim analysis warning IL2075: MongoDB.Bson.Serialization.Conventions.ReadWriteMemberFinderConvention.Apply(BsonClassMap): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Type.GetProperties(BindingFlags)'. The return value of method 'MongoDB.Bson.Serialization.BsonClassMap.ClassType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:49.2529880Z ILC : Trim analysis warning IL2075: MongoDB.Bson.Serialization.Conventions.NamedIdMemberConvention.Apply(BsonClassMap): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors', 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods', 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields', 'DynamicallyAccessedMemberTypes.PublicNestedTypes', 'DynamicallyAccessedMemberTypes.NonPublicNestedTypes', 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties', 'DynamicallyAccessedMemberTypes.PublicEvents', 'DynamicallyAccessedMemberTypes.NonPublicEvents' in call to 'System.Type.GetMember(String,MemberTypes,BindingFlags)'. The return value of method 'MongoDB.Bson.Serialization.BsonClassMap.ClassType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:49.2535350Z ILC : Trim analysis warning IL2075: MongoDB.Bson.Serialization.Conventions.NamedExtraElementsMemberConvention.Apply(BsonClassMap): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors', 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods', 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields', 'DynamicallyAccessedMemberTypes.PublicNestedTypes', 'DynamicallyAccessedMemberTypes.NonPublicNestedTypes', 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties', 'DynamicallyAccessedMemberTypes.PublicEvents', 'DynamicallyAccessedMemberTypes.NonPublicEvents' in call to 'System.Type.GetMember(String,MemberTypes,BindingFlags)'. The return value of method 'MongoDB.Bson.Serialization.BsonClassMap.ClassType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:49.2559660Z ILC : Trim analysis warning IL2075: MongoDB.Bson.Serialization.Conventions.ImmutableTypeClassMapConvention.Apply(BsonClassMap): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Type.GetConstructor(Type[])'. The return value of method 'MongoDB.Bson.Serialization.BsonClassMap.ClassType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:49.2561700Z ILC : Trim analysis warning IL2075: MongoDB.Bson.Serialization.Conventions.ImmutableTypeClassMapConvention.Apply(BsonClassMap): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperties(BindingFlags)'. The return value of method 'MongoDB.Bson.Serialization.BsonClassMap.ClassType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:49.6488270Z ILC : AOT analysis warning IL3050: MongoDB.Bson.Serialization.BsonSerializer.LookupIdGenerator(Type): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:49.6489910Z ILC : Trim analysis warning IL2070: MongoDB.Bson.Serialization.BsonSerializer.LookupIdGenerator(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Type.MakeGenericType(Type[])'. The parameter '#0' of method 'MongoDB.Bson.Serialization.BsonSerializer.LookupIdGenerator(Type)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:49.6491340Z ILC : AOT analysis warning IL3050: MongoDB.Bson.Serialization.BsonSerializer.LookupIdGenerator(Type): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
2024-01-15T21:50:49.6493050Z ILC : Trim analysis warning IL2070: MongoDB.Bson.Serialization.Conventions.ImmutableTypeClassMapConvention.GetUsableConstructors(TypeInfo): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Type.GetConstructors(BindingFlags)'. The parameter '#0' of method 'MongoDB.Bson.Serialization.Conventions.ImmutableTypeClassMapConvention.GetUsableConstructors(TypeInfo)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:49.6541920Z ILC : Trim analysis warning IL2075: MongoDB.Bson.Serialization.Conventions.AttributeConventionPack.AttributeConvention.OptInMembersWithBsonMemberMapModifierAttribute(BsonClassMap): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetFields(BindingFlags)'. The return value of method 'MongoDB.Bson.Serialization.BsonClassMap.ClassType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:49.6546050Z ILC : Trim analysis warning IL2075: MongoDB.Bson.Serialization.Conventions.AttributeConventionPack.AttributeConvention.OptInMembersWithBsonMemberMapModifierAttribute(BsonClassMap): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Type.GetProperties(BindingFlags)'. The return value of method 'MongoDB.Bson.Serialization.BsonClassMap.ClassType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:49.6548440Z ILC : Trim analysis warning IL2075: MongoDB.Bson.Serialization.Conventions.AttributeConventionPack.AttributeConvention.OptInMembersWithBsonCreatorMapModifierAttribute(BsonClassMap): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Type.GetConstructors(BindingFlags)'. The return value of method 'MongoDB.Bson.Serialization.BsonClassMap.ClassType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:49.6550600Z ILC : Trim analysis warning IL2075: MongoDB.Bson.Serialization.Conventions.AttributeConventionPack.AttributeConvention.OptInMembersWithBsonCreatorMapModifierAttribute(BsonClassMap): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethods(BindingFlags)'. The return value of method 'MongoDB.Bson.Serialization.BsonClassMap.ClassType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:51.6018620Z ILC : Trim analysis warning IL2070: MongoDB.Bson.Serialization.Conventions.NamedParameterCreatorMapConvention.Match(Type,MemberTypes,BindingFlags,ParameterInfo): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors', 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods', 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields', 'DynamicallyAccessedMemberTypes.PublicNestedTypes', 'DynamicallyAccessedMemberTypes.NonPublicNestedTypes', 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties', 'DynamicallyAccessedMemberTypes.PublicEvents', 'DynamicallyAccessedMemberTypes.NonPublicEvents' in call to 'System.Type.GetMember(String,MemberTypes,BindingFlags)'. The parameter '#0' of method 'MongoDB.Bson.Serialization.Conventions.NamedParameterCreatorMapConvention.Match(Type,MemberTypes,BindingFlags,ParameterInfo)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:54.2689270Z ILC : Trim analysis warning IL2067: MongoDB.Bson.Serialization.BsonMemberMap.GetDefaultValue(Type): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Activator.CreateInstance(Type)'. The parameter '#0' of method 'MongoDB.Bson.Serialization.BsonMemberMap.GetDefaultValue(Type)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
2024-01-15T21:50:32.7697420Z ILC : Trim analysis warning IL2026: Remotion.Linq.Parsing.RelinqExpressionVisitor.VisitNew(NewExpression): Using member 'System.Linq.Expressions.Expression.New(ConstructorInfo,IEnumerable`1<Expression>,IEnumerable`1<MemberInfo>)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The Property metadata or other accessor may be trimmed.

@nirinchev
Copy link
Member

Some of these are legitimate warnings, while others are warning about functionality that inherently relies on reflection to work correctly. I don't imagine we'll ever be able to get rid of all of them, but we can take a look and see if we can mitigate some of them. As a side note, as long as you don't use dynamic code (Realm.Dynamic or RealmObject.Dynamic) and you use generated classes rather than woven ones (i.e. your models inherit from IRealmObject rather than RealmObject), you should not be exercising the codepaths the static analysis warns you about.

@charlesroddie
Copy link

@nirinchev Solving this doesn't require fixing all of these methods, but marking them as trim-incompatible by adding <IsTrimmable>true</IsTrimmable>. As per https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/fixing-warnings (except that page is out of date - don't need a test project to test this, only a single line in any relevant project which has a dotnet6+ target). Then user code which doesn't reference unsafe methods won't see warnings. Hopefully the paths that need trim-unsafe reflection can be separated from the paths that don't as you suggest.

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

No branches or pull requests

3 participants