MonoGame.Extended icon indicating copy to clipboard operation
MonoGame.Extended copied to clipboard

Throw exception in ViewportAdapter constructor if the GraphicsDevice is null

Open safoster88 opened this issue 1 year ago • 1 comments

If the viewport adapter is initialized in the constructor of game, GraphicsDevice will be null.

There is no check for this, so the null ref only occurs when trying to call GetViewMatrix().

This PR aims to improve the public API.

safoster88 avatar Feb 17 '24 13:02 safoster88

Firstly, thank you for attention!

It's a good idea, but why do you use the custom exception? There is ArgumentNullException. It can be simply: if (graphicsDevice is null) throw new ArgumentNullException(nameof(graphicsDevice));

People often use this way, so more easy to understand.

Gandifil avatar Apr 07 '24 20:04 Gandifil