Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# project folder namespace with '-' character

Tags:

namespaces

c#

I realized that folder containing a '-' character which are namespace provider do get a different namespace than expected.

e.g. I observe that the embedded resource:

AssemblyName/lib/font/source-sans-pro/source-sans-pro.css

will have the following namespace at the end:

AssemblyName.lib.font.source_sans_pro.source-sans-pro.css

So for folders, but not for files (why?), the namespace changes such that '-' is replaced with the '_' underscore character.

Unfortunately I could not find any official references describing this behavior. Can anyone provide some references about this behavior? Why does the folder namespace change? And why not the namespace of the file?

like image 246
Sjoerd222888 Avatar asked Jul 31 '15 08:07

Sjoerd222888


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What is the full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.

What is C in C language?

What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.

Is C language easy?

C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.


1 Answers

Hyphens aren't allowed in identifiers, and namespaces are identifiers. The reason is pretty simple, if you think about it - x-y is the binary - operator with operands x and y. Trying to make it also a valid identifier would be pretty terrible.

The full description of permitted identifiers is in the C# 5 spec, section 2.4.2. Of course, your embedded resource ends up being more related to the CLI spec than the C# spec, but that has similar rules - defined (in ECMA-335) to follow the rules of Annex 7 of Technical Report 15 of the Unicode 3.0 Standard.

like image 80
Jon Skeet Avatar answered Sep 28 '22 06:09

Jon Skeet