コード例 #1
0
        public void TestPerAssemblyOptimizations(ITaskItem [] assemblyPaths)
        {
            var task = new MockTask()
            {
                AssemblyPaths = assemblyPaths
            };

            using (var driver = task.CreateDriver()) {
                foreach (var item in assemblyPaths)
                {
                    var assemblyName = Path.GetFileNameWithoutExtension(item.ItemSpec);
                    foreach (var optimization in MockTask.OptimizationNames)
                    {
                        Assert.True(MockDriver.GetOptimizationName(optimization, out CodeOptimizations codeOptimizations));
                        var optimizationValue = item.GetMetadata(optimization);
                        if (String.IsNullOrEmpty(optimizationValue))
                        {
                            continue;
                        }
                        var enabled     = Boolean.Parse(optimizationValue);
                        var actualValue = driver.Context.Optimizations.IsEnabled(codeOptimizations, assemblyName: assemblyName);
                        Assert.Equal(enabled, actualValue);
                    }
                }
            }
        }
コード例 #2
0
        public void TestGlobalOptimizations(string optimization, bool enabled)
        {
            var task = new MockTask();

            task.SetOptimization(optimization, enabled);
            // get the corresponding CodeOptimizations value
            Assert.True(MockDriver.GetOptimizationName(optimization, out CodeOptimizations codeOptimizations));
            using (var driver = task.CreateDriver()) {
                var actualValue = driver.Context.Optimizations.IsEnabled(codeOptimizations, assemblyName: null);
                Assert.Equal(enabled, actualValue);
            }
        }