Skip to content

Defining PartialOnly entities with variants breaks GameDataScrounger #7085

Description

@portfiend

I tried to define a !PartialOnly prototype with variants like so:

- type: !PartialOnly entity
  id: !type:CreateVariants
    values:
    - BaseBeaker
    - BaseBeakerMetallic
  components:
  - type: Sprite
    sprite: _Impstation/Objects/Specific/Chemistry/beaker.rsi
  - type: Item
    sprite: _Impstation/Objects/Specific/Chemistry/beaker.rsi

Doing this causes a massive amount of test fails that are really difficult to debug because the error message is not descriptive of the issue at all. Specifically, I traced the issue to GameDataScrounger.IndexPrototypesIn() called in GameDataScrounger.Scrounge().

For some reason, this partial defiinition causes the Scrounge() method to exit early without errors despite there being no return call anywhere in the method. This can cause, say - the scrounger to exit before it has processed the Species prototype folder, which means no species prototypes are loaded, which will cause the test fail.

This works, instead:

- type: entity
  id: !type:CreateVariants
    values:
    - BaseBeaker
    - BaseBeakerMetallic
  components:
  - type: Sprite
    sprite: _Impstation/Objects/Specific/Chemistry/beaker.rsi
  - type: Item
    sprite: _Impstation/Objects/Specific/Chemistry/beaker.rsi

This is what the error looked like:

System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
  ----> System.TypeInitializationException : The type initializer for 'Content.IntegrationTests.Tests._DEN.Traits.EntityTraitTests' threw an exception.
  ----> System.Collections.Generic.KeyNotFoundException : The given key 'species' was not present in the dictionary.
at System.RuntimeFieldHandle.GetValue(RtFieldInfo field, Object instance, RuntimeType fieldType, RuntimeType declaringType, Boolean& isClassInitialized)
at System.Reflection.FieldAccessor.GetValue(Object obj)
at NUnit.Framework.TestCaseSourceAttribute.GetTestCaseSource(IMethodInfo method)
at NUnit.Framework.TestCaseSourceAttribute.<>c__DisplayClass20_0.<GetTestCasesFor>b__0()
at NUnit.Framework.Internal.ContextUtils.<>c__DisplayClass1_0`1.<DoIsolated>b__0(Object _)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at NUnit.Framework.Internal.ContextUtils.DoIsolated(ContextCallback callback, Object state)
at NUnit.Framework.Internal.ContextUtils.DoIsolated[T](Func`1 func)
at NUnit.Framework.TestCaseSourceAttribute.GetTestCasesFor(IMethodInfo method)
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Content.IntegrationTests.Utility.GameDataScrounger.PrototypesOfKind(String kind) (file:///home/fm/Documents/Development/TheDenTwo/Content.IntegrationTests/Utility/GameDataScrounger.cs#L104,0)
at Content.IntegrationTests.Utility.GameDataScrounger.PrototypesOfKind[T]() (file:///home/fm/Documents/Development/TheDenTwo/Content.IntegrationTests/Utility/GameDataScrounger.cs#L89,0)
at Content.IntegrationTests.Tests._DEN.Traits.EntityTraitTests..cctor() (file:///home/fm/Documents/Development/TheDenTwo/Content.IntegrationTests/Tests/_DEN/Traits/EntityTraitTests.cs#L30,0)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions