Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Methods marked with the JetBrains UsedImplicitly attribute have an IDE0051 warning #39028

Closed
vsfeedback opened this issue Oct 3, 2019 · 5 comments
Assignees
Labels
Area-IDE Developer Community The issue was originally reported on https://developercommunity.visualstudio.com Question Resolution-By Design The behavior reported in the issue matches the current design

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


[regression] [worked-in:15.9.16]
Methods marked with the JetBrains attribute [UsedImplicitly] are greyed out with an IDE0051 analysis warning
For instance using PropertyChanged.Fody for classes that implement INotifyPropertyChanged there is no need to call the private method OnPropertyChanged in the C# file.
In Visual Studio 2017 the UsedImplicitly attribute was correctly recognised and there was no IDE0051 warning

using System.ComponentModel;
using System.Runtime.CompilerServices;
using JetBrains.Annotations;

namespace ExampleAnalysisIssue
{
    [UsedImplicitly]
    public sealed class Class1 : INotifyPropertyChanged
    {
        public int Data { get; set; }

public event PropertyChangedEventHandler PropertyChanged;

[NotifyPropertyChangedInvocator]
        [UsedImplicitly]
        private void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChanged?. Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}


Original Comments

Visual Studio Feedback System on 10/3/2019, 00:11 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.


Original Solutions

(no solutions)

@sharwell
Copy link
Member

sharwell commented Oct 3, 2019

📝 I believe IDE0051 is new for Visual Studio 2019

@mavasani
Copy link
Contributor

mavasani commented Oct 3, 2019

I believe this is by design and duplicate of #35767 (comment). The recommended approach would be to author a DiagnosticSuppressor for programmatically suppressing all violations on types with any extension specific attributes OR apply source suppressions for each case. I presume former is more preferable.

@mavasani
Copy link
Contributor

mavasani commented Oct 3, 2019

Such a diagnostic suppressor should then ship along with the package that adds such attributes. So for this case, JetBrains should author a DiagnosticSuppressor for IDE0051 and suppress it whenever it sees symbols with its custom attribute, and ship this suppressor along with their package.

@mavasani mavasani added Need Design Review The end user experience design needs to be reviewed and approved. Resolution-By Design The behavior reported in the issue matches the current design labels Oct 3, 2019
@sharwell sharwell added Question and removed Need Design Review The end user experience design needs to be reviewed and approved. labels Oct 3, 2019
@sharwell sharwell closed this as completed Oct 3, 2019
@sharwell sharwell added the Developer Community The issue was originally reported on https://developercommunity.visualstudio.com label Nov 21, 2019
@godrose
Copy link

godrose commented Dec 11, 2020

This is a breaking change. Has anyone in MS even contacted JEtBrains on that matter?

@CyrusNajmabadi
Copy link
Member

This is a breaking change

This is not a breaking change.

Has anyone in MS even contacted JEtBrains on that matter?

I'm unaware of any contact to jetbrains here. The information was provided so that the original filer could forward things along if they wished to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Developer Community The issue was originally reported on https://developercommunity.visualstudio.com Question Resolution-By Design The behavior reported in the issue matches the current design
Projects
None yet
Development

No branches or pull requests

5 participants