Ticket #33 (closed defect: invalid)
Cobra doesn't support .NET Attributes
Reported by: | Kurper | Owned by: | Kurper |
---|---|---|---|
Priority: | medium | Milestone: | |
Component: | Cobra Compiler | Version: | 0.8.0 |
Keywords: | Cc: | kurper@… |
Description
Apparently, attributes are a feature of .NET similar to interfaces, but different in some way. I'm not completely clear on what makes them different, but the RegexOptions enum ( http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regexoptions.aspx) uses them to allow bitwise operators to be used on objects. Presumably they have more uses, but without them, it's impossible to do this:
regex = Regex(r"long regex", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace)
for a case-insensitive regex that's easy to read. (As a sidenote, Cobra doesn't convert enums to lowerCamelCase, which may or may not be a bug.)
The corresponding C# code would be:
Regex regex = new Regex(@"long regex", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
and that works just fine.
Here are some other relevant MSDN articles:
http://msdn.microsoft.com/en-us/library/system.flagsattribute.aspx
http://msdn.microsoft.com/en-us/library/system.attributeusageattribute.aspx