Search code examples
c#genericsinheritancef#abstract-class

How to inherit from C# generic abstract class in F#


I have an abstract generic class in C#

public abstract class PaymentSystemBase<
    TPayInSettings,
    TPayOutSettings,
    TRefundSettings,
    TCashierContract,
    TPayoutContract
> : IPaymentSystemInitializable, IPaymentSystem

    where TPayInSettings : BasePayInPaymentSystemSettings, new()
    where TPayOutSettings : BasePayOutPaymentSystemSettings, new()
    where TRefundSettings : BaseRefundPaymentSystemSettings, new()
    where TCashierContract : PaymentSystemBaseCashierContract, new()
    where TPayoutContract : PaymentSystemBasePayOutContract, new()
{
..
}

Here's my F# code:

module Main =
    type CheckoutPaymentIdealUnitTest =
        inherit PaymentSystemBase<
            BasePayInPaymentSystemSettings,
            BasePayOutPaymentSystemSettings,
            BaseRefundPaymentSystemSettings,
            PaymentSystemBaseCashierContract,
            PaymentSystemBasePayOutContract
        > with
        member x = 1

IDE throws an error The type 'PaymentSystemBase<....>' is not an interface type

Is it possible to inherit from C# generic abstract class in F# and how to do it correctly?

I expect to receive a class similar to that, but in F#:

public class PaymentSystem : PaymentSystemBase<
    ..,
    ...,
    ...,
    ...,
    ...
>
{
...
}

Solution

  • I resolved a problem by creating all needed methods to override