public void AssertWeHaveAllLanguagesInUI()
        {
            var known  = CSharpLanguageVersionHelper.GetKnownLanguageVersions().ToDictionary(x => x.version, x => x.localized);
            var roslyn = Enum.GetValues(typeof(LanguageVersion)).Cast <LanguageVersion> ().ToArray();

            var toAdd = roslyn.Where(x => !known.ContainsKey(x)).ToArray();

            Assert.AreEqual(0, toAdd.Length, "Roslyn added new C# language versions: '{0}', add to CSharpLanguageVersionHelper.GetKnownLanguageVersions",
                            string.Join(", ", toAdd));
        }
Пример #2
0
        public CompilerOptionsPanelWidget(DotNetProject project)
        {
            this.Build();
            this.project = project;
            DotNetProjectConfiguration configuration      = (DotNetProjectConfiguration)project.GetConfiguration(IdeApp.Workspace.ActiveConfiguration);
            CSharpCompilerParameters   compilerParameters = (CSharpCompilerParameters)configuration.CompilationParameters;
            var csproject = (CSharpProject)project;

            compileTargetCombo.CompileTarget = configuration.CompileTarget;
            compileTargetCombo.Changed      += new EventHandler(OnTargetChanged);

            if (project.IsLibraryBasedProjectType)
            {
                //fixme: should we totally hide these?
                compileTargetCombo.Sensitive = false;
                mainClassEntry.Sensitive     = false;
            }
            else
            {
                classListStore                     = new ListStore(typeof(string));
                mainClassEntry.Model               = classListStore;
                mainClassEntry.TextColumn          = 0;
                ((Entry)mainClassEntry.Child).Text = csproject.MainClass ?? string.Empty;

                UpdateTarget();
            }

            // Load the codepage. If it matches any of the supported encodigs, use the encoding name
            string foundEncoding = null;

            foreach (TextEncoding e in TextEncoding.SupportedEncodings)
            {
                if (e.CodePage == -1)
                {
                    continue;
                }
                if (e.CodePage == csproject.CodePage)
                {
                    foundEncoding = e.Id;
                }
                codepageEntry.AppendText(e.Id);
            }
            if (foundEncoding != null)
            {
                codepageEntry.Entry.Text = foundEncoding;
            }
            else if (csproject.CodePage != 0)
            {
                codepageEntry.Entry.Text = csproject.CodePage.ToString();
            }

            iconEntry.Path                    = csproject.Win32Icon;
            iconEntry.DefaultPath             = project.BaseDirectory;
            allowUnsafeCodeCheckButton.Active = compilerParameters.UnsafeCode;
            noStdLibCheckButton.Active        = compilerParameters.NoStdLib;
            langVersionWarningIcon.Visible    = false;

            var             langVerStore = new ListStore(typeof(string), typeof(LanguageVersion), typeof(bool));
            var             langVersions = CSharpLanguageVersionHelper.GetKnownLanguageVersions();
            string          badVersion   = null;
            LanguageVersion?langVersion  = null;

            try {
                langVersion = compilerParameters.LangVersion;
            } catch (Exception) {
                badVersion = configuration.Properties.GetProperty("LangVersion").Value;
            }

            foreach (var(text, version) in langVersions)
            {
                if (unsupportedLanguageVersions.Contains(version))
                {
                    if (langVersion == version)
                    {
                        if (badVersion == null)
                        {
                            badVersion = text;
                        }
                    }
                    else
                    {
                        // Otherwise if it's an unsupported language but it's not the current project's
                        // version then it must be an unsupported version of Mono. Let's not add that to
                        // the list store.
                    }
                }
                else
                {
                    langVerStore.AppendValues(text, version, false);
                }
            }

            langVerCombo.Model = langVerStore;

            if (badVersion != null)
            {
                var badIter = langVerStore.AppendValues(GettextCatalog.GetString("{0} (Unknown Version)", badVersion), LanguageVersion.Default, true);
                langVerCombo.SetActiveIter(badIter);
                langVersionWarningIcon.Visible = true;
            }
            else
            {
                TreeIter iter;
                if (langVerStore.GetIterFirst(out iter))
                {
                    do
                    {
                        var val = (LanguageVersion)(int)langVerStore.GetValue(iter, 1);
                        if (val == compilerParameters.LangVersion)
                        {
                            langVerCombo.SetActiveIter(iter);
                            break;
                        }
                    } while (langVerStore.IterNext(ref iter));
                }
            }

            SetupAccessibility();
        }
Пример #3
0
        public CompilerOptionsPanelWidget(DotNetProject project)
        {
            this.Build();
            this.project = project;
            DotNetProjectConfiguration configuration      = (DotNetProjectConfiguration)project.GetConfiguration(IdeApp.Workspace.ActiveConfiguration);
            CSharpCompilerParameters   compilerParameters = (CSharpCompilerParameters)configuration.CompilationParameters;
            var csproject = (CSharpProject)project;

            compileTargetCombo.CompileTarget = configuration.CompileTarget;
            compileTargetCombo.Changed      += new EventHandler(OnTargetChanged);

            if (project.IsLibraryBasedProjectType)
            {
                //fixme: should we totally hide these?
                compileTargetCombo.Sensitive = false;
                mainClassEntry.Sensitive     = false;
            }
            else
            {
                classListStore                     = new ListStore(typeof(string));
                mainClassEntry.Model               = classListStore;
                mainClassEntry.TextColumn          = 0;
                ((Entry)mainClassEntry.Child).Text = csproject.MainClass ?? string.Empty;

                UpdateTarget();
            }

            // Load the codepage. If it matches any of the supported encodigs, use the encoding name
            string foundEncoding = null;

            foreach (TextEncoding e in TextEncoding.SupportedEncodings)
            {
                if (e.CodePage == -1)
                {
                    continue;
                }
                if (e.CodePage == csproject.CodePage)
                {
                    foundEncoding = e.Id;
                }
                codepageEntry.AppendText(e.Id);
            }
            if (foundEncoding != null)
            {
                codepageEntry.Entry.Text = foundEncoding;
            }
            else if (csproject.CodePage != 0)
            {
                codepageEntry.Entry.Text = csproject.CodePage.ToString();
            }

            iconEntry.Path                    = csproject.Win32Icon;
            iconEntry.DefaultPath             = project.BaseDirectory;
            allowUnsafeCodeCheckButton.Active = compilerParameters.UnsafeCode;
            noStdLibCheckButton.Active        = compilerParameters.NoStdLib;

            var langVerStore = new ListStore(typeof(string), typeof(LanguageVersion));

            foreach (var(text, version) in CSharpLanguageVersionHelper.GetKnownLanguageVersions())
            {
                langVerStore.AppendValues(text, version);
            }
            langVerCombo.Model = langVerStore;

            TreeIter iter;

            if (langVerStore.GetIterFirst(out iter))
            {
                do
                {
                    var val = (LanguageVersion)(int)langVerStore.GetValue(iter, 1);
                    if (val == compilerParameters.LangVersion)
                    {
                        langVerCombo.SetActiveIter(iter);
                        break;
                    }
                } while (langVerStore.IterNext(ref iter));
            }

            SetupAccessibility();
        }