Exemplo n.º 1
0
        /// <summary>
        /// Reads or writes the packet to the serializer.
        /// </summary>
        public void Translate(INodePacketTranslator translator)
        {
            if (translator.Mode == TranslationDirection.WriteToStream && _transferredProperties == null)
            {
                // When writing, we will transfer the state of any loaded project instance if we aren't transferring a limited subset.
                _transferredState = _project;
            }

            translator.Translate(ref _translateEntireProjectInstanceState);
            translator.Translate(ref _configId);
            translator.Translate(ref _projectFullPath);
            translator.Translate(ref _transferredState, ProjectInstance.FactoryForDeserialization);
            translator.Translate(ref _transferredProperties, ProjectPropertyInstance.FactoryForDeserialization);
            translator.Translate(ref _resultsNodeId);
            translator.Translate(ref _toolsVersion);
            translator.Translate(ref _explicitToolsVersionSpecified);
            translator.TranslateDictionary <PropertyDictionary <ProjectPropertyInstance>, ProjectPropertyInstance>(ref _globalProperties, ProjectPropertyInstance.FactoryForDeserialization);
            translator.Translate(ref _savedCurrentDirectory);
            translator.TranslateDictionary(ref _savedEnvironmentVariables, StringComparer.OrdinalIgnoreCase);

            // if the entire state is translated, then the transferred state, if exists, represents the full evaluation data
            if (_translateEntireProjectInstanceState &&
                translator.Mode == TranslationDirection.ReadFromStream &&
                _transferredState != null)
            {
                SetProjectBasedState(_transferredState);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Translates the packet to/from binary form.
 /// </summary>
 /// <param name="translator">The translator to use.</param>
 public void Translate(INodePacketTranslator translator)
 {
     translator.TranslateEnum(ref _taskResult, (int)_taskResult);
     translator.TranslateException(ref _taskException);
     translator.Translate(ref _taskExceptionMessage);
     translator.Translate(ref _taskExceptionMessageArgs);
     translator.TranslateDictionary(ref _taskOutputParameters, StringComparer.OrdinalIgnoreCase, TaskParameter.FactoryForDeserialization);
     translator.TranslateDictionary(ref _buildProcessEnvironment, StringComparer.OrdinalIgnoreCase);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Translates the packet to/from binary form.
 /// </summary>
 /// <param name="translator">The translator to use.</param>
 public void Translate(INodePacketTranslator translator)
 {
     translator.Translate(ref _nodeId);
     translator.Translate(ref _startupDirectory);
     translator.TranslateDictionary(ref _buildProcessEnvironment, StringComparer.OrdinalIgnoreCase);
     translator.TranslateCulture(ref _culture);
     translator.TranslateCulture(ref _uiCulture);
     translator.TranslateDotNet(ref _appDomainSetup);
     translator.Translate(ref _lineNumberOfTask);
     translator.Translate(ref _columnNumberOfTask);
     translator.Translate(ref _projectFileOfTask);
     translator.Translate(ref _taskName);
     translator.Translate(ref _taskLocation);
     translator.TranslateDictionary(ref _taskParameters, StringComparer.OrdinalIgnoreCase, TaskParameter.FactoryForDeserialization);
     translator.Translate(ref _continueOnError);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Implementation of the serialization mechanism.
        /// </summary>
        void INodePacketTranslatable.Translate(INodePacketTranslator translator)
        {
            translator.Translate(ref _buildId);
            /* No build thread priority during translation.  We specifically use the default (which is ThreadPriority.Normal) */
            translator.TranslateDictionary(ref _buildProcessEnvironment, StringComparer.OrdinalIgnoreCase);
            translator.TranslateCulture(ref _culture);
            translator.Translate(ref _defaultToolsVersion);
            translator.Translate(ref _disableInProcNode);
            translator.Translate(ref _enableNodeReuse);
            translator.TranslateProjectPropertyInstanceDictionary(ref _environmentProperties);
            /* No forwarding logger information sent here - that goes with the node configuration */
            translator.TranslateProjectPropertyInstanceDictionary(ref _globalProperties);
            /* No host services during translation */
            /* No loggers during translation */
            translator.Translate(ref _maxNodeCount);
            translator.Translate(ref _memoryUseLimit);
            translator.Translate(ref _nodeExeLocation);
            /* No node id during translation */
            translator.Translate(ref _onlyLogCriticalEvents);
            translator.Translate(ref s_startupDirectory);
            translator.TranslateCulture(ref _uiCulture);
            translator.Translate(ref _toolsetProvider, Microsoft.Build.Evaluation.ToolsetProvider.FactoryForDeserialization);
            translator.Translate(ref _useSynchronousLogging);
            translator.Translate(ref _shutdownInProcNodeOnBuildFinish);
            translator.Translate(ref _logTaskInputs);
            translator.Translate(ref _logInitialPropertiesAndItems);

            // ProjectRootElementCache is not transmitted.
            // ResetCaches is not transmitted.
            // LegacyThreadingSemantics is not transmitted.
        }
Exemplo n.º 5
0
        void INodePacketTranslatable.Translate(INodePacketTranslator translator)
        {
            if (translator.Mode == TranslationDirection.WriteToStream)
            {
                var typeName = this.GetType().FullName;
                translator.Translate(ref typeName);
            }

            translator.Translate(ref _name);
            translator.Translate(ref _condition);
            translator.Translate(ref _continueOnError);
            translator.Translate(ref _msbuildRuntime);
            translator.Translate(ref _msbuildArchitecture);
            translator.Translate(ref _outputs, ProjectTaskInstanceChild.FactoryForDeserialization);
            translator.Translate(ref _location, ElementLocation.FactoryForDeserialization);
            translator.Translate(ref _conditionLocation, ElementLocation.FactoryForDeserialization);
            translator.Translate(ref _continueOnErrorLocation, ElementLocation.FactoryForDeserialization);
            translator.Translate(ref _msbuildRuntimeLocation, ElementLocation.FactoryForDeserialization);
            translator.Translate(ref _msbuildArchitectureLocation, ElementLocation.FactoryForDeserialization);

            IDictionary <string, Tuple <string, ElementLocation> > localParameters = _parameters;

            translator.TranslateDictionary(
                ref localParameters,
                ParametersKeyTranslator,
                ParametersValueTranslator,
                count => new CopyOnWriteDictionary <string, Tuple <string, ElementLocation> >(count));

            if (translator.Mode == TranslationDirection.ReadFromStream && localParameters != null)
            {
                _parameters = (CopyOnWriteDictionary <string, Tuple <string, ElementLocation> >)localParameters;
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Reads or writes the packet to the serializer.
 /// </summary>
 void INodePacketTranslatable.Translate(INodePacketTranslator translator)
 {
     translator.Translate(ref _submissionId);
     translator.Translate(ref _configurationId);
     translator.Translate(ref _globalRequestId);
     translator.Translate(ref _parentGlobalRequestId);
     translator.Translate(ref _nodeRequestId);
     translator.Translate(ref _initialTargets);
     translator.Translate(ref _defaultTargets);
     translator.Translate(ref _circularDependency);
     translator.TranslateException(ref _requestException);
     translator.TranslateDictionary <ConcurrentDictionary <string, TargetResult>, TargetResult>(ref _resultsByTarget, TargetResult.FactoryForDeserialization, CreateTargetResultDictionary);
     translator.Translate(ref _baseOverallResult);
     translator.Translate(ref _projectStateAfterBuild, ProjectInstance.FactoryForDeserialization);
     translator.Translate(ref _savedCurrentDirectory);
     translator.TranslateDictionary(ref _savedEnvironmentVariables, StringComparer.OrdinalIgnoreCase);
 }
Exemplo n.º 7
0
        /// <summary>
        /// Read an ITaskItem into the given parameter, using the given read translator
        /// </summary>
        private void ReadITaskItem(INodePacketTranslator translator, ref ITaskItem wrappedItem)
        {
            ErrorUtilities.VerifyThrow(translator.Mode == TranslationDirection.ReadFromStream, "Cannot call this method when writing!");

            if (!TranslateNullable(translator, wrappedItem))
            {
                return;
            }

            string escapedItemSpec        = null;
            string escapedDefiningProject = null;
            Dictionary <string, string> escapedMetadata = null;

            translator.Translate(ref escapedItemSpec);
            translator.Translate(ref escapedDefiningProject);
            translator.TranslateDictionary(ref escapedMetadata, StringComparer.OrdinalIgnoreCase);

            wrappedItem = new TaskParameterTaskItem(escapedItemSpec, escapedDefiningProject, escapedMetadata);
        }
Exemplo n.º 8
0
 /// <summary>
 /// Translates the packet to/from binary form.
 /// </summary>
 /// <param name="translator">The translator to use.</param>
 public void Translate(INodePacketTranslator translator)
 {
     translator.TranslateEnum(ref _taskResult, (int)_taskResult);
     translator.TranslateDotNet(ref _taskException);
     translator.Translate(ref _taskExceptionMessage);
     translator.Translate(ref _taskExceptionMessageArgs);
     translator.TranslateDictionary(ref _taskOutputParameters, StringComparer.OrdinalIgnoreCase, TaskParameter.FactoryForDeserialization);
     translator.TranslateDictionary(ref _buildProcessEnvironment, StringComparer.OrdinalIgnoreCase);
 }
 void INodePacketTranslatable.Translate(INodePacketTranslator translator)
 {
     translator.Translate(ref _propertyFilters);
     translator.TranslateDictionary(ref _itemFilters, TranslateString, TranslateMetadataForItem, CreateItemMetadataDictionary);
 }
Exemplo n.º 10
0
        /// <summary>
        /// Write the given ITaskItem, using the given write translator
        /// </summary>
        private void WriteITaskItem(INodePacketTranslator translator, ITaskItem wrappedItem)
        {
            ErrorUtilities.VerifyThrow(translator.Mode == TranslationDirection.WriteToStream, "Cannot call this method when reading!");

            if (!TranslateNullable(translator, wrappedItem))
            {
                return;
            }

            string      escapedItemSpec;
            string      escapedDefiningProject;
            IDictionary wrappedMetadata;
            bool        wrappedMetadataIsEscaped;

            ITaskItem2 wrappedItemAsITaskItem2 = wrappedItem as ITaskItem2;

            if (wrappedItemAsITaskItem2 != null)
            {
                escapedItemSpec          = wrappedItemAsITaskItem2.EvaluatedIncludeEscaped;
                escapedDefiningProject   = wrappedItemAsITaskItem2.GetMetadataValueEscaped(FileUtilities.ItemSpecModifiers.DefiningProjectFullPath);
                wrappedMetadata          = wrappedItemAsITaskItem2.CloneCustomMetadataEscaped();
                wrappedMetadataIsEscaped = true;
            }
            else
            {
                // We know that the ITaskItem constructor expects an escaped string, and that ITaskItem.ItemSpec
                // is expected to be unescaped, so make sure we give the constructor what it wants.
                escapedItemSpec          = EscapingUtilities.Escape(wrappedItem.ItemSpec);
                escapedDefiningProject   = EscapingUtilities.EscapeWithCaching(wrappedItem.GetMetadata(FileUtilities.ItemSpecModifiers.DefiningProjectFullPath));
                wrappedMetadata          = wrappedItem.CloneCustomMetadata();
                wrappedMetadataIsEscaped = false;
            }

            Dictionary <string, string> escapedGenericWrappedMetadata = wrappedMetadata as Dictionary <string, string>;

            if (escapedGenericWrappedMetadata == null)
            {
                escapedGenericWrappedMetadata = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

                foreach (object key in wrappedMetadata.Keys)
                {
                    string value = (string)wrappedMetadata[key];

                    if (!wrappedMetadataIsEscaped)
                    {
                        value = (value == null) ? value : EscapingUtilities.Escape(value);
                    }

                    escapedGenericWrappedMetadata.Add((string)key, value);
                }
            }
            else if (!wrappedMetadataIsEscaped)
            {
                foreach (KeyValuePair <string, string> entry in escapedGenericWrappedMetadata)
                {
                    escapedGenericWrappedMetadata[entry.Key] = entry.Value == null ? entry.Value : EscapingUtilities.Escape(entry.Value);
                }
            }

            translator.Translate(ref escapedItemSpec);
            translator.Translate(ref escapedDefiningProject);
            translator.TranslateDictionary(ref escapedGenericWrappedMetadata, StringComparer.OrdinalIgnoreCase);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Implementation of the serialization mechanism.
        /// </summary>
        void INodePacketTranslatable.Translate(INodePacketTranslator translator)
        {
            translator.Translate(ref _buildId);
            /* No build thread priority during translation.  We specifically use the default (which is ThreadPriority.Normal) */
            translator.TranslateDictionary(ref _buildProcessEnvironment, StringComparer.OrdinalIgnoreCase);
            translator.TranslateCulture(ref _culture);
            translator.Translate(ref _defaultToolsVersion);
            translator.Translate(ref _disableInProcNode);
            translator.Translate(ref _enableNodeReuse);
            translator.TranslateProjectPropertyInstanceDictionary(ref _environmentProperties);
            /* No forwarding logger information sent here - that goes with the node configuration */
            translator.TranslateProjectPropertyInstanceDictionary(ref _globalProperties);
            /* No host services during translation */
            /* No loggers during translation */
            translator.Translate(ref _maxNodeCount);
            translator.Translate(ref _memoryUseLimit);
            translator.Translate(ref _nodeExeLocation);
            /* No node id during translation */
            translator.Translate(ref _onlyLogCriticalEvents);
            translator.Translate(ref s_startupDirectory);
            translator.TranslateCulture(ref _uiCulture);
            translator.Translate(ref _toolsetProvider, Microsoft.Build.Evaluation.ToolsetProvider.FactoryForDeserialization);
            translator.Translate(ref _useSynchronousLogging);
            translator.Translate(ref _shutdownInProcNodeOnBuildFinish);
            translator.Translate(ref _logTaskInputs);
            translator.Translate(ref _logInitialPropertiesAndItems);

            // ProjectRootElementCache is not transmitted.
            // ResetCaches is not transmitted.
            // LegacyThreadingSemantics is not transmitted.
        }
Exemplo n.º 12
0
 void INodePacketTranslatable.Translate(INodePacketTranslator translator)
 {
     translator.Translate(ref _itemType);
     translator.TranslateDictionary(ref _metadata, ProjectMetadataInstance.FactoryForDeserialization);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Function for serialization.
 /// </summary>
 void INodePacketTranslatable.Translate(INodePacketTranslator translator)
 {
     translator.Translate(ref _toolsVersion);
     translator.Translate(ref _toolsPath);
     translator.TranslateProjectPropertyInstanceDictionary(ref _properties);
     translator.TranslateProjectPropertyInstanceDictionary(ref _environmentProperties);
     translator.TranslateProjectPropertyInstanceDictionary(ref _globalProperties);
     translator.TranslateDictionary(ref _subToolsets, StringComparer.OrdinalIgnoreCase, SubToolset.FactoryForDeserialization);
     translator.Translate(ref _overrideTasksPath);
     translator.Translate(ref _defaultOverrideToolsVersion);
 }
Exemplo n.º 14
0
 /// <summary>
 /// Translates the packet to/from binary form.
 /// </summary>
 /// <param name="translator">The translator to use.</param>
 public void Translate(INodePacketTranslator translator)
 {
     translator.Translate(ref _nodeId);
     translator.Translate(ref _startupDirectory);
     translator.TranslateDictionary(ref _buildProcessEnvironment, StringComparer.OrdinalIgnoreCase);
     translator.TranslateCulture(ref _culture);
     translator.TranslateCulture(ref _uiCulture);
     translator.TranslateDotNet(ref _appDomainSetup);
     translator.Translate(ref _lineNumberOfTask);
     translator.Translate(ref _columnNumberOfTask);
     translator.Translate(ref _projectFileOfTask);
     translator.Translate(ref _taskName);
     translator.Translate(ref _taskLocation);
     translator.TranslateDictionary(ref _taskParameters, StringComparer.OrdinalIgnoreCase, TaskParameter.FactoryForDeserialization);
     translator.Translate(ref _continueOnError);
 }
Exemplo n.º 15
0
 /// <summary>
 /// Translates to and from binary form.
 /// </summary>
 void INodePacketTranslatable.Translate(INodePacketTranslator translator)
 {
     translator.TranslateDictionary(ref _toolsets, StringComparer.OrdinalIgnoreCase, Toolset.FactoryForDeserialization);
 }
Exemplo n.º 16
0
 /// <summary>
 /// Reads or writes the packet to the serializer.
 /// </summary>
 void INodePacketTranslatable.Translate(INodePacketTranslator translator)
 {
     translator.Translate(ref _submissionId);
     translator.Translate(ref _configurationId);
     translator.Translate(ref _globalRequestId);
     translator.Translate(ref _parentGlobalRequestId);
     translator.Translate(ref _nodeRequestId);
     translator.Translate(ref _initialTargets);
     translator.Translate(ref _defaultTargets);
     translator.Translate(ref _circularDependency);
     translator.TranslateDotNet(ref _requestException);
     translator.TranslateDictionary<ConcurrentDictionary<string, TargetResult>, TargetResult>(ref _resultsByTarget, TargetResult.FactoryForDeserialization, CreateTargetResultDictionary);
     translator.Translate(ref _baseOverallResult);
     translator.Translate(ref _projectStateAfterBuild, ProjectInstance.FactoryForDeserialization);
     translator.Translate(ref _savedCurrentDirectory);
     translator.TranslateDictionary(ref _savedEnvironmentVariables, StringComparer.OrdinalIgnoreCase);
 }
Exemplo n.º 17
0
 /// <summary>
 /// Translates to and from binary form.
 /// </summary>
 void INodePacketTranslatable.Translate(INodePacketTranslator translator)
 {
     translator.TranslateDictionary(ref _toolsets, StringComparer.OrdinalIgnoreCase, Toolset.FactoryForDeserialization);
 }