Incorrect location of suggested assume RRS feed

  • Question

  • Hi all,

    In the code below, the static checker suggests to add Contract.Assume(x != null) to method DelegateCalculation. The suggestion is correct, but IMHO it should have been located in the overridden method Calculate, just before the call to DelegateCalculation. 

    using System.Diagnostics.Contracts;
    namespace ReproAssumeMessage
       public class Calculator
          public virtual int Calculate(object x)
             return 0;
       public class DerivedCalculator : Calculator
          public override int Calculate(object x)
             // expected suggestion here
             return DelegateCalculation(x);
          private static int DelegateCalculation(object y)
             // analyzer reports on line below: 'Suggested assume: Contract.Assume(x != null)'
             Contract.Requires(y != null);
             return 10;
    And perhaps related, we get a few information messages like the one below with an unclear identifier SR100[0x23]. Also, the message has no location information (unable to navigate to the code fragment).
    Message	5	CodeContracts: Suggested assume: SR100[0x23]: Contract.Assume(node < this._inboundCount.Count);		1	1	<Project>

    Best regards,

    Ranco Marcus


    • Edited by Ranco Marcus Tuesday, January 17, 2012 1:44 PM added related note.
    Tuesday, January 17, 2012 1:04 PM

All replies

  • Hi Ranco,

    > unclear identifier SR100[0x23]

    You can try adding "-show progress -sortwarns=false" to identify the member being checked, as per Francesco's response in the following related discussion:


    - Dave

    Tuesday, January 17, 2012 2:10 PM
  • Thank you, Dave. 

    I already identified the members involved, but your link to Francesco's response may be useful in the future.

    So, the only question remaining is whether the location of the generated message is indeed incorrect.


    Best regards,

    Ranco Marcus

    • Edited by Ranco Marcus Tuesday, January 17, 2012 5:03 PM added 'location of the'
    Tuesday, January 17, 2012 2:25 PM
  • I can reproduce it. Thank you for pointing out. I will check what's wrong.




    Wednesday, January 18, 2012 5:21 AM