tumtumtum / Shaolinq

ORM for .NET with full LINQ support for Postgres, Sqlite, MySql and SqlServer
Other
127 stars 19 forks source link

AsyncRewrite ignores `override` keyword when the inheritance level is more than three #101

Open asizikov opened 5 years ago

asizikov commented 5 years ago

Given I have the following code:

    public partial interface IBase<T> {
        [RewriteAsync] T Foo();
    }

    public abstract partial class BaseClass<T> : IBase<T> {
        [RewriteAsync] public virtual T Foo() => default;
    }

    public abstract partial class Middle<T> : BaseClass<T> {
    }

    public abstract partial class Middle2<T> : Middle<T> {
    }

    public partial class Impl : Middle2<string> {
        [RewriteAsync] public override string Foo() => "haha";
    }

    public partial class Impl2 : Middle<string> {
        [RewriteAsync] public override string Foo() => "hoho";
    }

when I check the GeneratedAsync.cs file I can see that Impl2.Foo() and Impl.Foo() methods have different modifiers (vitual Task and override Task).

public partial interface IBase<T> {
    Task<T> FooAsync();
    Task<T> FooAsync(CancellationToken cancellationToken);
}

public abstract partial class BaseClass<T> {
    public virtual Task<T> FooAsync() => this.FooAsync(CancellationToken.None);
    public virtual async Task<T> FooAsync(CancellationToken cancellationToken) => default;
}

public partial class Impl {
    public virtual Task<string> FooAsync() => this.FooAsync(CancellationToken.None);
    public async virtual Task<string> FooAsync(CancellationToken cancellationToken) => "haha";
}

public partial class Impl2 {
    public override Task<string> FooAsync() => this.FooAsync(CancellationToken.None);
    public override async Task<string> FooAsync(CancellationToken cancellationToken) => "hoho";
}