Does FEZ Panda II support the StructLayoutAttribute?

I would like to define an efficient Color struct type, and this attribute together with the FieldOffset attribute would make that task a little easier.

This attribute is included in the Microsoft Micro Framework, but it doesn’t seem to be in the GHI SDK.

Am I missing something?

System.Runtime.InteropServices Namespace
Contains types that support interoperation and Platform Invoke services.
:
:

Items in this namespace are for use by Microsoft Visual Studio®. You should not try to use them in your applications.

This maybe for the full framework use for for use with some of the SDK features / add ins.

Thanks Rajesh.

I saw that “warning” in the Microsoft Help file, but I want to use it anyway :wink:

It is an excellent way to map three byte values on top of a ulong value, so that a color value can be retrieved as a full 32-bit value or as individual byte values without doing any bit shifting.

The System.Runtime.InteropServices reference is not available to choose from in the References Add dialog box.

Is it supported on the Panda II ??

Isn’t this part of the the core library DLL. You dont need to add a reference. It is not about the Panda. It is about the SDK.

There is nothing hard about getting a byte value out of a long. Just mask and shift. Using unsupported methods just makes your code more prone to problems cropping up in the future that are very hard to track down.

Jeff, The attribute is not “unsupported”. It is part of .Net and in the Micro Framework, and it is fully documented by Microsoft.

I tried entering:

using System.Runtime.InteropServices;

Intellisense couldn’t find this namespace, so I tried to add the reference to the project, but it wasn’t available.

I think I found the answer to my question. The following attribute is available:

[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Explicit)]

However, the accompanying field attribute is not available in the Micro Framework:

[FieldOffset(0)]

I found this link that seems to indicate Microsoft will not implement it:

[url]http://netmf.codeplex.com/workitem/309[/url]

The StructLayout attribute is useless without the FieldOffset attribute.

Bummer :frowning:

Jazdev, I feel your pain. This would be a nice performance-tweak in my application. A SerialPort.Read() could nicely lay down a stream right over my structure using (fast) native code, but to do that without FieldOffset means my fields would all have to bit-shift peeks and pokes at a byte[]; positively glacial. Admittedly, I can’t imagine many people have a need for this, but it sure would be nice.