softperson

Automating creativity

Features V2

Analysis Capabilities

What NStatic can find

Six categories of bugs that escape every other .NET static analyzer — found symbolically, not by pattern matching.

Category 01

Exception Analysis

NStatic tracks exceptions as first-class values in its symbolic model. An expression that might throw becomes If(condition, result, Exception(…)) — allowing the analyzer to determine whether any execution path can reach a thrown exception uncaught.

  • System exceptions: NullReferenceException,IndexOutOfRangeException, DivideByZeroException,OverflowException, StackOverflowException
  • Framework library exceptions — NStatic interprets .NET Framework IL directly to model what String.ToCharArray, List<T>.Add, and hundreds of other methods can throw
  • User-defined exceptions — tracked through throw/catch/finally chains symbolically
  • Failing assertions — Debug.Assert conditions verified; failures surfaced as findings

When an uncaught exception is found, NStatic shows the full interprocedural call stack and the symbolic condition under which it occurs.

Error highlighting in source editor
Error list showing exception findings

Category 02

Dead Code Detection

Code that can never execute isn't just untested — it's a maintenance hazard that confuses future readers and bloats the binary. NStatic identifies unreachable code through symbolic path analysis rather than simple control-flow heuristics.

  • Statements that follow unconditional throws or returns
  • Catch blocks for exceptions that cannot be thrown on any path reaching the try block
  • Branches of if or switch that the symbolic model proves unreachable
  • Methods whose return value is always an exception expression (they never return normally)
Execution paths showing dead branch

Category 03

Redundant Code

Redundant code compiles and runs — it just doesn't do anything useful. These findings point to logic errors, copy-paste mistakes, or stale code that should have been removed.

  • Always-true or always-false conditions in if, while, and ternary expressions
  • Contradictory conditions that can never be simultaneously true
  • Assignments to a variable that is immediately overwritten before being read
  • Method parameters that don't affect the return value (useless parameters)
  • Calls to methods with constant return values (calls that could be replaced with a literal)
  • Infinite loops with no reachable exit condition
Assumptions showing always-true condition

Category 04

Null Analysis

Null references are .NET's most common runtime crash. NStatic tracks nullability through the symbolic model — no [NotNull] or [CanBeNull] attributes needed. The analysis infers nullability from code, assignments, conditional branches, and method return types.

  • Definite null dereferences: a field access or method call on an expression the model proves is null
  • Conditional null dereferences: the model shows null is possible on some paths
  • Null propagation through call chains, tracked interprocedurally
  • Redundant null checks: conditions like if (x == null) wherex cannot be null
Locals panel showing null tracking

Category 05

Bounds and Range Violations

Array index out of bounds is a direct cause of IndexOutOfRangeException. NStatic models array lengths and index values symbolically, including loops that iterate over collections — which it solves to closed form rather than unrolling.

  • Array access with an index that the symbolic model shows can exceed the array length
  • Off-by-one errors in loop bounds — detected by solving the loop's closed-form expression
  • Negative index accesses
  • Collection accesses (List, Dictionary) with validated range models
Loop bounds solved symbolically

Category 06

Equivalence Detection

When two expressions in your code always produce the same value, NStatic can identify the opportunity for simplification. This category surfaces refactoring hints and occasionally reveals deeper logic errors where two different-looking computations were expected to diverge but don't.

  • Two branches of an if that produce identical results (the branch is redundant)
  • A computed value that always equals a constant or simpler expression
  • Duplicate sub-expressions that could be extracted to a shared variable
Equation solving showing equivalent expressions

Ready to try it?

NStatic is currently in pre-release. Join the waitlist to be notified when the Visual Studio extension is available.

Join the Waitlist