Exemplo n.º 1
0
		void GetAttributeUsage() {
			if (analyzedType.HasCustomAttributes) {
				foreach (CustomAttribute ca in analyzedType.CustomAttributes) {
					ITypeDefOrRef t = ca.AttributeType;
					if (t != null && t.Name == "AttributeUsageAttribute" && t.Namespace == "System" &&
						ca.ConstructorArguments.Count > 0 &&
						ca.ConstructorArguments[0].Value is int) {
						usage = (AttributeTargets)ca.ConstructorArguments[0].Value;
						if (ca.ConstructorArguments.Count > 2) {
							if (ca.ConstructorArguments[1].Value is bool)
								allowMutiple = (bool)ca.ConstructorArguments[1].Value;
							if (ca.ConstructorArguments[2].Value is bool)
								inherited = (bool)ca.ConstructorArguments[2].Value;
						}
						foreach (var namedArgument in ca.Properties) {
							switch (namedArgument.Name) {
							case "AllowMultiple":
								if (namedArgument.Argument.Value is bool)
									allowMutiple = (bool)namedArgument.Argument.Value;
								break;
							case "Inherited":
								if (namedArgument.Argument.Value is bool)
									inherited = (bool)namedArgument.Argument.Value;
								break;
							}
						}
					}
				}
			}
		}
		internal AttributeGen(AttributeTargets target, AttributeType attributeType, object[] args)
		{
			if (args != null)
			{
				foreach (object arg in args)
				{
					CheckValue(arg);
				}
			}

			// TODO: target validation

			this.attributeType = attributeType;

			Operand[] argOperands;
			if (args == null || args.Length == 0)
			{
				this.args = EmptyArray<object>.Instance;
				argOperands = Operand.EmptyArray;
			}
			else
			{
				this.args = args;
				argOperands = new Operand[args.Length];
				for (int i = 0; i < args.Length; i++)
				{
					argOperands[i] = GetOperand(args[i]);
				}
			}

			this.ctor = TypeInfo.FindConstructor(attributeType, argOperands);
		}
		private void GetAttributeUsage()
		{
			if (analyzedType.HasCustomAttributes) {
				foreach (CustomAttribute ca in analyzedType.CustomAttributes) {
					TypeReference t = ca.AttributeType;
					if (t.Name == "AttributeUsageAttribute" && t.Namespace == "System") {
						this.usage = (AttributeTargets)ca.ConstructorArguments[0].Value;
						if (ca.ConstructorArguments.Count > 1) {
							this.allowMutiple = (bool)ca.ConstructorArguments[1].Value;
							this.inherited = (bool)ca.ConstructorArguments[2].Value;
						}
						if (ca.HasProperties) {
							foreach (var namedArgument in ca.Properties) {
								switch (namedArgument.Name) {
									case "AllowMultiple":
										this.allowMutiple = (bool)namedArgument.Argument.Value;
										break;
									case "Inherited":
										this.inherited = (bool)namedArgument.Argument.Value;
										break;
								}
							}
						}
					}
				}
			}
		}
Exemplo n.º 4
0
 public AttributeBlockNode(Token token,
                           AttributeTargets location,
                           ParseNodeList attributes)
     : base(ParseNodeType.AttributeBlock, token) {
     _location = location;
     _attributes = GetParentedNodeList(attributes);
 }
 internal AttributeUsageAttribute(AttributeTargets validOn, bool allowMultiple, bool inherited)
 {
     this.m_attributeTarget = AttributeTargets.All;
     this.m_inherited = true;
     this.m_attributeTarget = validOn;
     this.m_allowMultiple = allowMultiple;
     this.m_inherited = inherited;
 }
 public void AttributeCanBeAppliedToCodeElementsSupportedBySubstituteAttributeRelay(AttributeTargets expectedTarget)
 {
     // Fixture setup
     var attributeUsage = typeof(SubstituteAttribute).GetCustomAttributes(false)
         .OfType<AttributeUsageAttribute>().Single();
     // Exercise system
     Assert.Equal(expectedTarget, attributeUsage.ValidOn & expectedTarget);
     // Verify outcome
     // Teardown
 }
Exemplo n.º 7
0
 public AttributeUsageTest(MemberInfo member,
                           AttributeTargets validOn,
                           bool allowMultiple,
                           bool inherited)
     : base(member)
 {
     ValidOn = validOn;
     AllowMultiple = allowMultiple;
     Inherited = inherited;
 }
        internal AttributeUsageInfo(AttributeTargets validTargets, bool allowMultiple, bool inherited)
        {
            // NOTE: VB allows AttributeUsageAttribute with no valid target, i.e. <AttributeUsageAttribute(0)>, and doesn't generate any diagnostics.
            // We use use PackedAttributeUsage.Initialized field to differentiate between uninitialized AttributeUsageInfo and initialized AttributeUsageInfo with no valid targets.
            flags = (PackedAttributeUsage)validTargets | PackedAttributeUsage.Initialized;
            
            if (allowMultiple)
            {
                flags |= PackedAttributeUsage.AllowMultiple;
            }

            if (inherited)
            {
                flags |= PackedAttributeUsage.Inherited;
            }
        }
        public CustomAttribute AttributeUsage(AttributeTargets validOn, bool?allowMultiple = null, bool?inherited = null)
        {
            MethodDefinition constructor = _wellKnownTypes.SystemAttributeUsageAttribute.Resolve().Methods.Single(method => method.IsConstructor && !method.IsStatic && method.Parameters.Count == 1);
            var customAttribute          = new CustomAttribute(_wellKnownTypes.Module.ImportReference(constructor));

            customAttribute.ConstructorArguments.Add(new CustomAttributeArgument(_wellKnownTypes.SystemAttributeTargets, (int)validOn));
            if (allowMultiple is object)
            {
                customAttribute.Properties.Add(new CustomAttributeNamedArgument(nameof(AttributeUsageAttribute.AllowMultiple), new CustomAttributeArgument(_wellKnownTypes.TypeSystem.Boolean, allowMultiple !.Value)));
            }

            if (inherited is object)
            {
                customAttribute.Properties.Add(new CustomAttributeNamedArgument(nameof(AttributeUsageAttribute.Inherited), new CustomAttributeArgument(_wellKnownTypes.TypeSystem.Boolean, inherited !.Value)));
            }

            return(customAttribute);
        }
