[Mono-list] need help getting started creating my own libraries
Bojan Rajkovic
brajkovic at coderinserepeat.com
Fri Dec 9 10:17:48 EST 2011
On Dec 9, 2011, at 9:05 AM, Fulko Hew wrote:
>
> On Thu, Dec 8, 2011 at 4:15 PM, Charlie Poole <charlie at nunit.com> wrote:
> On Thu, Dec 8, 2011 at 12:48 PM, Fulko Hew <fulko.hew at gmail.com> wrote:
>
> ... snip ...
>
> > Lets say my library ('mylib') consists of only two things right now:
> > myTypeA and myTypeB (that belong to my company 'xyz'.
> > And to use/test these library components I have a main app called 'tester'.
> >
> > So what I was expecting to do was to create the following directory
> > structure:
> >
> > ./com.xyz.mylib/
> > myTypeA.cs
> > myTypeb.cs
> > ./com.xyz.tester/tester.cs
> >
> > a) is this a valid structure?
>
> Sure, although the backwards naming of components something that is
> part of the Java culture and a little foreign to most C# folks. That's OK.
>
> Then what _is_ the recommended directory structure?
You'll find that a lot of folks use one the following, starting from the root of the project:
src/AssemblyName/Namespace/Namespace/Namespace/Class.cs — nested namespaces, rooted by assembly
src/AssemblyName/Namespace.Namespace.Namespace/Class.cs — top-level namespaces, rooted by assembly
Infinite combinations are possible, really—there's no canonical One True Directory Structure.
>
> > b) what compiler directives do I use to build my libraries?
>
> ... snip ...
>
> gmcs -t:library -out:mylib.dll myTypeA.cs myTypeB.cs
> gmcs -t:exe -out:tester -r:mylib.dll tester.cs
>
> Thanks, your help has gotten me past my original hurdle, but,
> is this kind of stuff documented anywhere? or is it just
> something you have to figure out and/or ask about like I did?
I think 'man gmcs' may have some examples. It'll definitely have documentation of all the command line switches that you need/want to use.
>
> In a related question... how would I go about compiling the components
> separately and then 'link' them together into a library? (ie. the traditional
> 'don't recompile unless the source file changed' approach.)
You don't (well…mostly. Netmodules exist, and I'll address them shortly). The C# compiler is plenty fast, so there's generally no need to do this. It's not like the C++ compiler, chewing through 450k of headers and source for "Hello, world!" That said, there is an intermediate format called a netmodule, but it's poorly documented because Microsoft has more or less dropped support for them. They can still be accessed via the compiler directly, but none of the IDE's support using them. I'm also not sure of the limitations—more likely than not, you can't go single .cs file to single .netmodule because you need to resolve all the referenced types at emit time.
>
> This would all be much easier if you were using MonoDevelop rather
> than working at the command line, but I suppose you're like me and
> want to do it the hard way first. :-)
>
> Your right. I'm an engineer and not a 'mouse jockey', and I need to know whats
> going on. Especially because I can't expect the 'next guy' to be using
> exactly the same tools (or platform) as I am. Heck... I didn't even know
> that MonoDevelop existed! None of the introductory docs _I_ read mentioned it.
>
> Fulko
>
MonoDevelop was at one point referenced from http://go-mono.com/http://mono-project.com. A simple search for "C# IDE Linux" would have also probably gotten you there quickly. :)
Hope that helps,
Bojan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20111209/61e33ffd/attachment.html
More information about the Mono-list
mailing list