Replies: 4 comments 1 reply
-
Hello, I am not aware of any contributor having plans about source generators. I can see one probably not so hard win with source generators: proxies generation. Currently proxies are generated at runtime as dynamically generated assemblies. (See the Nhibernate.Proxy namespace, especially the static proxy factory.) Generating them while compiling projects using NHibernate would avoid that runtime cost for generating proxies. (It would not improve the performances of an application once "hot", it would just improve its warm-up.) The main hurdle for the source generator would be to access and analyze the NHibernate mappings in order to know which proxies have to be generated. There is nothing available currently for doing that in a source generator stage. So, a prerequisite would be to investigate and implement a way for a source generator to access and analyze the mappings, ideally whatever how they are provided (hbm, attributes, by code, convention, ...). Can a source generator run an assembly like the NHibernate one? It basically would have to build the session factory to get all the mapping information. After that, for what would you attempt to use it? Avoiding reflection in entities hydration? It looks to me that would require some heavy changes in how NHibernate works. |
Beta Was this translation helpful? Give feedback.
-
@quicoli there is this project: https://github.com/nhibernate/NHibernate.ProxyGenerators which used to generate proxies for the classes. It uses old code generators, but still works. I think it would be a good candidate to use code generators. |
Beta Was this translation helpful? Give feedback.
-
NHibernate also uses |
Beta Was this translation helpful? Give feedback.
-
The best approach is to use source generators to generate proxy and unsafe accessors for NHibernate, which would greatly raise the performance at runtime. |
Beta Was this translation helpful? Give feedback.
-
Hi all!
I know... new .NET, a lot of 'noise'... new stuff, new changes...
After watching David Fowler talk about improvements in .NET, it's noticeable how source generators are highly used now.
Even before that, the MVVM Community Toolkit
started using this feature.
I believe that to start the use of Source Generators in NH would be good - performance, project longevity and modernization wise.
I also believe this would be a big effort/code change...
Is there any planning of using Source Generators for future versions?
How could we (I) help with this?
Beta Was this translation helpful? Give feedback.
All reactions