using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
+using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.IntegrationTests.Tests
{
await pair.CleanReturnAsync();
}
+ private static bool HasRequiredDataField(Component component)
+ {
+ foreach (var field in component.GetType().GetFields())
+ {
+ foreach (var attribute in field.GetCustomAttributes(true))
+ {
+ if (attribute is not DataFieldAttribute dataField)
+ continue;
+
+ if (dataField.Required)
+ return true;
+ }
+ }
+ foreach (var property in component.GetType().GetProperties())
+ {
+ foreach (var attribute in property.GetCustomAttributes(true))
+ {
+ if (attribute is not DataFieldAttribute dataField)
+ continue;
+
+ if (dataField.Required)
+ return true;
+ }
+ }
+ return false;
+ }
+
[Test]
public async Task AllComponentsOneToOneDeleteTest()
{
"ActivatableUI", // Requires enum key
};
- // TODO TESTS
- // auto ignore any components that have a "required" data field.
-
await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;
var entityManager = server.ResolveDependency<IEntityManager>();
foreach (var type in componentFactory.AllRegisteredTypes)
{
- var component = (Component) componentFactory.GetComponent(type);
+ var component = (Component)componentFactory.GetComponent(type);
var name = componentFactory.GetComponentName(type);
+ if (HasRequiredDataField(component))
+ continue;
+
// If this component is ignored
if (skipComponents.Contains(name))
{