コード例 #1
0
        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);
        }
コード例 #2
0
            public DisposeDataFlowOperationVisitor(
                INamedTypeSymbol iDisposable,
                INamedTypeSymbol taskType,
                ImmutableHashSet <INamedTypeSymbol> collectionTypes,
                ImmutableHashSet <INamedTypeSymbol> disposeOwnershipTransferLikelyTypes,
                DisposeAbstractValueDomain valueDomain,
                ISymbol owningSymbol,
                bool trackInstanceFields,
                DataFlowAnalysisResult <PointsToBlockAnalysisResult, PointsToAbstractValue> pointsToAnalysisResult,
                DataFlowAnalysisResult <NullBlockAnalysisResult, NullAbstractValue> nullAnalysisResultOpt)
                : base(valueDomain, owningSymbol, pessimisticAnalysis, nullAnalysisResultOpt: nullAnalysisResultOpt, pointsToAnalysisResultOpt: pointsToAnalysisResult)
            {
                Debug.Assert(iDisposable != null);
                Debug.Assert(collectionTypes.All(ct => ct.TypeKind == TypeKind.Interface));
                Debug.Assert(disposeOwnershipTransferLikelyTypes != null);
                Debug.Assert(pointsToAnalysisResult != null);

                _iDisposable     = iDisposable;
                _taskType        = taskType;
                _collectionTypes = collectionTypes;
                _disposeOwnershipTransferLikelyTypes = disposeOwnershipTransferLikelyTypes;
                if (trackInstanceFields)
                {
                    _trackedInstanceFieldLocationsOpt = new Dictionary <IFieldSymbol, PointsToAbstractValue>();
                }
            }
コード例 #3
0
ファイル: SerializableOptionSet.cs プロジェクト: belav/roslyn
        private SerializableOptionSet(
            ImmutableHashSet <string> languages,
            WorkspaceOptionSet workspaceOptionSet,
            ImmutableHashSet <IOption> serializableOptions,
            ImmutableDictionary <OptionKey, object?> values,
            ImmutableHashSet <OptionKey> changedOptionKeysSerializable,
            ImmutableHashSet <OptionKey> changedOptionKeysNonSerializable
            )
        {
            Debug.Assert(languages.All(RemoteSupportedLanguages.IsSupported));

            _languages                        = languages;
            _workspaceOptionSet               = workspaceOptionSet;
            _serializableOptions              = serializableOptions;
            _serializableOptionValues         = values;
            _changedOptionKeysSerializable    = changedOptionKeysSerializable;
            _changedOptionKeysNonSerializable = changedOptionKeysNonSerializable;

            Debug.Assert(values.Keys.All(ShouldSerialize));
            Debug.Assert(
                changedOptionKeysSerializable.All(optionKey => ShouldSerialize(optionKey))
                );
            Debug.Assert(
                changedOptionKeysNonSerializable.All(optionKey => !ShouldSerialize(optionKey))
                );
        }
コード例 #4
0
 private bool RespectsAllConstraints(ImmutableHashSet <Substitution> substitutions)
 {
     return(substitutions.All(sub => sub.typeParameter
                              .GetAllConstraints()
                              .All(constraint => IsAssignableTo(sub.typeArgument,
                                                                substitutions.First(s => s.typeParameter.Equals(constraint)).typeArgument))));
 }
コード例 #5
0
        private PointsToAbstractValue(ImmutableHashSet <AbstractLocation> locations, NullAbstractValue nullState)
        {
            Debug.Assert(!locations.IsEmpty);
            Debug.Assert(locations.All(location => !location.IsNull) || nullState != NullAbstractValue.NotNull);
            Debug.Assert(nullState != NullAbstractValue.Undefined);
            Debug.Assert(nullState != NullAbstractValue.Invalid);

            Locations = locations;
            Kind      = PointsToAbstractValueKind.Known;
            NullState = nullState;
        }
