0

XML comments do not show up when an object instance is defined using WithEvents; however, comments will show up for everything else. How do I resolve this?


EDIT

''' <summary>
''' Represents a <see cref="System.Windows.Forms.Button"/> control that when clicked displays the associated <see cref="System.Windows.Forms.CheckBox"/> controls which the user can use to toggle elements.
''' </summary>
Public WithEvents DropDownButton As New System.Windows.Forms.Button

Source Image: enter image description here Image from new project using the code: enter image description here

John89
  • 45
  • 1
  • 7
  • DO NOT post only pictures of code. Post the code as text, formatted as code. If a screenshot provides value then post it too but ALWAYS post the code as text. – jmcilhinney Aug 25 '21 at 14:18
  • Why would you care about the XML documentation for the field when mousing over the field declaration? You've got the documentation right there. It's when using the elsewhere in code that it matters. Does it show then? The screenshot doesn't indicate that you've actually checked that. – jmcilhinney Aug 25 '21 at 14:22
  • Exposing your fields publicly is bad practice anyway. You really ought to be declaring those fields `Private` and, if you need to expose them publicly, do so via a `Public` property. If there actually is an issue with fields declared `WithEvents`, it will be a moot point because the XML documentation will be on the property anyway. – jmcilhinney Aug 25 '21 at 14:23
  • Understandable, but in this case I included the image to display the issue of the XML comments not showing up. The code part is useless, I just wanted to illustrate that what you are supposed to see cannot be seen. Is that acceptable or should I remove the picture? – John89 Aug 25 '21 at 14:24
  • Yes, I need them public since I am using it in other projects. I have verified the comments do not show up. – John89 Aug 25 '21 at 14:25
  • *"Yes, I need them public"*. You don't need the fields to be public. Like I said, you should always declare fields private and expose them via public properties if required. – jmcilhinney Aug 25 '21 at 14:26
  • *"I have verified the comments do not show up"*. Then why haven't you shown us that in a screenshot instead of the irrelevant part you did show us? – jmcilhinney Aug 25 '21 at 14:27
  • 1
    Like I said, including a screenshot is fine if it adds value, but that doesn't mean that you shouldn't post the code as text. We can't copy code from a picture and paste it into VS to test it for ourselves. The same goes for error message, i.e. post a screenshot if it adds value but ALWAYS post the text first. – jmcilhinney Aug 25 '21 at 14:29
  • "_We can't copy code from a picture and paste it into VS to test it for ourselves_" that makes sense, thank you for the etiquette knowledge. As far as screenshots of comments from other projects, I can post that as well as add the code as text. – John89 Aug 25 '21 at 14:37
  • I just tested and I can confirm that the XML documentation is not displayed when mousing over the field name, either in the declaration or is other usages. Interestingly, it did show up in the Intellisense list displayed when I started typing the member name after a dot in code. I use ReSharper though, so I'm not 100% sure that vanilla VS would do the same. I'm really not sure why the documentation doesn't show but I doubt that you can change it. They may have assumed that fields declared `WithEvents` would always be private, which they really should be. You should use public properties. – jmcilhinney Aug 25 '21 at 14:41
  • Ok, thank you @jmcilhinney! I will see if I can figure it out by making it private and declaring a property for it instead. I will keep everyone posted. – John89 Aug 25 '21 at 14:49
  • 1
    The default behavior for `WithEvents` Fields (which should not be exposed) is to add an underscore in the XML documentation, before the `F:Name` descriptor, so it does not appear. -- Remove `WithEvents`, this doesn't really look like it's as an object handled by the Designer. – Jimi Aug 25 '21 at 15:05
  • I changed the `WithEvents` variable to `Private` and assigned a property value to it like suggested. I guess you were write that we just cannot add XML comments to `WithEvents` objects. That would make sense though since you're not really supposed to expose them anyway*. – John89 Aug 25 '21 at 15:18

0 Answers0