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,6 +1,6 @@
using System;
using System.Collections.Generic;
using Robust.Shared.Prototypes;
using System.Diagnostics.CodeAnalysis;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
@@ -12,12 +12,13 @@ namespace Content.Shared.Construction
{
[DataField("actions", serverOnly: true)]
private List<IGraphAction> _actions = new();
[DataField("edges")]
private List<ConstructionGraphEdge> _edges = new();
[ViewVariables]
[DataField("node")]
public string Name { get; private set; }
[DataField("node", required: true)]
public string Name { get; private set; } = default!;
[ViewVariables]
public IReadOnlyList<ConstructionGraphEdge> Edges => _edges;
@@ -27,9 +28,9 @@ namespace Content.Shared.Construction
[ViewVariables]
[DataField("entity")]
public string Entity { get; private set; }
public string? Entity { get; private set; }
public ConstructionGraphEdge GetEdge(string target)
public ConstructionGraphEdge? GetEdge(string target)
{
foreach (var edge in _edges)
{
@@ -39,5 +40,10 @@ namespace Content.Shared.Construction
return null;
}
public bool TryGetEdge(string target, [NotNullWhen(true)] out ConstructionGraphEdge? edge)
{
return (edge = GetEdge(target)) != null;
}
}
}