Closed
Description
Enabling warnings for NativeAOT reports some warnings. We should fix these.
Keeping a list of each of them individually, so they can also be fixed individually.
Ref: #18571.
- ObjCRuntime/Blocks.cs(502,4): Trim analysis warning IL2075: ObjCRuntime.BlockLiteral.GetBlockForDelegate(MethodInfo, Object, UInt32, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags)'. The return value of method 'ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&)' 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.
- ObjCRuntime/Blocks.cs(507,4): Trim analysis warning IL2075: ObjCRuntime.BlockLiteral.GetBlockForDelegate(MethodInfo, Object, UInt32, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetField(String, BindingFlags)'. The return value of method 'ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&)' 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.
- ObjCRuntime/Blocks.cs(415,26): Trim analysis warning IL2075: ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The return value of method 'System.Reflection.MemberInfo.DeclaringType.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.
- ObjCRuntime/Blocks.cs(419,5): Trim analysis warning IL2062: ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&): Value passed to parameter 'interfaceType' of method 'System.Type.GetInterfaceMap(Type)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements.
- Foundation/NSObject2.cs(236,4): Trim analysis warning IL2087: Foundation.NSObject.AllocateNSObject(IntPtr): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Runtime.CompilerServices.RuntimeHelpers.GetUninitializedObject(Type)'. The generic parameter 'T' of 'Foundation.NSObject.AllocateNSObject(IntPtr)' 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.
- Foundation/NSObject2.cs(247,5): Trim analysis warning IL2072: Foundation.NSObject.CreateNSObject(IntPtr, IntPtr, NSObject.Flags): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Runtime.CompilerServices.RuntimeHelpers.GetUninitializedObject(Type)'. The return value of method 'ObjCRuntime.Runtime.GetGCHandleTarget(IntPtr)' 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.
- ObjCRuntime/Runtime.CoreCLR.cs(267,4): Trim analysis warning IL2026: ObjCRuntime.Runtime.FindAssembly(IntPtr): Using member 'System.Reflection.Assembly.LoadFrom(String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types and members the loaded assembly depends on might be removed.
- ObjCRuntime/Runtime.cs(2202,23): Trim analysis warning IL2070: ObjCRuntime.Runtime.FindClosedMethod(Type, MethodBase): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethods(BindingFlags)'. The parameter 'closed_type' of method 'ObjCRuntime.Runtime.FindClosedMethod(Type, MethodBase)' 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.
- ObjCRuntime/Runtime.cs(1219,23): Trim analysis warning IL2075: ObjCRuntime.Runtime.FindPropertyInfo(MethodInfo): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperties()'. The return value of method 'System.Reflection.MemberInfo.DeclaringType.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.
- ObjCRuntime/Runtime.cs(1458,4): Trim analysis warning IL2070: ObjCRuntime.Runtime.GetIntPtr_BoolConstructor(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Type.GetConstructors(BindingFlags)'. The parameter 'type' of method 'ObjCRuntime.Runtime.GetIntPtr_BoolConstructor(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.
- ObjCRuntime/Runtime.cs(1413,4): Trim analysis warning IL2070: ObjCRuntime.Runtime.GetIntPtrConstructor(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Type.GetConstructors(BindingFlags)'. The parameter 'type' of method 'ObjCRuntime.Runtime.GetIntPtrConstructor(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.
- ObjCRuntime/Runtime.CoreCLR.cs(171,5): Trim analysis warning IL2026: ObjCRuntime.Runtime.ResolvingEventHandler(AssemblyLoadContext, AssemblyName): Using member 'System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types and members the loaded assembly depends on might be removed.
- Foundation/NSObject2.cs(236): Trim analysis warning IL2087: Foundation.NSObject.AllocateNSObject(IntPtr): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Runtime.CompilerServices.RuntimeHelpers.GetUninitializedObject(Type)'. The generic parameter 'T' of 'Foundation.NSObject.AllocateNSObject(IntPtr)' 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.
- Foundation/NSObject2.cs(247): Trim analysis warning IL2072: Foundation.NSObject.CreateNSObject(IntPtr,IntPtr,NSObject.Flags): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Runtime.CompilerServices.RuntimeHelpers.GetUninitializedObject(Type)'. The return value of method 'ObjCRuntime.Runtime.GetGCHandleTarget(IntPtr)' 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.
- ObjCRuntime/Runtime.CoreCLR.cs(171): Trim analysis warning IL2026: ObjCRuntime.Runtime.ResolvingEventHandler(AssemblyLoadContext,AssemblyName): Using member 'System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types and members the loaded assembly depends on might be removed.
- ObjCRuntime/Runtime.CoreCLR.cs(267): Trim analysis warning IL2026: ObjCRuntime.Runtime.FindAssembly(IntPtr): Using member 'System.Reflection.Assembly.LoadFrom(String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types and members the loaded assembly depends on might be removed.
- ObjCRuntime/Runtime.CoreCLR.cs(471): AOT analysis warning IL3050: ObjCRuntime.Runtime.StructureToPtr(Object,IntPtr): Using member 'System.Runtime.InteropServices.Marshal.StructureToPtr(Object,IntPtr,Boolean)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. Marshalling code for the object might not be available. Use the StructureToPtr overload instead.
- ObjCRuntime/Runtime.CoreCLR.cs(640): AOT analysis warning IL3050: ObjCRuntime.Runtime.SizeOf(Type): Using member 'System.Runtime.InteropServices.Marshal.SizeOf(Type)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. Marshalling code for the object might not be available. Use the SizeOf overload instead.
- ObjCRuntime/Runtime.CoreCLR.cs(827): AOT analysis warning IL3050: ObjCRuntime.Runtime.CreateArray(Runtime.MonoObject*,UInt64): Using member 'System.Array.CreateInstance(Type,Int32)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The code for an array of the specified type might not be available.
- ObjCRuntime/Runtime.CoreCLR.cs(952): AOT analysis warning IL3050: ObjCRuntime.Runtime.PtrToStructure(IntPtr,Type): Using member 'System.Runtime.InteropServices.Marshal.PtrToStructure(IntPtr,Type)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. Marshalling code for the object might not be available.
- ObjCRuntime/Runtime.cs(1106): AOT analysis warning IL3050: ObjCRuntime.Runtime.GetDelegateForBlock(IntPtr,Type): Using member 'System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointer(IntPtr,Type)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. Marshalling code for the delegate might not be available. Use the GetDelegateForFunctionPointer overload instead.
- ObjCRuntime/Runtime.cs(1219): Trim analysis warning IL2075: ObjCRuntime.Runtime.FindPropertyInfo(MethodInfo): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperties()'. The return value of method 'System.Reflection.MemberInfo.DeclaringType.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.
- ObjCRuntime/Runtime.cs(1413): Trim analysis warning IL2070: ObjCRuntime.Runtime.GetIntPtrConstructor(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Type.GetConstructors(BindingFlags)'. The parameter '#0' of method 'ObjCRuntime.Runtime.GetIntPtrConstructor(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.
- ObjCRuntime/Runtime.cs(1458): Trim analysis warning IL2070: ObjCRuntime.Runtime.GetIntPtr_BoolConstructor(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Type.GetConstructors(BindingFlags)'. The parameter '#0' of method 'ObjCRuntime.Runtime.GetIntPtr_BoolConstructor(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.
- ObjCRuntime/Runtime.cs(2202): Trim analysis warning IL2070: ObjCRuntime.Runtime.FindClosedMethod(Type,MethodBase): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethods(BindingFlags)'. The parameter '#0' of method 'ObjCRuntime.Runtime.FindClosedMethod(Type,MethodBase)' 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.
- ObjCRuntime/Blocks.cs(223): AOT analysis warning IL3050: ObjCRuntime.BlockLiteral.SetupBlockImpl(Delegate,Delegate,Boolean,Byte[]): Using member 'System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(Delegate)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. Marshalling code for the delegate might not be available. Use the GetFunctionPointerForDelegate overload instead.
- ObjCRuntime/Blocks.cs(415): Trim analysis warning IL2075: ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo,UInt32,MethodInfo&): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The return value of method 'System.Reflection.MemberInfo.DeclaringType.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.
- ObjCRuntime/Blocks.cs(419): Trim analysis warning IL2062: ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo,UInt32,MethodInfo&): Value passed to parameter 'interfaceType' of method 'System.Type.GetInterfaceMap(Type)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements.
- ObjCRuntime/Blocks.cs(502): Trim analysis warning IL2075: ObjCRuntime.BlockLiteral.GetBlockForDelegate(MethodInfo,Object,UInt32,String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethod(String,BindingFlags)'. The return value of method 'ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo,UInt32,MethodInfo&)' 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.
- ObjCRuntime/Blocks.cs(507): Trim analysis warning IL2075: ObjCRuntime.BlockLiteral.GetBlockForDelegate(MethodInfo,Object,UInt32,String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetField(String,BindingFlags)'. The return value of method 'ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo,UInt32,MethodInfo&)' 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.
- ObjCRuntime/Runtime.CoreCLR.cs(450): AOT analysis warning IL3050: ObjCRuntime.Runtime.MarshalStructure(!!0): Using member 'System.Runtime.InteropServices.Marshal.SizeOf(Type)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. Marshalling code for the object might not be available. Use the SizeOf overload instead.