Exemplo n.º 10
0
        static void Main()
        {
            var enumTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(assembly => assembly.GetTypes()).Where(type => type.IsEnum && !type.IsGenericType).ToList();

            //var methodInfo = typeof(Enums).GetMethod("GetUnderlyingType");
            using (new OperationTimer("All Available Enums Caching Performance"))
            {
                foreach (var enumType in enumTypes)
                {
                    //methodInfo.MakeGenericMethod(enumType).Invoke(null, null);
                    NonGenericEnums.GetUnderlyingType(enumType);
                }
            }
            Console.WriteLine(enumTypes.Count);

            Parse(enumTypes);

            var dayOfWeekArray = new DayOfWeek[14];

            for (var i = 0; i < dayOfWeekArray.Length; ++i)
            {
                dayOfWeekArray[i] = (DayOfWeek)i;
            }

            ToString(dayOfWeekArray);

            IsDefined(dayOfWeekArray);

            GetHashCode(dayOfWeekArray);

            var attributeTargetsArray = new AttributeTargets[15];

            attributeTargetsArray[0] = (AttributeTargets)0;
            attributeTargetsArray[1] = (AttributeTargets)1;
            for (var i = 2; i < attributeTargetsArray.Length; ++i)
            {
                attributeTargetsArray[i] = (AttributeTargets)(1 << (i - 1)) | (AttributeTargets)(1 << (i - 2));
            }
            var allAttributeTargets = (AttributeTargets[])Enum.GetValues(typeof(AttributeTargets));

            HasFlag(attributeTargetsArray, allAttributeTargets);

            Console.ReadLine();
        }
Exemplo n.º 11
0
 private static void AddMetaAnnotations(IKVM.StubGen.ClassFileWriter writer, TypeWrapper tw)
 {
     DotNetTypeWrapper.AttributeAnnotationTypeWrapperBase attributeAnnotation = tw as DotNetTypeWrapper.AttributeAnnotationTypeWrapperBase;
     if (attributeAnnotation != null)
     {
         // TODO write the annotation directly, instead of going thru the object[] encoding
         IKVM.StubGen.RuntimeVisibleAnnotationsAttribute annot = new IKVM.StubGen.RuntimeVisibleAnnotationsAttribute(writer);
         annot.Add(new object[] {
             AnnotationDefaultAttribute.TAG_ANNOTATION,
             "Ljava/lang/annotation/Retention;",
             "value",
             new object[] { AnnotationDefaultAttribute.TAG_ENUM, "Ljava/lang/annotation/RetentionPolicy;", "RUNTIME" }
         });
         AttributeTargets validOn = attributeAnnotation.AttributeTargets;
         List <object[]>  targets = new List <object[]>();
         if ((validOn & (AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Delegate | AttributeTargets.Assembly)) != 0)
         {
             targets.Add(new object[] { AnnotationDefaultAttribute.TAG_ENUM, "Ljava/lang/annotation/ElementType;", "TYPE" });
         }
         if ((validOn & AttributeTargets.Constructor) != 0)
         {
             targets.Add(new object[] { AnnotationDefaultAttribute.TAG_ENUM, "Ljava/lang/annotation/ElementType;", "CONSTRUCTOR" });
         }
         if ((validOn & AttributeTargets.Field) != 0)
         {
             targets.Add(new object[] { AnnotationDefaultAttribute.TAG_ENUM, "Ljava/lang/annotation/ElementType;", "FIELD" });
         }
         if ((validOn & (AttributeTargets.Method | AttributeTargets.ReturnValue)) != 0)
         {
             targets.Add(new object[] { AnnotationDefaultAttribute.TAG_ENUM, "Ljava/lang/annotation/ElementType;", "METHOD" });
         }
         if ((validOn & AttributeTargets.Parameter) != 0)
         {
             targets.Add(new object[] { AnnotationDefaultAttribute.TAG_ENUM, "Ljava/lang/annotation/ElementType;", "PARAMETER" });
         }
         annot.Add(new object[] {
             AnnotationDefaultAttribute.TAG_ANNOTATION,
             "Ljava/lang/annotation/Target;",
             "value",
             new object[] { AnnotationDefaultAttribute.TAG_ARRAY, targets.ToArray() }
         });
         writer.AddAttribute(annot);
     }
 }
Exemplo n.º 12
0
 public FilterAttribute(FilterAttribute other)
 {
     if (other == null)
     {
         return;
     }
     this.CanSelectType            = other.CanSelectType;
     this.DisplayDefaultStaticType = other.DisplayDefaultStaticType;
     this.DisplayGenericType       = other.DisplayGenericType;
     this.DisplayInstanceOnStatic  = other.DisplayInstanceOnStatic;
     this.HideSubClassType         = other.HideSubClassType;
     this.HideTypes          = new List <Type>(other.HideTypes);
     this.Inherited          = other.Inherited;
     this.Instance           = other.Instance;
     this.MaxMethodParam     = other.MaxMethodParam;
     this.MinMethodParam     = other.MinMethodParam;
     this.NestedType         = other.NestedType;
     this.NonPublic          = other.NonPublic;
     this.OnlyArrayType      = other.OnlyArrayType;
     this.UnityReference     = other.UnityReference;
     this.DisplayRuntimeType = other.DisplayRuntimeType;
     this.OnlyGenericType    = other.OnlyGenericType;
     this.OnlyGetType        = other.OnlyGetType;
     this.Public             = other.Public;
     this.SetMember          = other.SetMember;
     this.Static             = other.Static;
     this.Types                = new List <Type>(other.Types);
     this.ValidMemberType      = other.ValidMemberType;
     this.ValidNextMemberTypes = other.ValidNextMemberTypes;
     this.ArrayManipulator     = other.ArrayManipulator;
     this.SelectBaseType       = other.SelectBaseType;
     this.boxing               = other.boxing;
     this.DisplayInterfaceType = other.DisplayInterfaceType;
     this.DisplayValueType     = other.DisplayValueType;
     this.DisplayReferenceType = other.DisplayReferenceType;
     this.DisplaySealedType    = other.DisplaySealedType;
     this.DisplayAbstractType  = other.DisplayAbstractType;
     this.DisplayNativeType    = other.DisplayNativeType;
     this.attributeTargets     = other.attributeTargets;
     this.ValidTargetType      = other.ValidTargetType;
     this.InvalidTargetType    = other.InvalidTargetType;
     this.VoidType             = other.VoidType;
     this.AllowInterface       = other.AllowInterface;
 }
