472,958 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

Sharing namespaces across projects?

Is it valid to share namespaces across projects in C#?

For example, I have a project that contains the code for a core
assembly, this builds a DLL. I then have a second project in the same
solution that contains test cases for the assembly in the same
namespace, this references the first project's DLL and builds a further
DLL for testing. All code has the same namespace. The code in the tests
needs access to internal methods etc of the core assembly that wouldn't
be available outside the namespace.

Nov 17 '05 #1
5 8342
Yes, this is doable... A namespace only gives you ways to seperate your
code from other developers in case of name conflicts within the source code.
If you are writing all the pieces and have no reason to use seperate
namespaces then you don't have to, however, you bring up something that I
think you might not fully understand.

Just because you place components into their own namespace doesn't mean that
you can't access them from other parts of the program that might use
different name spaces. It only means that you have to add a using statement
to tell your source that that unit uses another namespace as well.

Good luck,

glenn

<ge*****************@yahoo.co.uk> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Is it valid to share namespaces across projects in C#?

For example, I have a project that contains the code for a core
assembly, this builds a DLL. I then have a second project in the same
solution that contains test cases for the assembly in the same
namespace, this references the first project's DLL and builds a further
DLL for testing. All code has the same namespace. The code in the tests
needs access to internal methods etc of the core assembly that wouldn't
be available outside the namespace.

Nov 17 '05 #2
internal is assembly scoped, not namespace scoped. so while you can spread a
namespace across multiple assemblies, it still won't solve your problem.
your unit test classes reside in a different assembly still can't access the
internal members of the core assembly.

"ge*****************@yahoo.co.uk" wrote:
Is it valid to share namespaces across projects in C#?

For example, I have a project that contains the code for a core
assembly, this builds a DLL. I then have a second project in the same
solution that contains test cases for the assembly in the same
namespace, this references the first project's DLL and builds a further
DLL for testing. All code has the same namespace. The code in the tests
needs access to internal methods etc of the core assembly that wouldn't
be available outside the namespace.

Nov 17 '05 #3
Sorry Glen I don't understand the point you're making in your last
paragraph? If the methods are marked internal then they can't be used
outside the namespace even with a using clause.

The methods I am testing are marked internal so they won't be available
to other users, but I need access in my test cases and so my test cases
are in the same namespace - so should be able to access the internal
methods.

Nov 17 '05 #4
Thanks Daniel. Pretty obvious really.
Not sure how I confused myself about that.

Nov 17 '05 #5
Sorry, I miss understood the question I guess. I missed the part about
wanting to get access to the internal methods not shared... :-)

glenn

<ge*****************@yahoo.co.uk> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Sorry Glen I don't understand the point you're making in your last
paragraph? If the methods are marked internal then they can't be used
outside the namespace even with a using clause.

The methods I am testing are marked internal so they won't be available
to other users, but I need access in my test cases and so my test cases
are in the same namespace - so should be able to access the internal
methods.

Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: DKode | last post by:
I have 2 projects in a solution: Web EmployeeManagement The namespace for Web is : CompanyName.Hybrid.Web The namespace for EmployeeManagement is just : CompanyName.Hybrid ...
1
by: Simon Neve | last post by:
Hello, This question is related to sharing .Net projects across solutions and is reposted from the SourceSafe group. We have several different solutions and want to share common assemblies...
5
by: cybertof | last post by:
Hi ! What is the common use of sharing a single .cs across multiple project files ? I think it's to share common classes between projects. I have actually a .cs file shared accross multiple...
3
by: Robert W. | last post by:
I'm embarking on a project that will have both a desktop application and a Pocket PC application. It seems logical to have as much code as possible sitting in a shared project, which would be...
0
by: Daniel | last post by:
Hi! I have several projects (approx 50) that includes basically the same files such as <atlcom.h> and <comdef.h>. The projects are set up to use a precompiled header wich includes these header...
0
by: Darren Oakey | last post by:
G'day - is there anyway of sharing the Session data across two different ASP.Net projects? Basically, I'm jumping from a page in one to a page in another, and I'd like to have the data flit...
0
by: rcolby | last post by:
Hi, A little advice on code sharing across projects, namespaces and dll's for references. I've got an application that is split between three different projects (one for a service, one for...
2
by: David | last post by:
How do I share code across files in C#, without including a reference to a class library. Here's what I want to do. I have a device I want to talk to. It's a machine in a factory. It can talk...
2
by: Jeff Dege | last post by:
I'm working with a group that's been doing C++ coding for quite a long time, now, and in that environment we've pretty much worked out development practices that serve us well. We've been doing...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.