diff --git a/Configuration.props b/Configuration.props index b816f97f020..f58f790bd27 100644 --- a/Configuration.props +++ b/Configuration.props @@ -108,6 +108,7 @@ $(MSBuildThisFileDirectory)external\proguard $(MSBuildThisFileDirectory)external\sqlite $(MSBuildThisFileDirectory) + $(MSBuildThisFileDirectory)src-ThirdParty\ armeabi-v7a;x86 arm64-v8a;x86_64 $(AllSupported32BitTargetAndroidAbis);$(AllSupported64BitTargetAndroidAbis) diff --git a/src/Xamarin.Android.NamingCustomAttributes/System.Diagnostics.CodeAnalysis/DynamicDependencyAttribute.cs b/src-ThirdParty/System.Diagnostics.CodeAnalysis/DynamicDependencyAttribute.cs similarity index 100% rename from src/Xamarin.Android.NamingCustomAttributes/System.Diagnostics.CodeAnalysis/DynamicDependencyAttribute.cs rename to src-ThirdParty/System.Diagnostics.CodeAnalysis/DynamicDependencyAttribute.cs diff --git a/src/Xamarin.Android.NamingCustomAttributes/System.Diagnostics.CodeAnalysis/DynamicallyAccessedMemberTypes.cs b/src-ThirdParty/System.Diagnostics.CodeAnalysis/DynamicallyAccessedMemberTypes.cs similarity index 100% rename from src/Xamarin.Android.NamingCustomAttributes/System.Diagnostics.CodeAnalysis/DynamicallyAccessedMemberTypes.cs rename to src-ThirdParty/System.Diagnostics.CodeAnalysis/DynamicallyAccessedMemberTypes.cs diff --git a/src-ThirdParty/System.Runtime.CompilerServices/UnconditionalSuppressMessageAttribute.cs b/src-ThirdParty/System.Runtime.CompilerServices/UnconditionalSuppressMessageAttribute.cs new file mode 100644 index 00000000000..5ee6c949bc9 --- /dev/null +++ b/src-ThirdParty/System.Runtime.CompilerServices/UnconditionalSuppressMessageAttribute.cs @@ -0,0 +1,92 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#nullable enable + +namespace System.Diagnostics.CodeAnalysis +{ + /// + /// Suppresses reporting of a specific rule violation, allowing multiple suppressions on a + /// single code artifact. + /// + /// + /// is different than + /// in that it doesn't have a + /// . So it is always preserved in the compiled assembly. + /// + [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] +#if SYSTEM_PRIVATE_CORELIB + public +#else + internal +#endif + sealed class UnconditionalSuppressMessageAttribute : Attribute + { + /// + /// Initializes a new instance of the + /// class, specifying the category of the tool and the identifier for an analysis rule. + /// + /// The category for the attribute. + /// The identifier of the analysis rule the attribute applies to. + public UnconditionalSuppressMessageAttribute(string category, string checkId) + { + Category = category; + CheckId = checkId; + } + + /// + /// Gets the category identifying the classification of the attribute. + /// + /// + /// The property describes the tool or tool analysis category + /// for which a message suppression attribute applies. + /// + public string Category { get; } + + /// + /// Gets the identifier of the analysis tool rule to be suppressed. + /// + /// + /// Concatenated together, the and + /// properties form a unique check identifier. + /// + public string CheckId { get; } + + /// + /// Gets or sets the scope of the code that is relevant for the attribute. + /// + /// + /// The Scope property is an optional argument that specifies the metadata scope for which + /// the attribute is relevant. + /// + public string? Scope { get; set; } + + /// + /// Gets or sets a fully qualified path that represents the target of the attribute. + /// + /// + /// The property is an optional argument identifying the analysis target + /// of the attribute. An example value is "System.IO.Stream.ctor():System.Void". + /// Because it is fully qualified, it can be long, particularly for targets such as parameters. + /// The analysis tool user interface should be capable of automatically formatting the parameter. + /// + public string? Target { get; set; } + + /// + /// Gets or sets an optional argument expanding on exclusion criteria. + /// + /// + /// The property is an optional argument that specifies additional + /// exclusion where the literal metadata target is not sufficiently precise. For example, + /// the cannot be applied within a method, + /// and it may be desirable to suppress a violation against a statement in the method that will + /// give a rule violation, but not against all statements in the method. + /// + public string? MessageId { get; set; } + + /// + /// Gets or sets the justification for suppressing the code analysis message. + /// + public string? Justification { get; set; } + } +} diff --git a/src/Mono.Android/Android.Runtime/AndroidRuntime.cs b/src/Mono.Android/Android.Runtime/AndroidRuntime.cs index 6ba1739cd5e..e57ec864cbb 100644 --- a/src/Mono.Android/Android.Runtime/AndroidRuntime.cs +++ b/src/Mono.Android/Android.Runtime/AndroidRuntime.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; using System.Threading; @@ -285,6 +286,8 @@ protected override IEnumerable GetSimpleReferences (Type type) static MethodInfo? dynamic_callback_gen; + // See ExportAttribute.cs + [UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = "Mono.Android.Export.dll is preserved when [Export] is used via [DynamicDependency].")] static Delegate CreateDynamicCallback (MethodInfo method) { if (dynamic_callback_gen == null) { diff --git a/src/Xamarin.Android.NamingCustomAttributes/Xamarin.Android.NamingCustomAttributes.projitems b/src/Xamarin.Android.NamingCustomAttributes/Xamarin.Android.NamingCustomAttributes.projitems index 85216201174..39bb89b33de 100644 --- a/src/Xamarin.Android.NamingCustomAttributes/Xamarin.Android.NamingCustomAttributes.projitems +++ b/src/Xamarin.Android.NamingCustomAttributes/Xamarin.Android.NamingCustomAttributes.projitems @@ -23,8 +23,9 @@ - - - + + + +