public FileInfo([NotNull] ProjectFile projectFile, [NotNull, ItemNotNull] IEnumerable <CodeReferenceConfigurationItem> configurations, [NotNull][ItemNotNull] ICollection <string> keys, ref long visited)
            {
                Contract.Requires(projectFile != null);
                Contract.Requires(configurations != null);
                Contract.Requires(keys != null);

                _projectFile = projectFile;

                _configurations = configurations
                                  .Where(item => item.ParseExtensions().Contains(projectFile.Extension, StringComparer.OrdinalIgnoreCase))
                                  .ToArray();

                if (_configurations.Any())
                {
                    _lines = _projectFile.ReadAllLines();

                    _lines.ForEach((line, index) =>
                                   // ReSharper disable once AssignNullToNotNullAttribute
                                   _regex.Split(line)
                                   .Where(keys.Contains)
                                   // ReSharper disable once PossibleNullReferenceException
                                   .ForEach(key => _keyLinesLookup.ForceValue(key, _ => new HashSet <int>()).Add(index)));
                }

                Interlocked.Increment(ref visited);
            }
Example #2
0
            public FileInfo(ProjectFile projectFile, IEnumerable <CodeReferenceConfigurationItem> configurations, ICollection <string> keys, ref long visited)
            {
                Contract.Requires(projectFile != null);
                Contract.Requires(configurations != null);
                Contract.Requires(keys != null);

                _projectFile = projectFile;

                _configurations = configurations
                                  .Where(item => item.ParseExtensions().Contains(projectFile.Extension, StringComparer.OrdinalIgnoreCase))
                                  .ToArray();

                if (_configurations.Any())
                {
                    _lines = _projectFile.ReadAllLines();

                    _lines?.ForEach((line, index) =>
                                    _regex.Split(line)
                                    .Where(keys.Contains)
                                    .ForEach(key => _keyLinesLookup.ForceValue(key, _ => new HashSet <int>()).Add(index)));
                }

                Interlocked.Increment(ref visited);
            }