#1 2014-11-12 15:30:56

mingda
Member
Registered: 2013-01-04
Posts: 121

interface contract check

first create a interface,

  ITest = interface(IInvokable)
    procedure baba1;
  end;

after server and client register the interface, then use the interface, every is ok.
then we delivery the client, after sometime, we need add procedure to ITest,
so interface looks like this,

  ITest = interface(IInvokable)
    procedure baba1;
    procedure baba2;
    procedure baba...;
  end;

but when run old client, will generate interface contract check exception,
can make wise since the procedure baba1 parameter is not change, thanks!

For some interface register in application start, will cause application
can not auto update.

Offline

#2 2014-11-12 16:21:55

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: interface contract check

By default, the contract is computed from all methods and parameters.

But you can specify a custom contract.
See the optional aContractExpected parameter to the ServiceRegister() method.
Of course, aContractExpected parameter should match on both client and server side, and you may add some new methods, but not change parameter of an existing method (unless you force transmission as object)!

Offline

#3 2014-11-13 02:30:11

mingda
Member
Registered: 2013-01-04
Posts: 121

Re: interface contract check

Ideally, if can check procedure contract one by one it would be great,
this will make backward compatible, for a server interface

  ITest = interface(IInvokable)
    procedure baba1;
    procedure baba2;
    procedure baba...;
  end;

client interface below will all pass check:

  ITest = interface(IInvokable)
    procedure baba1;
  end;

  ITest = interface(IInvokable)
    procedure baba1;
    procedure baba2;
  end;

  ITest = interface(IInvokable)
    procedure baba1;
    procedure baba2;
    procedure baba...;
  end;

I looked source, the parameter aContractExpected can't achieve this effect,
set server and client's aContractExpected a same value will just close the contract check function.

thanks!

Offline

#4 2014-11-13 08:28:22

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: interface contract check

We may implement this.

Could you create a feature request ticket?
See http://synopse.info/fossil/tktnew

Offline

#5 2014-11-13 12:32:09

mingda
Member
Registered: 2013-01-04
Posts: 121

Re: interface contract check

Done, feature request at http://synopse.info/fossil/tktview/1d6b … dde1cdc0f6, thanks!

Offline

#6 2014-11-17 15:02:31

LarsS
Member
Registered: 2014-04-25
Posts: 4

Re: interface contract check

This is a great suggestion! I hope it will get implemented.

Offline

Board footer

Powered by FluxBB