public static IEnumerable <PackageIssue> Validate(IPackage package)
        {
            var builder = new AddInfoBuilder(new BinaryStoreManager(), new SymbolStoreManager(), new SourceDiscover(new ManagedSourceExtractor(), new SourceStoreManager()));
            var info    = builder.Build(new PackageDirectoryInfo(package.GetFiles().ToArray()));

            foreach (var binaryInfo in info.Binaries)
            {
                if (binaryInfo.SymbolInfo != null && binaryInfo.SymbolInfo.SourceInfos != null)
                {
                    foreach (var sourceInfo in binaryInfo.SymbolInfo.SourceInfos)
                    {
                        if (sourceInfo.ActualPath == null)
                        {
                            yield return(NoSourceFileIssue(binaryInfo.File.FullPath, sourceInfo.OriginalPath));
                        }
                    }
                }
            }

            //var matched = info.Binaries
            //    .SelectMany(binary => binary.SymbolInfo.SourceInfos)
            //    .Where(source => source.ActualPath != null)
            //    .Select(source => source.ActualPath.FullPath)
            //    .ToList();

            //foreach (var file in package.GetFilesInFolder("src"))
            //{
            //    if (!matched.Contains(file))
            //        yield return UnnecessarySourceFileIssue(file);
            //}
        }
Esempio n. 2
0
        private void RunTest(params SourceTuple[] files)
        {
            var srcSourcesFileInfos = files
                                      .Select(f => f.SrcSourcePath)
                                      .OrderBy(f => f);

            var pdbSourcesFiles = files
                                  .Select(f => f.PdbSourcePath)
                                  .OrderByDescending(f => f)
                                  .ToArray();

            var binaryStream = new MemoryStream();
            var symbolStream = new MemoryStream();

            var sourceExtractor    = Mock.Of <ISourceExtractor>(p => p.ReadSources(binaryStream, symbolStream) == pdbSourcesFiles);
            var sourceStoreManager = Mock.Of <ISourceStoreManager>(s => s.ReadHash(null) == "__HASH__");
            var binaryStoreManager = Mock.Of <IBinaryStoreManager>(s => s.ReadBinaryHash(binaryStream) == "__BINARY_HASH__" && s.ReadPdbHash(binaryStream) == "__SYMBOL_HASH__");
            var symbolStoreManager = Mock.Of <ISymbolStoreManager>(s => s.ReadHash(symbolStream) == "__SYMBOL_HASH__");

            var sourceDiscover = new SourceDiscover(sourceExtractor, sourceStoreManager);
            var addInfoBuilder = new AddInfoBuilder(binaryStoreManager, symbolStoreManager, sourceDiscover);

            var zipFile = new ZipFile();

            zipFile.AddEntry(@"dummy\lib\Test.pdb", symbolStream);
            zipFile.AddEntry(@"dummy\lib\Test.dll", binaryStream);

            foreach (var srcSourcesFileInfo in srcSourcesFileInfos)
            {
                zipFile.AddEntry(srcSourcesFileInfo, srcSourcesFileInfo);
            }

            var allAddInfo = addInfoBuilder.Build(new ZipPackageFile(zipFile));

            foreach (var binaryInfo in allAddInfo.Binaries)
            {
                foreach (var sourceInfo in binaryInfo.SymbolInfo.SourceInfos)
                {
                    Assert.NotNull(sourceInfo.ActualPath);
                }
            }

            //foreach (var sourceTuple in files.Where(s => s.PdbSourcePath != null))
            //{
            //    var discovered = result.Single(d => d.OriginalPath == sourceTuple.PdbSourcePath);
            //    var actual = discovered.ActualPath != null ? discovered.ActualPath.FullPath : null;
            //    Assert.Equal(sourceTuple.SrcSourcePath, actual);
            //}
        }