コード例 #1
0
        public override bool Execute()
        {
            var success = true;

#if DEBUG
            if (AttachDebugger)
            {
                System.Diagnostics.Debugger.Launch();
            }
            ;
#endif
            var logger = new Translator.Logging.Logger(null, false, LoggerLevel.Info, true, new VSLoggerWriter(this.Log), new FileLoggerWriter());

            logger.Trace("Executing Bridge.Build.Task...");

            var bridgeOptions = this.GetBridgeOptions();

            var processor = new TranslatorProcessor(bridgeOptions, logger);

            try
            {
                processor.PreProcess();

                processor.Process();

                processor.PostProcess();
            }
            catch (EmitterException ex)
            {
                var errMsg = $"{ex.Message} {ex.StackTrace}";

                logger.Error(errMsg, ex.FileName, ex.StartLine + 1, ex.StartColumn + 1, ex.EndLine + 1, ex.EndColumn + 1);

                success = false;
            }
            catch (Exception ex)
            {
                var errMsg = $"{ex.Message} {ex.StackTrace}";

                var ee = processor.Translator != null?processor.Translator.CreateExceptionFromLastNode() : null;

                if (ee != null)
                {
                    logger.Error(errMsg, ee.FileName, ee.StartLine + 1, ee.StartColumn + 1, ee.EndLine + 1, ee.EndColumn + 1);
                }
                else
                {
                    logger.Error(errMsg);
                }

                success = false;
            }

            processor = null;

            return(success);
        }
コード例 #2
0
        public override bool Execute()
        {
            var success = true;

#if DEBUG
            if (AttachDebugger)
            {
                System.Diagnostics.Debugger.Launch();
            }
            ;
#endif
            var logger = new Translator.Logging.Logger(null, false, LoggerLevel.Info, true, new VSLoggerWriter(this.Log), new FileLoggerWriter());

            logger.Info("Executing Bridge.Build.Task...");

            var bridgeOptions = this.GetBridgeOptions();

            var processor = new TranslatorProcessor(bridgeOptions, logger);

            var result = processor.PreProcess();

            if (result != null)
            {
                processor = null;
                return(false);
            }

            try
            {
                processor.Process();

                processor.PostProcess();
            }
            catch (EmitterException e)
            {
                if (logger != null)
                {
                    logger.Error(e.ToString());
                }
                else
                {
                    this.Log.LogError(null, null, null, e.FileName, e.StartLine + 1, e.StartColumn + 1, e.EndLine + 1, e.EndColumn + 1, "Error: {0} {1}", e.Message, e.StackTrace);
                }

                success = false;
            }
            catch (Exception e)
            {
                var ee = processor.Translator != null?processor.Translator.CreateExceptionFromLastNode() : null;

                if (ee != null)
                {
                    if (logger != null)
                    {
                        logger.Error(e.ToString());
                    }

                    this.Log.LogError(null, null, null, ee.FileName, ee.StartLine + 1, ee.StartColumn + 1, ee.EndLine + 1, ee.EndColumn + 1, "Error: {0} {1}", e.Message, e.StackTrace);
                }
                else
                {
                    if (logger != null)
                    {
                        logger.Error(e.ToString());
                    }
                    else
                    {
                        this.Log.LogError("Bridge.NET Compiler error: {0} {1}", e.Message, e.StackTrace);
                    }
                }

                success = false;
            }

            processor = null;

            return(success);
        }