Exemplo n.º 13
0
        public void op_AttributeUsage_AttributeTargets_bool_bool()
        {
            var expected = new Mock <ITestType>().Object;

            const AttributeTargets validOn = AttributeTargets.All;

            var mock = new Mock <ITestType>();

            mock
            .Setup(x => x.AttributeUsage(validOn, true, false))
            .Returns(expected)
            .Verifiable();

            var actual = mock.Object.AttributeUsage(validOn, true, false);

            Assert.Same(expected, actual);

            mock.VerifyAll();
        }
Exemplo n.º 14
0
        public void Attributes()
        {
            Type t = typeof(SecurityCriticalAttribute);

            Assert.IsFalse(t.IsSerializable, "IsSerializable");

            object [] attrs = t.GetCustomAttributes(typeof(AttributeUsageAttribute), false);
            Assert.AreEqual(1, attrs.Length, "AttributeUsage");
            AttributeUsageAttribute aua = (AttributeUsageAttribute)attrs [0];

            Assert.IsFalse(aua.AllowMultiple, "AllowMultiple");
            Assert.IsFalse(aua.Inherited, "Inherited");
#if NET_4_0 && !MOBILE
            AttributeTargets at = (AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Delegate);
#else
            AttributeTargets at = (AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate);
#endif
            Assert.AreEqual(at, aua.ValidOn, "ValidOn");
        }
Exemplo n.º 15
0
        public AttributeGen <TypeGen> BeginAttribute(AttributeType type, params object[] args)
        {
            AttributeTargets target = AttributeTargets.Class;

            if (baseType == null)
            {
                target = AttributeTargets.Interface;
            }
            else if (baseType == typeof(ValueType))
            {
                target = AttributeTargets.Struct;
            }
            else
            {
                target = AttributeTargets.Class;
            }

            return(AttributeGen <TypeGen> .CreateAndAdd(this, ref customAttributes, target, type, args));
        }
Exemplo n.º 16
0
        public override AttributeGen <TypeGen> BeginAttribute(AttributeType type, params object[] args)
        {
            AttributeTargets target = AttributeTargets.Class;

            if (BaseType == null)
            {
                target = AttributeTargets.Interface;
            }
            else if (BaseType == TypeMapper.MapType(typeof(ValueType)))
            {
                target = AttributeTargets.Struct;
            }
            else
            {
                target = AttributeTargets.Class;
            }

            return(AttributeGen <TypeGen> .CreateAndAdd(this, ref _customAttributes, target, type, args, TypeMapper));
        }
        public void Attributes()
        {
            Type t = typeof(NonAbstractCodeAccessSecurityAttribute);

            Assert.IsFalse(t.IsSerializable, "IsSerializable");

            object[] attrs = t.GetCustomAttributes(typeof(AttributeUsageAttribute), false);
            Assert.AreEqual(0, attrs.Length, "AttributeUsage-false");

            attrs = t.GetCustomAttributes(typeof(AttributeUsageAttribute), true);
            Assert.AreEqual(1, attrs.Length, "AttributeUsage-true");
            AttributeUsageAttribute aua = (AttributeUsageAttribute)attrs [0];

            Assert.IsTrue(aua.AllowMultiple, "AllowMultiple");
            Assert.IsFalse(aua.Inherited, "Inherited");
            AttributeTargets at = (AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method);

            Assert.AreEqual(at, aua.ValidOn, "ValidOn");
        }
Exemplo n.º 18
0
 private MemberAttributeVisitor(Compilation compilation, AttributeTargets propertyOrClass, ITypeSymbol propertyOrClassType)
 {
     Debug.Assert(propertyOrClass == AttributeTargets.Property || propertyOrClass == AttributeTargets.Class);
     _compilation         = compilation;
     _propertyOrClass     = propertyOrClass;
     _propertyOrClassType = propertyOrClassType;
     _attributeType       = compilation.GetKnownType(KnownTypes.Attribute);
     if (_attributeType != null)
     {
         Visit(compilation.Assembly.GlobalNamespace);
         foreach (var reference in compilation.ExternalReferences)
         {
             var symbol = compilation.GetAssemblyOrModuleSymbol(reference);
             if (symbol is IAssemblySymbol assembly)
             {
                 Visit(assembly.GlobalNamespace);
             }
         }
     }
 }
Exemplo n.º 19
0
        /// <summary>
        /// Get's the configured parameter "HasAttribute"
        /// </summary>
        protected override void OnSited()
        {
            base.OnSited();
            IDictionaryService dictService =
                (IDictionaryService)GetService(typeof(IDictionaryService));
            string attributeName = (string)dictService.GetValue("ContainsAttribute");
            ITypeResolutionService typeResService =
                (ITypeResolutionService)GetService(typeof(ITypeResolutionService));

            attributeType = typeResService.GetType(attributeName, false);
            if (attributeType != null)
            {
                AttributeUsageAttribute[] usages =
                    (AttributeUsageAttribute[])Attribute.GetCustomAttributes(attributeType, typeof(AttributeUsageAttribute));
                foreach (AttributeUsageAttribute usage in usages)
                {
                    attributeUsage |= usage.ValidOn;
                }
            }
        }
Exemplo n.º 20
0
        internal AttributeUsageInfo(
            AttributeTargets validTargets,
            bool allowMultiple,
            bool inherited
            )
        {
            // NOTE: VB allows AttributeUsageAttribute with no valid target, i.e. <AttributeUsageAttribute(0)>, and doesn't generate any diagnostics.
            // We use PackedAttributeUsage.Initialized field to differentiate between uninitialized AttributeUsageInfo and initialized AttributeUsageInfo with no valid targets.
            _flags = (PackedAttributeUsage)validTargets | PackedAttributeUsage.Initialized;

            if (allowMultiple)
            {
                _flags |= PackedAttributeUsage.AllowMultiple;
            }

            if (inherited)
            {
                _flags |= PackedAttributeUsage.Inherited;
            }
        }
 // Generated using https://roslynquoter.azurewebsites.net/
 public static AttributeListSyntax GenerateSyntax(AttributeTargets usageTarget)
 {
     return(SyntaxFactory.AttributeList(
                SyntaxFactory.SingletonSeparatedList <AttributeSyntax>(
                    SyntaxFactory.Attribute(
                        SyntaxFactory.QualifiedName(
                            SyntaxFactory.IdentifierName("System"),
                            SyntaxFactory.IdentifierName("AttributeUsage")))
                    .WithArgumentList(
                        SyntaxFactory.AttributeArgumentList(
                            SyntaxFactory.SingletonSeparatedList <AttributeArgumentSyntax>(
                                SyntaxFactory.AttributeArgument(
                                    SyntaxFactory.MemberAccessExpression(
                                        SyntaxKind.SimpleMemberAccessExpression,
                                        SyntaxFactory.MemberAccessExpression(
                                            SyntaxKind.SimpleMemberAccessExpression,
                                            SyntaxFactory.IdentifierName("System"),
                                            SyntaxFactory.IdentifierName("AttributeTargets")),
                                        SyntaxFactory.IdentifierName(usageTarget.ToString())))))))));
 }
