/// <nodoc /> protected static ReadOnlyHashSet <T> ParallelProcessAllOutputs <T>( IPipFilterContext context, Action <PipId, HashSet <T> > action, IList <PipId> pips = null) { var outputs = new ReadOnlyHashSet <T>(); pips = pips ?? context.AllPips; // Note: pips better be an IList<...> in order to get good Parallel.ForEach performance Parallel.ForEach( pips, () => new HashSet <T>(), (pipId, loopState, index, localOutputs) => { action(pipId, localOutputs); return(localOutputs); }, localOutputs => { if (localOutputs.Count > 0) { lock (outputs) { // Even though the 'outputs' variable is of type ReadOnlyHashSet // we still can modify it. outputs.UnionWith(localOutputs); } } }); return(outputs); }
public Configuration(Configuration config) { AuditMode = config.AuditMode; PasswordValidatorRequiredLength = config.PasswordValidatorRequiredLength; MinimumPasswordValidatorProperties = config.MinimumPasswordValidatorProperties; _PasswordValidatorRequiredProperties = new HashSet <string>(config.PasswordValidatorRequiredProperties); PasswordValidatorRequiredProperties = new ReadOnlyHashSet <string>(_PasswordValidatorRequiredProperties); ConfigurationBehavior = new Dictionary <string, KeyValuePair <string, MethodBehavior> >(config.ConfigurationBehavior); Behavior = config.Behavior.ToDictionary(); _TaintEntryPoints = new HashSet <string>(config.TaintEntryPoints); TaintEntryPoints = new ReadOnlyHashSet <string>(_TaintEntryPoints); _AntiCsrfAttributes = config.AntiCsrfAttributes.ToDictionary(); _PasswordFields = new HashSet <string>(config.PasswordFields); PasswordFields = new ReadOnlyHashSet <string>(_PasswordFields); _ConstantFields = new HashSet <string>(config.ConstantFields); ConstantFields = new ReadOnlyHashSet <string>(_ConstantFields); TaintTypeNameToBit = new Dictionary <string, ulong>(config.TaintTypeNameToBit); }
public Configuration(Configuration config) { ReportAnalysisCompletion = config.ReportAnalysisCompletion; AuditMode = config.AuditMode; PasswordValidatorRequiredLength = config.PasswordValidatorRequiredLength; MinimumPasswordValidatorProperties = config.MinimumPasswordValidatorProperties; _PasswordValidatorRequiredProperties = new HashSet <string>(config.PasswordValidatorRequiredProperties); PasswordValidatorRequiredProperties = new ReadOnlyHashSet <string>(_PasswordValidatorRequiredProperties); ConfigurationBehavior = new Dictionary <string, KeyValuePair <string, MethodBehavior> >(config.ConfigurationBehavior); Behavior = config.Behavior.ToDictionary(); _TaintEntryPoints = new HashSet <string>(config.TaintEntryPoints); TaintEntryPoints = new ReadOnlyHashSet <string>(_TaintEntryPoints); _CsrfGroupsList = new LinkedList <CsrfNamedGroup>(config.CsrfGoups); _CsrfGroups = new Dictionary <string, LinkedListNode <CsrfNamedGroup> >(config.CsrfGoups.Count); var node = _CsrfGroupsList.First; while (node != null) { _CsrfGroups.Add(node.Value.Name, node); node = node.Next; } _PasswordFields = new HashSet <string>(config.PasswordFields); PasswordFields = new ReadOnlyHashSet <string>(_PasswordFields); _ConstantFields = new HashSet <string>(config.ConstantFields); ConstantFields = new ReadOnlyHashSet <string>(_ConstantFields); TaintTypeNameToBit = new Dictionary <string, ulong>(config.TaintTypeNameToBit); }
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); }
/// <summary> /// Finds a list of folder names to exclude when building for this platform /// </summary> public ReadOnlyHashSet <string> GetExcludedFolderNames() { if (CachedExcludedFolderNames == null) { CachedExcludedFolderNames = new ReadOnlyHashSet <string>(GetPlatformFolderNames().Except(GetIncludedFolderNames()), DirectoryReference.Comparer); } return(CachedExcludedFolderNames); }
public ReadOnlyInflatedCollectionCollector(InflatedCollectionCollector inflatedCollectionCollector) { this.Types = inflatedCollectionCollector.Types.Items; this.TypeDeclarations = inflatedCollectionCollector.TypeDeclarations.Items; this.TypeMethodDeclarations = inflatedCollectionCollector.TypeDeclarations.Items; this.Methods = inflatedCollectionCollector.Methods.Items; this.Arrays = inflatedCollectionCollector.Arrays.Items; this.EmptyTypes = inflatedCollectionCollector.EmptyTypes.Items; }
/// <summary> /// Initializes a new instance of the <see cref="CustomDataSourceBase"/> /// class. /// </summary> /// <param name="additionalTablesProvider"> /// A function the provides an additional set of tables descriptors and their /// underlying table types that should be exposed in addition to the tables /// found via reflection. /// </param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="additionalTablesProvider"/> is <c>null</c>. /// </exception> protected CustomDataSourceBase( Func <IDictionary <TableDescriptor, Action <ITableBuilder, IDataExtensionRetrieval> > > additionalTablesProvider) { Guard.NotNull(additionalTablesProvider, nameof(additionalTablesProvider)); this.allTables = new Dictionary <TableDescriptor, Action <ITableBuilder, IDataExtensionRetrieval> >(); this.allTablesRO = new ReadOnlyDictionary <TableDescriptor, Action <ITableBuilder, IDataExtensionRetrieval> >(this.allTables); this.metadataTables = new HashSet <TableDescriptor>(); this.metadataTablesRO = new ReadOnlyHashSet <TableDescriptor>(this.metadataTables); // See note in parameterless constructor this.tableAssemblyProvider = () => this.GetType().Assembly; this.additionalTablesProvider = additionalTablesProvider; }
/// <summary> /// Initializes a new instance of the <see cref="CustomDataSourceBase"/> /// class. /// </summary> /// <param name="additionalTablesProvider"> /// A function the provides an additional set of tables descriptors and their /// underlying table types that should be exposed in addition to the tables /// found via reflection. /// </param> /// <param name="tableAssemblyProvider"> /// A function that provides the <see cref="Assembly"/> that should be searched /// for tables. /// </param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="additionalTablesProvider"/> is <c>null</c>. /// - or - /// <paramref name="tableAssemblyProvider"/> is <c>null</c>. /// </exception> protected CustomDataSourceBase( Func <IDictionary <TableDescriptor, Action <ITableBuilder, IDataExtensionRetrieval> > > additionalTablesProvider, Func <Assembly> tableAssemblyProvider) { Guard.NotNull(additionalTablesProvider, nameof(additionalTablesProvider)); Guard.NotNull(tableAssemblyProvider, nameof(tableAssemblyProvider)); this.allTables = new Dictionary <TableDescriptor, Action <ITableBuilder, IDataExtensionRetrieval> >(); this.allTablesRO = new ReadOnlyDictionary <TableDescriptor, Action <ITableBuilder, IDataExtensionRetrieval> >(this.allTables); this.metadataTables = new HashSet <TableDescriptor>(); this.metadataTablesRO = new ReadOnlyHashSet <TableDescriptor>(this.metadataTables); this.tableAssemblyProvider = tableAssemblyProvider; this.additionalTablesProvider = additionalTablesProvider; }
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")); }
/// <summary> /// Initializes a new instance of the <see cref="CustomDataSourceBase"/> /// class. /// </summary> protected CustomDataSourceBase() { this.allTables = new Dictionary <TableDescriptor, Action <ITableBuilder, IDataExtensionRetrieval> >(); this.allTablesRO = new ReadOnlyDictionary <TableDescriptor, Action <ITableBuilder, IDataExtensionRetrieval> >(this.allTables); this.metadataTables = new HashSet <TableDescriptor>(); this.metadataTablesRO = new ReadOnlyHashSet <TableDescriptor>(this.metadataTables); // // We need to have the full concrete type, and so must use this.GetType(). // 'this' is not allowed to be used in a : this or : base call in the constructor, // so unfortunately we have to use an older idiom of every constructor calling an // init method so that we can pass the concrete type's assembly. // this.tableAssemblyProvider = () => this.GetType().Assembly; this.additionalTablesProvider = () => new Dictionary <TableDescriptor, Action <ITableBuilder, IDataExtensionRetrieval> >(); }
/// <summary> /// Finds a list of folder names to include when building for this platform /// </summary> public ReadOnlyHashSet <string> GetIncludedFolderNames() { if (CachedIncludedFolderNames == null) { HashSet <string> Names = new HashSet <string>(DirectoryReference.Comparer); Names.Add(Platform.ToString()); foreach (UnrealPlatformGroup Group in UEBuildPlatform.GetPlatformGroups(Platform)) { Names.Add(Group.ToString()); } CachedIncludedFolderNames = new ReadOnlyHashSet <string>(Names, DirectoryReference.Comparer); } return(CachedIncludedFolderNames); }
public Configuration() { _PasswordValidatorRequiredProperties = new HashSet <string>(); PasswordValidatorRequiredProperties = new ReadOnlyHashSet <string>(_PasswordValidatorRequiredProperties); ConfigurationBehavior = new Dictionary <string, KeyValuePair <string, MethodBehavior> >(); Behavior = new Dictionary <string, MethodBehavior>(); _TaintEntryPoints = new HashSet <string>(); TaintEntryPoints = new ReadOnlyHashSet <string>(_TaintEntryPoints); _AntiCsrfAttributes = new Dictionary <string, List <string> >(); _PasswordFields = new HashSet <string>(); PasswordFields = new ReadOnlyHashSet <string>(_PasswordFields); _ConstantFields = new HashSet <string>(); ConstantFields = new ReadOnlyHashSet <string>(_ConstantFields); TaintTypeNameToBit = new Dictionary <string, ulong>(62); }
/// <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); }
// Constructors internal ProviderInfo( string providerName, Version storageVersion, ProviderFeatures providerFeatures, int maxIdentifierLength, string constantPrimaryIndexName, string defaultDatabase, string defaultSchema, IEnumerable <Type> supportedTypes) { ProviderName = providerName; StorageVersion = storageVersion; ProviderFeatures = providerFeatures; MaxIdentifierLength = maxIdentifierLength; ConstantPrimaryIndexName = constantPrimaryIndexName; DefaultDatabase = defaultDatabase; DefaultSchema = defaultSchema; SupportedTypes = new ReadOnlyHashSet <Type>(supportedTypes.ToHashSet()); }
/// <summary> /// Checks if the makefile is valid for the current set of source files. This is done separately to the Load() method to allow pre-build steps to modify source files. /// </summary> /// <param name="Makefile">The makefile that has been loaded</param> /// <param name="ProjectFile">Path to the project file</param> /// <param name="Platform">The platform being built</param> /// <param name="WorkingSet">The current working set of source files</param> /// <param name="ReasonNotLoaded">If the makefile is not valid, is set to a message describing why</param> /// <returns>True if the makefile is valid, false otherwise</returns> public static bool IsValidForSourceFiles(TargetMakefile Makefile, FileReference ProjectFile, UnrealTargetPlatform Platform, ISourceFileWorkingSet WorkingSet, out string ReasonNotLoaded) { using (Timeline.ScopeEvent("TargetMakefile.IsValidForSourceFiles()")) { // Get the list of excluded folder names for this platform ReadOnlyHashSet <string> ExcludedFolderNames = UEBuildPlatform.GetBuildPlatform(Platform).GetExcludedFolderNames(); // Check if any source files have been added or removed foreach (KeyValuePair <DirectoryItem, FileItem[]> Pair in Makefile.DirectoryToSourceFiles) { DirectoryItem InputDirectory = Pair.Key; if (!InputDirectory.Exists || InputDirectory.LastWriteTimeUtc > Makefile.CreateTimeUtc) { FileItem[] SourceFiles = UEBuildModuleCPP.GetSourceFiles(InputDirectory); if (SourceFiles.Length < Pair.Value.Length) { ReasonNotLoaded = "source file removed"; return(false); } else if (SourceFiles.Length > Pair.Value.Length) { ReasonNotLoaded = "source file added"; return(false); } else if (SourceFiles.Intersect(Pair.Value).Count() != SourceFiles.Length) { ReasonNotLoaded = "source file modified"; return(false); } foreach (DirectoryItem Directory in InputDirectory.EnumerateDirectories()) { if (!Makefile.DirectoryToSourceFiles.ContainsKey(Directory) && ContainsSourceFiles(Directory, ExcludedFolderNames)) { ReasonNotLoaded = "directory added"; return(false); } } } } // Check if any external dependencies have changed. These comparisons are done against the makefile creation time. foreach (FileItem ExternalDependency in Makefile.ExternalDependencies) { if (!ExternalDependency.Exists) { Log.TraceLog("{0} has been deleted since makefile was built.", ExternalDependency.Location); ReasonNotLoaded = string.Format("{0} deleted", ExternalDependency.Location.GetFileName()); return(false); } if (ExternalDependency.LastWriteTimeUtc > Makefile.CreateTimeUtc) { Log.TraceLog("{0} has been modified since makefile was built.", ExternalDependency.Location); ReasonNotLoaded = string.Format("{0} modified", ExternalDependency.Location.GetFileName()); return(false); } } // Check if any internal dependencies has changed. These comparisons are done against the makefile modified time. foreach (FileItem InternalDependency in Makefile.InternalDependencies) { if (!InternalDependency.Exists) { Log.TraceLog("{0} has been deleted since makefile was written.", InternalDependency.Location); ReasonNotLoaded = string.Format("{0} deleted", InternalDependency.Location.GetFileName()); return(false); } if (InternalDependency.LastWriteTimeUtc > Makefile.ModifiedTimeUtc) { Log.TraceLog("{0} has been modified since makefile was written.", InternalDependency.Location); ReasonNotLoaded = string.Format("{0} modified", InternalDependency.Location.GetFileName()); return(false); } } // Check that no new plugins have been added foreach (FileReference PluginFile in Plugins.EnumeratePlugins(ProjectFile)) { FileItem PluginFileItem = FileItem.GetItemByFileReference(PluginFile); if (!Makefile.PluginFiles.Contains(PluginFileItem)) { Log.TraceLog("{0} has been added", PluginFile.GetFileName()); ReasonNotLoaded = string.Format("{0} has been added", PluginFile.GetFileName()); return(false); } } // Load the metadata cache SourceFileMetadataCache MetadataCache = SourceFileMetadataCache.CreateHierarchy(ProjectFile); // Find the set of files that contain reflection markup ConcurrentBag <FileItem> NewFilesWithMarkupBag = new ConcurrentBag <FileItem>(); using (ThreadPoolWorkQueue Queue = new ThreadPoolWorkQueue()) { foreach (DirectoryItem SourceDirectory in Makefile.SourceDirectories) { Queue.Enqueue(() => FindFilesWithMarkup(SourceDirectory, MetadataCache, ExcludedFolderNames, NewFilesWithMarkupBag, Queue)); } } // Check whether the list has changed List <FileItem> PrevFilesWithMarkup = Makefile.UObjectModuleHeaders.Where(x => !x.bUsePrecompiled).SelectMany(x => x.HeaderFiles).ToList(); List <FileItem> NextFilesWithMarkup = NewFilesWithMarkupBag.ToList(); if (NextFilesWithMarkup.Count != PrevFilesWithMarkup.Count || NextFilesWithMarkup.Intersect(PrevFilesWithMarkup).Count() != PrevFilesWithMarkup.Count) { ReasonNotLoaded = "UHT files changed"; return(false); } // If adaptive unity build is enabled, do a check to see if there are any source files that became part of the // working set since the Makefile was created (or, source files were removed from the working set.) If anything // changed, then we'll force a new Makefile to be created so that we have fresh unity build blobs. We always // want to make sure that source files in the working set are excluded from those unity blobs (for fastest possible // iteration times.) // Check if any source files in the working set no longer belong in it foreach (FileItem SourceFile in Makefile.WorkingSet) { if (!WorkingSet.Contains(SourceFile) && SourceFile.LastWriteTimeUtc > Makefile.CreateTimeUtc) { Log.TraceLog("{0} was part of source working set and now is not; invalidating makefile", SourceFile.AbsolutePath); ReasonNotLoaded = string.Format("working set of source files changed"); return(false); } } // Check if any source files that are eligible for being in the working set have been modified foreach (FileItem SourceFile in Makefile.CandidatesForWorkingSet) { if (WorkingSet.Contains(SourceFile) && SourceFile.LastWriteTimeUtc > Makefile.CreateTimeUtc) { Log.TraceLog("{0} was part of source working set and now is not", SourceFile.AbsolutePath); ReasonNotLoaded = string.Format("working set of source files changed"); return(false); } } } ReasonNotLoaded = null; return(true); }
/// <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); } } }
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")); }
public StringMap() { _umEntrySet = new ReadOnlyHashSet(_entrySet); }
/// <summary> /// /// </summary> /// <param name="ignoreCase">if true, key is case insensitive</param> public StringMap(bool ignoreCase) : base() { _ignoreCase = ignoreCase; _umEntrySet = new ReadOnlyHashSet(_entrySet); }
public void InvalidConstructorArgument() { var obj = new ReadOnlyHashSet <int>(null); }
public void InvalidConstructorArgument() { var obj = new ReadOnlyHashSet<int>(null); }