I don't think namespace should be restricted to CamelCase,
some projects (log4net, lucene.net) and my own use lowercase for first prefix for namespacing.
Forums
904-warn-lowercase.cobra
9 posts
• Page 1 of 1
Re: 904-warn-lowercase.cobra
Why case a namespace in the same way as a local var? Also, do you desire to do the same with classes, interfaces, etc.?
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: 904-warn-lowercase.cobra
you are kind of going with an open-ended question...
namespace are place holder with arbitrary name, having a warning is nice for consistency but I don't see the purpose of restricting how we name them as we do with interfaces (I*) with a compilation error
namespace are place holder with arbitrary name, having a warning is nice for consistency but I don't see the purpose of restricting how we name them as we do with interfaces (I*) with a compilation error
- gauthier
- Posts: 116
Re: 904-warn-lowercase.cobra
For namespaces The unadorned (existing) form is giving a warning to try and lead you to cobra practice idiomatic naming.
You should be able to suppress that warning
with a trailing warning suppression comment - to indicate you know what you want ( e.g for accessing an existing dll)
As an enhancement how about allowing a quoted string for the namespace - if quoted no warnings, no translations - use just as given ( with quotes removed)
I dont see any need for same with classes... Interfaces maybe if theres any C# libraries that use non camelcased naming....
You should be able to suppress that warning
with a trailing warning suppression comment - to indicate you know what you want ( e.g for accessing an existing dll)
- Code: Select all
namespace fred # .no-warnings. ::: I know this is non cobra but needed this way
As an enhancement how about allowing a quoted string for the namespace - if quoted no warnings, no translations - use just as given ( with quotes removed)
- Code: Select all
namespace "myNonCobraCompliantForm_Namespace"
I dont see any need for same with classes... Interfaces maybe if theres any C# libraries that use non camelcased naming....
- hopscc
- Posts: 632
- Location: New Plymouth, Taranaki, New Zealand
Re: 904-warn-lowercase.cobra
Chuck wrote:Why case a namespace in the same way as a local var? Also, do you desire to do the same with classes, interfaces, etc.?
I agree that consistency is a good thing, and that it makes more sense to have CamelCase namespace names (although, coming from a c++ background, I wouldn't roll my eyes if I see a lowercase namespace). However, as hopscc points out, Cobra should be respectful with other libraries that already use a lower case namespace. Suppose I'm working on some new modules for Lucene, and that I want to write them in Cobra. My code will not compile if I use the lucene namespace, but if I change it to Lucene then my code will not follow the conventions of the rest of the library. Consider how ugly this would be:
using Lucene; // For parts written in Cobra
using lucene; // For parts written in other .net languages
...
As for hopscc proposed solutions, I would rather suggest using a compiler flag : "Cobra --allow_lowercase_namespaces"
- jonathandavid
- Posts: 159
Re: 904-warn-lowercase.cobra
BTW, I just checked and Lucene.net seems to use CamelCase namespaces:
https://svn.apache.org/repos/asf/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Index/CheckIndex.cs
But my previous post is still meaningful, just replace "lucene" by any other library that *actually* uses lowercase namespaces.
https://svn.apache.org/repos/asf/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Index/CheckIndex.cs
But my previous post is still meaningful, just replace "lucene" by any other library that *actually* uses lowercase namespaces.
- jonathandavid
- Posts: 159
Re: 904-warn-lowercase.cobra
hopscc wrote:For namespaces The unadorned (existing) form is giving a warning to try and lead you to cobra practice idiomatic naming.
You should be able to suppress that warning
with a trailing warning suppression comment - to indicate you know what you want ( e.g for accessing an existing dll)
- Code: Select all
namespace fred # .no-warnings. ::: I know this is non cobra but needed this way
As an enhancement how about allowing a quoted string for the namespace - if quoted no warnings, no translations - use just as given ( with quotes removed)
- Code: Select all
namespace "myNonCobraCompliantForm_Namespace"
I dont see any need for same with classes... Interfaces maybe if theres any C# libraries that use non camelcased naming....
Correct, you can use # .no-warnings.
Note that I relaxed the code regarding namespaces read from binary libraries (DLLs).
I don't like the quoted version because it implies to me that you could have spaces and other punctuation in the name. For example, that is the case in:
use FooBar from 'Foo Bar'
The warning for source-based lowercase namespace names will be left in place.
Btw I'm not opposed to giving our warnings id tags like CW1000, CW1001, etc and then allowing the user to disable specific warnings or have them reported as errors. But it's low on my list of priorities. Patches welcome.
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: 904-warn-lowercase.cobra
Well you can have spaces an other punctuation in filenames and dirs - Windows systems revel in it ('Program Files', 'Documents and Settings')
Does c# disallow making/using dll files with spaces in their names ?
(whether anyone should actually be encouraged to do so is another question)
quoting is a rather accepted way of specifying that we're stepping outside any existing conventions/ accepted idioms...
can always check quoted string for chars didnt like and emit a warning....
Does c# disallow making/using dll files with spaces in their names ?
(whether anyone should actually be encouraged to do so is another question)
quoting is a rather accepted way of specifying that we're stepping outside any existing conventions/ accepted idioms...
can always check quoted string for chars didnt like and emit a warning....
- hopscc
- Posts: 632
- Location: New Plymouth, Taranaki, New Zealand
Re: 904-warn-lowercase.cobra
# .no-warnings. already works.
Moving on.
Moving on.
- Charles
- Posts: 2515
- Location: Los Angeles, CA
9 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 38 guests