Exemplo n.º 22
0
        public AdaptationUsage(SemanticModel semanticModel,
                               SyntaxTree syntaxTree,
                               SyntaxNode associatedSyntaxNode,
                               AttributeData attributeData,
                               AttributeTargets attributeTargets,
                               Type type,
                               bool escaped)
        {
            Escaped              = escaped;
            SemanticModel        = semanticModel;
            SyntaxTree           = syntaxTree;
            AssociatedSyntaxNode = associatedSyntaxNode;
            AttributeData        = attributeData;
            Type = type;

            AttributeTargets = attributeTargets;
            PreBuildMethod   = GetPreBuildMethod(type);
            PostBuildMethod  = GetPostBuildMethod(type);
            SetupMethods     = GetSetupMethods(type);
        }
Exemplo n.º 23
0
        private void AnalyzeMemberAttributeIntroductions(TargetClassDefinition classDefinition)
        {
            // Check that SuppressAttributesAttribute cannot be applied to methods, properties, and fields.
            // As long as this holds, we don't need to deal with potential suppressors here.
            const AttributeTargets memberTargets = AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field;

            Assertion.IsTrue((AttributeUtility.GetAttributeUsage(typeof(SuppressAttributesAttribute)).ValidOn & memberTargets) == 0,
                             "TargetClassDefinitionBuilder must be updated with AddPotentialSuppressors once SuppressAttributesAttribute supports members");

            foreach (MemberDefinitionBase member in classDefinition.GetAllMembers())
            {
                if (member.Overrides.Count != 0)
                {
                    var introductionBuilder = new AttributeIntroductionDefinitionBuilder(member);
                    foreach (MemberDefinitionBase overrider in member.Overrides)
                    {
                        introductionBuilder.Apply(overrider);
                    }
                }
            }
        }
Exemplo n.º 24
0
        public static void ApplyProjection(CustomAttribute attribute, CustomAttributeValueProjection projection)
        {
            if (projection != null)
            {
                bool flag;
                bool flag2;
                switch (projection.Treatment)
                {
                case CustomAttributeValueTreatment.AllowSingle:
                    flag  = false;
                    flag2 = false;
                    break;

                case CustomAttributeValueTreatment.AllowMultiple:
                    flag  = false;
                    flag2 = true;
                    break;

                case CustomAttributeValueTreatment.VersionAttribute:
                case CustomAttributeValueTreatment.DeprecatedAttribute:
                    flag  = true;
                    flag2 = true;
                    break;

                default:
                    throw new ArgumentException();
                }
                CustomAttributeArgument customAttributeArgument = attribute.ConstructorArguments[0];
                AttributeTargets        attributeTargets        = (AttributeTargets)customAttributeArgument.Value;
                if (flag)
                {
                    attributeTargets |= (AttributeTargets.Constructor | AttributeTargets.Property);
                }
                Collection <CustomAttributeArgument> constructorArguments = attribute.ConstructorArguments;
                customAttributeArgument = attribute.ConstructorArguments[0];
                constructorArguments[0] = new CustomAttributeArgument(customAttributeArgument.Type, attributeTargets);
                attribute.Properties.Add(new CustomAttributeNamedArgument("AllowMultiple", new CustomAttributeArgument(attribute.Module.TypeSystem.Boolean, flag2)));
                attribute.projection = projection;
            }
        }
        internal static AttributeUsageInfo DecodeAttributeUsageAttribute(TypedConstant positionalArg, ImmutableArray <KeyValuePair <string, TypedConstant> > namedArgs)
        {
            // BREAKING CHANGE (C#):
            //   If the well known attribute class System.AttributeUsage is overridden in source,
            //   we will use the overriding AttributeUsage type for attribute usage validation,
            //   i.e. we try to find a constructor in that type with signature AttributeUsage(AttributeTargets)
            //   and public bool properties Inherited and AllowMultiple.
            //   If we are unable to find any of these, we use their default values.
            //
            //   This behavior matches the approach chosen by native VB and Roslyn VB compilers,
            //   but breaks compatibility with native C# compiler.
            //   Native C# compiler preloads all the well known attribute types from mscorlib prior to binding,
            //   hence it uses the AttributeUsage type defined in mscorlib for attribute usage validation.
            //
            //   See Roslyn Bug 8603: ETA crashes with InvalidOperationException on duplicate attributes for details.

            AttributeTargets validOn       = (AttributeTargets)positionalArg.Value;
            bool             allowMultiple = DecodeNamedArgument(namedArgs, "AllowMultiple", SpecialType.System_Boolean, false);
            bool             inherited     = DecodeNamedArgument(namedArgs, "Inherited", SpecialType.System_Boolean, true);

            return(new AttributeUsageInfo(validOn, allowMultiple, inherited));
        }
Exemplo n.º 26
0
        private static string GetErrorDisplayNameResourceId(AttributeTargets target)
        {
            switch (target)
            {
            case AttributeTargets.Assembly: return("Assembly");

            case AttributeTargets.Class: return("Class1");

            case AttributeTargets.Constructor: return("Constructor");

            case AttributeTargets.Delegate: return("Delegate1");

            case AttributeTargets.Enum: return("Enum1");

            case AttributeTargets.Event: return("Event1");

            case AttributeTargets.Field: return("Field");

            case AttributeTargets.GenericParameter: return("TypeParameter");

            case AttributeTargets.Interface: return("Interface1");

            case AttributeTargets.Method: return("Method");

            case AttributeTargets.Module: return("Module");

            case AttributeTargets.Parameter: return("Parameter");

            case AttributeTargets.Property: return("Property");

            case AttributeTargets.ReturnValue: return("Return1");

            case AttributeTargets.Struct: return("Struct1");

            default:
                throw ExceptionUtilities.UnexpectedValue(target);
            }
        }
