Пример #1
0
 private void Init(FieldOffsetAttribute fieldOffset)
 {
     this.m_ctor = typeof(FieldOffsetAttribute).GetConstructors(BindingFlags.Public | BindingFlags.Instance)[0];
     CustomAttributeTypedArgument[] array = new CustomAttributeTypedArgument[] { new CustomAttributeTypedArgument(fieldOffset.Value) };
     this.m_typedCtorArgs = Array.AsReadOnly<CustomAttributeTypedArgument>(array);
     this.m_namedArgs = Array.AsReadOnly<CustomAttributeNamedArgument>(new CustomAttributeNamedArgument[0]);
 }
		internal object[] GetPseudoCustomAttributes ()
		{
			int count = 0;

			if (IsNotSerialized)
				count ++;

			if (DeclaringType.IsExplicitLayout)
				count ++;

			UnmanagedMarshal marshalAs = UMarshal;
			if (marshalAs != null)
				count ++;

			if (count == 0)
				return null;
			object[] attrs = new object [count];
			count = 0;

			if (IsNotSerialized)
				attrs [count ++] = new NonSerializedAttribute ();
			if (DeclaringType.IsExplicitLayout)
				attrs [count ++] = new FieldOffsetAttribute (GetFieldOffset ());
			if (marshalAs != null)
				attrs [count ++] = marshalAs.ToMarshalAsAttribute ();

			return attrs;
		}
Пример #3
0
        public static void Ctor_Value(int offset)
        {
            var attribute = new FieldOffsetAttribute(offset);

            Assert.Equal(offset, attribute.Value);
        }
Пример #4
0
 private void Init(FieldOffsetAttribute fieldOffset)
 {
     m_ctor = typeof(FieldOffsetAttribute).GetConstructors(BindingFlags.Public | BindingFlags.Instance)[0];
     m_typedCtorArgs = Array.AsReadOnly(new CustomAttributeTypedArgument[] {
         new CustomAttributeTypedArgument(fieldOffset.Value)
     });
     m_namedArgs = Array.AsReadOnly(Array.Empty<CustomAttributeNamedArgument>());
 }
Пример #5
0
 internal static bool IsDefined(RuntimeFieldInfo field)
 {
     return(FieldOffsetAttribute.GetCustomAttribute(field) != null);
 }