C#/Mono namespaces


S

Sid

Hobbyist codemonkey here!! :)

I'm new to C#/mono but not programming.

I prefer to code using emacs, and compiling from the CLI. I need to know how to physically organize namespace files (where should they live?) and how to reference them in a C#/mono program file.

I'm aware of the "Using" directive, as well as Namespaces { ... }. But I need to know how to tell the compiler where to find these "modules" without having to use the /r:blah.dll for every user-defined namespace. Is there a "config" file that I can tell the compiler to use to load the namespaces in one shot?

Other solution? No IDE suggestions - PLEASE!!!! TIA ...
 
Ad

Advertisements

A

Arne Vajhøj

I'm new to C#/mono but not programming.

I prefer to code using emacs, and compiling from the CLI. I need to
know how to physically organize namespace files (where should they
live?) and how to reference them in a C#/mono program file.

I'm aware of the "Using" directive, as well as Namespaces { ... }.
But I need to know how to tell the compiler where to find these
"modules" without having to use the /r:blah.dll for every
user-defined namespace. Is there a "config" file that I can tell the
compiler to use to load the namespaces in one shot?

Other solution? No IDE suggestions - PLEASE!!!!
First you need to realize that assemblies and namespaces
are not strictly tied together.

There is nothing in C# preventing you from having:
* A.dll with X.C1, Y.C2 and Z.C3 classes
* B.dll with X.C4, Y.C5 and Z.C6 classes
* C.dll with X.C7, Y.C8 and Z.C9 classes

It is purely a convention that all classes in namespace
Foo.Bar are located in assembly Foo.Bar.dll.

A good convention that you should follow because it is
the only way to understand what is where.

But due to this you cannot expect the tools to find
the assemblies just based on namespaces.

You need to explicit specify the names of the assemblies
you need.

Note that you do not need to specify full path. You can
tell Mono where to search via env var MONO_PATH.

You do not explain how you actually do the CLI builds.

I will strongly recommend against both shell scripts and
make.

Shell scripts are too cumbersome to maintain. And make
is just not optimal for C#.

Instead I will recommend you to use NAnt as build tool.

It is a build script in XML. XML in itself is no better or
no worse than anything else. But NAnt is specifically made
for building .NET stuff, so it matches what you need.

This includes making it easy to do a C# compile with
ref set to all assemblies in some specific directories.

http://nant.sourceforge.net/release/latest/help/tasks/csc.html
http://nant.sourceforge.net/release/latest/help/types/assemblyfileset.html

Arne

PS: Do not use the term modules about assemblies as modules
are something else in the .NET world.
 
S

Sid

First you need to realize that assemblies and namespaces
are not strictly tied together.

There is nothing in C# preventing you from having:
* A.dll with X.C1, Y.C2 and Z.C3 classes
* B.dll with X.C4, Y.C5 and Z.C6 classes
* C.dll with X.C7, Y.C8 and Z.C9 classes

It is purely a convention that all classes in namespace
Foo.Bar are located in assembly Foo.Bar.dll.

A good convention that you should follow because it is
the only way to understand what is where.

But due to this you cannot expect the tools to find
the assemblies just based on namespaces.

You need to explicit specify the names of the assemblies
you need.

Note that you do not need to specify full path. You can
tell Mono where to search via env var MONO_PATH.

You do not explain how you actually do the CLI builds.

I will strongly recommend against both shell scripts and
make.

Shell scripts are too cumbersome to maintain. And make
is just not optimal for C#.

Instead I will recommend you to use NAnt as build tool.

It is a build script in XML. XML in itself is no better or
no worse than anything else. But NAnt is specifically made
for building .NET stuff, so it matches what you need.

This includes making it easy to do a C# compile with
ref set to all assemblies in some specific directories.

http://nant.sourceforge.net/release/latest/help/tasks/csc.html
http://nant.sourceforge.net/release/latest/help/types/assemblyfileset.html

Arne

PS: Do not use the term modules about assemblies as modules
are something else in the .NET world.
Thanks Arne! I'll take a look at NAnt. MONOPATH is what I was looking for, but could not find any mention of in the tutorials that I Googled for. Everything out there is so IDE-centric, IMHO.
 
Ad

Advertisements

A

Arne Vajhøj

I'll take a look at NAnt. MONOPATH is what I was looking for, but could not
find any mention of in the tutorials that I Googled for. Everything out there
is so IDE-centric, IMHO.
Mono is a spin-off from the MS world. The MS world has always been very
IDE-centric.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

C# namespace 2
C# namespaces 3
Mono C#: basic question 2
new book on mono and c# 16
Evolution OM for mono c# 1
My Namespace and C#: 8
Excel namespace in C# 1
Documenting namespaces in C# 6

Top