Using HtmlPage.RegisterScriptableObject("Shell", serviceLocator.GetInstance<Shell>());
gives me a null warning. How can I make this go away?
Using HtmlPage.RegisterScriptableObject("Shell", serviceLocator.GetInstance<Shell>());
gives me a null warning. How can I make this go away?
The warning is that serviceLocator
is null?
Without seeing any more of your code (to get an idea of what other contracts might be in play), you could put
Contract.Assume(serviceLocator != null);
on the line above.
Perhaps serviceLocator.GetInstance<Shell>()
returns null if an instance is not found.
Try providing an alternative control flow for that situation.
var instance = serviceLocator.GetInstance<Shell>();
if (instance == null)
throw new InvalidOperationException("Shell instance is missing.");
HtmlPage.RegisterScriptableObject("Shell", instance);