Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetStructLayoutCustomAttribute()

static StructLayoutAttribute System.Reflection.PseudoCustomAttribute.GetStructLayoutCustomAttribute ( RuntimeType type)
inlinestaticpackage

Definition at line 321 of file PseudoCustomAttribute.cs.

322 {
323 if (type.IsInterface || type.HasElementType || type.IsGenericParameter)
324 {
325 return null;
326 }
328 switch (type.Attributes & TypeAttributes.LayoutMask)
329 {
330 case TypeAttributes.ExplicitLayout:
331 layoutKind = LayoutKind.Explicit;
332 break;
333 case TypeAttributes.NotPublic:
334 layoutKind = LayoutKind.Auto;
335 break;
336 case TypeAttributes.SequentialLayout:
337 layoutKind = LayoutKind.Sequential;
338 break;
339 }
340 CharSet charSet = CharSet.None;
341 switch (type.Attributes & TypeAttributes.StringFormatMask)
342 {
343 case TypeAttributes.NotPublic:
344 charSet = CharSet.Ansi;
345 break;
346 case TypeAttributes.AutoClass:
347 charSet = CharSet.Auto;
348 break;
349 case TypeAttributes.UnicodeClass:
350 charSet = CharSet.Unicode;
351 break;
352 }
353 type.GetRuntimeModule().MetadataImport.GetClassLayout(type.MetadataToken, out var packSize, out var classSize);
354 if (packSize == 0)
355 {
356 packSize = 8;
357 }
359 structLayoutAttribute.Pack = packSize;
360 structLayoutAttribute.Size = classSize;
361 structLayoutAttribute.CharSet = charSet;
363 }

References System.type.