Example #1
0
        private List <FileSystemPath> ExtractReferenceLocations([NotNull] IT4File file)
        {
            file.AssertContainsNoIncludeContext();
            var directives = file.GetThisAndIncludedFilesRecursive()
                             .SelectMany(it => it.Blocks)
                             .OfType <IT4AssemblyDirective>();
            var errors             = new FrugalLocalList <T4FailureRawData>();
            var directDependencies = directives.SelectNotNull(
                directive =>
            {
                var resolved = AssemblyReferenceResolver.Resolve(directive);
                if (resolved == null)
                {
                    errors.Add(CreateError(directive));
                }
                return(resolved);
            }
                ).AsList();

            if (!errors.IsEmpty)
            {
                throw new T4OutputGenerationException(errors);
            }
            AddBaseReferences(directDependencies, file);
            return(directDependencies);
        }
        public IEnumerable <T4AssemblyReferenceInfo> ExtractReferenceLocationsTransitive(IT4File file)
        {
            file.AssertContainsNoIncludeContext();
            var sourceFile  = file.PhysicalPsiSourceFile.NotNull();
            var projectFile = sourceFile.ToProjectFile().NotNull();
            var directives  = file.GetThisAndIncludedFilesRecursive()
                              .SelectMany(it => it.Blocks)
                              .OfType <IT4AssemblyDirective>();
            var errors             = new FrugalLocalList <T4FailureRawData>();
            var directDependencies = directives.SelectNotNull(
                directive =>
            {
                var resolved = AssemblyReferenceResolver.Resolve(directive);
                if (resolved == null)
                {
                    errors.Add(T4FailureRawData.FromElement(directive, "Unresolved assembly reference"));
                }

                return(resolved);
            }
                ).AsList();

            if (!errors.IsEmpty)
            {
                throw new T4OutputGenerationException(errors);
            }
            AddBaseReferences(directDependencies, file);
            return(LowLevelReferenceExtractionManager.ResolveTransitiveDependencies(
                       directDependencies,
                       projectFile.SelectResolveContext()
                       ));
        }