4 ms·
Interesting use of code generation - pretty cool, oft unused part of .net/C#. Also interesting how it's designed to be a drop-in single C# file, that often seem
by singular 16y ago
Interesting use of code generation - pretty cool, oft unused part of .net/C#. Also interesting how it's designed to be a drop-in single C# file, that often seems the easier way of getting functionality into a project, side-stepping DLL version issues.
- bad_user 16y agoI don't see code-generation; what are you referring to?
- singular 16y agoI mean dynamic code generation at runtime, rather than actually outputting text :-) E.g. CreateParamInfoGenerator() at line 208.
- bad_user 16y agoYes, you're right. It's pretty cool. Also, if you're looking for other cool samples, there's a chapter in "Beautiful Code" by Charles Petzold you may find interesting.
- arethuza 16y agoIt looks like it is using the Reflection Emit capabilities of .Net: http://msdn.microsoft.com/en-us/library/8ffc3x75.aspx http://msdn.microsoft.com/en-us/library/8ffc3x75.aspx
- kenjackson 16y agoLooking at the dynamic code gen... is it necessary? Can't they just use a method that takes 'type' and the set of properties as arguments? I'm sure I'm missing something, but don't see it at the moment.
- darrenkopp 16y agoit's an optimization so that you don't die from the reflection cost.
- kenjackson 16y agoOK, I buy that.
- glhaynes 16y agoI assume they've tested it out and aren't just assuming that the reflection would be a killer... but...