Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8834351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:59:32+00:00 2026-06-14T08:59:32+00:00

Say I have a rather expensive assertion: bool IsCompatible(Object x, Object y) { //

  • 0

Say I have a rather expensive assertion:

bool IsCompatible(Object x, Object y) { 
  // do expensive stuff here
}

If I test this assertion with:

Debug.Assert(IsCompatible(x,y));

Will IsCompatible be executed in release builds?

My understanding is that Debug.Assert being marked as [Conditional(“DEBUG”)], calls to it will only be emitted in debug builds. I’m thinking that this won’t prevent the expression from being evaluated in release mode though, since the method call may have side effects, only the passing of the result to Debug.Assert wouldn’t be emitted. Is that correct?

Should I be doing:

#if DEBUG
Debug.Assert(IsCompatible(x,y));
#endif

To ensure that I don’t pay the cost of IsCompatible in release mode?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T08:59:34+00:00Added an answer on June 14, 2026 at 8:59 am

    No.

    Debug.Assert is decorated with [Conditional("DEBUG")].

    When the compiler compiles a call to this method, it will remove that entire statement unless DEBUG is defined in the calling project.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a Stream that's rather expensive to compute. I can easily create
I need to do this rather strange thing, let's say i have: $number =
For simplicity's sake, let's say we have this rather contrived table: [ID] [Weekday] [Weather]
A rather cryptic title, but it's difficult to phrase. Say I have an object
This is a rather hypothetical question, but let's say I have 3 long parameters
Say I have a bunch of tables where the objects are marked deleted rather
Lets say have this immutable record type: public class Record { public Record(int x,
I noticed Date.Parse can't handle only 2 digits dates. Say I have this mm/dd/yy
Say I have a Range object for cells A1:A10 in my worksheet. These cells
Say I have an flash object embedded in XHTML like so... <object width=600 height=400>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.