Ejemplo n.º 1
0
        /// <summary>
        /// Searches all task declarations for the given task name. If no exact match is found, looks for partial matches.
        /// </summary>
        /// <remarks>
        /// It is possible to get multiple partial matches for a task name that is not fully qualified.
        /// NOTE: this method is marked internal for unit testing purposes only.
        /// </remarks>
        /// <param name="taskName"></param>
        /// <param name="exactMatchRequired"></param>
        /// <param name="registeredTasksFound"></param>
        /// <returns>true, if given task name matches one or more task declarations</returns>
        internal bool FindRegisteredTasks(string taskName, bool exactMatchRequired, out Hashtable registeredTasksFound)
        {
            registeredTasksFound = new Hashtable(StringComparer.OrdinalIgnoreCase);
            ArrayList taskAssemblies = registeredTasks != null ? (ArrayList)registeredTasks[taskName] : null;

            // if we find an exact match
            if (taskAssemblies != null)
            {
                // we're done
                registeredTasksFound[taskName] = taskAssemblies;
            }
            else if (!exactMatchRequired)
            {
                // look through all task declarations for partial matches
                foreach (DictionaryEntry registeredTask in registeredTasks)
                {
                    if (TypeLoader.IsPartialTypeNameMatch(taskName, (string)registeredTask.Key))
                    {
                        registeredTasksFound[registeredTask.Key] = registeredTask.Value;
                    }
                }
            }

            return(registeredTasksFound.Count > 0);
        }
Ejemplo n.º 2
0
 public void Basic()
 {
     Assert.True(TypeLoader.IsPartialTypeNameMatch("Csc", "csc"));                                             // ==> exact match
     Assert.True(TypeLoader.IsPartialTypeNameMatch("Microsoft.Build.Tasks.Csc", "Microsoft.Build.Tasks.Csc")); // ==> exact match
     Assert.True(TypeLoader.IsPartialTypeNameMatch("Microsoft.Build.Tasks.Csc", "Csc"));                       // ==> partial match
     Assert.True(TypeLoader.IsPartialTypeNameMatch("Microsoft.Build.Tasks.Csc", "Tasks.Csc"));                 // ==> partial match
     Assert.True(TypeLoader.IsPartialTypeNameMatch("MyTasks.ATask+NestedTask", "NestedTask"));                 // ==> partial match
     Assert.True(TypeLoader.IsPartialTypeNameMatch("MyTasks.ATask\\\\+NestedTask", "NestedTask"));             // ==> partial match
     Assert.False(TypeLoader.IsPartialTypeNameMatch("MyTasks.CscTask", "Csc"));                                // ==> no match
     Assert.False(TypeLoader.IsPartialTypeNameMatch("MyTasks.MyCsc", "Csc"));                                  // ==> no match
     Assert.False(TypeLoader.IsPartialTypeNameMatch("MyTasks.ATask\\.Csc", "Csc"));                            // ==> no match
     Assert.False(TypeLoader.IsPartialTypeNameMatch("MyTasks.ATask\\\\\\.Csc", "Csc"));                        // ==> no match
 }
Ejemplo n.º 3
0
 public void Basic()
 {
     Assertion.Assert(TypeLoader.IsPartialTypeNameMatch("Csc", "csc"));                                           // ==> exact match
     Assertion.Assert(TypeLoader.IsPartialTypeNameMatch("net.r_eg.IeXod.Tasks.Csc", "net.r_eg.IeXod.Tasks.Csc")); // ==> exact match
     Assertion.Assert(TypeLoader.IsPartialTypeNameMatch("net.r_eg.IeXod.Tasks.Csc", "Csc"));                      // ==> partial match
     Assertion.Assert(TypeLoader.IsPartialTypeNameMatch("net.r_eg.IeXod.Tasks.Csc", "Tasks.Csc"));                // ==> partial match
     Assertion.Assert(TypeLoader.IsPartialTypeNameMatch("MyTasks.ATask+NestedTask", "NestedTask"));               // ==> partial match
     Assertion.Assert(TypeLoader.IsPartialTypeNameMatch("MyTasks.ATask\\\\+NestedTask", "NestedTask"));           // ==> partial match
     Assertion.Assert(!TypeLoader.IsPartialTypeNameMatch("MyTasks.CscTask", "Csc"));                              // ==> no match
     Assertion.Assert(!TypeLoader.IsPartialTypeNameMatch("MyTasks.MyCsc", "Csc"));                                // ==> no match
     Assertion.Assert(!TypeLoader.IsPartialTypeNameMatch("MyTasks.ATask\\.Csc", "Csc"));                          // ==> no match
     Assertion.Assert(!TypeLoader.IsPartialTypeNameMatch("MyTasks.ATask\\\\\\.Csc", "Csc"));                      // ==> no match
 }
Ejemplo n.º 4
0
 public void Regress_Mutation_ParameterOrderDoesntMatter()
 {
     Assert.True(TypeLoader.IsPartialTypeNameMatch("Csc", "Microsoft.Build.Tasks.Csc"));
 }
Ejemplo n.º 5
0
 public void Regress_Mutation_TrailingPartMustMatch()
 {
     Assert.False(TypeLoader.IsPartialTypeNameMatch("Microsoft.Build.Tasks.Csc", "Vbc"));
 }
Ejemplo n.º 6
0
 public void Regress_Mutation_ParameterOrderDoesntMatter()
 {
     Assertion.Assert(TypeLoader.IsPartialTypeNameMatch("Csc", "net.r_eg.IeXod.Tasks.Csc"));
 }
Ejemplo n.º 7
0
 public void Regress_Mutation_TrailingPartMustMatch()
 {
     Assertion.Assert(!TypeLoader.IsPartialTypeNameMatch("net.r_eg.IeXod.Tasks.Csc", "Vbc"));
 }