Exemplo n.º 27
0
        private static string GetErrorDisplayNameResourceId(AttributeTargets target)
        {
            switch (target)
            {
            case AttributeTargets.Assembly: return(nameof(CodeAnalysisResources.Assembly));

            case AttributeTargets.Class: return(nameof(CodeAnalysisResources.Class1));

            case AttributeTargets.Constructor: return(nameof(CodeAnalysisResources.Constructor));

            case AttributeTargets.Delegate: return(nameof(CodeAnalysisResources.Delegate1));

            case AttributeTargets.Enum: return(nameof(CodeAnalysisResources.Enum1));

            case AttributeTargets.Event: return(nameof(CodeAnalysisResources.Event1));

            case AttributeTargets.Field: return(nameof(CodeAnalysisResources.Field));

            case AttributeTargets.GenericParameter: return(nameof(CodeAnalysisResources.TypeParameter));

            case AttributeTargets.Interface: return(nameof(CodeAnalysisResources.Interface1));

            case AttributeTargets.Method: return(nameof(CodeAnalysisResources.Method));

            case AttributeTargets.Module: return(nameof(CodeAnalysisResources.Module));

            case AttributeTargets.Parameter: return(nameof(CodeAnalysisResources.Parameter));

            case AttributeTargets.Property: return(nameof(CodeAnalysisResources.Property));

            case AttributeTargets.ReturnValue: return(nameof(CodeAnalysisResources.Return1));

            case AttributeTargets.Struct: return(nameof(CodeAnalysisResources.Struct1));

            default:
                throw ExceptionUtilities.UnexpectedValue(target);
            }
        }
