Example #1
0
 public BidirectionalMap(IEnumerable <KeyValuePair <TKey, TValue> > pairs)
 {
     _forwardMap  = ImmutableDictionary.CreateRange <TKey, TValue>(pairs);
     _backwardMap = ImmutableDictionary.CreateRange <TValue, TKey>(
         pairs.Select(p => KeyValuePairUtil.Create(p.Value, p.Key))
         );
 }
        public void GetEffectiveDiagnostics()
        {
            var c = CSharpCompilation.Create("c", options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary).
                                             WithSpecificDiagnosticOptions(
                                                 new[] { KeyValuePairUtil.Create($"CS{(int)ErrorCode.WRN_AlwaysNull:D4}", ReportDiagnostic.Suppress) }));

            var d1 = SimpleDiagnostic.Create(MessageProvider.Instance, (int)ErrorCode.WRN_AlignmentMagnitude);
            var d2 = SimpleDiagnostic.Create(MessageProvider.Instance, (int)ErrorCode.WRN_AlwaysNull);
            var ds = new[] { null, d1, d2 };

            var filtered = CompilationWithAnalyzers.GetEffectiveDiagnostics(ds, c);

            // overwrite the original value to test eagerness:
            ds[1] = null;

            AssertEx.Equal(new[] { d1 }, filtered);
        }