castleproject / Core

Castle Core, including Castle DynamicProxy, Logging Services and DictionaryAdapter
http://www.castleproject.org/
Other
2.21k stars 468 forks source link

Improve code generation performance/caching using open generic types #448

Open arashjfz opened 5 years ago

arashjfz commented 5 years ago

It is very useful that open generic types can be supported

stakx commented 5 years ago

Hi @arashjfz, can you describe one or more use cases why this would be a useful feature?

(Implementing it would probably mean a lot of work, so—regardless of who would be implementing this—without having a clear incentive, it most likely isn't going to happen.)

arashjfz commented 5 years ago

Ok let met describe you a situation I am developing a framework like out system. We use nhibernate as ORM. for some reason we want to proxy the ISession and generic IQueryOver there are two solution to proxy the generic IQueryOver first one is to make type for all entities like IQueryOver'Employee' and etc. As you see this is not an efficient solution.Because if we have 1000 entities in our application we need 1000 dynamic type that override generic IQueryOver second one is to proxy the generic IQueryOver but in the format of open generic

As you know stakx this behavior of generic type is the main different between Java and .net

stakx commented 5 years ago

If I understand you correctly, this would be mostly an optimization, then? You're not blocked from proxying the types you need to proxy--but you wish that DynamicProxy would be more efficient by making use of the CLR's "code sharing" for generic type instantiations?

arashjfz commented 5 years ago

yes exactly it is a performance problem

arashjfz commented 5 years ago

@stakx I am really interested in this issue. If it is possible I can give it a try

stakx commented 5 years ago

@arashjfz: Sure, it cannot hurt if you look into it and have a go at it. We do welcome contributions!

A word of warning (not to discourage you up-front, but so you know what to expect), this might be non-trivial and amount to a fair bit of work. I for one don't expect to be able to provide much guidance (among other things, due to my current workload at work).

Perhaps @jonorossi can let you know if and how this will fit with the planned release schedule.

jonorossi commented 5 years ago

@arashjfz go for it, contributions are definitely welcome. I should have time to answer specific questions, but like @stakx won't be able to dig in. Feel free to hack away at a prototype and submit a draft pull request for review. We can talk about releasing it when we've got something we all like.