예제 #1
0
        public void TagsAreSet()
        {
            var project = Project.GetProject(@"
{
    ""tags"": [""awesome"", ""fantastic"", ""aspnet""]
}",
                                             "foo",
                                             @"c:\foo\project.json");
            var tags = new ReadOnlyHashSet <string>(project.Tags);

            Assert.Equal(3, tags.Count);
            Assert.True(tags.Contains("awesome"));
            Assert.True(tags.Contains("fantastic"));
            Assert.True(tags.Contains("aspnet"));
        }
        public static bool IsTaintEntryPoint(this ISymbol symbol, ReadOnlyHashSet <string> entryPoints)
        {
            if (symbol.ContainingType == null)
            {
                return(false);
            }

            var nameSpace = symbol.ContainingType.ContainingNamespace.GetTypeName();

            // first search for method name
            string key = string.IsNullOrWhiteSpace(nameSpace)
                             ? $"{symbol.ContainingType.Name}|{symbol.Name}"
                             : $"{nameSpace}.{symbol.ContainingType.Name}|{symbol.Name}";

            if (entryPoints.Contains(key))
            {
                return(true);
            }

            if (symbol.IsPublic() && !symbol.IsConstructor()) // todo: attributes + filter NonAction
            {
                var containingType = symbol.ContainingType;
                if (containingType.IsTypeOrDerivedFrom(entryPoints))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #3
0
        /// <summary>
        /// Finds all the source files under a directory that contain reflection markup
        /// </summary>
        /// <param name="Directory">The directory to search</param>
        /// <param name="MetadataCache">Cache of source file metadata</param>
        /// <param name="ExcludedFolderNames">Set of folder names to ignore when recursing the directory tree</param>
        /// <param name="FilesWithMarkup">Receives the set of files which contain reflection markup</param>
        /// <param name="Queue">Queue to add sub-tasks to</param>
        static void FindFilesWithMarkup(DirectoryItem Directory, SourceFileMetadataCache MetadataCache, ReadOnlyHashSet <string> ExcludedFolderNames, ConcurrentBag <FileItem> FilesWithMarkup, ThreadPoolWorkQueue Queue)
        {
            // Search through all the subfolders
            foreach (DirectoryItem SubDirectory in Directory.EnumerateDirectories())
            {
                if (!ExcludedFolderNames.Contains(SubDirectory.Name))
                {
                    Queue.Enqueue(() => FindFilesWithMarkup(SubDirectory, MetadataCache, ExcludedFolderNames, FilesWithMarkup, Queue));
                }
            }

            // Check for all the headers in this folder
            foreach (FileItem File in Directory.EnumerateFiles())
            {
                if (File.HasExtension(".h") && MetadataCache.ContainsReflectionMarkup(File))
                {
                    FilesWithMarkup.Add(File);
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Determines if a directory, or any subdirectory of it, contains new source files
        /// </summary>
        /// <param name="Directory">Directory to search through</param>
        /// <param name="ExcludedFolderNames">Set of directory names to exclude</param>
        /// <returns>True if the directory contains any source files</returns>
        static bool ContainsSourceFiles(DirectoryItem Directory, ReadOnlyHashSet <string> ExcludedFolderNames)
        {
            // Check this directory isn't ignored
            if (!ExcludedFolderNames.Contains(Directory.Name))
            {
                // Check for any source files in this actual directory
                FileItem[] SourceFiles = UEBuildModuleCPP.GetSourceFiles(Directory);
                if (SourceFiles.Length > 0)
                {
                    return(true);
                }

                // Check for any source files in a subdirectory
                foreach (DirectoryItem SubDirectory in Directory.EnumerateDirectories())
                {
                    if (ContainsSourceFiles(SubDirectory, ExcludedFolderNames))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
예제 #5
0
        public void TagsAreSet()
        {
            var project = ProjectUtilities.GetProject(@"
            {
            ""tags"": [""awesome"", ""fantastic"", ""aspnet""]
            }",
            "foo",
            @"c:\foo\project.json");
            var tags = new ReadOnlyHashSet<string>(project.Tags);

            Assert.Equal(3, tags.Count);
            Assert.True(tags.Contains("awesome"));
            Assert.True(tags.Contains("fantastic"));
            Assert.True(tags.Contains("aspnet"));
        }