Exemplo n.º 1
0
    /// <summary>
    /// Draws the thin, Unity-style toolbar showing error counts and toggle buttons
    /// </summary>
    void DrawToolbar()
    {
        var toolbarStyle = GUI.skin.customStyles[3];

        GUILayout.BeginHorizontal();
        if (ButtonClamped("Clear", toolbarStyle))
        {
            Clear();
        }
        // PauseOnError  = ToggleClamped(PauseOnError, "Pause On Error", toolbarStyle);
        ShowTimes = ToggleClamped(ShowTimes, "Show Times", toolbarStyle);

        var buttonSize = toolbarStyle.CalcSize(new GUIContent("T")).y;

        GUILayout.FlexibleSpace();

        var showErrors   = ToggleClamped(ShowErrors, new GUIContent(NoErrors.ToString(), SmallErrorIcon), toolbarStyle, GUILayout.Height(buttonSize));
        var showWarnings = ToggleClamped(ShowWarnings, new GUIContent(NoWarnings.ToString(), SmallWarningIcon), toolbarStyle, GUILayout.Height(buttonSize));
        var showMessages = ToggleClamped(ShowMessages, new GUIContent(NoMessages.ToString(), SmallMessageIcon), toolbarStyle, GUILayout.Height(buttonSize));

        //If the errors/warning to show has changed, clear the selected message
        if (showErrors != ShowErrors || showWarnings != ShowWarnings || showMessages != ShowMessages)
        {
            ClearSelectedMessage();
        }
        ShowWarnings = showWarnings;
        ShowMessages = showMessages;
        ShowErrors   = showErrors;
        GUILayout.EndHorizontal();
    }
Exemplo n.º 2
0
        void _ParseOption(string name, string value, int iName, int iValue)
        {
            //AOutput.Write(name, value);
            _nameFrom  = iName; _nameTo = iName + name.Length;
            _valueFrom = iValue; _valueTo = iValue + value.Length;

            if (value.Length == 0)
            {
                _ErrorV("value cannot be empty"); return;
            }
            bool forCodeInfo = _flags.Has(EMPFlags.ForCodeInfo);

            switch (name)
            {
            case "r":
            case "com":
            case "pr" when _isMain:
                if (name[0] == 'p')
                {
                    Specified |= EMSpecified.pr;
                    if (!_PR(ref value) || forCodeInfo)
                    {
                        return;
                    }
                }

                try {
                    //var p1 = APerf.Create();
                    if (!References.Resolve(value, name[0] == 'c'))
                    {
                        _ErrorV("reference assembly not found: " + value);                         //FUTURE: need more info, or link to Help
                    }
                    //p1.NW('r');
                }
                catch (Exception e) {
                    _ErrorV("exception: " + e.Message);                     //unlikely. If bad format, will be error later, without position info.
                }
                return;

            case "c":
                var ff = _GetFile(value); if (ff == null)
                {
                    return;
                }
                if (!ff.IsClass)
                {
                    _ErrorV("must be a class file"); return;
                }
                if (_filesC == null)
                {
                    _filesC = new List <FileNode>();
                }
                else if (_filesC.Contains(ff))
                {
                    return;
                }
                _filesC.Add(ff);
                return;

            case "resource":
                var fs1 = _GetFileAndString(value);
                if (!forCodeInfo && fs1.f != null)
                {
                    if (Resources == null)
                    {
                        Resources = new List <MetaFileAndString>();
                    }
                    else if (Resources.Exists(o => o.f == fs1.f && o.s == fs1.s))
                    {
                        return;
                    }
                    Resources.Add(fs1);
                }
                return;
                //FUTURE: support wildcard:
                // resource *.png //add to managed resources all matching files in this C# file's folder.
                // resource Resources\*.png //add to managed resources all matching files in a subfolder of this C# file's folder.
                //Support folder (add all in folder).
            }
            if (!_isMain)
            {
                _ErrorN($"in this file only these options can be used: 'r', 'c', 'resource', 'com'. Others only in the main file of the compilation - {CodeFiles[0].f.Name}.");
                return;
            }

            switch (name)
            {
            case "optimize":
                _Specified(EMSpecified.optimize);
                if (_TrueFalse(out bool optim, value))
                {
                    Optimize = optim;
                }
                break;

            case "define":
                Specified |= EMSpecified.define;
                Defines.AddRange(value.SegSplit(", ", SegFlags.NoEmpty));
                break;

            case "warningLevel":
                _Specified(EMSpecified.warningLevel);
                int wl = value.ToInt();
                if (wl >= 0 && wl <= 4)
                {
                    WarningLevel = wl;
                }
                else
                {
                    _ErrorV("must be 0 - 4");
                }
                break;

            case "noWarnings":
                Specified |= EMSpecified.noWarnings;
                NoWarnings.AddRange(value.SegSplit(", ", SegFlags.NoEmpty));
                break;

            case "role":
                _Specified(EMSpecified.role);
                if (_Enum(out ERole ro, value))
                {
                    Role = ro;
                    if (IsScript && (ro == ERole.classFile || Role == ERole.classLibrary))
                    {
                        _ErrorV("role classFile and classLibrary can be only in class files");
                    }
                }
                break;

            case "preBuild":
                _Specified(EMSpecified.preBuild);
                PreBuild = _GetFileAndString(value);
                break;

            case "postBuild":
                _Specified(EMSpecified.postBuild);
                PostBuild = _GetFileAndString(value);
                break;

            case "outputPath":
                _Specified(EMSpecified.outputPath);
                if (!forCodeInfo)
                {
                    OutputPath = _GetOutPath(value);
                }
                break;

            case "runMode":
                _Specified(EMSpecified.runMode);
                if (_Enum(out ERunMode rm, value))
                {
                    RunMode = rm;
                }
                break;

            case "ifRunning":
                _Specified(EMSpecified.ifRunning);
                if (_Enum(out EIfRunning ifR, value))
                {
                    IfRunning = ifR;
                }
                break;

            case "ifRunning2":
                _Specified(EMSpecified.ifRunning2);
                if (_Enum(out EIfRunning2 ifR2, value))
                {
                    IfRunning2 = ifR2;
                }
                break;

            case "uac":
                _Specified(EMSpecified.uac);
                if (_Enum(out EUac uac, value))
                {
                    Uac = uac;
                }
                break;

            case "prefer32bit":
                _Specified(EMSpecified.prefer32bit);
                if (_TrueFalse(out bool is32, value))
                {
                    Prefer32Bit = is32;
                }
                break;

            case "console":
                _Specified(EMSpecified.console);
                if (_TrueFalse(out bool con, value))
                {
                    Console = con;
                }
                break;

            //case "config":
            //	_Specified(EMSpecified.config);
            //	ConfigFile = _GetFile(value);
            //	break;
            case "manifest":
                _Specified(EMSpecified.manifest);
                ManifestFile = _GetFile(value);
                break;

            case "icon":
                _Specified(EMSpecified.icon);
                IconFile = _GetFile(value);
                break;

            case "resFile":
                _Specified(EMSpecified.resFile);
                ResFile = _GetFile(value);
                break;

            case "sign":
                _Specified(EMSpecified.sign);
                SignFile = _GetFile(value);
                break;

            case "xmlDoc":
                _Specified(EMSpecified.xmlDoc);
                XmlDocFile = value;
                break;

            //case "version": //will be auto-created from [assembly: AssemblyVersion] etc
            //	break;
            default:
                _ErrorN("unknown meta comment option");
                break;
            }
        }