I’m developing a cross-platform game. In my Visual Studio solution, one of the projects is based on the MonoGame Windows Project template (MonoGame.Framework.dll is version 220.127.116.118).
This project references code in a shared project. There, I hoped to test for touch capabilities by using TouchPanel.GetCapabilities().
Regrettably, when I invoke this method a NullReferenceException is thrown. While its certainly easy enough to work-around, by catching and ignoring the exception, this seems like a bug.
Hmm, this is interesting. After further experimentation, the issue appears to be platform independent. If I use this method during field/property initialization, for the Game, things go poorly and I get the NullReferenceException. However, if I use it only slightly later, in the constructor for the Game, things go fine and I get no exception.
While its certainly less impactful, this still seems like a bug in the TouchPanel.GetCapabilities() method. This static method, in a static class, should be more aware of its state of initialization and avoid a NullReferenceException.
That said, I would completely understand if it threw an InvalidOperationException, or something similar, to let me know I was calling the method too early.