public bool PosTest2()
    {
        bool retVal = true;

        // Add your scenario description here
        TestLibrary.TestFramework.BeginScenario("PosTest2: Verify ctor(false)");

        try
        {
            CLSCompliantAttribute cca = new CLSCompliantAttribute(false);

            if (cca.IsCompliant != false)
            {
                TestLibrary.TestFramework.LogError("002.1", "Ctor Err !");
                retVal = false;
                return retVal;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002.2", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
Exemple #2
0
        public AboutBox()
        {
            InitializeComponent();

            foreach (Assembly s in AppDomain.CurrentDomain.GetAssemblies())
            {
                string[] lvsi = new string[3];
                lvsi[0] = s.GetName().Name;
                lvsi[1] = s.GetName().FullName;
                lvsi[2] = s.GetName().Version.ToString();
                ListViewItem lvi = new ListViewItem(lvsi, 0);
                this.ListOfAssemblies.Items.Add(lvi);
            }

            AssemblyCopyrightAttribute   objCopyright   = AssemblyCopyrightAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyCopyrightAttribute)) as AssemblyCopyrightAttribute;
            AssemblyDescriptionAttribute objDescription = AssemblyDescriptionAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyDescriptionAttribute)) as AssemblyDescriptionAttribute;
            AssemblyCompanyAttribute     objCompany     = AssemblyCompanyAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyCompanyAttribute)) as AssemblyCompanyAttribute;
            AssemblyTrademarkAttribute   objTrademark   = AssemblyTrademarkAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyTrademarkAttribute)) as AssemblyTrademarkAttribute;
            AssemblyProductAttribute     objProduct     = AssemblyProductAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyProductAttribute)) as AssemblyProductAttribute;
            AssemblyTitleAttribute       objTitle       = AssemblyTitleAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyTitleAttribute)) as AssemblyTitleAttribute;
            GuidAttribute         objGuid         = GuidAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(GuidAttribute)) as GuidAttribute;
            DebuggableAttribute   objDebuggable   = DebuggableAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(DebuggableAttribute)) as DebuggableAttribute;
            CLSCompliantAttribute objCLSCompliant = CLSCompliantAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(CLSCompliantAttribute)) as CLSCompliantAttribute;

            AppName.Text        = objProduct.Product;
            BigTitle.Text       = objTitle.Title;
            ProdVer.Text        = QuestDesignerMain.Version;
            AppDesc.Text        = objDescription.Description;
            CopyrightLabel.Text = objCopyright.Copyright;
            SerialNo.Text       = objGuid.Value;
            Company.Text        = objCompany.Company;
        }
