Example #1
0
        private void ProcessFiles()
        {
            var filePaths = _projectXml
                            .Descendants(XName.Get("Compile", Namespace))
                            .Select(x => x.Attribute(XName.Get("Include"))?.Value)
                            .Where(x => !string.IsNullOrWhiteSpace(x))
                            .ToArray();

            Info($"Project: detected {filePaths.Length} file(s) for compilation.");

            foreach (var filePath in filePaths)
            {
                var fullFilePath = GetFullPath(filePath);
                var fileStrategy = new FileTarget(fullFilePath);
                fileStrategy.Process();
                AssemblyTypeDetector.AddTypeDefinitions(fileStrategy.Definition.AllTypeCombinations);
            }
        }
Example #2
0
        public void Process()
        {
            EmptyLine();
            Info($"Start processing the project '{ProjectFilePath}'");
            if (!FileIsProject())
            {
                return;
            }

            if (!ProjectExists())
            {
                return;
            }

            AssemblyTypeDetector.AddAssemblySearchPath(ProjectDirectory);
            _projectXml = XElement.Load(ProjectFilePath);
            ProcessFiles();
            ProcessReferences();
            SearchFakesConfigurationFiles();
            Info($"Stop processing the project '{ProjectFilePath}'");
        }
Example #3
0
        private void ProcessReferences()
        {
            AssemblyTypeDetector.AddReferencePaths(new[] { ProjectDirectory });
            var references = _projectXml
                             .Descendants(XName.Get("Reference", Namespace))
                             .Select(x => new
            {
                x.Element(XName.Get("HintPath", Namespace))?.Value,
                Include = x.Attribute(XName.Get("Include"))?.Value
            }).ToArray();

            Info($"Project: detected {references.Length} references.");

            var fileReferences = references
                                 .Where(x => x.Value.EndsWithOrdinalIgnoreCase(FileExtensions.LibraryFileExtension))
                                 .ToArray();
            var referencePaths = fileReferences
                                 .Select(x => Path.GetDirectoryName(GetFullPath(x.Value)))
                                 .Distinct()
                                 .ToArray();

            AssemblyTypeDetector.AddReferencePaths(referencePaths);

            AssemblyTypeDetector.AddAssembly(Assembly.Load("mscorlib").Location);
            foreach (var reference in fileReferences)
            {
                if (reference.Include.EndsWithOrdinalIgnoreCase(".Fakes"))
                {
                    Info($"Project: add '{reference.Include}' assembly to check types.");
                    AssemblyTypeDetector.AddAssembly(GetFullPath(reference.Value));
                }
                else
                {
                    Info($"Project: '{reference.Include}' is not fake assembly.");
                }
            }
        }