Namespaces in Generated Code

Aug 9, 2010 at 1:32 PM

 

First let me say that I was pleases to see that this project still has someone still doing something because I could never get the original Pipeline builder to work and had resorted to writing all the code manually which was a major pain. Every time I add something to a class I had to spend ages writing conversion classes for host and addin and because my project will eventually implement two sets of addins I was beginning to lose the will to live.

I do have a couple of questions/issues though.......number 4 is the problem :-)

1) Sometimes the dialog box where you select projects will just vanish when I click on the contracts project drop down or in the text area - I can't be any more specific because sometimes this just does not happen - I think it may be when I open solution A after having used the pipeline builder in solution B (the drop downs still seem to be populated with the previous project names) - I'm using VS2010 on Win7 x64 - If there is anything you want me to try or log files etc just ask.

2) Is the data from that form saved to a file? I ask because I will eventually have two sets of addins so will have to run the pipeline builder twice and was looking for a way to save having to fill in the 5 project names each time. (i.e. fill in form, save file as A, run, fill in form, save file as B, run - then in future run B, rename file run A)

3)I keep getting this error - any ideas what would cause it? It happens in my noddy test project (where it has no effect as far as I can see) as well as my real live project.

System.Runtime.InteropServices.COMException (0x8004D745): A reference to the component 'System.AddIn.Contract' already exists in the project.

   at VSLangProj.References.Add(String bstrPath)

   at VSPipelineBuilder.Connect.addContractReference(VSProject2 target, Project sourceProject)

   at VSPipelineBuilder.Connect.buildPipeline(PipelineConfiguration config, Action`2 reportProgress)

   at VSPipelineBuilder.Connect.Exec(String commandName, vsCommandExecOption executeOption, Object& varIn, Object& varOut, Boolean& handled)

 

4) What influences the namespaces for the generated code? Changing the default namespace in the adapter and view projects seems to have no effect but changing the namespace in the Contract project does. Currently this is a show stopper for me but it is tantalisingly close to working and I do not want to go back to doing it all manually. I'll gladly send you the project if that will help.

I have a contract that includes

using System.AddIn.Contract;
using System.Collections.Generic;
using System;
using System.Drawing;
namespace Gentoo
{
    public interface ICEntityDescription : IContract
    {
        string Description { getset; }
        Guid TypeId { getset; }
        List<ICEntityChild> PermittedChildren { getset; }
        Dictionary<intIcon> StatusIcons { getset; }
        List<ICStatusBitDefinition> StatusBitDefinitions { getset; }
        List<ICStatusIconMasks> StatusIconMasks { getset; }
    }

    public interface ICEntityChild : IContract
    {
        Guid PermittedChildType { getset; }
        UInt16 MaxChildrenofType { getset; }
        bool ShowInTree { getset; }
    }

    public interface ICStatusBitDefinition : IContract
    {
        int BitPosition { getset; }
        string FieldName { getset; }
        Color SetColour { getset; }
        Color ClrColour { getset; }
    }

    public interface ICStatusIconMasks : IContract
    {
        int IconId { getset; }
        ulong SetMask { getset; }
        ulong ClrMask { getset; }
    }
}

This creates a class in the HostViewProject

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.1
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Gentoo.HostViews
{
    public interface ICEntityDescription
    {
        string Description
        {
            get;
            set;
        }
        System.Guid TypeId
        {
            get;
            set;
        }
        System.Collections.Generic.List<Gentoo.ICEntityChild> PermittedChildren
        {
            get;
            set;
        }
        System.Collections.Generic.Dictionary<int, System.Drawing.Icon> StatusIcons
        {
            get;
            set;
        }
        System.Collections.Generic.List<Gentoo.ICStatusBitDefinition> StatusBitDefinitions
        {
            get;
            set;
        }
        System.Collections.Generic.List<Gentoo.ICStatusIconMasks> StatusIconMasks
        {
            get;
            set;
        }
    }
}

Unfortunately this will not compile because (I think) Gentoo.ICEntityChild should be Gentoo.HostViews.ICEntityChild (or just ICEntityChild) Gentoo.ICStatusBitDefinition should be Gentoo.HostViews.ICStatusBitDefinitions ans Gentoo.ICStatusIconMasks should be Gentoo.HostViews.ICStatusIconMasks

The AddInView project has exactly the same issues - Fixing these manually and I then rebuild to get more errors

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.1
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Gentoo.AddInViews
{
    public interface IApp
    {
        System.Collections.Generic.List<Gentoo.ICEntityDescription> GetEntityDescriptions();
    }
}
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.1
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Gentoo.HostViews
{
   public interface IApp
    {
        System.Collections.Generic.List<Gentoo.ICEntityDescription> GetEntityDescriptions();
    }
}

Both the above need to be edited to change Gentoo to Gentoo.AddInViews &  Gentoo.HostViews respectively - at this point I rebuild and a further tranche of errors about both the addin adapter and the host adapter not implementing interface members because they do not have the correct matching return type. 

 

Any thoughts, pointers to documentation or even just sympathy gratefully received. 

Dave

Aug 10, 2010 at 2:09 PM

Having read http://blogs.msdn.com/b/clraddins/archive/2007/02/27/restrictions-on-contracts.aspx

the following seems to work

{
    public interface ICEntityDescription : IContract
    {
        string Description { getset; }
        Guid TypeId { getset; }
        System.AddIn.Contract.IListContract<DFB.Contracts.IHEntityChild> PermittedChildren { getset; }
        System.AddIn.Contract.IListContract<Icon> StatusIcons { getset; }
        System.AddIn.Contract.IListContract<DFB.Contracts.IHStatusBitDefinition> StatusBitDefinitions { getset; }
        System.AddIn.Contract.IListContract<DFB.Contracts.IHStatusIconMasks> StatusIconMasks { getset; }
    }
}