Esempio n. 1
0
 public IEnumerable<IStepDefinitionBinding> GetBindingsFromProjectItem(ProjectItem projectItem, out List<ProjectItem> relatedProjectItems)
 {
     var bindingProcessor = new IdeBindingSourceProcessor(tracer);
     relatedProjectItems = new List<ProjectItem>();
     ProcessBindingsFromProjectItem(projectItem, bindingProcessor, relatedProjectItems);
     return bindingProcessor.ReadStepDefinitionBindings();
 }
        public IEnumerable <IStepDefinitionBinding> GetStepDefinitionsFromAssembly(string assemblyPath)
        {
            var bindingProcessor = new IdeBindingSourceProcessor();

            ProcessStepDefinitionsFromAssembly(assemblyPath, bindingProcessor);
            return(bindingProcessor.ReadStepDefinitionBindings());
        }
        private void ProcessBindingsFromProjectItem(ProjectItem projectItem, IdeBindingSourceProcessor bindingSourceProcessor, List<ProjectItem> relatedProjectItems)
        {
            foreach (CodeClass codeClass in VsxHelper.GetClasses(projectItem))
            {
                CodeClass2 bindingClassIncludingParts = codeClass as CodeClass2;

                var parts = new List<CodeClass>();

                if (bindingClassIncludingParts == null)
                {
                    parts.Add(codeClass);
                }
                else
                {
                    parts.AddRange(bindingClassIncludingParts.Parts.OfType<CodeClass>());
                }


                var baseClass = GetBaseClass(codeClass);

                while (baseClass != null)
                {
                    tracer.Trace("Adding inherited bindings for class: " + baseClass.FullName, GetType().Name);
                    parts.Add(baseClass);
                    baseClass = GetBaseClass(baseClass);
                }

                // we need to use the class parts to grab class-related information (e.g. [Binding] attribute)
                // but we need to process the binding methods only from the current part, otherwise these
                // methods would be registered to multiple file paths, and the update tracking would not work
                    
                relatedProjectItems.AddRange(parts.Select(SafeGetProjectItem).Where(pi => pi != null && pi != projectItem));
                ProcessCodeClass(codeClass, bindingSourceProcessor, parts.ToArray());
            }
        }
Esempio n. 4
0
 private void ProcessCodeFunctions(CodeClass codeClass, BindingSourceType bindingSourceType, IdeBindingSourceProcessor bindingSourceProcessor)
 {
     foreach (var codeFunction in codeClass.Children.OfType<CodeFunction>())
     {
         var bindingSourceMethod = CreateBindingSourceMethod(codeFunction, bindingSourceType, bindingSourceProcessor);
         if (bindingSourceMethod != null)
             bindingSourceProcessor.ProcessMethod(bindingSourceMethod);
     }
 }
 private BindingSourceMethod CreateBindingSourceMethod(CodeFunction codeFunction, BindingSourceType bindingSourceType, IdeBindingSourceProcessor bindingSourceProcessor)
 {
     try
     {
         var filteredAttributes = codeFunction.Attributes.Cast<CodeAttribute2>().Where(attr => bindingSourceProcessor.CanProcessTypeAttribute(attr.FullName)).ToArray();
         return bindingReflectionFactory.CreateBindingSourceMethod(codeFunction, bindingSourceType, filteredAttributes);
     }
     catch (Exception ex)
     {
         tracer.Trace("CreateBindingSourceMethod error: {0}", this, ex);
         return null;
     }
 }
