void OnITextExpressionFound(Activity activity, ExpressionCompilerActivityVisitor visitor)
        {
            CompiledDataContextDescriptor contextDescriptor = null;
            CompiledDataContextDescriptor currentContextDescriptor = this.compiledDataContexts.Peek();

            if (this.InVariableScopeArgument)
            {
                //
                // Temporarily popping the stack so don't use PopDataContextDescriptor
                // because that is for when the descriptor is done being built
                this.compiledDataContexts.Pop();
                contextDescriptor = PushDataContextDescriptor();
            }
            else
            {
                contextDescriptor = currentContextDescriptor;
            }
            

            if (TryGenerateExpressionCode(activity, contextDescriptor, visitor.NextExpressionId, this.settings.Language))
            {
                expressionIdToLocationReferences.Add(visitor.NextExpressionId, this.FindLocationReferences(activity));
                visitor.NextExpressionId++;
                this.generateSource = true;
            }

            if (this.InVariableScopeArgument)
            {
                PopDataContextDescriptor();
                this.compiledDataContexts.Push(currentContextDescriptor);
            }
        }
        void Parse()
        {                    
            if (!this.settings.Activity.IsMetadataCached)
            {
                IList<ValidationError> validationErrors = null;
                try
                {
                    ActivityUtilities.CacheRootMetadata(this.settings.Activity, new ActivityLocationReferenceEnvironment(), ProcessActivityTreeOptions.FullCachingOptions, null, ref validationErrors);
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }

                    throw FxTrace.Exception.AsError(new InvalidOperationException(SR.CompiledExpressionsCacheMetadataException(this.settings.Activity.GetType().AssemblyQualifiedName, e.ToString())));
                }
            }

            // Get the source location for an activity             
            if (this.TryGetSymbols(this.settings.Activity, out this.symbols, out this.fileName))
            {
                // Get line number info for namespaces
                TextExpressionCompilerHelper.GetNamespacesLineInfo(this.fileName, this.lineNumbersForNSes, this.lineNumbersForNSesForImpl);
            }
           
            this.compileUnit = new CodeCompileUnit();
            this.codeNamespace = GenerateCodeNamespace();
            this.classDeclaration = GenerateClass();

            this.codeNamespace.Types.Add(classDeclaration);
            this.compileUnit.Namespaces.Add(this.codeNamespace);

            //
            // Generate data contexts with properties and expression methods
            // Use the shared, public tree walk for expressions routine for consistency.       
            ExpressionCompilerActivityVisitor visitor = new ExpressionCompilerActivityVisitor(this)
            {
                NextExpressionId = 0,
            };

            try
            {
                visitor.Visit(this.settings.Activity, this.settings.ForImplementation);
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
                //
                // Note that unlike the above where the exception from CacheMetadata is always going to be from the user's code 
                // an exception here is more likely to be from our code and unexpected.  However it could be from user code in some cases.
                // Output a message that attempts to normalize this and presents enough info to the user to determine if they can take action.                
                throw FxTrace.Exception.AsError(new InvalidOperationException(SR.CompiledExpressionsActivityException(e.GetType().FullName, this.settings.Activity.GetType().AssemblyQualifiedName, e.ToString())));
            }

            if (this.generateSource)
            {
                GenerateInvokeExpressionMethod(true);
                GenerateInvokeExpressionMethod(false);

                GenerateCanExecuteMethod();

                GenerateGetRequiredLocationsMethod();

                GenerateGetExpressionTreeForExpressionMethod();
            }

        }