コード例 #6
0
        private PointsToAbstractValue(ImmutableHashSet <AbstractLocation> locations, NullAbstractValue nullState)
        {
            Debug.Assert(!locations.IsEmpty);
            Debug.Assert(locations.All(location => !location.IsNull) || nullState != NullAbstractValue.NotNull);
            Debug.Assert(nullState != NullAbstractValue.Undefined);
            Debug.Assert(nullState != NullAbstractValue.Invalid);
            Debug.Assert(!locations.Any(l => l.IsAnalysisEntityDefaultLocation && l.AnalysisEntity !.HasUnknownInstanceLocation));
            Debug.Assert(locations.Count <= LocationThreshold);

            Locations = locations;
            LValueCapturedOperations = ImmutableHashSet <IOperation> .Empty;
            Kind      = PointsToAbstractValueKind.KnownLocations;
            NullState = nullState;
        }
コード例 #7
0
        internal CopyAbstractValue(ImmutableHashSet <AnalysisEntity> analysisEntities, CopyAbstractValueKind kind)
        {
            Debug.Assert(analysisEntities.IsEmpty != kind.IsKnown());
            Debug.Assert(kind != CopyAbstractValueKind.KnownReferenceCopy || analysisEntities.All(a => !a.Type.IsValueType));

            if (kind == CopyAbstractValueKind.KnownValueCopy &&
                analysisEntities.Count == 1 &&
                !analysisEntities.First().Type.IsValueType)
            {
                kind = CopyAbstractValueKind.KnownReferenceCopy;
            }

            AnalysisEntities = analysisEntities;
            Kind             = kind;
        }
コード例 #8
0
        private SerializableOptionSet(
            WorkspaceOptionSet workspaceOptionSet,
            ImmutableDictionary <OptionKey, object?> values,
            ImmutableHashSet <OptionKey> changedOptionKeysSerializable,
            ImmutableHashSet <OptionKey> changedOptionKeysNonSerializable)
        {
            _workspaceOptionSet               = workspaceOptionSet;
            _serializableOptionValues         = values;
            _changedOptionKeysSerializable    = changedOptionKeysSerializable;
            _changedOptionKeysNonSerializable = changedOptionKeysNonSerializable;

            Debug.Assert(values.Keys.All(ShouldSerialize));
            Debug.Assert(changedOptionKeysSerializable.All(optionKey => ShouldSerialize(optionKey)));
            Debug.Assert(changedOptionKeysNonSerializable.All(optionKey => !ShouldSerialize(optionKey)));

            _languages = new Lazy <ImmutableHashSet <string> >(() => this.GetLanguagesAndValuesToSerialize(includeValues: false).languages);
        }
コード例 #9
0
        public GlobalFlowStateAnalysisValueSet(
            ImmutableHashSet <IAbstractAnalysisValue> analysisValues,
            ImmutableHashSet <GlobalFlowStateAnalysisValueSet> parents,
            int height,
            GlobalFlowStateAnalysisValueSetKind kind)
        {
            Debug.Assert((!analysisValues.IsEmpty || !parents.IsEmpty) == (kind == GlobalFlowStateAnalysisValueSetKind.Known));
            Debug.Assert(analysisValues.All(value => value != default));
            Debug.Assert(parents.All(parent => parent != null));
            Debug.Assert(height >= 0);
            Debug.Assert(height == 0 || kind == GlobalFlowStateAnalysisValueSetKind.Known);
            Debug.Assert(height == 0 == parents.IsEmpty);

            AnalysisValues = analysisValues;
            Parents        = parents;
            Height         = height;
            Kind           = kind;
        }
コード例 #10
0
        public FlightEnabledAbstractValue(
            ImmutableHashSet <string> enabledFlights,
            ImmutableHashSet <FlightEnabledAbstractValue> parents,
            int height,
            FlightEnabledAbstractValueKind kind)
        {
            Debug.Assert((!enabledFlights.IsEmpty || !parents.IsEmpty) == (kind == FlightEnabledAbstractValueKind.Known));
            Debug.Assert(enabledFlights.All(enabledFlightSet => !string.IsNullOrEmpty(enabledFlightSet)));
            Debug.Assert(parents.All(parent => parent != null));
            Debug.Assert(height >= 0);
            Debug.Assert(height == 0 || kind == FlightEnabledAbstractValueKind.Known);
            Debug.Assert(height == 0 == parents.IsEmpty);

            EnabledFlights = enabledFlights;
            Parents        = parents;
            Height         = height;
            Kind           = kind;
        }
