Exemplo n.º 1
0
        private bool ShouldEmitErrorWarning(System.CodeDom.Compiler.CompilerError error)
        {
            Contract.Requires(error != null);

            if (!error.IsWarning || this.failOnWarnings)
            {
                return(true);
            }

            if (warn <= 0)
            {
                return(false);
            }

            var eName = error.ErrorNumber;

            if (eName != null && eName.StartsWith("CC") && eName.Length >= 3)
            {
                int num;
                if (Int32.TryParse(eName.Substring(2), out num))
                {
                    if (nowarn.Contains(num))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
 public override void EmitError(System.CodeDom.Compiler.CompilerError error)
 {
     if (this.isMethodOk)
     {
         base.EmitError(error);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 ///     Raise a warning
 /// </summary>
 public void Warning(string message)
 {
     System.CodeDom.Compiler.CompilerError error = new System.CodeDom.Compiler.CompilerError();
     error.ErrorText = message;
     error.IsWarning = true;
     Errors.Add(error);
 }
Exemplo n.º 4
0
 public override void EmitError(CompilerError error)
 {
     if (this.expectedAssemblyOutcomes == null)
     {
         if (this.delayedErrors == null)
         {
             this.delayedErrors = new List <CompilerError>();
         }
         this.delayedErrors.Add(error);
     }
     else
     {
         if (this.expectedOutcomes != null)
         {
             // we are inside a method
             if (!this.expectedOutcomes.CheckOutcome(this.UnderlyingOutput, this.currentMethod, error, this.mdDecoder))
             {
                 // show outcome
                 base.EmitError(error);
             }
         }
         else
         {
             if (!this.expectedAssemblyOutcomes.CheckOutcome(this.UnderlyingOutput, this.currentAssembly, error, this.mdDecoder))
             {
                 // show outcome
                 base.EmitError(error);
             }
         }
     }
 }
 public override void EmitError(System.CodeDom.Compiler.CompilerError error)
 {
     if (ok)
     {
         base.EmitError(error);
     }
 }
Exemplo n.º 6
0
 public CompilerError(System.CodeDom.Compiler.CompilerError error)
 {
     this.Column = error.Column;
     this.File   = error.FileName;
     this.Line   = error.Line;
     this.Number = error.ErrorNumber;
     this.Text   = error.ErrorText;
 }
Exemplo n.º 7
0
 internal CompilerError(System.CodeDom.Compiler.CompilerError compilerError)
     : base(compilerError.ErrorText, !compilerError.IsWarning, compilerError.IsWarning)
 {
     Line        = compilerError.Line;
     Column      = compilerError.Column;
     ErrorNumber = compilerError.ErrorNumber;
     FileName    = compilerError.FileName;
 }
Exemplo n.º 8
0
 string GetErrorLines(System.CodeDom.Compiler.CompilerError error)
 {
     if (File.Exists(error.FileName))
     {
         var lines = File.ReadAllLines(error.FileName);
         return(lines[error.Line]);
     }
     return(String.Empty);
 }
Exemplo n.º 9
0
        public CompilerError(System.CodeDom.Compiler.CompilerError error)
        {
            Slyce.Common.Utility.CheckForNulls(new object[] { error }, new[] { "error" });

            Column    = error.Column;
            File      = error.FileName;
            Line      = error.Line;
            Number    = error.ErrorNumber;
            Text      = error.ErrorText;
            IsWarning = error.IsWarning;
        }
Exemplo n.º 10
0
 private void compilerErrors_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     if (compilerErrors.SelectedItem != null)
     {
         System.CodeDom.Compiler.CompilerError er = (compilerErrors.SelectedItem as System.CodeDom.Compiler.CompilerError);
         string t = compilerCode.Text.Split(new char[] { '\r' })[er.Line - 1];
         compilerCode.ScrollToLine(er.Line);
         compilerCode.CaretOffset = (compilerCode.Text.IndexOf(t) + er.Column);
         compilerCode.Focus();
     }
 }
Exemplo n.º 11
0
        public string FormatError(System.CodeDom.Compiler.CompilerError error)
        {
            string retVal = "";

            if (error.IsWarning)
            {
                retVal = "Warning: ";
            }
            else
            {
                retVal = "Error: ";
            }
            retVal += error.ErrorNumber + " " + error.FileName + "(" + error.Line + "," + error.Column + "):\n";
            retVal += "\t" + error.ErrorText;

            return(retVal);
        }
Exemplo n.º 12
0
        internal void EmitError(System.CodeDom.Compiler.CompilerError error)
        {
            Contract.Requires(error != null);

            if (!error.IsWarning || this.failOnWarnings)
            {
                ErrorCount++;
            }

            if (ShouldEmitErrorWarning(error))
            {
                if (error.IsWarning && this.failOnWarnings)
                {
                    error.IsWarning = false;
                }

                Console.WriteLine(error.ToString());
            }
        }
Exemplo n.º 13
0
        public override void EmitError(System.CodeDom.Compiler.CompilerError error)
        {
            this.errorsWereEmitted = true;

            if (this.assemblymask == null)
            {
                if (this.delayedErrors == null)
                {
                    this.delayedErrors = new List <System.CodeDom.Compiler.CompilerError>();
                }
                this.delayedErrors.Add(error);
            }
            else
            {
                if (this.methodmask != null)
                {
                    // we are inside a method
                    if (this.methodmask.IsMasked(error.ErrorText))
                    {
                        Contract.Assert(error.ErrorText != null);
                        this.methodmask.SignalMasked(error.ErrorText);
                    }
                    else
                    {
                        // show outcome
                        base.EmitError(error);
                    }
                }
                else
                {
                    if (this.assemblymask.Contains(error.ErrorText))
                    {
                        // do nothing as we do not have a valid methodmask object here...
                    }
                    else
                    {
                        // show outcome
                        base.EmitError(error);
                    }
                }
            }
        }
Exemplo n.º 14
0
 private void RunCode(Assembly assembly)
 {
     try
     {
         Type[] types = assembly.GetExportedTypes();
         foreach (Type type in types)
         {
             Type interfaceType = type.GetInterface("NOToolsTests.CSharpTextEditor1.IScriptComponent");
             if (null != interfaceType)
             {
                 IScriptComponent component = assembly.CreateInstance(type.FullName) as IScriptComponent;
                 component.Execute();
                 return;
             }
         }
     }
     catch (Exception exception)
     {
         System.CodeDom.Compiler.CompilerErrorCollection collection = new System.CodeDom.Compiler.CompilerErrorCollection();
         System.CodeDom.Compiler.CompilerError error = new System.CodeDom.Compiler.CompilerError("", 0, 0, "0", exception.Message);
         collection.Add(error);
         codeEditorControl1.ShowErrors(collection);
     }
 }
Exemplo n.º 15
0
 private void RunCode(Assembly assembly)
 {
     try
     {
         Type[] types = assembly.GetExportedTypes();
         foreach (Type type in types)
         {
             Type interfaceType = type.GetInterface("NOToolsTests.CSharpTextEditor1.IScriptComponent");
             if (null != interfaceType)
             {
                 IScriptComponent component = assembly.CreateInstance(type.FullName) as IScriptComponent;
                 component.Execute();
                 return;
             }
         }
     }
     catch (Exception exception)
     {
         System.CodeDom.Compiler.CompilerErrorCollection collection = new System.CodeDom.Compiler.CompilerErrorCollection();
         System.CodeDom.Compiler.CompilerError           error      = new System.CodeDom.Compiler.CompilerError("", 0, 0, "0", exception.Message);
         collection.Add(error);
         codeEditorControl1.ShowErrors(collection);
     }
 }
Exemplo n.º 16
0
 public void EmitError(System.CodeDom.Compiler.CompilerError error)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 17
0
 public CompilerError(System.CodeDom.Compiler.CompilerError error)
 {
     _error = error;
 }
Exemplo n.º 18
0
 public override void ReportCompilerError(System.CodeDom.Compiler.CompilerError error)
 {
     Logger.Error(error.ErrorText);
 }
 // Methods
 public virtual void ReportCompilerError(System.CodeDom.Compiler.CompilerError error)
 {
 }
Exemplo n.º 20
0
        private void compileMenu_Click(object sender, EventArgs e)
        {
            //Tear down and setup the bin directory
            if (!IsProjectOpen)
            {
                if (editorTabs.SelectedTab.Text.TrimStart('*').Trim().StartsWith("new"))
                {
                    MessageBox.Show("Please save this file before trying to compile it");
                    return;
                }
                else
                {
                    Directory.SetCurrentDirectory(Path.GetDirectoryName(DocumentManager.GetFileName(editorTabs.SelectedTab.Text)));
                }
            }

            var path = Directory.GetCurrentDirectory() + "\\bin";

            try
            {
                if (Directory.Exists(path))
                {
                    Directory.Delete(path, true);
                }
                Directory.CreateDirectory(path);
            }
            catch (Exception)
            {
                MessageBox.Show("Compilation failed -- it's probable that the bin directory or something in it is locked");
                return;
            }

            AssemblyName[] a = Assembly.GetExecutingAssembly().GetReferencedAssemblies();
            foreach (AssemblyName an in a)
            {
                if (an.FullName.ToLower().Contains("shiro"))
                {
                    if (File.Exists(path + "\\Shiro.Lang.dll"))
                    {
                        File.Delete(path + "\\Shiro.Lang.dll");
                    }

                    var shiroPath = new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName;
                    File.Copy(shiroPath + "\\Shiro.Lang.dll", path + "\\Shiro.Lang.dll");
                }
            }

            foreach (var file in Directory.GetFiles(Directory.GetCurrentDirectory()))
            {
                if (file.EndsWith(".dll"))
                {
                    File.Copy(file, file.Replace(Directory.GetCurrentDirectory(), path));
                }
            }

            //Now do the compile
            System.CodeDom.Compiler.CompilerError ce = null;
            if (!IsProjectOpen)
            {
                //Single file compile, nice and easy
                var c = new Compiler(editorTabs.SelectedTab.Text.TrimStart('*').Trim());
                c.AddShiroModule(editorTabs.SelectedTab.Text.TrimStart('*').Trim(), editor.Text);
                c.Compile(editorTabs.SelectedTab.Text.Split('.')[0] + ".exe", path, out ce);
            }
            else
            {
                //Project compile.  Slightly trickier
                var pt = ProjectTree;
            }

            if (ce == null)
            {
                SafeWrite("Compile success");
            }
            else
            {
                SafeWrite("Compile failed: " + ce.ErrorText);
            }
        }
Exemplo n.º 21
0
 public void EmitError(System.CodeDom.Compiler.CompilerError error)
 {
     Contract.Requires(error != null);
 }
Exemplo n.º 22
0
 /// <summary>
 /// Raise an error
 /// </summary>
 public void Error(string message)
 {
     System.CodeDom.Compiler.CompilerError error = new System.CodeDom.Compiler.CompilerError();
     error.ErrorText = message;
     this.Errors.Add(error);
 }
Exemplo n.º 23
0
 /// <summary>
 /// Raise a warning
 /// </summary>
 public void Warning(string message)
 {
     System.CodeDom.Compiler.CompilerError error = new System.CodeDom.Compiler.CompilerError();
     error.ErrorText = message;
     error.IsWarning = true;
     this.Errors.Add(error);
 }
Exemplo n.º 24
0
 public void EmitError(System.CodeDom.Compiler.CompilerError error)
 {
     this.WriteLine("{0}({1},{2}): {3}", error.FileName, error.Line, error.Column, error.ErrorText);
 }