Sunday, February 05, 2012
Support » Support Forum
Register Login
HomeWhat is NDO?- Executive Overview- NDO for DevelopersHow NDO Works- Persistent Classes- Mapping- Queries- Reverse Engineering- Inheritance, Polymorphism- Distributed ApplicationsLicensingSupport- Support Forum- FAQ- Solutions- Downloads- E-Mail Support- Tutorial VideosOnline ShopContact
Welcome to the NDO support forum!
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. 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. The forum software requires that javascript is enabled. Please do not insert licence information or licence keys in forum posts. If you know a good answer to a post of another user, feel free to reply! The forum is monitored. We reserve the right to remove posts we consider not to be useful for other forum users.
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
[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."); }}
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