The Labs \ Source Viewer \ SSCLI \ System.Runtime.CompilerServices \ FixedBufferAttribute

  1. // ==++==
  2. //
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. //
  14. // ==--==
  15. /*============================================================
  16. **
  17. ** Class:  FixedBufferAttribute
  18. **
  19. ** Purpose: Used by a compiler for generating value types
  20. **  in-place within other value types containing a certain
  21. **  number of elements of the given (primitive) type.  Somewhat
  22. **  similar to P/Invoke's ByValTStr attribute.
  23. **  Used by C# with this syntax: "fixed int buffer[10];"
  24. **
  25. ===========================================================*/
  26. using System;
  27. namespace System.Runtime.CompilerServices
  28. {
  29.     [AttributeUsage(AttributeTargets.Field, Inherited = false)]
  30.     public sealed class FixedBufferAttribute : Attribute
  31.     {
  32.         private Type elementType;
  33.         private int length;
  34.        
  35.         public FixedBufferAttribute(Type elementType, int length)
  36.         {
  37.             this.elementType = elementType;
  38.             this.length = length;
  39.         }
  40.        
  41.         public Type ElementType {
  42.             get { return elementType; }
  43.         }
  44.        
  45.         public int Length {
  46.             get { return length; }
  47.         }
  48.     }
  49. }

Developer Fusion