mikhailshilkov / With.Fody

A Fody addin to extend immutable C# classes with With() methods to return a copy of an object with one property modified.
MIT License
36 stars 3 forks source link

Cache name and version of assembly in GeneratedCodeAttribute() #17

Closed aalmada closed 5 years ago

aalmada commented 5 years ago

The PR #16 introduced the addition of [GeneratedCode("With.Fody", "0.9.0")] attribute to the generated methods. This doesn't change the behavior of the code but makes it easier to find in a decompiler what methods were generated by this addin and what version was used. It uses reflection to get the up to date information.

This PR caches these values into lazy static variables. Reflection is only used the first time the method is called, improving performance of the addin.

The PR #16 also introduced the addition of [MethodImpl(MethodImplOptions.AggressiveInlining)] attribute to the generated methods. This improves performance of the compiled code by saving one method call.

These attribute were only being added when a new With method was generated. This PR adds the attributes also to methods where only the body is changed by this addin.