title: Is it bad practice to put a lot of code in the get function of a property which wraps PInvoke stuff?
body: <p>A confusing title I know. Let me explain.</p>
  
  <p>I have to marshal an array of structs, which then get converted to an array of classes (legacy compatibility). For instance</p>
  
  <pre><code>public class InnerClass {}
  
  public class OuterClass { private InnerClass[] innerClasses; }
  
  
  public struct InnerStruct {
     // Data
  }
  
  private static buildInnerClass( InnerStruct i );
  
  public struct OuterStruct {
     private int _numInnerStructs;
     private IntPtr _innerStructs;
     // Other members
  
     public InnerClass[] InnerClasses {
        get {
               InnerClass[] ret = new InnerClass[_numInnerStructs];
  
               var structSize = Marshal.SizeOf(typeof(InnerStruct));
               var ptr = _innerStructs;
  
               for (int i = 0; i &lt; _numInnerStructs; i++)
               {
                  InnerStruct innerStruct = (InnerStruct)Marshal.PtrToStructure(
                                            ptr, typeof(InnerStruct));
                  ret[i] = buildInnerClass(innerStruct);
                  ptr = (IntPtr)((int)ptr + structSize);
               }
               return ret;
        }
     }
  
  }
  </code></pre>