Question: It understands that if the assertion is false that Debug.Assert will throw rather than continue and thus it knows the assertion is true past that point.

I'd like the same reasoning for Trace.Assert. Yeah, you can continue, if you continue past such a warning and it then throws on a null that's your problem. I want to get rid of those spurious possible null reference messages.

Answer: 
I just tested this in ReSharper 9.1.3 with the following sample code.

```
private void M(string a)
{
    Trace.Assert(a != null); // or Debug.Assert(a != null);

    if (a == null)
        Console.WriteLine("a is null");
}

```

R# reported for both `Debug.Assert()` and `Trace.Assert()` that the `Console.WriteLine()` call is "heuristically unreachable". This is the case because both methods are annotated in ReSharper's [external annotations](https://www.jetbrains.com/resharper/help/Code_Analysis__External_Annotations.html) with `[ContractAnnotation("condition:false=>halt")]` (you can see this by hitting Ctrl+Shift+F1 on the method and clicking on "[...]").

Which version of ReSharper/of the external annotations package do you have?

BTW: The `condition:false=>halt` annotation is not really correct because a) you could click "Ignore" in the `DefaultTraceListener` message box and execution will continue and b) it depends on the `Trace.Listeners` configuration (e.g. if you call `Trace.Listeners.Clear()` or set the [`AssertUiEnabled`](https://msdn.microsoft.com/en-us/library/vstudio/system.diagnostics.defaulttracelistener.assertuienabled.aspx) property to false the message box will not even appear).
This works on ReSharper 9.2.

In case your version of ReSharper doesn't have an annotation on `Trace.Assert`:

You'd need the following [annotation attribute](https://www.jetbrains.com/resharper/help/Code_Analysis__Code_Annotations.html) on the `Trace.Assert` method:

```csharp
[ContractAnnotation("condition:false=>halt")]

```

Which tells ReSharper that if the `condition` parameter is `false`, the method will not return normally (`halt`).

Well, this is what you'd put in your own code if you were the author of the method. But you can't just insert an attribute to `System.dll`.

You can use [external annotations](https://www.jetbrains.com/resharper/help/Code_Analysis__External_Annotations.html) though. With these, you'll have to write some XML:

```xml
<assembly name="System">
  <member name="M:System.Diagnostics.Trace.Assert(System.Boolean)">
    <attribute ctor="M:JetBrains.Annotations.AssertionMethodAttribute.#ctor"/>
    <attribute ctor="M:JetBrains.Annotations.ContractAnnotationAttribute.#ctor(System.String)">
        <argument>condition:false=&gt;halt</argument>
    </attribute>
  </member>
  <member name="M:System.Diagnostics.Trace.Assert(System.Boolean,System.String)">
    <attribute ctor="M:JetBrains.Annotations.AssertionMethodAttribute.#ctor"/>
    <attribute ctor="M:JetBrains.Annotations.ContractAnnotationAttribute.#ctor(System.String)">
        <argument>condition:false=&gt;halt</argument>
    </attribute>
  </member>
  <member name="M:System.Diagnostics.Trace.Assert(System.Boolean,System.String,System.String)">
    <attribute ctor="M:JetBrains.Annotations.AssertionMethodAttribute.#ctor"/>
    <attribute ctor="M:JetBrains.Annotations.ContractAnnotationAttribute.#ctor(System.String)">
        <argument>condition:false=&gt;halt</argument>
    </attribute>
  </member>
</assembly>

```

The [help page](https://www.jetbrains.com/resharper/help/Code_Analysis__External_Annotations.html) I linked to explains how to install this to ReSharper.

Or... You could write your own `Assert` method in your own helper class, which only delegates to `Trace.Assert`, so you can use the attribute:

```csharp
[ContractAnnotation("condition:false=>halt")]
public static void Assert(bool condition)
{
    Trace.Assert(condition);
}

```