Search   

Friday, February 10, 2012

Support » Support Forum

Register  Login

 Menu  
 
    

 Welcome!  
 


Welcome to the NDO support forum!

kreis.gif Please register/login at the site if you want to post a thread. We sometimes copy support mails of common interest to the forum. They appear with anonymous sender.
kreis.gif Please post your messages in English language if possible. You can do your posts also in German, we will translate your post and our answer so that all users of the forum can read your posts.
kreis.gif The forum software requires that javascript is enabled.
kreis.gif Please do not insert licence information or licence keys in forum posts.
kreis.gif If you know a good answer to a post of another user, feel free to reply!
kreis.gif The forum is monitored. We reserve the right to remove posts we consider not to be useful for other forum users.

   Print   

      
 NDO Support Forum  
 
SearchForum Home
  NDO-Forum postings in english please, if possible.  Developing with NDO  .maxstack...
 .maxstack
 
 3/27/2007 11:26:03 AM
schinmnu
4 posts


.maxstack
Hello,
I have a quite annoying problem with the current version of NDO Professional.

A class named "SystemComponent" implements the following Interface:

public interface IChannelProvider : IProvider<IChannel>
{
    IChannel AddNewChannel(Type dataType, bool IsInput);
    IChannel<CHType> AddNewChannel<CHType>(bool IsInput)
        where CHType : struct;        
}

As soon as I insert the source formatted bold: "where CHType : struct", my project refuses to compile.

The NDO Enhancer complains with the following error message:
Error  |  23  |  Error: Funktion Sara.Common.NDO.SystemComponent.SystemComponent..ctor hat keine .maxstack-Anweisung  |  NDO Enhancer

Any ideas?
 3/27/2007 12:04:39 PM
Mirko
109 posts
5th


Re: .maxstack

Hi,

I tried to verify the behavior, but my sample compiled fine. Have a look at my sample and tell me, what's the difference to your code.


public interface IChannel
{
    void ChannelFunc();
}

public interface IChannel<T>
{
    void ChannelFunc2(T t);
}

public interface IProvider<T>
{
    void foo(T t);
}

public interface IChannelProvider : IProvider<IChannel>
{
    IChannel AddNewChannel(Type dataType, bool IsInput);
    IChannel<CHType> AddNewChannel<CHType>(bool IsInput)
        where CHType : struct;
}

[NDOPersistent]
public class SystemComponent : IChannelProvider
{
    string name;
    public string Name
    {
        get { return name; }
        set { name = value; }
    }

    //public SystemComponent(string name) // Works either with or w/out ctor
    //{
    //    this.name = name;
    //}

    public IChannel AddNewChannel(Type dataType, bool IsInput)
    {
        throw new Exception("The method or operation is not implemented.");
    }

    public IChannel<CHType> AddNewChannel<CHType>(bool IsInput) where CHType : struct
    {
        throw new Exception("The method or operation is not implemented.");
    }

    public void foo(IChannel t)
    {
        throw new Exception("The method or operation is not implemented.");
    }

}


Regards:
Mirko

 

 3/27/2007 1:34:25 PM
schinmnu
4 posts


Re: .maxstack
Hi Mirko,

My code looks like this:

[NDOPersistent]
public abstract class SystemComponent : IChannelProvider
{
    string name;
    public string Name
    {
        get { return name; }
        set { name = value; }
    }

    public SystemComponent(string name) // Works either with or w/out ctor
    {
        this.name = name;
    }

    public abstract IChannel AddNewChannel(Type dataType, bool IsInput);

 
    public abstract IChannel<CHType> AddNewChannel<CHType>(bool IsInput) where CHType : struct;
   

    public void foo(IChannel t)
    {
        throw new Exception("The method or operation is not implemented.");
    }
}

I just made an interesting discovery:

If I change the line

public abstract IChannel<CHType> AddNewChannel<CHType>(bool IsInput) where CHType : struct;

to

public virtual IChannel<CHType> AddNewChannel<CHType>(bool IsInput) where CHType : struct { return null; }

then the compiler has nothing to complain about.


I think that's a rather strange behaviour?!

best regards

Manuel
 3/27/2007 2:57:22 PM
Mirko
109 posts
5th


Re: .maxstack
 Modified By Mirko  on 3/27/2007 2:59:09 PM)

Hi Manuel,

it is indeed strange and it is a bug in NDO. I'm sorry for the inconvenience.

It's not easy to explain, what's going wrong, so I show you the IL code of your abstract generic function:

.method public hidebysig newslot abstract virtual
instance class BusinessClasses.IChannel`1<!!CHType>
AddNewChannel<valuetype .ctor ([mscorlib]System.ValueType) CHType>(bool IsInput) cil managed
{
} // end of method SystemComponent::AddNewChannel

Your clause "where CHType : struct" is translated to the type parameter

<valuetype .ctor ([mscorlib]System.ValueType) CHType>

The keyword .ctor makes NDO think, that it has to do with a constructor -- that's the bug. But why doesn't the bug appear, if you make the function concrete? NDO believes, that your function is a constructor. NDO always inserts specific code in each constructor and has to make sure, that the .maxstack statement reserves sufficient space on the stack. Note that a constructor is never abstract. Since each non abstract method must have a .maxstack statement NDO stops the enhancer execution, when it doesn't find the .maxstack statement.

Making the function concrete means, that it gets a .maxstack statement. But that doesn't remove the bug. NDO inserts the constructor code in the function where it definitely shouldn't appear.

The only workaround for the moment is not to use the where clause (where CHType : struct). I'm aware, that you didn't use the where clause just for fun. Since this bug doesn't have another workaround I'm going to write an immediate fix which should be ready in the next few days. I'll send a new NDOEnhancer.exe to you via EMail as soon as it is available.

Best Regards:
Mirko

 3/27/2007 3:29:31 PM
schinmnu
4 posts


Re: .maxstack
Many thanks for the quick reply and proving that I am not a complete noob (some parts are still missing ).

best regards

Manuel
  NDO-Forum postings in english please, if possible.  Developing with NDO  .maxstack...
  SearchSearch  Forum HomeForum Home