Example #1
0
        private static bool EvaluateCondition(
            string condition,
            ProjectElement element,
            ExpanderOptions expanderOptions,
            ParserOptions parserOptions,
            Expander <P, I> expander,
            LazyItemEvaluator <P, I, M, D> lazyEvaluator
            )
        {
            if (condition?.Length == 0)
            {
                return(true);
            }
            MSBuildEventSource.Log.EvaluateConditionStart(condition);

            using (lazyEvaluator._evaluationProfiler.TrackCondition(element.ConditionLocation, condition))
            {
                bool result = ConditionEvaluator.EvaluateCondition
                              (
                    condition,
                    parserOptions,
                    expander,
                    expanderOptions,
                    GetCurrentDirectoryForConditionEvaluation(element, lazyEvaluator),
                    element.ConditionLocation,
                    lazyEvaluator._loggingContext.LoggingService,
                    lazyEvaluator._loggingContext.BuildEventContext,
                    lazyEvaluator.FileSystem
                              );
                MSBuildEventSource.Log.EvaluateConditionStop(condition, result);

                return(result);
            }
        }
Example #2
0
            public IncludeOperation(IncludeOperationBuilder builder, LazyItemEvaluator <P, I, M, D> lazyEvaluator)
                : base(builder, lazyEvaluator)
            {
                _elementOrder  = builder.ElementOrder;
                _rootDirectory = builder.RootDirectory;

                _excludes = builder.Excludes.ToImmutable();
                _metadata = builder.Metadata.ToImmutable();
            }
Example #3
0
 private static bool EvaluateCondition(
     ProjectElement element,
     ExpanderOptions expanderOptions,
     ParserOptions parserOptions,
     Expander <P, I> expander,
     LazyItemEvaluator <P, I, M, D> lazyEvaluator
     )
 {
     return(EvaluateCondition(element.Condition, element, expanderOptions, parserOptions, expander, lazyEvaluator));
 }
Example #4
0
            public LazyItemOperation(OperationBuilder builder, LazyItemEvaluator <P, I, M, D> lazyEvaluator)
            {
                _itemElement         = builder.ItemElement;
                _itemType            = builder.ItemType;
                _operations          = builder.Operations.ToImmutable();
                _referencedItemLists = builder.ReferencedItemLists.ToImmutable();

                _lazyEvaluator = lazyEvaluator;
                _evaluatorData = new EvaluatorData(_lazyEvaluator._outerEvaluatorData, itemType => GetReferencedItems(itemType, ImmutableHashSet <string> .Empty));
                _expander      = new Expander <P, I>(_evaluatorData, _evaluatorData);

                _itemFactory = new ItemFactoryWrapper(_itemElement, _lazyEvaluator._itemFactory);
            }
            public RemoveOperation(RemoveOperationBuilder builder, LazyItemEvaluator <P, I, M, D> lazyEvaluator)
                : base(builder, lazyEvaluator)
            {
                _matchOnMetadata = builder.MatchOnMetadata.ToImmutable();

                ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile(
                    _matchOnMetadata.IsEmpty || _itemSpec.Fragments.All(f => f is ItemSpec <P, I> .ItemExpressionFragment),
                    new BuildEventFileInfo(string.Empty),
                    "OM_MatchOnMetadataIsRestrictedToReferencedItems");

                if (!_matchOnMetadata.IsEmpty)
                {
                    _metadataSet = new MetadataTrie <P, I>(builder.MatchOnMetadataOptions, _matchOnMetadata, _itemSpec);
                }
            }
Example #6
0
            protected LazyItemOperation(OperationBuilder builder, LazyItemEvaluator <P, I, M, D> lazyEvaluator)
            {
                _itemElement         = builder.ItemElement;
                _itemType            = builder.ItemType;
                _itemSpec            = builder.ItemSpec;
                _referencedItemLists = builder.ReferencedItemLists.ToImmutable();
                _conditionResult     = builder.ConditionResult;

                _lazyEvaluator = lazyEvaluator;

                _evaluatorData = new EvaluatorData(_lazyEvaluator._outerEvaluatorData, itemType => GetReferencedItems(itemType, ImmutableHashSet <string> .Empty));
                _itemFactory   = new ItemFactoryWrapper(_itemElement, _lazyEvaluator._itemFactory);
                _expander      = new Expander <P, I>(_evaluatorData, _evaluatorData, _lazyEvaluator.EvaluationContext);

                _itemSpec.Expander = _expander;
            }
 public UpdateOperation(OperationBuilderWithMetadata builder, LazyItemEvaluator <P, I, M, D> lazyEvaluator)
     : base(builder, lazyEvaluator)
 {
     _metadata = builder.Metadata.ToImmutable();
 }
Example #8
0
 /// <summary>
 /// COMPAT: Whidbey used the "current project file/targets" directory for evaluating Import and PropertyGroup conditions
 /// Orcas broke this by using the current root project file for all conditions
 /// For Dev10+, we'll fix this, and use the current project file/targets directory for Import, ImportGroup and PropertyGroup
 /// but the root project file for the rest. Inside of targets will use the root project file as always.
 /// </summary>
 private static string GetCurrentDirectoryForConditionEvaluation(ProjectElement element, LazyItemEvaluator <P, I, M, D> lazyEvaluator)
 {
     if (element is ProjectPropertyGroupElement || element is ProjectImportElement || element is ProjectImportGroupElement)
     {
         return(element.ContainingProject.DirectoryPath);
     }
     else
     {
         return(lazyEvaluator._outerEvaluatorData.Directory);
     }
 }
Example #9
0
 public RemoveOperation(RemoveOperationBuilder builder, LazyItemEvaluator <P, I, M, D> lazyEvaluator)
     : base(builder, lazyEvaluator)
 {
     _matchOnMetadata        = builder.MatchOnMetadata.ToImmutable();
     _matchOnMetadataOptions = builder.MatchOnMetadataOptions;
 }
 public RemoveOperation(OperationBuilder builder, LazyItemEvaluator <P, I, M, D> lazyEvaluator)
     : base(builder, lazyEvaluator)
 {
 }
Example #11
0
        static bool EvaluateCondition(ProjectElement element, ExpanderOptions expanderOptions, ParserOptions parserOptions, Expander <P, I> expander, LazyItemEvaluator <P, I, M, D> lazyEvaluator)
        {
            if (element.Condition.Length == 0)
            {
                return(true);
            }

            bool result = ConditionEvaluator.EvaluateCondition
                          (
                element.Condition,
                parserOptions,
                expander,
                expanderOptions,
                GetCurrentDirectoryForConditionEvaluation(element, lazyEvaluator),
                element.ConditionLocation,
                lazyEvaluator._loggingService,
                lazyEvaluator._buildEventContext
                          );

            return(result);
        }