Unused properties when only used for data binding

It seems that if I create an private class in which I declare a property,
and I only use this class for binding lists to a combo box, resharper flags
that I have not used the property get anywhere and it can be removed.  When
actually it is used  as the DataMember of the combo box:

IList list = GetpopulatedList();
ComboBox.DataSource = list;
ComboBox.DisplayMember = "Name";


        private class PrivateClass
            {
            public NamedWaypointSourceForm (string name, Form form)
                {
                Name = name;
                Form = form;
                }

            public string Name { get; private set; }


            public Form Form { get; private set; }
            }

Is there anyway that this can be avoided, or is the fact that it is only
used via reflection just one of those things?


1 comment
Comment actions Permalink

You can include the JetBrains.Annotations library and mark the property with
the UsedImplictly attribute which should clear the suggestion.

HTH

David

"Sam Holder" <sam.holder@bentley.com> wrote in message
news:befa57e832ef8ccadcf4acf8d1b@news.jetbrains.com...

It seems that if I create an private class in which I declare a property,
and I only use this class for binding lists to a combo box, resharper
flags that I have not used the property get anywhere and it can be
removed.  When actually it is used  as the DataMember of the combo box:

>

IList<PrivateClass> list = GetpopulatedList();
ComboBox.DataSource = list;
ComboBox.DisplayMember = "Name";

>
>

       private class PrivateClass
           {
           public NamedWaypointSourceForm (string name, Form form)
               {
               Name = name;
               Form = form;
               }

>

           public string Name { get; private set; }

>
>

           public Form Form { get; private set; }
           }

>

Is there anyway that this can be avoided, or is the fact that it is only
used via reflection just one of those things?

>



0

Please sign in to leave a comment.