Godot Version
Godot_v4.7.2-stable_mono_win64
Question
I think this is potentially a problem because I’ve renamed some of my C# classes and there are now possibly some corrupted references. However I’m not entirely sure where to start looking for these corrupted references, and how I can fix them other than creating new classes with new names.
I have the following setup: a node called InventoryCompositionComponent that has a child node InventoryComponent. These are both “global” classes defined in a C# script. The composition component requires that it has a child inventory component, similar to how a static body component requires a collision shape component.
The error below is what I expect to happen when the composition component doesn’t have an inventory component- but is happening despite the fact that the inventory component is attached in all cases they appear in my game. But when I run the game everything works as I expect it to
ERROR: /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/ExceptionUtils.cs:113 - System.InvalidOperationException: Sequence contains no matching element
ERROR: at System.Linq.ThrowHelper.ThrowNoMatchException()
ERROR: at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
ERROR: at CoffeeClone.Util.RequireChild[T](Node parent) in D:\Projects\Games\CookingGameStudies\CoffeeClone\src\Util.cs:line 8
ERROR: at CoffeeClone.Inventory.InventoryCompositionComponent._GetConfigurationWarnings() in D:\Projects\Games\CookingGameStudies\CoffeeClone\src\Inventory\InventoryCompositionComponent.cs:line 80
ERROR: at Godot.Node.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret) in /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Generated/GodotObjects/Node.cs:line 2630
ERROR: at CoffeeClone.Inventory.InventoryCompositionComponent.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret) in D:\Projects\Games\CookingGameStudies\CoffeeClone\.godot\mono\temp\obj\Debug\Godot.SourceGenerators\Godot.SourceGenerators.ScriptMethodsGenerator\CoffeeClone.Inventory.InventoryCompositionComponent_ScriptMethods.generated.cs:line 60
ERROR: at Godot.Bridge.CSharpInstanceBridge.Call(IntPtr godotObjectGCHandle, godot_string_name* method, godot_variant** args, Int32 argCount, godot_variant_call_error* refCallError, godot_variant* ret) in /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/CSharpInstanceBridge.cs:line 24
The thing is, I recently renamed InventoryComponent from its previous name Inventory. Before this rename I didn’t get this error, which makes me think that’s where the problem is coming from. For reference, here’s my code that the errors are complaining about
public static class Util
{
public static T RequireChild<T>(Node parent) where T : Node
{
return (T)parent.GetChildren().First(child => child is T);
}
}
[GlobalClass, Tool]
public partial class InventoryCompositionComponent : Node
{
// ...
public override string[] _GetConfigurationWarnings()
{
var warnings = new List<string>();
if (Util.RequireChild<InventoryComponent>(this) == null)
{
warnings.Add("Inventory composition component must have an inventory component attached to it");
}
return warnings.ToArray();
}
}
The warning actually doesn’t show up in the editor at all, but Linq’s IEnumerable<T>.First(<Condition>) will throw an error if the condition is never met - which is the intended behavior of my utility function (albeit a bit lazy - I should probably throw my own more relevant error). This string of error messages gets spit out into the output window whenever I switch into a scene tab that has a - correctly set up - inventory composition component, which is not what I expect. Images below show that it is in fact set up correctly: no warnings on the composition component, and the inventory component is the correct type

Does anyone have a suggested starting point of where I can start prodding around to see if there are any outdated references? I tried deleting the temp folder in .godot but it didn’t fix anything. Or am I better off just seeing if I can revert the name refactor or even just copy paste my code into a new class name?
