473,394 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Implement Interface in debug build only

I have a class which implements several interfaces. One of them I
would like to have implemented only if it is a debug build. Is there
a way to do this?

Thanks.

Aug 30 '07 #1
8 1794
Hello ramhog,

and what the problem? just use #if DEBUG preprocessor directive for this

but u cant miss implementing some interfaces, u need provide either debug
implementation or the standart one

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
rI have a class which implements several interfaces. One of them I
rwould like to have implemented only if it is a debug build. Is there
ra way to do this?
r>
rThanks.
r>
Aug 30 '07 #2
The problem with this is that if I only want to have the interface
implmented during a debug build. If I just put the #if DEBUG...#endif
around the methods, then a release build will have errors because the
interface isn't fully implemented.

public class MyBigTestClass : IReleaseMethods, ITestMethods
{
....
}

In this example, I want to only have the ITestMethods implemented in a
debug build.

I hope I am making sense.

Thank you for your help.

On Aug 30, 10:05 am, Michael Nemtsev <nemt...@msn.comwrote:
Hello ramhog,

and what the problem? just use #if DEBUG preprocessor directive for this

but u cant miss implementing some interfaces, u need provide either debug
implementation or the standart one

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog:http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

rI have a class which implements several interfaces. One of them I
rwould like to have implemented only if it is a debug build. Is there
ra way to do this?
r>
rThanks.
r>

Aug 30 '07 #3
Hello ramhog,

Then I suppose u need to have the 2 classes, and wrapping one with #if debug
and another with #if RELEASE

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
rThe problem with this is that if I only want to have the interface
rimplmented during a debug build. If I just put the #if
rDEBUG...#endif around the methods, then a release build will have
rerrors because the interface isn't fully implemented.
r>
rpublic class MyBigTestClass : IReleaseMethods, ITestMethods
r{
r...
r}
rIn this example, I want to only have the ITestMethods implemented in
ra debug build.
r>
rI hope I am making sense.
r>
rThank you for your help.
r>
rOn Aug 30, 10:05 am, Michael Nemtsev <nemt...@msn.comwrote:
r>
>Hello ramhog,

and what the problem? just use #if DEBUG preprocessor directive for
this

but u cant miss implementing some interfaces, u need provide either
debug implementation or the standart one

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog:http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high
and we miss it, but that it is too low and we reach it" (c)
Michelangelo

rI have a class which implements several interfaces. One of them I
rwould like to have implemented only if it is a debug build. Is
there
ra way to do this?
r>
rThanks.
r>

Aug 30 '07 #4
Hi,
"ramhog" <ka*********@ngc.comwrote in message
news:11**********************@d55g2000hsg.googlegr oups.com...
The problem with this is that if I only want to have the interface
implmented during a debug build. If I just put the #if DEBUG...#endif
around the methods, then a release build will have errors because the
interface isn't fully implemented.
You have to do the same in the declaration:
class AddEditAgencySessionInfo
#if DEBUG
: IDisposable
#endif
Aug 30 '07 #5
On Aug 30, 10:19 am, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions.comwrote:
Hi,

"ramhog" <kalvin.t...@ngc.comwrote in message

news:11**********************@d55g2000hsg.googlegr oups.com...
The problem with this is that if I only want to have the interface
implmented during a debug build. If I just put the #if DEBUG...#endif
around the methods, then a release build will have errors because the
interface isn't fully implemented.

You have to do the same in the declaration:
class AddEditAgencySessionInfo
#if DEBUG
: IDisposable
#endif
Thanks for everyones help.

This gives me an error:
class MyTestClass : IReleaseMethods #if DEBUG , IDebugMethods #endif
{...}

I have tried different variantions of this with the same problem, such
as:
class MyTestClass : IReleaseMethods, #if DEBUG IDebugMethods #endif
class MyTestClass #if DEBUG : IReleaseMethods, IDebugMethods #endif
Aug 30 '07 #6
Hello ramhog,

Just check your code, everything works fine

u can use the following code to check it

public interface IMyInterface
{
void MethodOne();
void MethodTwo();
}

class Program
#if DEBUG
: IMyInterface
#endif

