public bool SetEquals(CustomSet <T> other) { if (factory != other.factory) { throw new NotImplementedException(); } return(set.SetEquals(other.set)); }
// Cognitive Complexity 5 public static ContentView GetContentView(string contentId, IReadOnlyCollection <string> requestedUriTypes) { ImmutableHashSet <string> subsetUriTypes = AllSupportedUriTypes.Intersect(requestedUriTypes); if (!subsetUriTypes.Any()) { throw new Exception("message"); } return(new ContentView { ResultStatus = AllSupportedUriTypes.SetEquals(subsetUriTypes) ? ResultStatusComplete : ResultStatusPartial, Uris = subsetUriTypes.Select(uriType => { if (IsViewerA(uriType)) { return $"https://{ViewerA}/{contentId}"; } else if (IsViewerC(uriType)) { return $"https://{ViewerC}/{contentId}"; } else { return $"https://{ViewerD}/{contentId}"; } }) }); }
private Task <ImmutableArray <AnalyzerDependencyConflict> > GetConflictsAsync() { ImmutableHashSet <string> currentAnalyzerPaths = _workspace.CurrentSolution .Projects .SelectMany(p => p.AnalyzerReferences) .OfType <AnalyzerFileReference>() .Select(a => a.FullPath) .ToImmutableHashSet(StringComparer.OrdinalIgnoreCase); if (currentAnalyzerPaths.SetEquals(_analyzerPaths)) { return(_task); } _cancellationTokenSource.Cancel(); _cancellationTokenSource = new CancellationTokenSource(); _analyzerPaths = currentAnalyzerPaths; _task = _task.SafeContinueWith(_ => { return(new AnalyzerDependencyChecker(currentAnalyzerPaths).Run(_cancellationTokenSource.Token)); }, TaskScheduler.Default); return(_task); }
public void TestLoadedIgnoredPackages() { IInsertionApiFactory apiFactory = new InsertionApiFactory(); IInsertionApi api = apiFactory.Create(TimeSpan.FromSeconds(75), TimeSpan.FromSeconds(4)); UpdateResults results; string assetsDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Assets"); string manifestFile = Path.Combine(assetsDirectory, "manifest.json"); string defaultConfigFile = Path.Combine(assetsDirectory, "default.config"); IEnumerable <Regex> whitelistedPackages = Enumerable.Empty <Regex>(); ImmutableHashSet <string> ignoredPackages = InputLoading.LoadPackagesToIgnore(Path.Combine(assetsDirectory, "ignored.txt")); results = api.UpdateVersions( manifestFile, defaultConfigFile, whitelistedPackages, ignoredPackages, null, null, null); Assert.IsTrue(ignoredPackages.SetEquals(results.IgnoredNuGets), $"Mismatched ignore packages"); Assert.IsFalse(results.UpdatedPackages.Any(n => ignoredPackages.Contains(n.PackageId)), "Packages that shouldn't have been updated were updated."); }
public IConstraintManager GetSubSet(ISet <Constraint> subset) { // Don't make a new ConstraintManager if the constraints are the same. if (InternalConstraints.SetEquals(subset)) { return(this); } if (subset.Count >= InternalConstraints.Count) { throw new ArgumentException("Subset has count >= to count of this constraint manager's constraints"); } // Is this the most efficient way to do this? ConstraintManager other = (ConstraintManager)this.MemberwiseClone(); Debug.Assert(subset.IsSubsetOf(InternalConstraints), "argument ``subset`` is not a valid subset"); var asIm = ImmutableHashSet <Constraint> .Empty.Union(subset); other.InternalConstraints = asIm.ToBuilder(); // Fully recompute the hashcode on the new constraint manager other.FullyRecomputeHashCode(); return(other); }
private Task <AnalyzerDependencyResults> GetConflictsAsync() { ImmutableHashSet <string> currentAnalyzerPaths = _workspace.CurrentSolution .Projects .SelectMany(p => p.AnalyzerReferences) .OfType <AnalyzerFileReference>() .Select(a => a.FullPath) .ToImmutableHashSet(StringComparer.OrdinalIgnoreCase); if (currentAnalyzerPaths.SetEquals(_analyzerPaths)) { return(_task); } _cancellationTokenSource.Cancel(); _cancellationTokenSource = new CancellationTokenSource(); _analyzerPaths = currentAnalyzerPaths; _task = _task.SafeContinueWith(_ => { IEnumerable <AssemblyIdentity> loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies().Select(assembly => AssemblyIdentity.FromAssemblyDefinition(assembly)); IgnorableAssemblyIdentityList loadedAssembliesList = new IgnorableAssemblyIdentityList(loadedAssemblies); IIgnorableAssemblyList[] ignorableAssemblyLists = new[] { s_systemPrefixList, s_codeAnalysisPrefixList, s_explicitlyIgnoredAssemblyList, s_assembliesIgnoredByNameList, loadedAssembliesList }; return(new AnalyzerDependencyChecker(currentAnalyzerPaths, ignorableAssemblyLists, _bindingRedirectionService).Run(_cancellationTokenSource.Token)); }, TaskScheduler.Default); return(_task); }
public SerializableOptionSet WithLanguages(ImmutableHashSet <string> languages) { Debug.Assert(languages.All(RemoteSupportedLanguages.IsSupported)); if (_languages.SetEquals(languages)) { return(this); } // First create a base option set for the given languages. var newOptionSet = _workspaceOptionSet.OptionService.GetSerializableOptionsSnapshot(languages); // Then apply all the changed options from the current option set to the new option set. foreach (var changedOption in this.GetChangedOptions()) { var valueInNewOptionSet = newOptionSet.GetOption(changedOption); var changedValueInThisOptionSet = this.GetOption(changedOption); if (!Equals(changedValueInThisOptionSet, valueInNewOptionSet)) { newOptionSet = (SerializableOptionSet)newOptionSet.WithChangedOption(changedOption, changedValueInThisOptionSet); } } return(newOptionSet); }
private static void AddOptionMapping(ConcurrentDictionary <string, ImmutableHashSet <IOption> > map, string diagnosticId, ImmutableHashSet <IOption> options) { // Verify that the option is either being added for the first time, or the existing option is already the same. // Latter can happen in tests as we re-instantiate the analyzer for every test, which attempts to add the mapping every time. Debug.Assert(!map.TryGetValue(diagnosticId, out var existingOptions) || options.SetEquals(existingOptions)); map.TryAdd(diagnosticId, options); }
public void ImmutableSetAdapter_Ctor_Succeeds() { const int NumberOfMethods = 17; int[] methodsCalled = new int[NumberOfMethods]; ImmutableHashSet <int> realSet = ImmutableHashSet <int> .Empty; System.Collections.Immutable.IImmutableSet <int> backingSet = new MockSystemImmutableSet <int>( addDelegate: x => { methodsCalled[0]++; return(realSet.Add(x)); }, clearDelegate: () => { methodsCalled[1]++; return(realSet.Clear()); }, containsDelegate: x => { methodsCalled[2]++; return(realSet.Contains(x)); }, countDelegate: () => { methodsCalled[3]++; return(realSet.Count); }, equalsDelegate: null, exceptDelegate: x => { methodsCalled[4]++; return(realSet.Except(x)); }, getEnumeratorDelegate: () => { methodsCalled[5]++; return(realSet.GetEnumerator()); }, getHashCodeDelegate: null, intersectDelegate: x => { methodsCalled[6]++; return(realSet.Intersect(x)); }, isProperSubsetOfDelegate: x => { methodsCalled[7]++; return(realSet.IsProperSubsetOf(x)); }, isProperSupersetOfDelegate: x => { methodsCalled[8]++; return(realSet.IsProperSupersetOf(x)); }, isSubsetOfDelegate: x => { methodsCalled[9]++; return(realSet.IsSubsetOf(x)); }, isSupersetOfDelegate: x => { methodsCalled[10]++; return(realSet.IsSupersetOf(x)); }, overlapsDelegate: x => { methodsCalled[11]++; return(realSet.Overlaps(x)); }, removeDelegate: x => { methodsCalled[12]++; return(realSet.Remove(x)); }, setEqualsDelegate: x => { methodsCalled[13]++; return(realSet.SetEquals(x)); }, symmetricExceptDelegate: x => { methodsCalled[14]++; return(realSet.SymmetricExcept(x)); }, toStringDelegate: null, tryGetValueDelegate: (int x, out int y) => { methodsCalled[15]++; return(realSet.TryGetValue(x, out y)); }, unionDelegate: x => { methodsCalled[16]++; return(realSet.Union(x)); }); #pragma warning disable IDE0028 // Simplify collection initialization. Intentionally calling .Add separately for clarity ImmutableSetAdapter <int> set = new ImmutableSetAdapter <int>(backingSet); #pragma warning restore IDE0028 // Simplify collection initialization. set.Add(12); set.Clear(); set.Contains(12); _ = set.Count; set.Except(Array.Empty <int>()); set.GetEnumerator(); set.Intersect(Array.Empty <int>()); set.IsProperSubsetOf(Array.Empty <int>()); set.IsProperSupersetOf(Array.Empty <int>()); set.IsSubsetOf(Array.Empty <int>()); set.IsSupersetOf(Array.Empty <int>()); set.Overlaps(Array.Empty <int>()); set.Remove(12); set.SetEquals(Array.Empty <int>()); set.SymmetricExcept(Array.Empty <int>()); set.TryGetValue(12, out _); set.Union(Array.Empty <int>()); for (int counter = 0; counter < NumberOfMethods; counter++) { Assert.AreEqual(1, methodsCalled[counter]); } }
public SerializableOptionSet WithLanguages(ImmutableHashSet <string> languages) { if (_languages.SetEquals(languages)) { return(this); } return(_workspaceOptionSet.OptionService.GetSerializableOptionsSnapshot(languages)); }
public bool Equals(ImmutableHashSet <TValue>?x, ImmutableHashSet <TValue>?y) { if (ReferenceEquals(x, y)) { return(true); } if (x == null || y == null) { return(false); } return(x.SetEquals(y)); }
public bool Equals(ImmutableHashSet <TValue> x, ImmutableHashSet <TValue> y) { if (x == null ^ y == null) { return(false); } if (x == null) { return(true); } return(x.SetEquals(y)); }
public bool Equals(VocabularySet?other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(_nameComparer.Equals(Name, other.Name) && _words.SetEquals(other._words)); }
public bool Equals(FieldSelection other) { if (other is null) { return(false); } if (ReferenceEquals(other, this)) { return(true); } return(other.ResponseName.EqualsOrdinal(ResponseName) && ReferenceEquals(other.Field, Field) && _nodes.SetEquals(other._nodes)); }
public override bool Equals(ImmutableHashSet <ValueTag> first, ImmutableHashSet <ValueTag> second) { return(first.SetEquals(second)); }
private void AssertActors(ImmutableHashSet<IActorRef> expected, ImmutableHashSet<IActorRef> actual) { Assert.True(expected.SetEquals(actual)); }
public static ImmutableHashSet <T> ResetContents <T>(this ImmutableHashSet <T> set, IEnumerable <T> values) { return(set.SetEquals(values) ? set : set.Clear().Union(values)); }
private void AssertActors(ImmutableHashSet <IActorRef> expected, ImmutableHashSet <IActorRef> actual) { Assert.True(expected.SetEquals(actual)); }
public bool SetEquals(IEnumerable <string> other) { return(_set.SetEquals(other)); }
public bool Equals(SymbolNamesOption other) { return(other != null && _names.SetEquals(other._names) && _symbols.SetEquals(other._symbols)); }