Doraku / DefaultEcs.Analyzer

Roslyn analyzers for DefaultEcs users.
MIT No Attribution
13 stars 1 forks source link

"no suitable method found to override" error in Unity #13

Open slimshader opened 1 year ago

slimshader commented 1 year ago

Hi,

trying Analyzer in Unity 2021 (with https://docs.unity3d.com/Manual/roslyn-analyzers.html).

My test system is:

[With(typeof(Example))]
[Without(typeof(CExample))]
public sealed partial class ExampleSetAttributeSystemAuto : AEntitySetSystem<float>
{
    public ExampleSetAttributeSystemAuto(World world) :
        base(world)
    {

    }

    [Update]
    private static void Update(float state, ref Example example)
    {
        Debug.Log($"E {example.Value}");
    }
}

this unfortunately causes error:

DefaultEcs.Analyzer\DefaultEcs.Analyzer.Generators.SystemGenerator\ExampleSetAttributeSystemAuto_EntitySystem1.cs(25,33): error CS0115: 'ExampleSetAttributeSystemAuto.Update(float, ReadOnlySpan<Entity>)': no suitable method found to override
slimshader commented 1 year ago

Hey, an update: it only happens when class in outside of any namespace, after placing it in the namespace, rest of the partial class seems to be generated correctly.

Doraku commented 1 year ago

hum not putting types in namespace is a very unity thing to do, which may cause this line https://github.com/Doraku/DefaultEcs.Analyzer/blob/master/source/DefaultEcs.Analyzer/Generators/SystemGenerator.cs#L342 to generate bad code. If that's really the issue it should be easy enough to fix, thanks for the workaround in the meantime!