Esempio n. 6
0
        private void ProcessCodeClass(CodeClass codeClass, IdeBindingSourceProcessor bindingSourceProcessor, params CodeClass[] classParts)
        {
            var filteredAttributes = classParts
                .SelectMany(cc => cc.Attributes.Cast<CodeAttribute2>().Where(attr => CanProcessTypeAttribute(bindingSourceProcessor, attr))).ToArray();
                
            if (!bindingSourceProcessor.PreFilterType(filteredAttributes.Select(attr => attr.FullName)))
                return;

            var bindingSourceType = bindingReflectionFactory.CreateBindingSourceType(classParts, filteredAttributes); //TODO: merge info from parts

            if (!bindingSourceProcessor.ProcessType(bindingSourceType))
                return;

            ProcessCodeFunctions(codeClass, bindingSourceType, bindingSourceProcessor);

            bindingSourceProcessor.ProcessTypeDone();
        }
 private void ProcessBindingsFromProjectItem(ProjectItem projectItem, IdeBindingSourceProcessor bindingSourceProcessor)
 {
     foreach (CodeClass codeClass in VsxHelper.GetClasses(projectItem))
     {
         CodeClass2 bindingClassIncludingParts = codeClass as CodeClass2;
         if (bindingClassIncludingParts == null)
         {
             ProcessCodeClass(codeClass, bindingSourceProcessor);
         }
         else
         {
             foreach (CodeClass2 partialClassParts in bindingClassIncludingParts.Parts)
             {
                 ProcessCodeClass(partialClassParts, bindingSourceProcessor);
             }
         }
     }
 }
        private void ProcessCodeClass(CodeClass codeClass, IdeBindingSourceProcessor bindingSourceProcessor)
        {
            var filteredAttributes = codeClass.Attributes.Cast<CodeAttribute2>().Where(attr => bindingSourceProcessor.CanProcessTypeAttribute(attr.FullName)).ToArray();
            if (!bindingSourceProcessor.PreFilterType(filteredAttributes.Select(attr => attr.FullName)))
                return;

            var bindingSourceType = bindingReflectionFactory.CreateBindingSourceType(codeClass, filteredAttributes);

            if (!bindingSourceProcessor.ProcessType(bindingSourceType))
                return;

            foreach (var codeFunction in codeClass.Children.OfType<CodeFunction>())
            {
                bindingSourceProcessor.ProcessMethod(CreateBindingSourceMethod(codeFunction, bindingSourceType, bindingSourceProcessor));
            }

            bindingSourceProcessor.ProcessTypeDone();
        }
Esempio n. 9
0
 private void ProcessBindingsFromProjectItem(ProjectItem projectItem, IdeBindingSourceProcessor bindingSourceProcessor, List<ProjectItem> relatedProjectItems)
 {
     foreach (CodeClass codeClass in VsxHelper.GetClasses(projectItem))
     {
         CodeClass2 bindingClassIncludingParts = codeClass as CodeClass2;
         if (bindingClassIncludingParts == null)
         {
             ProcessCodeClass(codeClass, bindingSourceProcessor, codeClass);
         }
         else
         {
             var parts = bindingClassIncludingParts.Parts.OfType<CodeClass>().ToArray();
             relatedProjectItems.AddRange(parts.Select(p => p.ProjectItem).Where(pi => pi != null && pi != projectItem));
             // we need to use the class parts to grab class-related information (e.g. [Binding] attribute)
             // but we need to process the binding methods only from the current part, otherwise these
             // methods would be registered to multiple file pathes, and the update tracking would not work
             ProcessCodeClass(codeClass, bindingSourceProcessor, parts.ToArray());
         }
     }
 }
Esempio n. 10
0
 public IEnumerable<IStepDefinitionBinding> GetBindingsFromProjectItem(ProjectItem projectItem)
 {
     var bindingProcessor = new IdeBindingSourceProcessor();
     ProcessBindingsFromProjectItem(projectItem, bindingProcessor);
     return bindingProcessor.ReadStepDefinitionBindings();
 }
Esempio n. 11
0
        private static bool CanProcessTypeAttribute(IdeBindingSourceProcessor bindingSourceProcessor, CodeAttribute2 attr)
        {
            string attributeTypeName;
            try
            {
                attributeTypeName = attr.FullName;
            }
            catch (Exception)
            {
                // invalid attribute - ignore
                return false;
            }

            return bindingSourceProcessor.CanProcessTypeAttribute(attributeTypeName);
        }
 private BindingSourceMethod CreateBindingSourceMethod(CodeFunction codeFunction, BindingSourceType bindingSourceType, IdeBindingSourceProcessor bindingSourceProcessor)
 {
     var filteredAttributes = codeFunction.Attributes.Cast<CodeAttribute2>().Where(attr => bindingSourceProcessor.CanProcessTypeAttribute(attr.FullName)).ToArray();
     return bindingReflectionFactory.CreateBindingSourceMethod(codeFunction, bindingSourceType, filteredAttributes);
 }
Esempio n. 13
0
 public IEnumerable<IStepDefinitionBinding> GetStepDefinitionsFromAssembly(string assemblyPath)
 {
     var bindingProcessor = new IdeBindingSourceProcessor(tracer);
     ProcessStepDefinitionsFromAssembly(assemblyPath, bindingProcessor);
     return bindingProcessor.ReadStepDefinitionBindings();
 }