{
static void Main(string[] args)
{
}
#if DEBUG

#region IMyInterface Members

public void MethodOne()
{
throw new NotImplementedException();
}

public void MethodTwo()
{
throw new NotImplementedException();
}

#endregion

#endif

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
rOn Aug 30, 10:19 am, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
rlaceupsolutions.comwrote:
r>
>Hi,

"ramhog" <kalvin.t...@ngc.comwrote in message

news:11**********************@d55g2000hsg.googleg roups.com...
>>The problem with this is that if I only want to have the interface
implmented during a debug build. If I just put the #if
DEBUG...#endif around the methods, then a release build will have
errors because the interface isn't fully implemented.
You have to do the same in the declaration:
class AddEditAgencySessionInfo
#if DEBUG
: IDisposable
#endif
rThanks for everyones help.
r>
rThis gives me an error:
rclass MyTestClass : IReleaseMethods #if DEBUG , IDebugMethods #endif
r{...}
rI have tried different variantions of this with the same problem,
rsuch
ras:
rclass MyTestClass : IReleaseMethods, #if DEBUG IDebugMethods #endif
rclass MyTestClass #if DEBUG : IReleaseMethods, IDebugMethods #endif
Aug 30 '07 #7
ramhog <ka*********@ngc.comwrote:
Thanks for everyones help.

This gives me an error:
class MyTestClass : IReleaseMethods #if DEBUG , IDebugMethods #endif
{...}
Yes, it would.
I have tried different variantions of this with the same problem, such
as:
class MyTestClass : IReleaseMethods, #if DEBUG IDebugMethods #endif
class MyTestClass #if DEBUG : IReleaseMethods, IDebugMethods #endif
You didn't try the code as posted though, I suspect.

Pre-processor directives need to be on lines on their own. Use exactly
the code Ignacio posted instead.

To be honest though, I'd try to avoid having this kind of thing in the
first place. It sounds like a recipe for problems.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Aug 30 '07 #8
On Aug 30, 1:04 pm, Jon Skeet [C# MVP] <sk...@pobox.comwrote:
ramhog <kalvin.t...@ngc.comwrote:
Thanks for everyones help.
This gives me an error:
class MyTestClass : IReleaseMethods #if DEBUG , IDebugMethods #endif
{...}

Yes, it would.
I have tried different variantions of this with the same problem, such
as:
class MyTestClass : IReleaseMethods, #if DEBUG IDebugMethods #endif
class MyTestClass #if DEBUG : IReleaseMethods, IDebugMethods #endif

You didn't try the code as posted though, I suspect.

Pre-processor directives need to be on lines on their own. Use exactly
the code Ignacio posted instead.

To be honest though, I'd try to avoid having this kind of thing in the
first place. It sounds like a recipe for problems.

--
Jon Skeet - <sk...@pobox.com>http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Thank you very much all of you for your help. I didn't realize the
directive had to be on it's own line, that worked good.

class MyTestClass : IReleaseMethods
#if DEBUG
, ITestMethods
#endif

Aug 30 '07 #9

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

Similar topics

0
by: Joe Hershman | last post by:
all, not sure what the best place to post this one, hopefully someone can help because this is a real show stopper. i am getting the error shown below when i try to build a deployment project. ...
0
by: Adam Tomjack | last post by:
I'm trying to embed Python 2.3.5 into a C++ application on Windows XP. When I build my app with debug symbols and link to a debug build of Python, then my program seems to crash most (but not all)...
175
by: Ken Brady | last post by:
I'm on a team building some class libraries to be used by many other projects. Some members of our team insist that "All public methods should be virtual" just in case "anything needs to be...
6
by: Alpha | last post by:
Hi, I'm fixing a bug in an application and need to step thru the appl to find where it's occuring. The main project includs 33 other projects each having a .resx file in it. When I step through it...
7
by: Tom | last post by:
How can I make code not execute for a debug build, but do execute for a production build? I have code which prompts for an account and password when the program starts up. It is a pain to have to...
7
by: moondaddy | last post by:
If I'm in a class that inherits an interface, is there a shortcut key that will write the implementation of the interface into the class? I remember seeing something like this in vb.net. ...
0
by: emin.shopper | last post by:
I had a need recently to check if my subclasses properly implemented the desired interface and wished that I could use something like an abstract base class in python. After reading up on metaclass...
4
by: =?Utf-8?B?Sm9obg==?= | last post by:
Hi all, I am developing website application in asp.net , visual C# and atl com. I am using atl com component in visual C# application. One of the function of com component interface returns...
7
by: Jwe | last post by:
Hi, I've written a program which has both a command line interface and Windows form interface, however it isn't quite working correctly. When run from command line with no arguments it should...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...

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.