예제 #1
0
        public void Ctor_UInt(uint flags)
        {
            var attribute = new AssemblyFlagsAttribute(flags);

            Assert.Equal(flags, attribute.Flags);
            Assert.Equal((int)flags, attribute.AssemblyFlags);
        }
예제 #2
0
        public void Ctor_Int(int assemblyFlags)
        {
            var attribute = new AssemblyFlagsAttribute(assemblyFlags);

            Assert.Equal((uint)assemblyFlags, attribute.Flags);
            Assert.Equal(assemblyFlags, attribute.AssemblyFlags);
        }
예제 #3
0
        public void Ctor_AssemblyNameFlags(AssemblyNameFlags assemblyFlags)
        {
            var attribute = new AssemblyFlagsAttribute(assemblyFlags);

            Assert.Equal((uint)assemblyFlags, attribute.Flags);
            Assert.Equal((int)assemblyFlags, attribute.AssemblyFlags);
        }
예제 #4
0
    public static void Main()
    {
        // Get this assembly.
        Assembly thisAsm = typeof(Example).Assembly;

        // Get the AssemblyName for this assembly.
        AssemblyName thisAsmName = thisAsm.GetName(false);

        // Display the flags that were set for this assembly.
        ListFlags(thisAsmName.Flags);

        // Create an instance of AssemblyFlagsAttribute with the
        // same combination of flags that was specified for this
        // assembly. Note that PublicKey is included automatically
        // for the assembly, but not for this instance of
        // AssemblyFlagsAttribute.
        AssemblyFlagsAttribute afa = new AssemblyFlagsAttribute(
            AssemblyNameFlags.EnableJITcompileOptimizer |
            AssemblyNameFlags.Retargetable);

        // Get the flags. The property returns an integer, so
        // the return value must be cast to AssemblyNameFlags.
        AssemblyNameFlags anf = (AssemblyNameFlags)afa.AssemblyFlags;

        // Display the flags.
        Console.WriteLine();
        ListFlags(anf);
    }
        public AssemblyFlagsAttributeTest()
        {
            //create a dynamic assembly with the required attribute
            //and check for the validity

            dynAsmName.Name = "TestAssembly";

            dynAssembly = Thread.GetDomain().DefineDynamicAssembly(
                dynAsmName, AssemblyBuilderAccess.Run
                );

            // Set the required Attribute of the assembly.
            Type            attribute = typeof(AssemblyFlagsAttribute);
            ConstructorInfo ctrInfo   = attribute.GetConstructor(
                new Type [] { typeof(AssemblyNameFlags) }
                );
            CustomAttributeBuilder attrBuilder =
                new CustomAttributeBuilder(ctrInfo, new object [1] {
                AssemblyNameFlags.PublicKey | AssemblyNameFlags.Retargetable
            });

            dynAssembly.SetCustomAttribute(attrBuilder);
            object [] attributes = dynAssembly.GetCustomAttributes(true);
            attr = attributes [0] as AssemblyFlagsAttribute;
        }
        public void CtorTest()
        {
            var a = new AssemblyFlagsAttribute(AssemblyNameFlags.PublicKey);

            Assert.AreEqual((int)AssemblyNameFlags.PublicKey, a.AssemblyFlags);

            a = new AssemblyFlagsAttribute((int)AssemblyNameFlags.PublicKey);
            Assert.AreEqual((int)AssemblyNameFlags.PublicKey, a.AssemblyFlags);

            a = new AssemblyFlagsAttribute((uint)AssemblyNameFlags.PublicKey);
            Assert.AreEqual((uint)AssemblyNameFlags.PublicKey, a.Flags);
        }
예제 #7
0
        public static void AssemblyFlagsAttributeTests()
        {
            var attr1 = new AssemblyFlagsAttribute(1);

            Assert.Equal((uint)AssemblyNameFlags.PublicKey, attr1.Flags);

            var attr2 = new AssemblyFlagsAttribute(0u);

            Assert.Equal((uint)AssemblyNameFlags.None, attr2.Flags);

            var attr3 = new AssemblyFlagsAttribute(AssemblyNameFlags.EnableJITcompileTracking);

            Assert.Equal((uint)AssemblyNameFlags.EnableJITcompileTracking, attr3.Flags);
        }