Properties marked as "never used" when only used in DataBinding

I turned on the option for doing solution wide analysis. I have a class with several properties that are ONLY used in the designer for automted data binding. ReSharper incorrectly tags these as never used. Is there an option to tell ReSharper to consider data binding a use?

5 comments

Not the best solution, but I discovered there is a new [UsedImplicitly] annotation that will get rid of the warnings when sprinkled liberally throughout the class.  I still don't understand why it doesn't see the get and set calls. Just to be sure as a test I commented out the set and predictably the code broke.  Here's an example of what I had to do for anyone else that runs into a similar problem:


        public short XAxisUnitsPost
        {
            get { return _sensorDisplayRow.XAxisUnitsPost; }
            [UsedImplicitly]
            set { _sensorDisplayRow.XAxisUnitsPost = value; }
        }


and sometimes


        [UsedImplicitly]
        public bool Rotate180
        {
            get { return _sensorDisplayRow.Rotate180; }
            set { _sensorDisplayRow.Rotate180 = value; }
        }     

0

Hello,

I still don't understand
why it doesn't see the get and set calls.


What do the set calls look like?

Just to be sure as a test I commented out the set and predictably the code

broke.

Did it get red in R#, or were it broken at runtime only?


Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”


0

Here is one sample Property

       
        public Color TraceColor
        {
            get { return Color.FromArgb(_sensorDisplayRow.TraceColorArgb); }
            [UsedImplicitly]
            set { _sensorDisplayRow.TraceColorArgb = value.ToArgb(); }
        }



 



If I comment out the set clause it compiles and I never even get a run time error but _sensorDisplayRow.TraceColorArgb never gets set.
When it is commented in, the data binding works properly.

0

Hello,

If I comment out the set clause it compiles and I never even get a run
time error but _sensorDisplayRow.TraceColorArgb never gets set.


This means that there're no usages for the set clause in your code, and that's
why R# does not see the "set" calls -- because there aren't any to see.

There's an indirect evidence that the property setter has implicit usages
-- the databinding declaration somewhere in the designer definitions file.
Ideally, R# should have heuristics for popular cases like this. But they
have not been implemented yet, unfortunately.


Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”


0

This came up again in another section of my code. I would like to suggest that in the spirit of "do no harm" that the order of the proposed options in the context menu be changed so that the "Annotate with Used Implicitly" option is first and the destructive "Removed unused accessor" come later.

0

Please sign in to leave a comment.