コード例 #11
0
        /// <summary>
        /// <inheritdoc cref="IOrderService.NewAsync(InOrder)"/>
        /// <para>InvalidEntityException is thrown if:</para>
        /// <list type="bullet">
        /// <item>Provided OrderItems are not unique by referenced ProductId</item>
        /// <item>Provided OrderItems have inexistent ProductIds</item>
        /// <item>There is an Order by the same company in the same day</item>
        /// <item>The Product total is under 100.0</item>
        /// <item>Some Product has a stock amount that is inferior to the ordered quantity</item>
        /// </list>
        /// </summary>
        /// <param name="product">POCO representing the Order to save</param>
        /// <returns>POCO representing the output Order</returns>
        public async Task <Order> NewAsync(InOrder order)
        {
            ImmutableHashSet <int> productIds = order.Items.Select(item => item.ProductId).ToImmutableHashSet();

            if (productIds.Count != order.Items.Count())
            {
                throw new InvalidEntityException("There is some duplicated product entry in current order, please merge for unique productId entries");
            }

            DbOrder newOrder = await unit.ExecuteAsync(async (prodRepo, orderRepo) =>
            {
                IDictionary <int, DbProduct> products = await prodRepo.GetByIdIn(productIds);

                DbOrder toInsert = OrderFrom(order, products);

                if (!productIds.All(products.ContainsKey))
                {
                    throw new InvalidEntityException("Cannot accept an order with invalid product ids");
                }
                if (await orderRepo.HasCompanyOrdersForToday(toInsert))
                {
                    throw new InvalidEntityException($"Today company {order.CompanyCode} has already ordered something");
                }
                if (order.Items.Sum(item => products[item.ProductId].UnitPrice *item.OrderedQuantity) < 100.0)
                {
                    throw new InvalidEntityException("Cannot accept orders for less than 100.0");
                }
                if (order.Items.Any(item => products[item.ProductId].StockQuantity < item.OrderedQuantity))
                {
                    throw new InvalidEntityException("Cannot accept order as there is some shortage in the ordered products");
                }

                DbOrder saved = await orderRepo.NewOrder(toInsert);

                await Task.WhenAll(order.Items.Select(item => prodRepo.DecrementStockBy(products[item.ProductId], item.OrderedQuantity)).ToArray());

                return(saved);
            });

            return(mapper.Map <Order>(newOrder));
        }
コード例 #12
0
ファイル: Replicator.cs プロジェクト: ziez/akka.net
 private void PerformRemovedNodePruning()
 {
     foreach (var entry in _dataEntries)
     {
         var key      = entry.Key;
         var envelope = entry.Value.Item1;
         if (entry.Value.Item1.Data is IRemovedNodePruning)
         {
             foreach (var pruning in entry.Value.Item1.Pruning)
             {
                 var removed = pruning.Key;
                 var owner   = pruning.Value.Owner;
                 var phase   = pruning.Value.Phase as PruningInitialized;
                 if (phase != null && owner == _selfUniqueAddress && (_nodes.Count == 0 || _nodes.All(x => phase.Seen.Contains(x))))
                 {
                     var newEnvelope = envelope.Prune(removed);
                     _pruningPerformed = _pruningPerformed.SetItem(removed, _allReachableClockTime);
                     _log.Debug("Perform pruning of {0} from {1} to {2}", key, removed, _selfUniqueAddress);
                     SetData(key, newEnvelope);
                 }
             }
         }
     }
 }
コード例 #13
0
 private bool IsSafeSet(ImmutableHashSet <object> set)
 {
     return(set.All(x => ZenBoolType.IsAssignableFrom(x.GetType())));
 }
コード例 #14
0
 public bool IsIncluded(Key key)
 {
     return(_keys.All(x => x.IsIncluded(key)));
 }