Enable nullability in Content.Shared (#3626)

* Enable nullability in Content.Shared

* Fix null errors in server

* aye github i swear on me mom
This commit is contained in:
DrSmugleaf
2021-03-15 21:55:49 +01:00
committed by GitHub
parent 04201e944c
commit 6f012cb9ad
31 changed files with 167 additions and 117 deletions

View File

@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using Content.Shared.GameObjects.Components.Movement;
using Content.Shared.GameObjects.EntitySystems.EffectBlocker;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Reflection;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
@@ -16,16 +14,14 @@ namespace Content.Shared.GameObjects.Components.Inventory
{
public abstract class SharedInventoryComponent : Component, IMoveSpeedModifier
{
// ReSharper disable UnassignedReadonlyField
[Dependency] protected readonly IReflectionManager ReflectionManager;
[Dependency] protected readonly IDynamicTypeFactory DynamicTypeFactory;
// ReSharper restore UnassignedReadonlyField
[Dependency] protected readonly IReflectionManager ReflectionManager = default!;
[Dependency] protected readonly IDynamicTypeFactory DynamicTypeFactory = default!;
public sealed override string Name => "Inventory";
public sealed override uint? NetID => ContentNetIDs.STORAGE;
[ViewVariables]
protected Inventory InventoryInstance { get; private set; }
protected Inventory InventoryInstance { get; private set; } = default!;
[ViewVariables]
[DataField("Template")]
@@ -42,7 +38,7 @@ namespace Content.Shared.GameObjects.Components.Inventory
{
var type = ReflectionManager.LooseGetType(_templateName);
DebugTools.Assert(type != null);
InventoryInstance = DynamicTypeFactory.CreateInstance<Inventory>(type);
InventoryInstance = DynamicTypeFactory.CreateInstance<Inventory>(type!);
}
/// <returns>true if the item is equipped to an equip slot (NOT inside an equipped container