From da2525b7fb9e852717574c7a88a137c723c4b592 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 16 Feb 2024 16:53:12 +0100 Subject: [PATCH] [tests] Add test to keep track of trimmer warnings. (#20125) Add test to keep track of trimmer warnings and to make sure we don't accidentally introduce new ones. Ref: https://github.com/xamarin/xamarin-macios/issues/10405 --- tests/common/BinLog.cs | 17 + tests/dotnet/UnitTests/Extensions.cs | 67 ++++ tests/dotnet/UnitTests/TrimmerWarningsTest.cs | 336 ++++++++++++++++++ 3 files changed, 420 insertions(+) create mode 100644 tests/dotnet/UnitTests/TrimmerWarningsTest.cs diff --git a/tests/common/BinLog.cs b/tests/common/BinLog.cs index 4abda3d95d0..f1ddbaba860 100644 --- a/tests/common/BinLog.cs +++ b/tests/common/BinLog.cs @@ -27,6 +27,23 @@ public class BuildLogEvent { public string? ProjectFile; public string? Message; + public BuildLogEvent Clone () + { + var rv = new BuildLogEvent { + Type = Type, + ColumnNumber = ColumnNumber, + EndColumnNumber = EndColumnNumber, + LineNumber = LineNumber, + EndLineNumber = EndLineNumber, + Code = Code, + SubCategory = SubCategory, + File = File, + ProjectFile = ProjectFile, + Message = Message + }; + return rv; + } + public override string ToString () { var rv = new StringBuilder (); diff --git a/tests/dotnet/UnitTests/Extensions.cs b/tests/dotnet/UnitTests/Extensions.cs index c595a3044b7..67940c0b41f 100644 --- a/tests/dotnet/UnitTests/Extensions.cs +++ b/tests/dotnet/UnitTests/Extensions.cs @@ -14,5 +14,72 @@ public static void AssertNoWarnings (this ExecutionResult result, Func v.ToString ()))}"); } + + public static void AssertWarnings (this IEnumerable actualWarnings, IEnumerable expectedWarnings) + { + // Source paths may be full (and local) paths. So make full paths relative to the root of the repository. + actualWarnings = actualWarnings.Select (w => { + if (w.File?.StartsWith (Configuration.SourceRoot) == true) { + var rv = w.Clone (); + rv.File = w.File [(Configuration.SourceRoot.Length + 1)..]; + return rv; + } + return w; + }); + + var newWarnings = actualWarnings.Where (v => !expectedWarnings.Any (x => x.IsMatch (v))).ToArray (); + var missingWarnings = expectedWarnings.Where (v => !actualWarnings.Any (x => v.IsMatch (x))).ToArray (); + + if (newWarnings.Length == 0 && missingWarnings.Length == 0) + return; + + var sb = new StringBuilder (); + sb.AppendLine ($"\t\t\t\texpectedWarnings = new ExpectedBuildMessage [] {{"); + foreach (var w in actualWarnings.OrderBy (v => v.File).ThenBy (v => v.Message)) { + sb.AppendLine ($"\t\t\t\t\tnew ExpectedBuildMessage (\"{w.File}\" /* line {w.LineNumber} */, \"{w.Message}\"),"); + } + sb.AppendLine ($"\t\t\t\t}};"); + if (newWarnings.Length > 0) { + Console.WriteLine ($"Got {newWarnings.Length} new warnings:"); + Console.WriteLine (); + foreach (var evt in newWarnings) + Console.WriteLine ($" {evt.File}:{evt.LineNumber} {evt.Message}"); + } + if (missingWarnings.Length > 0) { + Console.WriteLine ($"Did not get {missingWarnings.Length} missing warnings:"); + Console.WriteLine (); + foreach (var evt in missingWarnings) + Console.WriteLine ($" {evt.File}: {evt.Message}"); + } + Console.WriteLine ($"If this is expected, here's the updated list of expected warnings:"); + Console.WriteLine (sb); + Assert.That (newWarnings, Is.Empty, "New warnings"); + Assert.That (missingWarnings, Is.Empty, "Empty warnings"); + } + } + + public class ExpectedBuildMessage { + public string File; + public string Message; + + public ExpectedBuildMessage (string file, string message) + { + File = file; + Message = message; + } + + public bool IsMatch (BuildLogEvent evt) + { + if (evt.Message != Message) + return false; + if (evt.File != File) + return false; + return true; + } + + public override string? ToString () + { + return $"{File}: {Message}"; + } } } diff --git a/tests/dotnet/UnitTests/TrimmerWarningsTest.cs b/tests/dotnet/UnitTests/TrimmerWarningsTest.cs new file mode 100644 index 00000000000..ae1f2cde703 --- /dev/null +++ b/tests/dotnet/UnitTests/TrimmerWarningsTest.cs @@ -0,0 +1,336 @@ +namespace Xamarin.Tests { + [TestFixture] + public class TrimmerWarningsTest : TestBaseClass { + [Test] + [TestCase (ApplePlatform.iOS, "ios-arm64")] + [TestCase (ApplePlatform.MacOSX, "osx-x64")] + [TestCase (ApplePlatform.MacCatalyst, "maccatalyst-arm64")] + [TestCase (ApplePlatform.TVOS, "tvossimulator-x64")] + public void TrimmerWarningsManagedStaticRegistrar (ApplePlatform platform, string runtimeIdentifiers) + { + ExpectedBuildMessage [] expectedWarnings; + switch (platform) { + case ApplePlatform.iOS: + case ApplePlatform.TVOS: + expectedWarnings = new ExpectedBuildMessage [] { + new ExpectedBuildMessage ("ILLink" /* line 0 */, "Internal.Runtime.InteropServices.ComponentActivator.GetFunctionPointer(IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr): Using member 'Internal.Runtime.InteropServices.ComponentActivator.InternalGetFunctionPointer(AssemblyLoadContext, String, String, IntPtr)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Native hosting is not trim compatible and this warning will be seen if trimming is enabled. https://aka.ms/dotnet-illink/nativehost"), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 520 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 515 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 423 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 427 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 2434 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1279 */, "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."), + }; + break; + case ApplePlatform.MacOSX: + expectedWarnings = new ExpectedBuildMessage [] { + new ExpectedBuildMessage ("ILLink" /* line 0 */, "Internal.Runtime.InteropServices.ComponentActivator.GetFunctionPointer(IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr): Using member 'Internal.Runtime.InteropServices.ComponentActivator.InternalGetFunctionPointer(AssemblyLoadContext, String, String, IntPtr)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Native hosting is not trim compatible and this warning will be seen if trimming is enabled. https://aka.ms/dotnet-illink/nativehost"), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 520 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 515 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 423 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 427 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.CoreCLR.cs" /* line 276 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.CoreCLR.cs" /* line 177 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 714 */, "ObjCRuntime.Runtime.CollectReferencedAssemblies(List, Assembly): Using member 'System.Reflection.Assembly.GetReferencedAssemblies()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Assembly references might be removed."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 2434 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1279 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 648 */, "ObjCRuntime.Runtime.GetEntryAssembly(): Using member 'System.Reflection.Assembly.LoadFile(String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types and members the loaded assembly depends on might be removed."), + }; + break; + case ApplePlatform.MacCatalyst: + expectedWarnings = new ExpectedBuildMessage [] { + new ExpectedBuildMessage ("ILLink" /* line 0 */, "Internal.Runtime.InteropServices.ComponentActivator.GetFunctionPointer(IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr): Using member 'Internal.Runtime.InteropServices.ComponentActivator.InternalGetFunctionPointer(AssemblyLoadContext, String, String, IntPtr)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Native hosting is not trim compatible and this warning will be seen if trimming is enabled. https://aka.ms/dotnet-illink/nativehost"), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 520 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 515 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 423 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 427 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 2434 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1279 */, "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."), + }; + break; + default: + Assert.Fail ($"Unknown platform: {platform}"); + return; + } + TrimmerWarnings (platform, runtimeIdentifiers, "managed-static", expectedWarnings); + } + + [Test] + [TestCase (ApplePlatform.iOS, "iossimulator-arm64")] + [TestCase (ApplePlatform.MacOSX, "osx-arm64")] + [TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64")] + [TestCase (ApplePlatform.TVOS, "tvos-arm64")] + public void TrimmerWarningsStaticRegistrar (ApplePlatform platform, string runtimeIdentifiers) + { + ExpectedBuildMessage [] expectedWarnings; + switch (platform) { + case ApplePlatform.iOS: + case ApplePlatform.TVOS: + expectedWarnings = new ExpectedBuildMessage [] { + new ExpectedBuildMessage ("ILLink" /* line 0 */, "Internal.Runtime.InteropServices.ComponentActivator.GetFunctionPointer(IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr): Using member 'Internal.Runtime.InteropServices.ComponentActivator.InternalGetFunctionPointer(AssemblyLoadContext, String, String, IntPtr)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Native hosting is not trim compatible and this warning will be seen if trimming is enabled. https://aka.ms/dotnet-illink/nativehost"), + new ExpectedBuildMessage ("src/Foundation/NSObject2.cs" /* line 266 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 520 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 515 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 423 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 427 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Class.cs" /* line 541 */, "ObjCRuntime.Class.ResolveToken(Assembly, Module, UInt32): Using member 'System.Reflection.Module.ResolveMethod(Int32)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimming changes metadata tokens."), + new ExpectedBuildMessage ("src/ObjCRuntime/Class.cs" /* line 528 */, "ObjCRuntime.Class.ResolveToken(Assembly, Module, UInt32): Using member 'System.Reflection.Module.ResolveType(Int32)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimming changes metadata tokens."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 2434 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1279 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1673 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1623 */, "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."), + }; + break; + case ApplePlatform.MacOSX: + expectedWarnings = new ExpectedBuildMessage [] { + new ExpectedBuildMessage ("ILLink" /* line 0 */, "Internal.Runtime.InteropServices.ComponentActivator.GetFunctionPointer(IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr): Using member 'Internal.Runtime.InteropServices.ComponentActivator.InternalGetFunctionPointer(AssemblyLoadContext, String, String, IntPtr)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Native hosting is not trim compatible and this warning will be seen if trimming is enabled. https://aka.ms/dotnet-illink/nativehost"), + new ExpectedBuildMessage ("src/Foundation/NSObject2.cs" /* line 266 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 520 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 515 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 423 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 427 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Class.cs" /* line 541 */, "ObjCRuntime.Class.ResolveToken(Assembly, Module, UInt32): Using member 'System.Reflection.Module.ResolveMethod(Int32)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimming changes metadata tokens."), + new ExpectedBuildMessage ("src/ObjCRuntime/Class.cs" /* line 528 */, "ObjCRuntime.Class.ResolveToken(Assembly, Module, UInt32): Using member 'System.Reflection.Module.ResolveType(Int32)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimming changes metadata tokens."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.CoreCLR.cs" /* line 276 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.CoreCLR.cs" /* line 177 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 714 */, "ObjCRuntime.Runtime.CollectReferencedAssemblies(List, Assembly): Using member 'System.Reflection.Assembly.GetReferencedAssemblies()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Assembly references might be removed."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 2434 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1279 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 648 */, "ObjCRuntime.Runtime.GetEntryAssembly(): Using member 'System.Reflection.Assembly.LoadFile(String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types and members the loaded assembly depends on might be removed."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1673 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1623 */, "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."), + }; + break; + case ApplePlatform.MacCatalyst: + expectedWarnings = new ExpectedBuildMessage [] { + new ExpectedBuildMessage ("ILLink" /* line 0 */, "Internal.Runtime.InteropServices.ComponentActivator.GetFunctionPointer(IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr): Using member 'Internal.Runtime.InteropServices.ComponentActivator.InternalGetFunctionPointer(AssemblyLoadContext, String, String, IntPtr)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Native hosting is not trim compatible and this warning will be seen if trimming is enabled. https://aka.ms/dotnet-illink/nativehost"), + new ExpectedBuildMessage ("src/Foundation/NSObject2.cs" /* line 266 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 520 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 515 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 423 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 427 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Class.cs" /* line 541 */, "ObjCRuntime.Class.ResolveToken(Assembly, Module, UInt32): Using member 'System.Reflection.Module.ResolveMethod(Int32)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimming changes metadata tokens."), + new ExpectedBuildMessage ("src/ObjCRuntime/Class.cs" /* line 528 */, "ObjCRuntime.Class.ResolveToken(Assembly, Module, UInt32): Using member 'System.Reflection.Module.ResolveType(Int32)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimming changes metadata tokens."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 2434 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1279 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1673 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1623 */, "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."), + }; + break; + default: + Assert.Fail ($"Unknown platform: {platform}"); + return; + } + + TrimmerWarnings (platform, runtimeIdentifiers, "static", expectedWarnings); + } + + [Test] + [TestCase (ApplePlatform.iOS, "iossimulator-arm64")] + [TestCase (ApplePlatform.MacOSX, "osx-arm64")] + [TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64")] + [TestCase (ApplePlatform.TVOS, "tvos-arm64")] + public void TrimmerWarningsDynamicRegistrar (ApplePlatform platform, string runtimeIdentifiers) + { + ExpectedBuildMessage [] expectedWarnings; + switch (platform) { + case ApplePlatform.iOS: + case ApplePlatform.TVOS: + expectedWarnings = new ExpectedBuildMessage [] { + new ExpectedBuildMessage ("ILLink" /* line 0 */, "Internal.Runtime.InteropServices.ComponentActivator.GetFunctionPointer(IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr): Using member 'Internal.Runtime.InteropServices.ComponentActivator.InternalGetFunctionPointer(AssemblyLoadContext, String, String, IntPtr)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Native hosting is not trim compatible and this warning will be seen if trimming is enabled. https://aka.ms/dotnet-illink/nativehost"), + new ExpectedBuildMessage ("src/Foundation/NSObject2.cs" /* line 266 */, "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."), + new ExpectedBuildMessage ("src/Foundation/NSObject2.cs" /* line 554 */, "Foundation.NSObject.DynamicConformsToProtocol(NativeHandle): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The return value of method 'System.Object.GetType()' 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 154 */, "ObjCRuntime.BlockLiteral.FindTrampoline(Type, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags)'. The parameter 'trampolineType' of method 'ObjCRuntime.BlockLiteral.FindTrampoline(Type, 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 520 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 515 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 423 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 427 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 213 */, "ObjCRuntime.BlockLiteral.SetupBlock(Delegate, Delegate, Boolean): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'. The return value of method 'ObjCRuntime.UserDelegateTypeAttribute.UserDelegateType.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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 313 */, "ObjCRuntime.BlockLiteral.SetupBlock(Delegate, Delegate): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'. The return value of method 'ObjCRuntime.MonoPInvokeCallbackAttribute.DelegateType.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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Class.cs" /* line 541 */, "ObjCRuntime.Class.ResolveToken(Assembly, Module, UInt32): Using member 'System.Reflection.Module.ResolveMethod(Int32)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimming changes metadata tokens."), + new ExpectedBuildMessage ("src/ObjCRuntime/Class.cs" /* line 528 */, "ObjCRuntime.Class.ResolveToken(Assembly, Module, UInt32): Using member 'System.Reflection.Module.ResolveType(Int32)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimming changes metadata tokens."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 180 */, "Registrar.DynamicRegistrar.d__16.MoveNext(): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethods(BindingFlags)'. The parameter 'type' of method 'Registrar.DynamicRegistrar.FindMethods(Type, 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 206 */, "Registrar.DynamicRegistrar.CollectConstructors(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Type.GetConstructors(BindingFlags)'. The parameter 'type' of method 'Registrar.DynamicRegistrar.CollectConstructors(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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 211 */, "Registrar.DynamicRegistrar.CollectMethods(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethods(BindingFlags)'. The parameter 'type' of method 'Registrar.DynamicRegistrar.CollectMethods(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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 216 */, "Registrar.DynamicRegistrar.CollectProperties(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Type.GetProperties(BindingFlags)'. The parameter 'type' of method 'Registrar.DynamicRegistrar.CollectProperties(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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 222 */, "Registrar.DynamicRegistrar.CollectTypes(Assembly): Using member 'System.Reflection.Assembly.GetTypes()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types might be removed."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 117 */, "Registrar.DynamicRegistrar.ContainsPlatformReference(Assembly): Using member 'System.Reflection.Assembly.GetReferencedAssemblies()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Assembly references might be removed."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 187 */, "Registrar.DynamicRegistrar.FindProperty(Type, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Type.GetProperty(String, BindingFlags)'. The parameter 'type' of method 'Registrar.DynamicRegistrar.FindProperty(Type, 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 192 */, "Registrar.DynamicRegistrar.FindType(Type, String, String): Using member 'System.Reflection.Assembly.GetTypes()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types might be removed."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 397 */, "Registrar.DynamicRegistrar.GetFields(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetFields(BindingFlags)'. The parameter 'type' of method 'Registrar.DynamicRegistrar.GetFields(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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 668 */, "Registrar.DynamicRegistrar.GetInterfaces(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The parameter 'type' of method 'Registrar.DynamicRegistrar.GetInterfaces(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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 542 */, "Registrar.DynamicRegistrar.HasThisAttributeImpl(MethodBase): Attribute 'System.Runtime.CompilerServices.ExtensionAttribute' is being referenced in code but the trimmer was instructed to remove all instances of this attribute. If the attribute instances are necessary make sure to either remove the trimmer attribute XML portion which removes the attribute instances, or override the removal by using the trimmer XML descriptor to keep the attribute type (which in turn keeps all of its instances)."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 1066 */, "Registrar.DynamicRegistrar.TryMatchProperty(Type, PropertyInfo): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Type.GetProperties(BindingFlags)'. The parameter 'type' of method 'Registrar.DynamicRegistrar.TryMatchProperty(Type, PropertyInfo)' 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 499 */, "Registrar.DynamicRegistrar.VerifyIsConstrainedToNSObject(Type, 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 33 */, "Registrar.SharedDynamic.PrepareInterfaceMethodMapping(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.FindInterfaces(TypeFilter, Object)'. The parameter 'type' of method 'Registrar.SharedDynamic.PrepareInterfaceMethodMapping(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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 39 */, "Registrar.SharedDynamic.PrepareInterfaceMethodMapping(Type): Value passed to parameter 'interfaceType' of method 'System.Type.GetInterfaceMap(Type)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 714 */, "ObjCRuntime.Runtime.CollectReferencedAssemblies(List, Assembly): Using member 'System.Reflection.Assembly.GetReferencedAssemblies()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Assembly references might be removed."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 2434 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1279 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 983 */, "ObjCRuntime.Runtime.GetBlockProxyAttributeMethod(MethodInfo, Int32): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'. The return value of method 'ObjCRuntime.BlockProxyAttribute.Type.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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1064 */, "ObjCRuntime.Runtime.GetBlockWrapperCreator(MethodInfo, Int32): '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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1103 */, "ObjCRuntime.Runtime.GetBlockWrapperCreator(MethodInfo, Int32): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags, Binder, Type[], ParameterModifier[])'. The return value of method 'System.Reflection.Assembly.GetType(String, Boolean)' 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1094 */, "ObjCRuntime.Runtime.GetBlockWrapperCreator(MethodInfo, Int32): Using member 'System.Reflection.Assembly.GetType(String, Boolean)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types might be removed."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1085 */, "ObjCRuntime.Runtime.GetBlockWrapperCreator(MethodInfo, Int32): Value passed to implicit 'this' parameter of method 'System.Type.GetMethod(String)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1068 */, "ObjCRuntime.Runtime.GetBlockWrapperCreator(MethodInfo, Int32): Value passed to parameter 'interfaceType' of method 'System.Type.GetInterfaceMap(Type)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1673 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1623 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Stret.cs" /* line 191 */, "ObjCRuntime.Stret.GetValueTypeSize(Type, List, Boolean, Object): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetFields(BindingFlags)'. The parameter 'type' of method 'ObjCRuntime.Stret.GetValueTypeSize(Type, List, Boolean, Object)' 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Stret.cs" /* line 303 */, "ObjCRuntime.Stret.GetValueTypeSize(Type, Type, List, Boolean, Int32&, Int32&, Object): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetFields(BindingFlags)'. The parameter 'type' of method 'ObjCRuntime.Stret.GetValueTypeSize(Type, Type, List, Boolean, Int32&, Int32&, Object)' 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."), + }; + break; + case ApplePlatform.MacOSX: + expectedWarnings = new ExpectedBuildMessage [] { + new ExpectedBuildMessage ("ILLink" /* line 0 */, "Internal.Runtime.InteropServices.ComponentActivator.GetFunctionPointer(IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr): Using member 'Internal.Runtime.InteropServices.ComponentActivator.InternalGetFunctionPointer(AssemblyLoadContext, String, String, IntPtr)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Native hosting is not trim compatible and this warning will be seen if trimming is enabled. https://aka.ms/dotnet-illink/nativehost"), + new ExpectedBuildMessage ("src/Foundation/NSObject2.cs" /* line 266 */, "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."), + new ExpectedBuildMessage ("src/Foundation/NSObject2.cs" /* line 554 */, "Foundation.NSObject.DynamicConformsToProtocol(NativeHandle): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The return value of method 'System.Object.GetType()' 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 154 */, "ObjCRuntime.BlockLiteral.FindTrampoline(Type, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags)'. The parameter 'trampolineType' of method 'ObjCRuntime.BlockLiteral.FindTrampoline(Type, 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 520 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 515 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 423 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 427 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 213 */, "ObjCRuntime.BlockLiteral.SetupBlock(Delegate, Delegate, Boolean): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'. The return value of method 'ObjCRuntime.UserDelegateTypeAttribute.UserDelegateType.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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Class.cs" /* line 541 */, "ObjCRuntime.Class.ResolveToken(Assembly, Module, UInt32): Using member 'System.Reflection.Module.ResolveMethod(Int32)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimming changes metadata tokens."), + new ExpectedBuildMessage ("src/ObjCRuntime/Class.cs" /* line 528 */, "ObjCRuntime.Class.ResolveToken(Assembly, Module, UInt32): Using member 'System.Reflection.Module.ResolveType(Int32)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimming changes metadata tokens."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 180 */, "Registrar.DynamicRegistrar.d__16.MoveNext(): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethods(BindingFlags)'. The parameter 'type' of method 'Registrar.DynamicRegistrar.FindMethods(Type, 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 206 */, "Registrar.DynamicRegistrar.CollectConstructors(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Type.GetConstructors(BindingFlags)'. The parameter 'type' of method 'Registrar.DynamicRegistrar.CollectConstructors(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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 211 */, "Registrar.DynamicRegistrar.CollectMethods(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethods(BindingFlags)'. The parameter 'type' of method 'Registrar.DynamicRegistrar.CollectMethods(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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 216 */, "Registrar.DynamicRegistrar.CollectProperties(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Type.GetProperties(BindingFlags)'. The parameter 'type' of method 'Registrar.DynamicRegistrar.CollectProperties(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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 222 */, "Registrar.DynamicRegistrar.CollectTypes(Assembly): Using member 'System.Reflection.Assembly.GetTypes()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types might be removed."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 117 */, "Registrar.DynamicRegistrar.ContainsPlatformReference(Assembly): Using member 'System.Reflection.Assembly.GetReferencedAssemblies()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Assembly references might be removed."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 187 */, "Registrar.DynamicRegistrar.FindProperty(Type, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Type.GetProperty(String, BindingFlags)'. The parameter 'type' of method 'Registrar.DynamicRegistrar.FindProperty(Type, 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 192 */, "Registrar.DynamicRegistrar.FindType(Type, String, String): Using member 'System.Reflection.Assembly.GetTypes()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types might be removed."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 397 */, "Registrar.DynamicRegistrar.GetFields(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetFields(BindingFlags)'. The parameter 'type' of method 'Registrar.DynamicRegistrar.GetFields(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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 668 */, "Registrar.DynamicRegistrar.GetInterfaces(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The parameter 'type' of method 'Registrar.DynamicRegistrar.GetInterfaces(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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 542 */, "Registrar.DynamicRegistrar.HasThisAttributeImpl(MethodBase): Attribute 'System.Runtime.CompilerServices.ExtensionAttribute' is being referenced in code but the trimmer was instructed to remove all instances of this attribute. If the attribute instances are necessary make sure to either remove the trimmer attribute XML portion which removes the attribute instances, or override the removal by using the trimmer XML descriptor to keep the attribute type (which in turn keeps all of its instances)."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 1066 */, "Registrar.DynamicRegistrar.TryMatchProperty(Type, PropertyInfo): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Type.GetProperties(BindingFlags)'. The parameter 'type' of method 'Registrar.DynamicRegistrar.TryMatchProperty(Type, PropertyInfo)' 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 499 */, "Registrar.DynamicRegistrar.VerifyIsConstrainedToNSObject(Type, 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 33 */, "Registrar.SharedDynamic.PrepareInterfaceMethodMapping(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.FindInterfaces(TypeFilter, Object)'. The parameter 'type' of method 'Registrar.SharedDynamic.PrepareInterfaceMethodMapping(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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 39 */, "Registrar.SharedDynamic.PrepareInterfaceMethodMapping(Type): Value passed to parameter 'interfaceType' of method 'System.Type.GetInterfaceMap(Type)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.CoreCLR.cs" /* line 276 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.CoreCLR.cs" /* line 177 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 714 */, "ObjCRuntime.Runtime.CollectReferencedAssemblies(List, Assembly): Using member 'System.Reflection.Assembly.GetReferencedAssemblies()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Assembly references might be removed."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 2434 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1279 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 983 */, "ObjCRuntime.Runtime.GetBlockProxyAttributeMethod(MethodInfo, Int32): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'. The return value of method 'ObjCRuntime.BlockProxyAttribute.Type.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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1064 */, "ObjCRuntime.Runtime.GetBlockWrapperCreator(MethodInfo, Int32): '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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1103 */, "ObjCRuntime.Runtime.GetBlockWrapperCreator(MethodInfo, Int32): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags, Binder, Type[], ParameterModifier[])'. The return value of method 'System.Reflection.Assembly.GetType(String, Boolean)' 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1094 */, "ObjCRuntime.Runtime.GetBlockWrapperCreator(MethodInfo, Int32): Using member 'System.Reflection.Assembly.GetType(String, Boolean)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types might be removed."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1085 */, "ObjCRuntime.Runtime.GetBlockWrapperCreator(MethodInfo, Int32): Value passed to implicit 'this' parameter of method 'System.Type.GetMethod(String)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1068 */, "ObjCRuntime.Runtime.GetBlockWrapperCreator(MethodInfo, Int32): Value passed to parameter 'interfaceType' of method 'System.Type.GetInterfaceMap(Type)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 648 */, "ObjCRuntime.Runtime.GetEntryAssembly(): Using member 'System.Reflection.Assembly.LoadFile(String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types and members the loaded assembly depends on might be removed."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1673 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1623 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Stret.cs" /* line 191 */, "ObjCRuntime.Stret.GetValueTypeSize(Type, List, Boolean, Object): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetFields(BindingFlags)'. The parameter 'type' of method 'ObjCRuntime.Stret.GetValueTypeSize(Type, List, Boolean, Object)' 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Stret.cs" /* line 303 */, "ObjCRuntime.Stret.GetValueTypeSize(Type, Type, List, Boolean, Int32&, Int32&, Object): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetFields(BindingFlags)'. The parameter 'type' of method 'ObjCRuntime.Stret.GetValueTypeSize(Type, Type, List, Boolean, Int32&, Int32&, Object)' 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."), + }; + break; + case ApplePlatform.MacCatalyst: + expectedWarnings = new ExpectedBuildMessage [] { + new ExpectedBuildMessage ("ILLink" /* line 0 */, "Internal.Runtime.InteropServices.ComponentActivator.GetFunctionPointer(IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr): Using member 'Internal.Runtime.InteropServices.ComponentActivator.InternalGetFunctionPointer(AssemblyLoadContext, String, String, IntPtr)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Native hosting is not trim compatible and this warning will be seen if trimming is enabled. https://aka.ms/dotnet-illink/nativehost"), + new ExpectedBuildMessage ("src/Foundation/NSObject2.cs" /* line 266 */, "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."), + new ExpectedBuildMessage ("src/Foundation/NSObject2.cs" /* line 554 */, "Foundation.NSObject.DynamicConformsToProtocol(NativeHandle): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The return value of method 'System.Object.GetType()' 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 154 */, "ObjCRuntime.BlockLiteral.FindTrampoline(Type, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags)'. The parameter 'trampolineType' of method 'ObjCRuntime.BlockLiteral.FindTrampoline(Type, 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 520 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 515 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 423 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 427 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 213 */, "ObjCRuntime.BlockLiteral.SetupBlock(Delegate, Delegate, Boolean): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'. The return value of method 'ObjCRuntime.UserDelegateTypeAttribute.UserDelegateType.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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Class.cs" /* line 541 */, "ObjCRuntime.Class.ResolveToken(Assembly, Module, UInt32): Using member 'System.Reflection.Module.ResolveMethod(Int32)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimming changes metadata tokens."), + new ExpectedBuildMessage ("src/ObjCRuntime/Class.cs" /* line 528 */, "ObjCRuntime.Class.ResolveToken(Assembly, Module, UInt32): Using member 'System.Reflection.Module.ResolveType(Int32)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimming changes metadata tokens."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 180 */, "Registrar.DynamicRegistrar.d__16.MoveNext(): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethods(BindingFlags)'. The parameter 'type' of method 'Registrar.DynamicRegistrar.FindMethods(Type, 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 206 */, "Registrar.DynamicRegistrar.CollectConstructors(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Type.GetConstructors(BindingFlags)'. The parameter 'type' of method 'Registrar.DynamicRegistrar.CollectConstructors(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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 211 */, "Registrar.DynamicRegistrar.CollectMethods(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethods(BindingFlags)'. The parameter 'type' of method 'Registrar.DynamicRegistrar.CollectMethods(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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 216 */, "Registrar.DynamicRegistrar.CollectProperties(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Type.GetProperties(BindingFlags)'. The parameter 'type' of method 'Registrar.DynamicRegistrar.CollectProperties(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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 222 */, "Registrar.DynamicRegistrar.CollectTypes(Assembly): Using member 'System.Reflection.Assembly.GetTypes()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types might be removed."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 117 */, "Registrar.DynamicRegistrar.ContainsPlatformReference(Assembly): Using member 'System.Reflection.Assembly.GetReferencedAssemblies()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Assembly references might be removed."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 187 */, "Registrar.DynamicRegistrar.FindProperty(Type, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Type.GetProperty(String, BindingFlags)'. The parameter 'type' of method 'Registrar.DynamicRegistrar.FindProperty(Type, 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 192 */, "Registrar.DynamicRegistrar.FindType(Type, String, String): Using member 'System.Reflection.Assembly.GetTypes()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types might be removed."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 397 */, "Registrar.DynamicRegistrar.GetFields(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetFields(BindingFlags)'. The parameter 'type' of method 'Registrar.DynamicRegistrar.GetFields(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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 668 */, "Registrar.DynamicRegistrar.GetInterfaces(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The parameter 'type' of method 'Registrar.DynamicRegistrar.GetInterfaces(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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 542 */, "Registrar.DynamicRegistrar.HasThisAttributeImpl(MethodBase): Attribute 'System.Runtime.CompilerServices.ExtensionAttribute' is being referenced in code but the trimmer was instructed to remove all instances of this attribute. If the attribute instances are necessary make sure to either remove the trimmer attribute XML portion which removes the attribute instances, or override the removal by using the trimmer XML descriptor to keep the attribute type (which in turn keeps all of its instances)."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 1066 */, "Registrar.DynamicRegistrar.TryMatchProperty(Type, PropertyInfo): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Type.GetProperties(BindingFlags)'. The parameter 'type' of method 'Registrar.DynamicRegistrar.TryMatchProperty(Type, PropertyInfo)' 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 499 */, "Registrar.DynamicRegistrar.VerifyIsConstrainedToNSObject(Type, 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 33 */, "Registrar.SharedDynamic.PrepareInterfaceMethodMapping(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.FindInterfaces(TypeFilter, Object)'. The parameter 'type' of method 'Registrar.SharedDynamic.PrepareInterfaceMethodMapping(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."), + new ExpectedBuildMessage ("src/ObjCRuntime/DynamicRegistrar.cs" /* line 39 */, "Registrar.SharedDynamic.PrepareInterfaceMethodMapping(Type): Value passed to parameter 'interfaceType' of method 'System.Type.GetInterfaceMap(Type)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 714 */, "ObjCRuntime.Runtime.CollectReferencedAssemblies(List, Assembly): Using member 'System.Reflection.Assembly.GetReferencedAssemblies()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Assembly references might be removed."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 2434 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1279 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 983 */, "ObjCRuntime.Runtime.GetBlockProxyAttributeMethod(MethodInfo, Int32): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'. The return value of method 'ObjCRuntime.BlockProxyAttribute.Type.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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1064 */, "ObjCRuntime.Runtime.GetBlockWrapperCreator(MethodInfo, Int32): '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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1103 */, "ObjCRuntime.Runtime.GetBlockWrapperCreator(MethodInfo, Int32): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags, Binder, Type[], ParameterModifier[])'. The return value of method 'System.Reflection.Assembly.GetType(String, Boolean)' 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1094 */, "ObjCRuntime.Runtime.GetBlockWrapperCreator(MethodInfo, Int32): Using member 'System.Reflection.Assembly.GetType(String, Boolean)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types might be removed."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1085 */, "ObjCRuntime.Runtime.GetBlockWrapperCreator(MethodInfo, Int32): Value passed to implicit 'this' parameter of method 'System.Type.GetMethod(String)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1068 */, "ObjCRuntime.Runtime.GetBlockWrapperCreator(MethodInfo, Int32): Value passed to parameter 'interfaceType' of method 'System.Type.GetInterfaceMap(Type)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1673 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 1623 */, "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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Stret.cs" /* line 191 */, "ObjCRuntime.Stret.GetValueTypeSize(Type, List, Boolean, Object): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetFields(BindingFlags)'. The parameter 'type' of method 'ObjCRuntime.Stret.GetValueTypeSize(Type, List, Boolean, Object)' 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."), + new ExpectedBuildMessage ("src/ObjCRuntime/Stret.cs" /* line 303 */, "ObjCRuntime.Stret.GetValueTypeSize(Type, Type, List, Boolean, Int32&, Int32&, Object): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetFields(BindingFlags)'. The parameter 'type' of method 'ObjCRuntime.Stret.GetValueTypeSize(Type, Type, List, Boolean, Int32&, Int32&, Object)' 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."), + }; + break; + default: + Assert.Fail ($"Unknown platform: {platform}"); + return; + } + + TrimmerWarnings (platform, runtimeIdentifiers, "dynamic", expectedWarnings); + } + + void TrimmerWarnings (ApplePlatform platform, string runtimeIdentifiers, string registrar, params ExpectedBuildMessage [] expectedWarnings) + { + // https://github.com/xamarin/xamarin-macios/issues/10405 + var project = "MySimpleApp"; + Configuration.IgnoreIfIgnoredPlatform (platform); + Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers); + + var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath); + Clean (project_path); + + var properties = GetDefaultProperties (runtimeIdentifiers); + + // Don't be shy, we want the warnings + properties ["SuppressTrimAnalysisWarnings"] = "false"; + // And we want all of them! + properties ["TrimmerSingleWarn"] = "false"; + + // Select the registrar we want. + properties ["Registrar"] = registrar; + + // The trimmer must trim at least the sdk assemblies for trimmer warnings to make sense, + // otherwise it'll report warnings for features it would be told to swift off (and trim away). + // Setting link mode to "Full" also works here, but I figure we won't get any warnings in "Full" + // mode we wouldn't get in "SdkOnly" mode, but we could get warnings in "SdkOnly" that we wouldn't + // get in "Full", so just use "SdkOnly" in the test for greater potential coverage (although + // at the writing of this test it doesn't matter, either linker mode produce the same results). + var linkMode = "SdkOnly"; + properties ["MtouchLink"] = linkMode; + properties ["LinkMode"] = linkMode; + + // Sidenote to the previous point: the SdkOnly link mode produces the same results as the Full + // link mode as long as neither Touch.Unit nor NUnitLite are included in LinkSdk, beacuse neiter + // are anywhere close to trim-safe (they're both trimmed away in Full mode, so replicate that + // in SdkOnly mode): + properties ["ExcludeTouchUnitReference"] = "true"; + properties ["ExcludeNUnitLiteReference"] = "true"; + + // Enable all optimizations + var extraArgs = string.Empty; + if (registrar != "dynamic") { + // If we're not using the dynamic registrar, we want it gone. + extraArgs = "--optimize:remove-dynamic-registrar"; + } + properties ["MtouchExtraArgs"] = extraArgs; + properties ["MonoBundlingExtraArgs"] = extraArgs; + + var rv = DotNet.AssertBuild (project_path, properties); + + var warnings = BinLog.GetBuildLogWarnings (rv.BinLogPath) + .Where (evt => { + if (platform == ApplePlatform.iOS && evt.Message?.Trim () == "Supported iPhone orientations have not been set") + return false; + return true; + }); + warnings.AssertWarnings (expectedWarnings); + } + } +}