ProxyGen Error

Latest post 12-15-2006 12:44 AM by Mustafin Artur. 3 replies.
  • 12-11-2006 10:44 AM

    ProxyGen Error

    Does anybody knows, why ProxyGen tool does not support generics?

    ProxyGen.exe Error: 0 : Error: Generics are not supported. Type IParent`1 contains generic parameters and will be excluded. Its occurrences will be replaced by
     System.Object.

    This is a real-world sample:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace Ngt.Svd.Kernel2.Data
    {
    public interface IDepartments : ICollection<IDepartment> { }
    public interface IDictionaries : ICollection<IDictionary> { }
    public interface IDictionaryGroups : ICollection<IDictionaryGroup> { }
    public interface IJournals : ICollection<IJournal> { }
    public interface IJournalGroups : ICollection<IJournalGroup> { }
    public interface IActionGroups : ICollection<IActionGroup> { }
    public interface IForms : ICollection<IForm> { }
    public interface IAttributes : ICollection<IAttribute> { }
    }

     

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace Ngt.Svd.Kernel2.Data
    {
    public interface IEntity {}
    public interface IParent<T> where T : IEntity { T Parent { get; } }
    public interface IDepartmentParent : IParent<IDepartment>, IEntity { }
    public interface IDictionaryParent : IParent<IDictionaryGroup>, IEntity { }
    public interface IFormParent : IParent<IActionGroup>, IEntity { }
    public interface IJournalParent : IParent<IJournalGroup>, IEntity { }
    public interface IAttributeParent : IParent<IJournal>, IEntity { }
    public interface IDictionary : IDictionaryParent { }
    public interface IDictionaryGroup : IDepartmentGroup
    {
    IDictionaries Dictionaries { get; }
    }
    public interface IJournal : IJournalParent
    {
    IForms Forms { get; }
    IAttributes Attributes { get; }
    }
    public interface IJournalGroup : IDepartmentGroup
    {
    IJournals Journals { get; }
    }
    public interface IAttribute : IAttributeParent
    {
    IDictionary Dictionary { get; }
    }
    public interface IActionGroup : IDepartmentGroup
    {
    IForms Forms { get; }
    }
    public interface IForm : IFormParent
    {
    IJournal Journal { get; }
    }
    public interface ILinearForm : IForm { }
    public interface ITableForm : IForm { }
    public interface IDepartment : IDepartmentGroup
    {
    IDictionaryGroups DictionaryGroups { get; }
    IJournalGroups JournalGroups { get; }
    IActionGroups ActionGroups { get; }
    }
    public interface IDepartmentGroup : IDepartmentParent
    {
    IDepartments Departments { get; }
    }
    }

  • 12-11-2006 10:54 AM In reply to

    Re: ProxyGen Error

    Mustafin:

    Generics are not supported in VSTA v1.  Take a look here for more info:

    http://www.summsoft.com/blogs/davesblog/archive/2006/12/07/vsta-and-generics.aspx

    Filed under:
  • 12-12-2006 12:07 AM In reply to

    Re: ProxyGen Error

    Thanks, :))
  • 12-15-2006 12:44 AM In reply to

    Re: ProxyGen Error

    dschneid:

    Mustafin:

    Generics are not supported in VSTA v1.  Take a look here for more info:

    http://www.summsoft.com/blogs/davesblog/archive/2006/12/07/vsta-and-generics.aspx

    I have a woraround of generics. if someone have generics interfaces, and even classes, it is possible to create an addditional assembly (non-generics to generics layer), strong named it and add a reference to original assembly in proxy configuration. I my case it simply adds an an additional surface. Bisimilla!

    Shown below:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    using System;
    using System.Text;

    using System.Windows.Forms;
    using VSTADTEProvider.Interop;
    using EnvDTE;
    using EnvDTE80;
    using System.IO;
    using Microsoft.VisualStudio.Tools.Applications;
    using Microsoft.VisualStudio.Tools.Applications.ExternalProcess;
    using Microsoft.VisualStudio.Tools.Applications.DesignTime.Interop;
    using Microsoft.VisualStudio.Tools.Applications.Contract;

    using Ngt.Svd.Kernel2.Data;

    namespace Ngt.Svd.Kernel2.Proxy
    {
    public interface IEntityProxy : IEntity { }
    public interface IDepartmentParentProxy : IDepartmentParent { }
    public interface IDictionaryParentProxy : IDictionaryParent { }
    public interface IFormParentProxy : IFormParent { }
    public interface IJournalParentProxy : IJournalParent { }
    public interface IAttributeParentProxy : IAttributeParent { }
    public interface IDictionaryProxy : IDictionary { }
    public interface IDictionaryGroupProxy : IDictionaryGroup { }
    public interface IJournalProxy : IJournal { }
    public interface IJournalGroupProxy : IJournalGroup { }
    public interface IAttributeProxy : IAttribute { }
    public interface IActionGroupProxy : IActionGroup { }
    public interface IFormProxy : IForm { }
    public interface ILinearFormProxy : ILinearForm { }
    public interface ITableFormProxy : ITableForm { }
    public interface IDepartmentProxy : IDepartment { }
    public interface IDepartmentGroupProxy : IDepartmentGroup { }
    }

    So my VSTA proxy uses Data Proxy Layer, not a Data Layer due to the generics and therefore ProxyGen.exe generates a TypeInfrastructureManager class in a ordinal way. All we need to do is to cast back each time we are using a ...Proxy version of an interface or impement GetInterface() in each of interfaces for safely typecasting of this references ;)

    Now I'm thinking about desighn for beautify my code. But it really works, in cost of additional casting. Most of them must be eliminated by the comiler if classes and interface will be properly desighned. This is not a lot of work to do, in fact.

Page 1 of 1 (4 items) | RSS
Copyright Summit Software Company, 2008. All rights reserved.