Exemplo n.º 28
0
        public void RegisterTestRunStart(AttributeTargets attributeTarget)
        {
            if (RunContext.GetCurrentTestRun() == null)
            {
                Log($"Registering test run start...");
                var startTestRunRequest = new StartTestRunRequest
                {
                    Name           = GetSuiteName(attributeTarget),
                    Framework      = "nunit",
                    StartedAt      = DateTime.UtcNow,
                    JenkinsContext = GetJenkinsContext(),
                    Config         = new StartTestRunRequest.ConfigDto
                    {
                        Environment = Configuration.GetEnvironment(),
                        Build       = Configuration.GetBuild()
                    }
                };
                var saveTestRunResponse = _apiClient.RegisterTestRunStart(startTestRunRequest);
                RunContext.SetCurrentTestRun(saveTestRunResponse);

                Log($"({saveTestRunResponse.Id}) Test run start was registered successfully with id.");
            }
        }
    public bool PosTest2()
    {
        bool retVal = true;

        AttributeTargets validOn = AttributeTargets.Assembly;

        TestLibrary.TestFramework.BeginScenario("PosTest2:set ValidOn as AttributeTargets.Assembly and create a instance of class AttributeUsageAttribute.");
        try
        {
            AttributeUsageAttribute aUT = new AttributeUsageAttribute(validOn);
            if (aUT == null)
            {
                TestLibrary.TestFramework.LogError("003", "ExpectedObject(Not null) !=Actual(null)");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception:" + e);
            retVal = false;
        }
        return(retVal);
    }
Exemplo n.º 30
0
        /// <summary>
        /// Common logic for handling the data on an IAttributeConverter and applying it to a member
        /// </summary>
        /// <param name="converter">The IAttributeConverter whose data is being applied</param>
        /// <param name="targets">The target to which the attribute is being applied</param>
        /// <param name="adder">A function to add an attribute to the member. Necessary because
        /// SetCustomAttribute is not on a common interface on the member Builder types.</param>
        /// <param name="customAttributeData">The data on the attributes to convert</param>
        internal static void HandleAttributes(this IAttributeConverter converter, AttributeTargets targets, Action <CustomAttributeBuilder> adder, CustomAttributeData[] customAttributeData)
        {
            foreach (var attData in customAttributeData)
            {
                var cBuilder = new CustomAttributeBuilderBuilder(attData);
                var att      = cBuilder.BuildAttribute();
                if (converter.Convert(cBuilder, true, targets, out CustomAttributeBuilderBuilder aBuilder))
                {
                    if (aBuilder != null)
                    {
                        adder(aBuilder.Build());
                    }
                }
                else
                {
                    adder(cBuilder.Build());
                }
            }

            foreach (var newAttBuilder in converter.GetNewAttributes())
            {
                adder(newAttBuilder.Build());
            }
        }
Exemplo n.º 31
0
        public static Type Apply(Type t, AttributeTargets target, ModuleBuilder builder = null, List <Assembly> refsAsm = null)
        {
            Type attrType     = Type.GetType("AK.EFContextCommon.HierarchyAttribute");
            bool HasHierarchy = false;

            if (target == AttributeTargets.Class)
            {
                var pr = t.GetCustomAttributes(attrType, true);
                if (pr.Length > 0)
                {
                    HasHierarchy = (pr[0] as HierarchyAttribute).HasHierarchy;
                }
                if (HasHierarchy && builder != null)
                {
                    var props = t.GetProperties();
                    List <PropertyInfo> propsToCopy = new List <PropertyInfo>();
                    foreach (var prop in props)
                    {
                        var PropertyAttributes = prop.GetCustomAttributes(attrType, true);
                        if (PropertyAttributes.Length > 0 && (PropertyAttributes[0] as HierarchyAttribute).HasHierarchy)
                        {
                            propsToCopy.Add(prop);
                        }
                    }
                    // create class
                    string ClassName   = String.IsNullOrWhiteSpace(t.Namespace) ? "" : t.Namespace + "." + t.Name + "Hierarchy";
                    var    TypeBuilder = builder.DefineType(ClassName, TypeAttributes.Class | TypeAttributes.Public);
                    foreach (var prop in propsToCopy)
                    {
                        Helper.AddGetSetMethodsForProperty(prop, TypeBuilder, refsAsm);
                    }
                    return(TypeBuilder.CreateTypeInfo());
                }
            }
            return(null);
        }
        private void check_for_usage_attribute(definition_node dn, AttributeTargets targets, string name, location loc, SemanticTree.attribute_qualifier_kind qualifier)
        {
        	switch (dn.semantic_node_type)
        	{
        		case semantic_node_type.common_type_node : 
        			{
        				common_type_node ctn = dn as common_type_node;
        				if (ctn.IsDelegate)
        				{
        					if ((targets & (AttributeTargets.Delegate)) != (AttributeTargets.Delegate))
        						AddError(loc, "ATTRIBUTE_{0}_NOT_APPLICABLE_TO_DELEGATE", name);
        				}
        				else
        				if (ctn.IsInterface)
        				{
        					if ((targets & AttributeTargets.Interface) != AttributeTargets.Interface)
        						AddError(loc, "ATTRIBUTE_{0}_NOT_APPLICABLE_TO_INTERFACE", name);
        				}
        				else
        				if (ctn.IsEnum)
        				{
        					if ((targets & (AttributeTargets.Enum)) != (AttributeTargets.Enum))
        						AddError(loc, "ATTRIBUTE_{0}_NOT_APPLICABLE_TO_ENUM", name);
        				}
        				else
        				if (ctn.is_value_type)
        				{
        					if ((targets & AttributeTargets.Struct) != AttributeTargets.Struct)
        						AddError(loc, "ATTRIBUTE_{0}_NOT_APPLICABLE_TO_STRUCT", name);
        				}
        				else
        					if ((targets & AttributeTargets.Class) != AttributeTargets.Class)
        						AddError(loc, "ATTRIBUTE_{0}_NOT_APPLICABLE_TO_CLASS", name);
        			}
        			break;
        		case semantic_node_type.common_method_node:
        			if ((dn as common_method_node).is_constructor)
        			{
        				if ((targets & AttributeTargets.Constructor) != AttributeTargets.Constructor)
        					AddError(loc, "ATTRIBUTE_{0}_NOT_APPLICABLE_TO_CONSTRUCTOR", name);
        			}
        			else
        				if ((targets & AttributeTargets.Method) != AttributeTargets.Method && qualifier != SemanticTree.attribute_qualifier_kind.return_kind)
        					AddError(loc, "ATTRIBUTE_{0}_NOT_APPLICABLE_TO_METHOD", name);
        			break;
        		case semantic_node_type.common_namespace_function_node:
        			if ((targets & AttributeTargets.Method) != AttributeTargets.Method && qualifier != SemanticTree.attribute_qualifier_kind.return_kind)
        				AddError(loc, "ATTRIBUTE_{0}_NOT_APPLICABLE_TO_METHOD", name);
        			break;
        		case semantic_node_type.class_field:
        			if ((targets & AttributeTargets.Field) != AttributeTargets.Field)
        				AddError(loc, "ATTRIBUTE_{0}_NOT_APPLICABLE_TO_FIELD", name);
        			break;
        		case semantic_node_type.common_property_node:
        			if ((targets & AttributeTargets.Property) != AttributeTargets.Property)
        				AddError(loc, "ATTRIBUTE_{0}_NOT_APPLICABLE_TO_PROPERTY", name);
        			break;
                case semantic_node_type.common_namespace_event:
        		case semantic_node_type.common_event:
        			if ((targets & AttributeTargets.Event) != AttributeTargets.Event)
        				AddError(loc, "ATTRIBUTE_{0}_NOT_APPLICABLE_TO_EVENT", name);
        			break;
        		case semantic_node_type.common_parameter:
        			if ((targets & AttributeTargets.Parameter) != AttributeTargets.Parameter)
                        AddError(loc, "ATTRIBUTE_{0}_NOT_APPLICABLE_TO_FIELD", name);
					break;
                case semantic_node_type.common_unit_node:
                    if ((targets & AttributeTargets.Assembly) != AttributeTargets.Assembly)
        				AddError(loc, "ATTRIBUTE_{0}_NOT_APPLICABLE_TO_ASSEMBLY", name);
        			break;
        	}
        }
Exemplo n.º 33
0
 public virtual string GetAttributeTargetName(AttributeTargets targets) {
   StringBuilder sb = new StringBuilder();
   if ((targets & AttributeTargets.Assembly) != 0 || (targets & AttributeTargets.Module) != 0)
     sb.Append("assembly");
   if ((targets & AttributeTargets.Constructor) != 0) {
     if (sb.Length > 0) sb.Append(", ");
     sb.Append("constructor");
   }
   if ((targets & AttributeTargets.Event) != 0) {
     if (sb.Length > 0) sb.Append(", ");
     sb.Append("event");
   }
   if ((targets & AttributeTargets.Field) != 0) {
     if (sb.Length > 0) sb.Append(", ");
     sb.Append("field");
   }
   if ((targets & AttributeTargets.Method) != 0) {
     if (sb.Length > 0) sb.Append(", ");
     sb.Append("method");
   }
   if ((targets & AttributeTargets.Parameter) != 0){
     if (sb.Length > 0) sb.Append(", ");
     sb.Append("param");
   }
   if ((targets & AttributeTargets.Property) != 0){
     if (sb.Length > 0) sb.Append(", ");
     sb.Append("property");
   }
   if ((targets & AttributeTargets.ReturnValue) != 0){
     if (sb.Length > 0) sb.Append(", ");
     sb.Append("return");
   }
   if ((targets & AttributeTargets.Class) != 0 && (targets & AttributeTargets.Delegate) != 0 &&
     (targets & AttributeTargets.Enum) != 0 && (targets & AttributeTargets.Interface) != 0 && (targets & AttributeTargets.Struct) != 0){
     if (sb.Length > 0) sb.Append(", ");
     sb.Append("type");
   }else{
     if ((targets & AttributeTargets.Class) != 0){
       if (sb.Length > 0) sb.Append(", ");
       sb.Append("class");
     }
     if ((targets & AttributeTargets.Delegate) != 0){
       if (sb.Length > 0) sb.Append(", ");
       sb.Append("delegate");
     }
     if ((targets & AttributeTargets.Enum) != 0){
       if (sb.Length > 0) sb.Append(", ");
       sb.Append("enum");
     }
     if ((targets & AttributeTargets.Interface) != 0){
       if (sb.Length > 0) sb.Append(", ");
       sb.Append("interface");
     }
     if ((targets & AttributeTargets.Struct) != 0){
       if (sb.Length > 0) sb.Append(", ");
       sb.Append("struct");
     }
   }
   return sb.ToString();
 }
 public IEnumerable <ICustomAttributeUsage <TAttributeProvider> > QueryCustomAttributeUsagesOfType <TAttributeProvider>(Type tAttribute, AssemblyDefinition targetAssemly, AttributeTargets filter) where TAttributeProvider : ICustomAttributeProvider
 {
     return(QueryCustomAttributeUsagesOfType(tAttribute, targetAssemly, filter).OfType <ICustomAttributeUsage <TAttributeProvider> >());
 }
Exemplo n.º 35
0
 public static CompilerError InvalidAttributeTarget(Node node, Type attrType, AttributeTargets validOn)
 {
     return new CompilerError("BCE0153", SafeLexicalInfo(node), attrType, validOn);
 }
 /// <summary>
 /// Adds an expectation that the type is decorated with the  <see cref="T:System.AttributeUsageAttribute"/>.
 /// </summary>
 /// <param name="validOn">The expected value of the <see cref="P:System.AttributeUsageAttribute.ValidOn"/> property.</param>
 /// <returns>The current instance.</returns>
 /// <seealso href="http://msdn.microsoft.com/library/system.attributeusageattribute">AttributeUsageAttribute Class</seealso>
 ITestType ITestType.AttributeUsage(AttributeTargets validOn)
 {
     return((this as ITestType).AttributeUsage(validOn, false, true));
 }
 public void MethodWithEnum(AttributeTargets arg = AttributeTargets.All)
 {
 }
		public AttributeUsageAttribute(AttributeTargets validOn) {
			Inherited = true;
			return;
		}
 /// <summary>
 /// Initializes a new instance of the AttributeUsageAttribute class with the specified list of AttributeTargets, the AllowMultiple value, and the Inherited value.
 /// </summary>
 /// <param name="validOn">The set of values combined using a bitwise OR operation to indicate which program elements are valid.</param>
 public AttributeUsageAttribute(AttributeTargets validOn)
 {
     _attributeTarget = validOn;
 }
Exemplo n.º 40
0
		public AttributeUsageAttribute (AttributeTargets validOn)
		{
			valid_on = validOn;
		}
Exemplo n.º 41
0
		private static bool IsValid(AttributeUsageAttribute usage, AttributeTargets target)
		{
			return target == (usage.ValidOn & target);
		}
Exemplo n.º 42
0
 public virtual string GetAttributeTargetName(AttributeTargets targets) {
   if (this.ErrorHandler == null) return "";
   return this.ErrorHandler.GetAttributeTargetName(targets);
 }
Exemplo n.º 43
0
 static AttributeList CreateAttributeList(TypeNode[] attributeTypes, AttributeTargets target){
   AttributeList list = new AttributeList(1);
   foreach (TypeNode t in attributeTypes){
     if (t != null){
       InstanceInitializer ctor = t.GetConstructor();
       if (ctor != null){
         list.Add(new AttributeNode(new MemberBinding(null, ctor), null, target));
       }
     }
   }
   return list;
 }
        public static bool IsValidOn(this CustomAttributeData data, AttributeTargets flags)
        {
            var attributes = data.AttributeType.GetCustomAttributes(typeof(AttributeUsageAttribute), true);

            return attributes.Length == 0 || attributes.Any(x => ((AttributeUsageAttribute)x).ValidOn.HasFlag(flags));
        }
Exemplo n.º 45
0
		public bool CheckTarget ()
		{
			string[] valid_targets = Owner.ValidAttributeTargets;
			if (ExplicitTarget == null || ExplicitTarget == valid_targets [0]) {
				Target = Owner.AttributeTargets;
				return true;
			}

			// TODO: we can skip the first item
			if (((IList) valid_targets).Contains (ExplicitTarget)) {
				switch (ExplicitTarget) {
				case "return": Target = AttributeTargets.ReturnValue; return true;
				case "param": Target = AttributeTargets.Parameter; return true;
				case "field": Target = AttributeTargets.Field; return true;
				case "method": Target = AttributeTargets.Method; return true;
				case "property": Target = AttributeTargets.Property; return true;
				}
				throw new InternalErrorException ("Unknown explicit target: " + ExplicitTarget);
			}
				
			StringBuilder sb = new StringBuilder ();
			foreach (string s in valid_targets) {
				sb.Append (s);
				sb.Append (", ");
			}
			sb.Remove (sb.Length - 2, 2);
			Report.Error (657, Location, "`{0}' is not a valid attribute location for this declaration. " +
				"Valid attribute locations for this declaration are `{1}'", ExplicitTarget, sb.ToString ());
			return false;
		}
Exemplo n.º 46
0
 public AttributeUsageAttribute(AttributeTargets validOn)
 {
     _attributeTarget = validOn;
     _inherited = true;
 }
Exemplo n.º 47
0
 public AttributeUsageAttribute(AttributeTargets validOn) { }
Exemplo n.º 48
0
 internal AttributeUsageAttribute(AttributeTargets validOn, bool allowMultiple, bool inherited)
 {
     m_attributeTarget = validOn;
     m_allowMultiple = allowMultiple;
     m_inherited = inherited;
 }
 //Constructors
 public AttributeUsageAttribute(AttributeTargets validOn)
 {
     m_attributeTarget = validOn;
 }
Exemplo n.º 50
0
 [System.Security.SecurityCritical]  // auto-generated
 private static void ParseAttributeUsageAttribute(
     ConstArray ca, out AttributeTargets targets, out bool inherited, out bool allowMultiple)
 {
     int _targets;
     _ParseAttributeUsageAttribute(ca.Signature, ca.Length, out _targets, out inherited, out allowMultiple);
     targets = (AttributeTargets)_targets;
 }
Exemplo n.º 51
0
 public AttributeUsageAttribute(AttributeTargets validOn)
 {
     this.validOn = validOn;
 }
Exemplo n.º 52
0
		private static bool IsValid(AttributeTargets target, AttributeTargets validAttributeTargets)
		{
			return target == (validAttributeTargets & target);
		}
Exemplo n.º 53
0
			public NonInheritedAttribute(Type type, string str, int i, AttributeTargets e):
				this(type, str)
			{
			}
Exemplo n.º 54
0
 public static CompilerError InvalidAttributeTarget(Node node, Type attrType, AttributeTargets validOn)
 {
     return Instantiate("BCE0153", node, attrType, validOn);
 }
 public void RegisterTestRunStart(AttributeTargets attributeTarget)
 {
 }
 public AttributeUsageAttribute(AttributeTargets validOn)
 {
     this.m_attributeTarget = AttributeTargets.All;
     this.m_inherited = true;
     this.m_attributeTarget = validOn;
 }
        public IEnumerable <ICustomAttributeUsage> QueryCustomAttributeUsagesOfType(Type tAttribute, AssemblyDefinition targetAssemly, AttributeTargets filter)
        {
            int attributeTypeToken = tAttribute.MetadataToken;

            return(QueryCustomAttributeUsages(targetAssemly, filter).Where(usage => usage.Attribute.AttributeType.MetadataToken.ToInt32().Equals(attributeTypeToken)));
        }
Exemplo n.º 58
0
 public AttributeUsageAttribute()
 {
     validOn = AttributeTargets.All;
 }
        public IEnumerable <ICustomAttributeUsage> QueryCustomAttributeUsages(AssemblyDefinition targetAssemly, AttributeTargets filter)
        {
            IEnumerable <ICustomAttributeUsage> attributeQueryResult = new List <ICustomAttributeUsage>();

            var hasAllFlags = filter.HasFlag(AttributeTargets.All);

            if (hasAllFlags || filter.HasFlag(AttributeTargets.Assembly))
            {
                attributeQueryResult = attributeQueryResult.Concat(targetAssemly.CustomAttributes.Select(a => new CustomAttributeUsage <AssemblyDefinition> {
                    Attribute = a, DeclaringAttributeProvider = targetAssemly
                }));
            }

            if (hasAllFlags || filter.HasFlag(AttributeTargets.Module))
            {
                attributeQueryResult = attributeQueryResult.Concat(GetAttributeUsages(QueryModules(targetAssemly)));
            }

            if (hasAllFlags || filter.HasFlag(AttributeTargets.Class))
            {
                attributeQueryResult = attributeQueryResult.Concat(GetAttributeUsages(QueryClasses(targetAssemly)));
            }

            if (hasAllFlags || filter.HasFlag(AttributeTargets.Struct))
            {
                attributeQueryResult = attributeQueryResult.Concat(GetAttributeUsages(QueryStructs(targetAssemly)));
            }

            if (hasAllFlags || filter.HasFlag(AttributeTargets.Enum))
            {
                attributeQueryResult = attributeQueryResult.Concat(GetAttributeUsages(QueryEnums(targetAssemly)));
            }

            if (hasAllFlags || filter.HasFlag(AttributeTargets.Constructor))
            {
                attributeQueryResult = attributeQueryResult.Concat(GetAttributeUsages(QueryConstructors(targetAssemly)));
            }

            if (hasAllFlags || filter.HasFlag(AttributeTargets.Method))
            {
                attributeQueryResult = attributeQueryResult.Concat(GetAttributeUsages(QueryMethods(targetAssemly)));
            }

            if (hasAllFlags || filter.HasFlag(AttributeTargets.Property))
            {
                attributeQueryResult = attributeQueryResult.Concat(GetAttributeUsages(QueryProperties(targetAssemly)));
            }

            if (hasAllFlags || filter.HasFlag(AttributeTargets.Field))
            {
                attributeQueryResult = attributeQueryResult.Concat(GetAttributeUsages(QueryFields(targetAssemly)));
            }

            if (hasAllFlags || filter.HasFlag(AttributeTargets.Event))
            {
                attributeQueryResult = attributeQueryResult.Concat(GetAttributeUsages(QueryEvents(targetAssemly)));
            }

            if (hasAllFlags || filter.HasFlag(AttributeTargets.Interface))
            {
                attributeQueryResult = attributeQueryResult.Concat(GetAttributeUsages(QueryInterfaces(targetAssemly)));
            }

            if (hasAllFlags || filter.HasFlag(AttributeTargets.Parameter))
            {
                attributeQueryResult = attributeQueryResult.Concat(GetAttributeUsages(QueryParameters(targetAssemly)));
            }

            if (hasAllFlags || filter.HasFlag(AttributeTargets.Delegate))
            {
                attributeQueryResult = attributeQueryResult.Concat(GetAttributeUsages(QueryDelegateTypes(targetAssemly)));
            }

            if (hasAllFlags || filter.HasFlag(AttributeTargets.ReturnValue))
            {
                attributeQueryResult = attributeQueryResult.Concat(GetAttributeUsages(QueryReturnTypes(targetAssemly)));
            }

            if (hasAllFlags || filter.HasFlag(AttributeTargets.GenericParameter))
            {
                attributeQueryResult = attributeQueryResult.Concat(GetAttributeUsages(QueryGenericParameters(targetAssemly)));
            }

            return(attributeQueryResult);
        }
Exemplo n.º 60
0
 internal Class(Context context, AST id, TypeExpression superTypeExpression, TypeExpression[] interfaces, Block body, 
   FieldAttributes attributes, bool isAbstract, bool isFinal, bool isStatic, bool isInterface, CustomAttributeList customAttributes)
   : base(context) {
   this.name = id.ToString();
   this.superTypeExpression = superTypeExpression;
   this.interfaces = interfaces;
   this.body = body;
   this.enclosingScope = (ScriptObject)Globals.ScopeStack.Peek(1);
   this.attributes = TypeAttributes.Class|TypeAttributes.Serializable;
   this.SetAccessibility(attributes);
   if (isAbstract)
     this.attributes |= TypeAttributes.Abstract;
   this.isAbstract = isAbstract || isInterface;
   this.isAlreadyPartiallyEvaluated = false;
   if (isFinal)
     this.attributes |= TypeAttributes.Sealed;
   if (isInterface)
     this.attributes |= TypeAttributes.Interface | TypeAttributes.Abstract;
   this.isCooked = false;
   this.cookedType = null;
   this.isExpando = false;
   this.isInterface = isInterface;
   this.isStatic = isStatic;
   this.needsEngine = !isInterface;
   this.validOn = (AttributeTargets)0;
   this.allowMultiple = true;
   this.classob = (ClassScope)Globals.ScopeStack.Peek();
   this.classob.name = this.name;
   this.classob.owner = this;
   this.implicitDefaultConstructor = null;
   if (!isInterface && !(this is EnumDeclaration))
     this.SetupConstructors();
   this.EnterNameIntoEnclosingScopeAndGetOwnField(id, isStatic);
   this.fields = this.classob.GetMemberFields();
   this.superClass = null;
   this.superIR = null;
   this.superMembers = null;
   this.firstIndex = null;
   this.fieldInitializer = null;
   this.customAttributes = customAttributes;
   this.clsCompliance = CLSComplianceSpec.NotAttributed;
   this.generateCodeForExpando = false;
   this.expandoItemProp = null;
   this.getHashTableMethod = null;
   this.getItem = null;
   this.setItem = null;
 }