You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When there is the need to access a field of a class you have to add a ref variable to one of its plug method and use the attribute "FieldAccess" this could be easily become ugly when you need to access a lot of fields:
I've had two constructors to plug (one that take a String representing a File Path and an other in which you pass a Stream already created) and so the ideal solution would have been to use an utility function to initialize all the field but I will have to pass all the ref variables and their value to it that well defeat the purpose of it a lot!
My idea is leaving the attribute version for the old code (or replace it if we are so brave) and to use ref locals introduced in C# 7 to resolve this problem so the Init() would become:
refobjectGetFieldAccess(StringFieldName);refobject[]GetFieldAccess(StringFieldName);unsaferefvoid*GetFieldAccess(StringFieldName);// Not working in C# 7.0 should be added in future releases
The text was updated successfully, but these errors were encountered:
With a little of compiler "trickery" we will obtain that: stream wouldn't change
it wouldn't even be compiled if we want when loading or storing that field, the compiler would load or store _stream instead.
When there is the need to access a field of a class you have to add a ref variable to one of its plug method and use the attribute "FieldAccess" this could be easily become ugly when you need to access a lot of fields:
I've had two constructors to plug (one that take a String representing a File Path and an other in which you pass a Stream already created) and so the ideal solution would have been to use an utility function to initialize all the field but I will have to pass all the ref variables and their value to it that well defeat the purpose of it a lot!
My idea is leaving the attribute version for the old code (or replace it if we are so brave) and to use ref locals introduced in C# 7 to resolve this problem so the Init() would become:
GetFieldAccess should have these prototypes:
The text was updated successfully, but these errors were encountered: