void ValidateMethodRequiresUnreferencedCodeAreSame(MethodDefinition method, MethodDefinition baseMethod)
        {
            var  annotations        = Context.Annotations;
            bool methodHasAttribute = annotations.HasLinkerAttribute <RequiresUnreferencedCodeAttribute> (method);

            if (methodHasAttribute != annotations.HasLinkerAttribute <RequiresUnreferencedCodeAttribute> (baseMethod))
            {
                string message = MessageFormat.FormatRequiresAttributeMismatch(methodHasAttribute, baseMethod.DeclaringType.IsInterface, nameof(RequiresUnreferencedCodeAttribute), method.GetDisplayName(), baseMethod.GetDisplayName());
                Context.LogWarning(string.Format(SharedStrings.RequiresAttributeMismatchMessage, message), 2046, method, subcategory: MessageSubCategory.TrimAnalysis);
            }
        }
Example #2
0
        void ValidateMethodRequiresUnreferencedCodeAreSame(MethodDefinition method, MethodDefinition baseMethod)
        {
            var  annotations        = Context.Annotations;
            bool methodHasAttribute = annotations.IsMethodInRequiresUnreferencedCodeScope(method);

            if (methodHasAttribute != annotations.IsMethodInRequiresUnreferencedCodeScope(baseMethod))
            {
                string message = MessageFormat.FormatRequiresAttributeMismatch(methodHasAttribute,
                                                                               baseMethod.DeclaringType.IsInterface, nameof(RequiresUnreferencedCodeAttribute), method.GetDisplayName(), baseMethod.GetDisplayName());
                Context.LogWarning(method, DiagnosticId.RequiresUnreferencedCodeAttributeMismatch, message);
            }
        }