Exemple #3
0
    public bool PosTest2()
    {
        bool retVal = true;

        // Add your scenario description here
        TestLibrary.TestFramework.BeginScenario("PosTest2: Verify ctor(false)");

        try
        {
            CLSCompliantAttribute cca = new CLSCompliantAttribute(false);

            if (cca.IsCompliant != false)
            {
                TestLibrary.TestFramework.LogError("002.1", "Ctor Err !");
                retVal = false;
                return(retVal);
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002.2", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
Exemple #4
0
        public void Explicitly_AssertThat_SingleCustomAttributeOfSpecifiedTypeIsAppliedToTheInspectedAssembly()
        {
            // Arrange
            AssemblyService service = new();

            // Act
            Assembly assembly = service.GetAssembly();

            // Assert
            CLSCompliantAttribute attribute = Test.That(assembly).HasAttribute <CLSCompliantAttribute>();

            Assert.IsTrue(attribute.IsCompliant);
        }
Exemple #5
0
        AttributeCollection ICustomTypeDescriptor.GetAttributes()
        {
            object value = _staticAttributeCollection;

            if (value == null)
            {
                CLSCompliantAttribute  clsAttr    = new CLSCompliantAttribute(true);
                DefaultMemberAttribute defMemAttr = new DefaultMemberAttribute("Item");
                Attribute []           attrs      = { clsAttr, defMemAttr };
                value = new AttributeCollection(attrs);
            }
            System.Threading.Interlocked.CompareExchange(ref _staticAttributeCollection, value, null);
            return(_staticAttributeCollection as AttributeCollection);
        }
Exemple #6
0
    static void PrintTypes(string assembly, bool show_private, bool filter_obsolete)
    {
        Assembly a = GetAssembly(assembly, true);

        Console.WriteLine();
        Console.WriteLine("Assembly Information:");

        object[] cls = a.GetCustomAttributes(typeof(CLSCompliantAttribute), false);
        if (cls.Length > 0)
        {
            CLSCompliantAttribute cca = cls[0] as CLSCompliantAttribute;
            if (cca.IsCompliant)
            {
                Console.WriteLine("[CLSCompliant]");
            }
        }

        foreach (string ai in a.ToString().Split(','))
        {
            Console.WriteLine(ai.Trim());
        }

        Console.WriteLine();
        Type [] types = show_private ? a.GetTypes() : a.GetExportedTypes();
        Array.Sort(types, new TypeSorter());

        int obsolete_count = 0;

        foreach (Type t in types)
        {
            if (filter_obsolete && t.IsDefined(typeof(ObsoleteAttribute), false))
            {
                obsolete_count++;
            }
            else
            {
                Console.WriteLine(t.FullName);
            }
        }

        Console.WriteLine("\nTotal: {0} types.", types.Length - obsolete_count);
    }
Exemple #7
0
    static void ShowAll(string assembly, bool show_private, bool filter_obsolete)
    {
        Assembly a = GetAssembly(assembly, true);

        object[] cls = a.GetCustomAttributes(typeof(CLSCompliantAttribute), false);
        if (cls.Length > 0)
        {
            CLSCompliantAttribute cca = cls[0] as CLSCompliantAttribute;
            if (cca.IsCompliant)
            {
                Console.WriteLine("[CLSCompliant]");
            }
        }

        foreach (string ai in a.ToString().Split(','))
        {
            Console.WriteLine(ai.Trim());
        }

        Console.WriteLine();
        Type [] types = show_private ? a.GetTypes() : a.GetExportedTypes();
        Array.Sort(types, new TypeSorter());

        var sw = new StreamWriter(Console.OpenStandardOutput(), Console.Out.Encoding);

        foreach (Type t in types)
        {
            if (filter_obsolete && t.IsDefined(typeof(ObsoleteAttribute), false))
            {
                continue;
            }

            new Outline(t, sw, true, show_private, filter_obsolete).OutlineType();
        }
        sw.Flush();
    }
 public void Ctor_Bool(bool isCompliant)
 {
     var attribute = new CLSCompliantAttribute(isCompliant);
     Assert.Equal(isCompliant, attribute.IsCompliant);
 }
        /*
         * Returns the PropertyInfo or FieldInfo corresponding to the
         * specified property name.
         */
        internal static MemberInfo GetMemberInfo(Type ctrlType, string name, out string nameForCodeGen)
        {
            Type         currentType = ctrlType;
            PropertyInfo propInfo    = null;
            FieldInfo    fieldInfo   = null;

            string mappedName = MapNameToPropertyName(ctrlType, name);

            nameForCodeGen = null;

            int startIndex = 0;

            while (startIndex < mappedName.Length)     // parse thru dots of object model to locate PropertyInfo
            {
                string propName;
                int    index = mappedName.IndexOf(OM_CHAR, startIndex);

                if (index < 0)
                {
                    propName   = mappedName.Substring(startIndex);
                    startIndex = mappedName.Length;
                }
                else
                {
                    propName   = mappedName.Substring(startIndex, index - startIndex);
                    startIndex = index + 1;
                }

                propInfo = currentType.GetProperty(propName,
                                                   BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.IgnoreCase);

                if (propInfo == null)     // could not find a public property, look for a public field
                {
                    fieldInfo = currentType.GetField(propName,
                                                     BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.IgnoreCase);
                    if (fieldInfo == null)
                    {
                        nameForCodeGen = null;
                        break;
                    }
                }

                propName = null;
                if (propInfo != null)     // found a public property
                {
                    currentType = propInfo.PropertyType;
                    propName    = propInfo.Name;
                }
                else     // found a public field
                {
                    currentType = fieldInfo.FieldType;
                    propName    = fieldInfo.Name;
                }

                // Throw if the type of not CLS-compliant (ASURT 83438)
                CLSCompliantAttribute clsCompliant = null;
                object[] attrs = currentType.GetCustomAttributes(typeof(CLSCompliantAttribute), /*inherit*/ true);
                if ((attrs != null) && (attrs.Length == 1))
                {
                    clsCompliant = (CLSCompliantAttribute)attrs[0];
                    if (!clsCompliant.IsCompliant)
                    {
                        throw new HttpException(HttpRuntime.FormatResourceString(
                                                    SR.Property_Not_ClsCompliant, name, ctrlType.FullName, currentType.FullName));
                    }
                }

                if (propName != null)
                {
                    if (nameForCodeGen == null)
                    {
                        nameForCodeGen = propName;
                    }
                    else
                    {
                        nameForCodeGen += STR_OM_CHAR + propName;
                    }
                }
            }

            if (propInfo != null)
            {
                return(propInfo);
            }
            else
            {
                return(fieldInfo);
            }
        }