Does Area2D and PhysicsBody2D duplicate code?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jarlowrey

I am working in C# and am encountering a scenario where I need to set the layer/mask on a Node that could be a Area2D or a KinematicBody2D. Their common ancestor is CollisionObject2D, but I was surprised to find this class does not have a CollisionLayer or CollisionMask property. Turns out Area2D has it, and PhysicsBody2D has it, the only 2 classes that inherit from it. Is the engine duplicating code in these child classes? I can handle my scenario with extra functions, casting conditionals, etc, but it’s dirty. Would be much easier if these classes could be combined, is there an active issue for this?

Edit: made an issue here - Difficult to work with Area2D/PhysicsBody2D in C# due to duplicated code in Godot Engine · Issue #26680 · godotengine/godot · GitHub