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 9219491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:07:44+00:00 2026-06-18T03:07:44+00:00

I my code I’m using the System.Function method Debug.Assert(..) for verify the input parameter

  • 0

I my code I’m using the System.Function method Debug.Assert(..) for verify the input parameter at the beginning of a method (see following example code snipped):

public class TestClass : IInterface
{
}

public class Verifier
  {
     public static void Verify(IInterface objectToVerify)
     {
        Debug.Assert((objectToVerify is TestClass), "Passed object must be type of TestClass");

        // ReSharper (Version 7.1.1) marks here "Expression is always false
        if (!(objectToVerify is TestClass))
        {
           return;
        }

        // do something ...
     }
  }

If I comment out the Debug.Assert statement the ReSharper warning disappears.
In my opinion, ReSharper has to ignore this Debug.Assert statement, because also if the Debug.Assert statement is not fulfilled, the code beneath is executed (e.g. in Release-mode)

What is your opinion? Or is there a alternative implementation idea?

  • 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-18T03:07:45+00:00Added an answer on June 18, 2026 at 3:07 am

    ReSharper is smart enough to know that Debug.Assert() will stop execution if objectToVerify is not a TestClass. Therefore, the expression in your if statement is indeed always false (otherwise the if statement wouldn’t be reached in the first place).

    You can work around the warning by writing something like:

    public static void Verify(IInterface objectToVerify)
    {
        if (!(objectToVerify is TestClass))
        {
            Debug.Assert(false, "Passed object must be type of TestClass");
            return;
        }
    
        // do something ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Code to create new form instance of a closed form using form name I
Code : $('#myLink').click(function (e) { e.preventDefault(); ... if (someCondition) { ... code ... }
Code for button: Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Code I created the following program: #include <iostream> void f(char v[]) { for(char* p
Code that was built using VS 2003 for generating 32 bit binary was built
CODE am trying: <input type=radio name=type value=Male <?php if ($type == 'Male') echo 'checked=checked';
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
Code : HTML <a id="go" href="javascript:void(0);">Start</a> <div id="container"> <div class="example" id="example1">1</div> <div class="example" id="example2">2</div>
Code below taken from here . * qsort example */ #include <stdio.h> #include <stdlib.h>
Code in html.haml in Rails using AngularJS %table %tbody{:ng-init => my_model=#{@current_user_things.to_json}} %tr{:ng-repeat => row

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.