Enums, Intellisense, and switchs…
-
What is the format needed for Intellisense to pick up on my comments for my enums? So when I type “MyEnum.ItemOne” the intellisense will display the documentation I’ve written for “ItemOne”? Also, is there some sort of command I can use in Visual Studio that will generate a compile error if I don’t use all possible Enum values in a switch statement? I’m looking for a compile-time dummy catch incase I add an extra Enum value later but might miss a statement that should switch on all possible values of the Enum. Thanks!
/// <summary> /// Absolutely /// </summary> public enum Blah { /// <summary> /// The Absolete System.Terror /// </summary> Terror, /// <summary> /// Liquid.Nitrogen /// </summary> Nitro }
[Edit]Fixed "<" signs For Point 2: Not that I know of. But It shouldn't be too hard to create a method that checks each enumeration used. [/Edit]
-
What is the format needed for Intellisense to pick up on my comments for my enums? So when I type “MyEnum.ItemOne” the intellisense will display the documentation I’ve written for “ItemOne”? Also, is there some sort of command I can use in Visual Studio that will generate a compile error if I don’t use all possible Enum values in a switch statement? I’m looking for a compile-time dummy catch incase I add an extra Enum value later but might miss a statement that should switch on all possible values of the Enum. Thanks!
Anticast wrote:
a compile error if I don’t use all possible Enum values
nope. you could come up with extra code that performs some checks, but it isn't straightforward. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
-
What is the format needed for Intellisense to pick up on my comments for my enums? So when I type “MyEnum.ItemOne” the intellisense will display the documentation I’ve written for “ItemOne”? Also, is there some sort of command I can use in Visual Studio that will generate a compile error if I don’t use all possible Enum values in a switch statement? I’m looking for a compile-time dummy catch incase I add an extra Enum value later but might miss a statement that should switch on all possible values of the Enum. Thanks!
-
/// <summary> /// Absolutely /// </summary> public enum Blah { /// <summary> /// The Absolete System.Terror /// </summary> Terror, /// <summary> /// Liquid.Nitrogen /// </summary> Nitro }
[Edit]Fixed "<" signs For Point 2: Not that I know of. But It shouldn't be too hard to create a method that checks each enumeration used. [/Edit]
Thanks, works perfectly! I was trying variations on
public enum MyEnum
{
ItemOne //My notes
}with no success =/
-
I didn't know this until recently, when I did it by accident - imagine the chances of that happening ! :)
I agree, thanks for the tip!
-
I didn't know this until recently, when I did it by accident - imagine the chances of that happening ! :)
-
Thanks, works perfectly! I was trying variations on
public enum MyEnum
{
ItemOne //My notes
}with no success =/
-
I had no idea! Real cool! :thumbsup:
-Bryan My latest programming adventure was coding the multimedia features for the Rip Ride Rockit coaster at Universal Studios Florida. I love my job.
-
What is the format needed for Intellisense to pick up on my comments for my enums? So when I type “MyEnum.ItemOne” the intellisense will display the documentation I’ve written for “ItemOne”? Also, is there some sort of command I can use in Visual Studio that will generate a compile error if I don’t use all possible Enum values in a switch statement? I’m looking for a compile-time dummy catch incase I add an extra Enum value later but might miss a statement that should switch on all possible values of the Enum. Thanks!
You may want to check out GhostDoc[^] It is a free add on for Visual Studio that makes documenting stuff (for Intellisense or not) realy easy. Ctl+Shift+d while the insertion point is in your enum and all of the
///<summary></summary>
tags for each option are inserted (and the stuff at the top). I am a bit of a fan since I found it. -
What is the format needed for Intellisense to pick up on my comments for my enums? So when I type “MyEnum.ItemOne” the intellisense will display the documentation I’ve written for “ItemOne”? Also, is there some sort of command I can use in Visual Studio that will generate a compile error if I don’t use all possible Enum values in a switch statement? I’m looking for a compile-time dummy catch incase I add an extra Enum value later but might miss a statement that should switch on all possible values of the Enum. Thanks!
Putting all enums in a switch statement simply because they exist is pointless. There are MANY times when you simply don't care about 1 or more of the ordinals (lumping their handling into the
default:
clause)..45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001