  We propose an algorithm for computing bases and dimensions of spaces of
invariants of Weil representations of $\mathrm{SL}_2(\mathbb{Z})$ associated to
finite quadratic modules. We prove that these spaces are defined over
$\mathbb{Z}$, and that their dimension remains stable if we replace the base
field by suitable finite prime fields.
