コード例 #1
0
        private void toolStripButtonCheck_Click(object sender, EventArgs e)
        {
            CompilerErrorCollection errors = new CompilerErrorCollection();
            int lineCount = 0;

            _Editor.ClearAllAnnotations();
            _CompileErrors.Clear();
            if (!_Editor.Compile(_ServerEvent, _AdditionalReferences, _AdditionalNamespaces, errors, out lineCount))
            {
                foreach (CompilerError error in errors)
                {
                    int    errorLine  = (error.Line - 1) - lineCount;
                    string typeString = error.IsWarning ? "Warning" : "Error";

                    if (!_CompileErrors.ContainsKey(errorLine))
                    {
                        _CompileErrors[errorLine] = new List <string>();
                    }

                    typeString = string.Format("{0} [{1},{2}]: ", typeString, errorLine + 1, error.Column);
                    _CompileErrors[errorLine].Add(typeString + error.ErrorText);
                }

                _Editor.DisplayErrors(_CompileErrors);
            }
        }