Pipeline project doesn't compile when one contract interface returns an instance of a contract interface

Jan 23, 2008 at 12:29 AM
I'm having some problems with a simple project when one contract interface returns an instance of another contract interface.

Given a simple contract:
namespace Poc.AddIn.Contracts {
[AddInContract]
public interface ICell : IContract {
int GetColumnIndex();
int GetRowIndex();
}

[AddInContract]
public interface IRow : IContract {
IList<ICell> GetCells();
}
}

The namespaces selected for IRow and ICell in method signatures do not match up with the reference assemblies. For example, the contract namespace is used in the view, but that namespace only appears in the contract assembly, with the truncated name used elsewhere. Is there something I should do differently?
Jan 23, 2008 at 1:20 AM
It looks like the problem is actually a bit more subtle, and it's related to IList<ICell>. If I return just a single instance rather than the list, I don't have the problem. So if IRow is defined like this, my pipeline compiles:
[AddInContract]
public interface IRow : IContract {
ICell GetCells();
}
Jan 23, 2008 at 4:29 PM
The IList<T> interface isn't designed to cross isolation boundaries and so can't be used directly in contracts.

We have defined System.AddIn.Contract.IListContract<T> that can be used instead. The PipelineBuilder will automatically do the right thing with those and express them as, in your case, IList<Poc.AddIn.ICell> in your views.



On a related note, if you look closely you may see the System.AddIn.Contract.Collections namespace in the System.AddIn.Contract assembly. We generally recomend against using those so make sure you use the one in the root System.Addin.Contract namespace. There is nothing wrong with the interfaces specificially, but there is no built in help (by the Framework or the PipelineBuilder) for using them and they were mostly left in the assembly for compatibility reasons.
Jan 26, 2008 at 5:07 AM
Edited Jan 26, 2008 at 5:07 AM
Great, that will help -- thanks!