473,473 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 8440
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: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.