craftworkgames / MonoGame.Extended

Extensions to make MonoGame more awesome
http://www.monogameextended.net/
Other
1.44k stars 325 forks source link

Throw exception in ViewportAdapter constructor if the GraphicsDevice is null #838

Open safoster88 opened 9 months ago

safoster88 commented 9 months ago

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.

Gandifil commented 7 months ago

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.

Cev0li commented 6 days ago

Is this resolved? I'd like to take a shot at my first PR if it's not!