public void DuplicateSources()
        {
            MyManagedCompiler m = new MyManagedCompiler();

            m.BuildEngine = new MockEngine(true);
            m.Sources     = new ITaskItem[] { new TaskItem("foo"), new TaskItem("foo") };
            Assert.IsTrue(!m.AccessValidateParameters());
            ((MockEngine)m.BuildEngine).AssertLogContains("MSB3105");
        }
        public void DuplicateResourcesWithNoLogicalNames()
        {
            MyManagedCompiler m = new MyManagedCompiler();

            m.BuildEngine = new MockEngine(true);
            m.Sources     = new ITaskItem[] { new TaskItem("bar") };
            m.Resources   = new ITaskItem[] { new TaskItem("foo.resources"), new TaskItem("foo.resources") };
            // This is an error
            Assert.IsTrue(!m.AccessValidateParameters());
            ((MockEngine)m.BuildEngine).AssertLogContains("MSB3105");
        }
        public void DefaultWin32ManifestEmbeddedInConsoleAppWhenTargetTypeInferred()
        {
            MyManagedCompiler m = new MyManagedCompiler();

            m.BuildEngine = new MockEngine(true);
            m.Sources     = new ITaskItem[] { new TaskItem("bar") };

            Assert.IsTrue
            (
                m.AccessGetWin32ManifestSwitch(false, null).EndsWith("default.win32manifest", StringComparison.OrdinalIgnoreCase),
                "default.win32manifest should be embedded in a console exe!"
            );
        }
        public void DefaultWin32ManifestNotEmbeddedInNetModule()
        {
            MyManagedCompiler m = new MyManagedCompiler();

            m.BuildEngine = new MockEngine(true);
            m.Sources     = new ITaskItem[] { new TaskItem("bar") };
            m.TargetType  = "modULE";

            Assert.IsTrue
            (
                String.IsNullOrEmpty(m.AccessGetWin32ManifestSwitch(false, null)),
                "default.win32manifest should NOT be embedded in a net module!"
            );
        }
        public void TestDebugSymbolsTrue()
        {
            // Verify each of the DebugType settings when EmitDebugInformation is true
            MyManagedCompiler m = new MyManagedCompiler();

            m.DebugType            = "Full";
            m.EmitDebugInformation = true;
            m.AddResponseFileCommands();
            // We expect to see only /debug+ on the commandline
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug+") == true, "Expected to find /debug+ on the commandline");
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug-") == false, "Not expected to find /debug- on the commandline");
            // Expect to only find Full on the commandline
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:Full") == true, "Expected to find /debug:Full on the commandline");
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:PdbOnly") == false, "Not expected to find /debug:PdbOnly on the commandline");

            m                      = new MyManagedCompiler();
            m.DebugType            = "PdbOnly";
            m.EmitDebugInformation = true;
            m.AddResponseFileCommands();
            // We expect to see only /debug+ on the commandline
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug+") == true, "Expected to find /debug+ on the commandline");
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug-") == false, "Not expected to find /debug- on the commandline");
            // Expect to find only PdbOnly on the commandline
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:PdbOnly") == true, "Expected to find /debug:PdbOnly on the commandline");
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:Full") == false, "Not expected to find /debug:Full on the commandline");

            m                      = new MyManagedCompiler();
            m.DebugType            = "none";
            m.EmitDebugInformation = true;
            m.AddResponseFileCommands();
            // We expect to see /debug- on the commandline
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug-") == true, "Expected to find /debug- on the commandline");
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug+") == false, "Not expected to find /debug+ on the commandline");
            // We do not expect to see any /debug: on the commandline
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:") == false, "Not expected to find /debug: on the commandline");

            m                      = new MyManagedCompiler();
            m.DebugType            = null;
            m.EmitDebugInformation = true;
            m.AddResponseFileCommands();
            // We expect to see only /debug+ on the commandline
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug+") == true, "Expected to find /debug+ on the commandline");
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug-") == false, "Not expected to find /debug- on the commandline");
            // We expect to not find any /debug: on the commandline
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:") == false, "Not expected to find /debug: on the commandline");
        }
        public void DuplicateResourcesWithSameLogicalNames()
        {
            MyManagedCompiler m = new MyManagedCompiler();

            m.BuildEngine = new MockEngine(true);
            m.Sources     = new ITaskItem[] { new TaskItem("bar") };
            TaskItem resource1 = new TaskItem("foo.resources");

            resource1.SetMetadata("LogicalName", "value1");
            TaskItem resource2 = new TaskItem("foo.resources");

            resource2.SetMetadata("LogicalName", "value1");
            m.Resources = new ITaskItem[] { resource1, resource2 };
            // This is an error
            Assert.IsTrue(!m.AccessValidateParameters());
            ((MockEngine)m.BuildEngine).AssertLogContains("MSB3083");
        }
        public void TestDebugSymbolsNull()
        {
            MyManagedCompiler m = new MyManagedCompiler();

            m.DebugType = "Full";
            m.AddResponseFileCommands();
            // We expect to not see /debug + or -
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug-") == false, "Not expected to find /debug- on the commandline");
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug+") == false, "Not expected to find /debug+ on the commandline");
            // We expect to find /debug:Full
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:Full") == true, "Expected to find /debug:Full on the commandline");
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:PdbOnly") == false, "Not expected to find /debug:PdbOnly on the commandline");

            m           = new MyManagedCompiler();
            m.DebugType = "PdbOnly";
            m.AddResponseFileCommands();
            // We do not expect to see /debug + or -
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug-") == false, "Not expected to find /debug- on the commandline");
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug+") == false, "Not expected to find /debug+ on the commandline");
            // We expect to find /debug:PdbOnly
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:PdbOnly") == true, "Expected to find /debug:PdbOnly on the commandline");
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:Full") == false, "Not expected to find /debug:Full on the commandline");

            m           = new MyManagedCompiler();
            m.DebugType = "none";
            m.AddResponseFileCommands();
            // We expect to see /debug- on the commandline
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug-") == true, "Expected to find /debug- on the commandline");
            // We do not expect to see any /debug: on the commandline
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:") == false, "Not expected to find /debug: on the commandline");

            // The cases where DebugType and DebugSymbols are Blank(not set) is a special case because in microsoft.common.targets
            // when the configuration is "debug" and both DebugType and DebugSymbols are blank DebugSymbols will be set to True.
            // In relase the DebugSymbols will remail blank
            // Debug:   Blank              Blank       /debug+ //Microsof.common.targets will set DebugSymbols to true.
            // This makes the case equal to the testing of EmitDebugSymbols=true and DebugType=null which is done in TestDebugSymbolsTrue above.
            // Release: Blank              Blank       "Nothing for either switch"
            m           = new MyManagedCompiler();
            m.DebugType = null;
            m.AddResponseFileCommands();
            // We do not expect to find /debug+ or /debug-
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug+") == false, "Not expected to find /debug+ on the commandline");
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug-") == false, "Not expected to find /debug- on the commandline");
            // We do not expect to find /debug:
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:") == false, "Not expected to find /debug: on the commandline");
        }
        public void TestDebugSymbolsTrue()
        {
            // Verify each of the DebugType settings when EmitDebugInformation is true
            MyManagedCompiler m = new MyManagedCompiler();
            m.DebugType = "Full";
            m.EmitDebugInformation = true;
            m.AddResponseFileCommands();
            // We expect to see only /debug+ on the commandline
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug+") == true, "Expected to find /debug+ on the commandline");
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug-") == false, "Not expected to find /debug- on the commandline");
            // Expect to only find Full on the commandline
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:Full") == true, "Expected to find /debug:Full on the commandline");
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:PdbOnly") == false, "Not expected to find /debug:PdbOnly on the commandline");

            m = new MyManagedCompiler();
            m.DebugType = "PdbOnly";
            m.EmitDebugInformation = true;
            m.AddResponseFileCommands();
            // We expect to see only /debug+ on the commandline
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug+") == true, "Expected to find /debug+ on the commandline");
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug-") == false, "Not expected to find /debug- on the commandline");
            // Expect to find only PdbOnly on the commandline
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:PdbOnly") == true, "Expected to find /debug:PdbOnly on the commandline");
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:Full") == false, "Not expected to find /debug:Full on the commandline");

            m = new MyManagedCompiler();
            m.DebugType = "none";
            m.EmitDebugInformation = true;
            m.AddResponseFileCommands();
            // We expect to see /debug- on the commandline
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug-") == true, "Expected to find /debug- on the commandline");
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug+") == false, "Not expected to find /debug+ on the commandline");
            // We do not expect to see any /debug: on the commandline
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:") == false, "Not expected to find /debug: on the commandline");

            m = new MyManagedCompiler();
            m.DebugType = null;
            m.EmitDebugInformation = true;
            m.AddResponseFileCommands();
            // We expect to see only /debug+ on the commandline
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug+") == true, "Expected to find /debug+ on the commandline");
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug-") == false, "Not expected to find /debug- on the commandline");
            // We expect to not find any /debug: on the commandline
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:") == false, "Not expected to find /debug: on the commandline");
        }
        public void DuplicateResourcesButWithDifferentLogicalNames()
        {
            MyManagedCompiler m = new MyManagedCompiler();

            m.BuildEngine = new MockEngine(true);
            m.Sources     = new ITaskItem[] { new TaskItem("bar") };
            TaskItem resource1 = new TaskItem("foo.resources");

            resource1.SetMetadata("LogicalName", "value1");
            TaskItem resource2 = new TaskItem("foo.resources");

            resource2.SetMetadata("LogicalName", "value2");
            m.Resources = new ITaskItem[] { resource1, resource2 };
            // This is okay
            Assert.IsTrue(m.AccessValidateParameters());
            ((MockEngine)m.BuildEngine).AssertLogDoesntContain("MSB3105");
            ((MockEngine)m.BuildEngine).AssertLogDoesntContain("MSB3083");
        }
        public void DefaultWin32ManifestNotEmbeddedInNetModule()
        {
            MyManagedCompiler m = new MyManagedCompiler();
            m.BuildEngine = new MockEngine(true);
            m.Sources = new ITaskItem[] { new TaskItem("bar") };
            m.TargetType = "modULE";

            Assert.IsTrue
            (
                String.IsNullOrEmpty(m.AccessGetWin32ManifestSwitch(false, null)),
                "default.win32manifest should NOT be embedded in a net module!"
            );
        }
 public void DuplicateResourcesWithSameLogicalNames()
 {
     MyManagedCompiler m = new MyManagedCompiler();
     m.BuildEngine = new MockEngine(true);
     m.Sources = new ITaskItem[] { new TaskItem("bar") };
     TaskItem resource1 = new TaskItem("foo.resources");
     resource1.SetMetadata("LogicalName", "value1");
     TaskItem resource2 = new TaskItem("foo.resources");
     resource2.SetMetadata("LogicalName", "value1");
     m.Resources = new ITaskItem[] { resource1, resource2 };
     // This is an error
     Assert.IsTrue(!m.AccessValidateParameters());
     ((MockEngine)m.BuildEngine).AssertLogContains("MSB3083");
 }
        public void DefaultWin32ManifestEmbeddedInConsoleAppWhenTargetTypeInferred()
        {
            MyManagedCompiler m = new MyManagedCompiler();
            m.BuildEngine = new MockEngine(true);
            m.Sources = new ITaskItem[] { new TaskItem("bar") };

            Assert.IsTrue
            (
                m.AccessGetWin32ManifestSwitch(false, null).EndsWith("default.win32manifest", StringComparison.OrdinalIgnoreCase),
                "default.win32manifest should be embedded in a console exe!"
            );
        }
 public void DuplicateResourcesButWithDifferentLogicalNames()
 {
     MyManagedCompiler m = new MyManagedCompiler();
     m.BuildEngine = new MockEngine(true);
     m.Sources = new ITaskItem[] { new TaskItem("bar") };
     TaskItem resource1 = new TaskItem("foo.resources");
     resource1.SetMetadata("LogicalName", "value1");
     TaskItem resource2 = new TaskItem("foo.resources");
     resource2.SetMetadata("LogicalName", "value2");
     m.Resources = new ITaskItem[] { resource1, resource2 };
     // This is okay
     Assert.IsTrue(m.AccessValidateParameters());
     ((MockEngine)m.BuildEngine).AssertLogDoesntContain("MSB3105");
     ((MockEngine)m.BuildEngine).AssertLogDoesntContain("MSB3083");
 }
 public void DuplicateResourcesWithNoLogicalNames()
 {
     MyManagedCompiler m = new MyManagedCompiler();
     m.BuildEngine = new MockEngine(true);
     m.Sources = new ITaskItem[] { new TaskItem("bar") };
     m.Resources = new ITaskItem[] { new TaskItem("foo.resources"), new TaskItem("foo.resources") };
     // This is an error
     Assert.IsTrue(!m.AccessValidateParameters());
     ((MockEngine)m.BuildEngine).AssertLogContains("MSB3105");
 }
 public void DuplicateSources()
 {
     MyManagedCompiler m = new MyManagedCompiler();
     m.BuildEngine = new MockEngine(true);
     m.Sources = new ITaskItem[] { new TaskItem("foo"), new TaskItem("foo") };
     Assert.IsTrue(!m.AccessValidateParameters());
     ((MockEngine)m.BuildEngine).AssertLogContains("MSB3105");
 }
        public void TestDebugSymbolsNull()
        {
            MyManagedCompiler m = new MyManagedCompiler();
            m.DebugType = "Full";
            m.AddResponseFileCommands();
            // We expect to not see /debug + or -
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug-") == false, "Not expected to find /debug- on the commandline");
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug+") == false, "Not expected to find /debug+ on the commandline");
            // We expect to find /debug:Full
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:Full") == true, "Expected to find /debug:Full on the commandline");
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:PdbOnly") == false, "Not expected to find /debug:PdbOnly on the commandline");

            m = new MyManagedCompiler();
            m.DebugType = "PdbOnly";
            m.AddResponseFileCommands();
            // We do not expect to see /debug + or -
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug-") == false, "Not expected to find /debug- on the commandline");
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug+") == false, "Not expected to find /debug+ on the commandline");
            // We expect to find /debug:PdbOnly
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:PdbOnly") == true, "Expected to find /debug:PdbOnly on the commandline");
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:Full") == false, "Not expected to find /debug:Full on the commandline");

            m = new MyManagedCompiler();
            m.DebugType = "none";
            m.AddResponseFileCommands();
            // We expect to see /debug- on the commandline
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug-") == true, "Expected to find /debug- on the commandline");
            // We do not expect to see any /debug: on the commandline
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:") == false, "Not expected to find /debug: on the commandline");

            // The cases where DebugType and DebugSymbols are Blank(not set) is a special case because in microsoft.common.targets 
            // when the configuration is "debug" and both DebugType and DebugSymbols are blank DebugSymbols will be set to True.
            // In relase the DebugSymbols will remail blank
            // Debug:   Blank              Blank       /debug+ //Microsof.common.targets will set DebugSymbols to true.
            // This makes the case equal to the testing of EmitDebugSymbols=true and DebugType=null which is done in TestDebugSymbolsTrue above.
            // Release: Blank              Blank       "Nothing for either switch"
            m = new MyManagedCompiler();
            m.DebugType = null;
            m.AddResponseFileCommands();
            // We do not expect to find /debug+ or /debug-
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug+") == false, "Not expected to find /debug+ on the commandline");
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug-") == false, "Not expected to find /debug- on the commandline");
            // We do not expect to find /debug:
            Assert.IsTrue(m.VerifySwitchOnCommandLine("/debug:") == false, "Not expected to find /debug: on the commandline");
        }