diff --git a/src/Controls/src/Xaml/XamlServiceProvider.cs b/src/Controls/src/Xaml/XamlServiceProvider.cs index c2b86f47db39..61fe1097bf19 100644 --- a/src/Controls/src/Xaml/XamlServiceProvider.cs +++ b/src/Controls/src/Xaml/XamlServiceProvider.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; -using System.Linq; using System.Reflection; using System.Xml; using Microsoft.Maui.Controls.Internals; @@ -37,7 +35,7 @@ internal XamlServiceProvider(INode node, HydrationContext context) IValueConverterProvider = defaultValueConverterProvider; if (node is IElementNode elementNode) - Add(typeof(IXamlDataTypeProvider), new XamlDataTypeProvider(elementNode, context)); + Add(typeof(IXamlDataTypeProvider), new XamlDataTypeProvider(elementNode)); } public XamlServiceProvider() => IValueConverterProvider = defaultValueConverterProvider; @@ -296,15 +294,8 @@ public string LookupNamespace(string prefix) class XamlDataTypeProvider : IXamlDataTypeProvider { - [RequiresUnreferencedCode(TrimmerConstants.XamlRuntimeParsingNotSupportedWarning)] -#if !NETSTANDARD - [RequiresDynamicCode(TrimmerConstants.XamlRuntimeParsingNotSupportedWarning)] -#endif - public XamlDataTypeProvider(IElementNode node, HydrationContext context) + public XamlDataTypeProvider(IElementNode node) { - Context = context; - - static IElementNode GetParent(IElementNode node) { return node switch @@ -324,21 +315,6 @@ static bool IsBindingContextBinding(IElementNode node) return false; } - static bool IsBindingBaseProperty(IElementNode node, HydrationContext context) - { - if ( node.TryGetPropertyName(node.Parent, out XmlName name) - && node.Parent is IElementNode parent - && XamlParser.GetElementType(parent.XmlType, - new XmlLineInfo(((IXmlLineInfo)node).LineNumber, ((IXmlLineInfo)node).LinePosition), - context.RootElement.GetType().Assembly, out var xpe) is Type parentType - && parentType.GetRuntimeProperties().FirstOrDefault(p => p.Name == name.LocalName) is PropertyInfo propertyInfo - && propertyInfo.PropertyType == typeof(BindingBase)) - { - return true; - } - return false; - } - INode dataTypeNode = null; IElementNode n = node as IElementNode; @@ -355,21 +331,17 @@ static bool IsBindingBaseProperty(IElementNode node, HydrationContext context) while (n != null) { - if (n != skipNode && n.Properties.TryGetValue(XmlName.xDataType, out dataTypeNode)) { break; } - if (IsBindingBaseProperty(n, context)) - { - break; - } + n = GetParent(n); } if (dataTypeNode is ValueNode valueNode) BindingDataType = valueNode.Value as string; + } public string BindingDataType { get; } - public HydrationContext Context { get; } } -} +} \ No newline at end of file diff --git a/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj b/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj index f0dccf50d07a..4ded530f749a 100644 --- a/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj +++ b/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj @@ -6,7 +6,7 @@ Microsoft.Maui.Controls.Xaml.UnitTests 4 $(NoWarn);0672;0219;0414;CS0436;CS0618 - $(WarningsNotAsErrors);XC0618;XC0022;XC0023;XC0045 + $(WarningsNotAsErrors);XC0618;XC0022,XC0023 false true @@ -19,7 +19,6 @@ - @@ -54,4 +53,4 @@ - + \ No newline at end of file diff --git a/src/TestUtils/src/Microsoft.Maui.IntegrationTests/Utilities/BuildWarningsUtilities.cs b/src/TestUtils/src/Microsoft.Maui.IntegrationTests/Utilities/BuildWarningsUtilities.cs index e865e5e8db4a..ab8111cf9770 100644 --- a/src/TestUtils/src/Microsoft.Maui.IntegrationTests/Utilities/BuildWarningsUtilities.cs +++ b/src/TestUtils/src/Microsoft.Maui.IntegrationTests/Utilities/BuildWarningsUtilities.cs @@ -1,6 +1,7 @@ using System.Linq; using Microsoft.Build.Framework; using Microsoft.Build.Logging.StructuredLogger; +using static Microsoft.Maui.IntegrationTests.TemplateTests; namespace Microsoft.Maui.IntegrationTests { @@ -8,7 +9,6 @@ public class WarningsPerFile { public string File { get; set; } = string.Empty; public List WarningsPerCode { get; set; } = new List(); - public override string ToString() => string.Join("\n", WarningsPerCode.SelectMany(warningPerCode => warningPerCode.Messages.Select(message => $"{File}: {warningPerCode.Code}: {message}")).ToList()); } public class WarningsPerCode @@ -82,11 +82,6 @@ private static void AddActualWarning(this List warnings, string } } - public static void AssertNoWarnings(this List actualWarnings) - { - Assert.AreEqual(0, actualWarnings.Count, $"No warnings expected, but got {actualWarnings.Count} warnings:\n{string.Join("\n", actualWarnings.Select(actualWarning => actualWarning.ToString()))}"); - } - public static void AssertWarnings(this List actualWarnings, List expectedWarnings) { foreach (var expectedWarningsPerFile in expectedWarnings) @@ -126,7 +121,340 @@ public static void AssertWarnings(this List actualWarnings, Lis #region Expected warning messages // IMPORTANT: Always store expected File information as a relative path to the repo ROOT - private static readonly List expectedNativeAOTWarnings = new(); + private static readonly List expectedNativeAOTWarnings = new() + { + new WarningsPerFile + { + File = "src/Controls/src/Xaml/XamlParser.cs", + WarningsPerCode = new List + { + new WarningsPerCode + { + Code = "IL2055", + Messages = new List + { + "Microsoft.Maui.Controls.Xaml.XamlParser.GetElementType(XmlType,IXmlLineInfo,Assembly,XamlParseException&): 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 WarningsPerCode + { + Code = "IL3050", + Messages = new List + { + "Microsoft.Maui.Controls.Xaml.XamlParser.GetElementType(XmlType,IXmlLineInfo,Assembly,XamlParseException&): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.", + } + }, + new WarningsPerCode + { + Code = "IL2057", + Messages = new List + { + "Microsoft.Maui.Controls.Xaml.XamlParser.<>c__DisplayClass11_0.b__0(ValueTuple`3): Unrecognized value passed to the parameter 'typeName' of method 'System.Type.GetType(String)'. It's not possible to guarantee the availability of the target type.", + } + }, + } + }, + new WarningsPerFile + { + File = "src/Controls/src/Core/Xaml/TypeConversionExtensions.cs", + WarningsPerCode = new List + { + new WarningsPerCode + { + Code = "IL2070", + Messages = new List + { + "Microsoft.Maui.Controls.Xaml.TypeConversionExtensions.GetImplicitConversionOperator(Type,Type,Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String,BindingFlags,Binder,Type[],ParameterModifier[])'. The parameter '#0' of method 'Microsoft.Maui.Controls.Xaml.TypeConversionExtensions.GetImplicitConversionOperator(Type,Type,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.", + "Microsoft.Maui.Controls.Xaml.TypeConversionExtensions.GetImplicitConversionOperator(Type,Type,Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethods(BindingFlags)'. The parameter '#0' of method 'Microsoft.Maui.Controls.Xaml.TypeConversionExtensions.GetImplicitConversionOperator(Type,Type,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 WarningsPerFile + { + File = "src/Controls/src/Core/Shell/ShellContent.cs", + WarningsPerCode = new List + { + new WarningsPerCode + { + Code = "IL2072", + Messages = new List + { + "Microsoft.Maui.Controls.ShellContent.ApplyQueryAttributes(Object,ShellRouteParameters,ShellRouteParameters): 'name' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Reflection.RuntimeReflectionExtensions.GetRuntimeProperty(Type,String)'. 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.", + "Microsoft.Maui.Controls.ShellContent.ApplyQueryAttributes(Object,ShellRouteParameters,ShellRouteParameters): 'name' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Reflection.RuntimeReflectionExtensions.GetRuntimeProperty(Type,String)'. 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 WarningsPerFile + { + File = "src/Controls/src/Core/BindablePropertyConverter.cs", + WarningsPerCode = new List + { + new WarningsPerCode + { + Code = "IL2057", + Messages = new List + { + "Microsoft.Maui.Controls.BindablePropertyConverter.ConvertFrom(ITypeDescriptorContext,CultureInfo,Object): Unrecognized value passed to the parameter 'typeName' of method 'System.Type.GetType(String)'. It's not possible to guarantee the availability of the target type.", + } + }, + } + }, + new WarningsPerFile + { + File = "src/Controls/src/Core/BindingExpression.cs", + WarningsPerCode = new List + { + new WarningsPerCode + { + Code = "IL2070", + Messages = new List + { + "Microsoft.Maui.Controls.BindingExpression.SetupPart(TypeInfo,BindingExpression.BindingExpressionPart): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Reflection.TypeInfo.GetDeclaredMethod(String)'. The parameter '#0' of method 'Microsoft.Maui.Controls.BindingExpression.SetupPart(TypeInfo,BindingExpression.BindingExpressionPart)' 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.", + "Microsoft.Maui.Controls.BindingExpression.SetupPart(TypeInfo,BindingExpression.BindingExpressionPart): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Reflection.TypeInfo.GetDeclaredMethod(String)'. The parameter '#0' of method 'Microsoft.Maui.Controls.BindingExpression.SetupPart(TypeInfo,BindingExpression.BindingExpressionPart)' 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.", + "Microsoft.Maui.Controls.BindingExpression.SetupPart(TypeInfo,BindingExpression.BindingExpressionPart): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Reflection.TypeInfo.GetDeclaredProperty(String)'. The parameter '#0' of method 'Microsoft.Maui.Controls.BindingExpression.SetupPart(TypeInfo,BindingExpression.BindingExpressionPart)' 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.", + "Microsoft.Maui.Controls.BindingExpression.SetupPart(TypeInfo,BindingExpression.BindingExpressionPart): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Reflection.TypeInfo.GetDeclaredField(String)'. The parameter '#0' of method 'Microsoft.Maui.Controls.BindingExpression.SetupPart(TypeInfo,BindingExpression.BindingExpressionPart)' 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.", + "Microsoft.Maui.Controls.BindingExpression.SetupPart(TypeInfo,BindingExpression.BindingExpressionPart): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Reflection.TypeInfo.ImplementedInterfaces.get'. The parameter '#0' of method 'Microsoft.Maui.Controls.BindingExpression.SetupPart(TypeInfo,BindingExpression.BindingExpressionPart)' 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.", + "Microsoft.Maui.Controls.BindingExpression.GetIndexer(TypeInfo,String,String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Reflection.TypeInfo.DeclaredProperties.get'. The parameter '#0' of method 'Microsoft.Maui.Controls.BindingExpression.GetIndexer(TypeInfo,String,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.", + "Microsoft.Maui.Controls.BindingExpression.GetIndexer(TypeInfo,String,String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Reflection.TypeInfo.DeclaredProperties.get'. The parameter '#0' of method 'Microsoft.Maui.Controls.BindingExpression.GetIndexer(TypeInfo,String,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.", + "Microsoft.Maui.Controls.BindingExpression.GetIndexer(TypeInfo,String,String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Reflection.TypeInfo.DeclaredProperties.get'. The parameter '#0' of method 'Microsoft.Maui.Controls.BindingExpression.GetIndexer(TypeInfo,String,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.", + "Microsoft.Maui.Controls.BindingExpression.GetIndexer(TypeInfo,String,String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Reflection.TypeInfo.ImplementedInterfaces.get'. The parameter '#0' of method 'Microsoft.Maui.Controls.BindingExpression.GetIndexer(TypeInfo,String,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 WarningsPerFile + { + File = "src/Controls/src/Core/Visuals/VisualTypeConverter.cs", + WarningsPerCode = new List + { + new WarningsPerCode + { + Code = "IL2026", + Messages = new List + { + "Microsoft.Maui.Controls.VisualTypeConverter.Register(Assembly,Dictionary`2): Using member 'System.Reflection.Assembly.GetExportedTypes()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types might be removed.", + } + }, + new WarningsPerCode + { + Code = "IL2062", + Messages = new List + { + "Microsoft.Maui.Controls.VisualTypeConverter.Register(Assembly,Dictionary`2): Value passed to parameter '' of method 'Microsoft.Maui.Controls.VisualTypeConverter.Register(Type,Dictionary`2)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements.", + } + }, + } + }, + new WarningsPerFile + { + File = "src/Controls/src/Xaml/ApplyPropertiesVisitor.cs", + WarningsPerCode = new List + { + new WarningsPerCode + { + Code = "IL2072", + Messages = new List + { + "Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.Visit(ElementNode,INode): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Reflection.RuntimeReflectionExtensions.GetRuntimeMethods(Type)'. The return value of method 'System.Collections.Generic.Dictionary`2.Item.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.", + "Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.Visit(ElementNode,INode): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Reflection.RuntimeReflectionExtensions.GetRuntimeMethods(Type)'. The return value of method 'System.Collections.Generic.Dictionary`2.Item.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.", + "Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.Visit(ElementNode,INode): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Reflection.RuntimeReflectionExtensions.GetRuntimeMethods(Type)'. 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.", + "Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.GetTargetProperty(Object,XmlName,Object,IXmlLineInfo): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Reflection.RuntimeReflectionExtensions.GetRuntimeProperties(Type)'. 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.", + "Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.TryConnectEvent(Object,String,Boolean,Object,Object,IXmlLineInfo,Exception&): 'name' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicEvents' in call to 'System.Reflection.RuntimeReflectionExtensions.GetRuntimeEvent(Type,String)'. 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.", + "Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.TryConnectEvent(Object,String,Boolean,Object,Object,IXmlLineInfo,Exception&): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicEvents', 'DynamicallyAccessedMemberTypes.NonPublicEvents' in call to 'System.Reflection.RuntimeReflectionExtensions.GetRuntimeEvents(Type)'. 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.", + "Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.<>c__DisplayClass37_0.b__1(): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Reflection.RuntimeReflectionExtensions.GetRuntimeProperties(Type)'. The return value of method 'Microsoft.Maui.Controls.BindableProperty.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.", + "Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.TrySetProperty(Object,String,Object,IXmlLineInfo,IServiceProvider,Object,Exception&): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Reflection.RuntimeReflectionExtensions.GetRuntimeProperties(Type)'. 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.", + "Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.TryAddToProperty(Object,XmlName,Object,String,IXmlLineInfo,IServiceProvider,Object,Exception&): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Reflection.RuntimeReflectionExtensions.GetRuntimeMethods(Type)'. 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 WarningsPerCode + { + Code = "IL2070", + Messages = new List + { + "Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.GetBindableProperty(Type,String,IXmlLineInfo): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetField(String,BindingFlags)'. The parameter '#0' of method 'Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.GetBindableProperty(Type,String,IXmlLineInfo)' 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.", + "Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.GetAllRuntimeMethods(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The parameter '#0' of method 'Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.GetAllRuntimeMethods(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 WarningsPerCode + { + Code = "IL2075", + Messages = new List + { + "Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.TryGetProperty(Object,String,Object&,IXmlLineInfo,Object,Exception&,Object&): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String,BindingFlags)'. 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.", + "Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.TryConnectEvent(Object,String,Boolean,Object,Object,IXmlLineInfo,Exception&): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethod(String,BindingFlags)'. 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.", + "Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.TryConnectEvent(Object,String,Boolean,Object,Object,IXmlLineInfo,Exception&): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'. The return value of method 'System.Reflection.EventInfo.EventHandlerType.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.", + "Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.TryConnectEvent(Object,String,Boolean,Object,Object,IXmlLineInfo,Exception&): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethods(BindingFlags)'. 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.", + "Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.TryConnectEvent(Object,String,Boolean,Object,Object,IXmlLineInfo,Exception&): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'. The return value of method 'System.Reflection.EventInfo.EventHandlerType.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 WarningsPerCode + { + Code = "IL2067", + Messages = new List + { + "Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.GetAllRuntimeMethods(Type): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Reflection.RuntimeReflectionExtensions.GetRuntimeMethods(Type)'. The parameter '#0' of method 'Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.GetAllRuntimeMethods(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.", + "Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.<>c.b__46_0(Type): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Reflection.RuntimeReflectionExtensions.GetRuntimeMethods(Type)'. The parameter 't' of method 'Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.<>c.b__46_0(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 WarningsPerFile + { + File = "src/Controls/src/Xaml/CreateValuesVisitor.cs", + WarningsPerCode = new List + { + new WarningsPerCode + { + Code = "IL2075", + Messages = new List + { + "Microsoft.Maui.Controls.Xaml.CreateValuesVisitor.Visit(ElementNode,INode): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Reflection.TypeInfo.DeclaredConstructors.get'. The return value of method 'Microsoft.Maui.Controls.Xaml.XamlParser.GetElementType(XmlType,IXmlLineInfo,Assembly,XamlParseException&)' 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.", + "Microsoft.Maui.Controls.Xaml.CreateValuesVisitor.Visit(ElementNode,INode): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Reflection.TypeInfo.DeclaredConstructors.get'. The return value of method 'Microsoft.Maui.Controls.Xaml.XamlParser.GetElementType(XmlType,IXmlLineInfo,Assembly,XamlParseException&)' 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 WarningsPerCode + { + Code = "IL2072", + Messages = new List + { + "Microsoft.Maui.Controls.Xaml.CreateValuesVisitor.Visit(ElementNode,INode): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Activator.CreateInstance(Type)'. The return value of method 'Microsoft.Maui.Controls.Xaml.XamlParser.GetElementType(XmlType,IXmlLineInfo,Assembly,XamlParseException&)' 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 WarningsPerCode + { + Code = "IL2067", + Messages = new List + { + "Microsoft.Maui.Controls.Xaml.CreateValuesVisitor.CreateLanguagePrimitive(Type,IElementNode): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Activator.CreateInstance(Type)'. The parameter '#0' of method 'Microsoft.Maui.Controls.Xaml.CreateValuesVisitor.CreateLanguagePrimitive(Type,IElementNode)' 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.", + "Microsoft.Maui.Controls.Xaml.CreateValuesVisitor.CreateFromFactory(Type,IElementNode): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'System.Activator.CreateInstance(Type,Object[])'. The parameter '#0' of method 'Microsoft.Maui.Controls.Xaml.CreateValuesVisitor.CreateFromFactory(Type,IElementNode)' 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.", + "Microsoft.Maui.Controls.Xaml.CreateValuesVisitor.CreateFromFactory(Type,IElementNode): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Reflection.RuntimeReflectionExtensions.GetRuntimeMethods(Type)'. The parameter '#0' of method 'Microsoft.Maui.Controls.Xaml.CreateValuesVisitor.CreateFromFactory(Type,IElementNode)' 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 WarningsPerCode + { + Code = "IL2070", + Messages = new List + { + "Microsoft.Maui.Controls.Xaml.CreateValuesVisitor.ValidateCtorArguments(Type,IElementNode,String&): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Reflection.TypeInfo.DeclaredConstructors.get'. The parameter '#0' of method 'Microsoft.Maui.Controls.Xaml.CreateValuesVisitor.ValidateCtorArguments(Type,IElementNode,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.", + "Microsoft.Maui.Controls.Xaml.CreateValuesVisitor.CreateFromParameterizedConstructor(Type,IElementNode): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Reflection.TypeInfo.DeclaredConstructors.get'. The parameter '#0' of method 'Microsoft.Maui.Controls.Xaml.CreateValuesVisitor.CreateFromParameterizedConstructor(Type,IElementNode)' 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 WarningsPerFile + { + File = "src/Core/src/Hosting/Internal/MauiFactory.cs", + WarningsPerCode = new List + { + new WarningsPerCode + { + Code = "IL2055", + Messages = new List + { + "Microsoft.Maui.Hosting.Internal.MauiFactory.GetService(Type,ServiceDescriptor,IEnumerable`1): 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 WarningsPerCode + { + Code = "IL3050", + Messages = new List + { + "Microsoft.Maui.Hosting.Internal.MauiFactory.GetService(Type,ServiceDescriptor,IEnumerable`1): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.", + } + }, + new WarningsPerCode + { + Code = "IL2077", + Messages = new List + { + "Microsoft.Maui.Hosting.Internal.MauiFactory.GetService(Type,ServiceDescriptor,IEnumerable`1): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Activator.CreateInstance(Type)'. The field 'Microsoft.Maui.Hosting.Internal.MauiFactory.ListType' 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 WarningsPerCode + { + Code = "IL2070", + Messages = new List + { + "Microsoft.Maui.Hosting.Internal.MauiFactory.GetServiceBaseTypes(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The parameter '#0' of method 'Microsoft.Maui.Hosting.Internal.MauiFactory.GetServiceBaseTypes(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 WarningsPerFile + { + File = "src/Core/src/Hosting/ImageSources/ImageSourceServiceProvider.cs", + WarningsPerCode = new List + { + new WarningsPerCode + { + Code = "IL2070", + Messages = new List + { + "Microsoft.Maui.Hosting.ImageSourceServiceProvider.CreateImageSourceTypeCacheEntry(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterface(String)'. The parameter 'type' of method 'Microsoft.Maui.Hosting.ImageSourceServiceProvider.CreateImageSourceTypeCacheEntry(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.", + "Microsoft.Maui.Hosting.ImageSourceServiceProvider.CreateImageSourceTypeCacheEntry(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The parameter 'type' of method 'Microsoft.Maui.Hosting.ImageSourceServiceProvider.CreateImageSourceTypeCacheEntry(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 WarningsPerCode + { + Code = "IL2065", + Messages = new List + { + "Microsoft.Maui.Hosting.ImageSourceServiceProvider.CreateImageSourceTypeCacheEntry(Type): Value passed to implicit 'this' parameter of method 'System.Type.GetInterface(String)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements.", + } + }, + new WarningsPerCode + { + Code = "IL2055", + Messages = new List + { + "Microsoft.Maui.Hosting.ImageSourceServiceProvider.b__9_0(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.", + "Microsoft.Maui.Hosting.ImageSourceServiceProvider.b__9_0(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 WarningsPerCode + { + Code = "IL3050", + Messages = new List + { + "Microsoft.Maui.Hosting.ImageSourceServiceProvider.b__9_0(Type): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.", + "Microsoft.Maui.Hosting.ImageSourceServiceProvider.b__9_0(Type): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.", + } + }, + } + }, + new WarningsPerFile + { + File = "src/Core/src/Platform/ReflectionExtensions.cs", + WarningsPerCode = new List + { + new WarningsPerCode + { + Code = "IL2070", + Messages = new List + { + "Microsoft.Maui.Platform.ReflectionExtensions.<>c.b__1_0(TypeInfo): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Reflection.TypeInfo.DeclaredFields.get'. The parameter 'i' of method 'Microsoft.Maui.Platform.ReflectionExtensions.<>c.b__1_0(TypeInfo)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.", + } + }, + } + }, + new WarningsPerFile + { + File = "src/Controls/src/Xaml/MarkupExpressionParser.cs", + WarningsPerCode = new List + { + new WarningsPerCode + { + Code = "IL2072", + Messages = new List + { + "Microsoft.Maui.Controls.Xaml.MarkupExpressionParser.ParseExpression(String&,IServiceProvider): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Activator.CreateInstance(Type)'. 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.", + } + }, + } + }, + }; #region Utility methods for generating the list of expected warnings