This class handles project specific compiler parameters
Inheritance: MonoDevelop.Projects.DotNetCompilerParameters
コード例 #1
0
		public void Load (DotNetProjectConfiguration configuration)
		{
			this.configuration = configuration;
			compilerParameters = (CSharpCompilerParameters) configuration.CompilationParameters;
			
			symbolsEntry.Text                          = compilerParameters.DefineSymbols;
			generateXmlOutputCheckButton.Active        = !string.IsNullOrEmpty (compilerParameters.DocumentationFile);
			enableOptimizationCheckButton.Active       = compilerParameters.Optimize;
			generateOverflowChecksCheckButton.Active   = compilerParameters.GenerateOverflowChecks;
			warningsAsErrorsCheckButton.Active         = compilerParameters.TreatWarningsAsErrors;
			warningLevelSpinButton.Value               = compilerParameters.WarningLevel;
			ignoreWarningsEntry.Text                   = compilerParameters.NoWarnings;
			
			int i = CSharpLanguageBinding.SupportedPlatforms.IndexOf (compilerParameters.PlatformTarget);
			comboPlatforms.Active = i != -1 ? i : 0;

			if (!configuration.DebugMode || string.Equals ("none", compilerParameters.DebugType, StringComparison.OrdinalIgnoreCase)) {
				comboDebug.Active = DEBUG_NONE;
			} else if (string.Equals ("pdbonly", compilerParameters.DebugType, StringComparison.OrdinalIgnoreCase)) {
				comboDebug.Active = DEBUG_PDB_ONLY;
			} else {
				comboDebug.Active = DEBUG_FULL;
			}

			xmlDocsEntry.DefaultPath = configuration.OutputDirectory;

			xmlDocsEntry.Path = string.IsNullOrEmpty (compilerParameters.DocumentationFile)
				? configuration.CompiledOutputName.ChangeExtension (".xml")
				: compilerParameters.DocumentationFile;
		}
コード例 #2
0
		public void TestSetup()
		{
			_project = new DotNetAssemblyProject ("C#");
			var p = new CSharpCompilerParameters ();
			var config = new DotNetProjectConfiguration () { CompilationParameters = p };
			_project.DefaultConfiguration = config;

			_update = new MonoIsland ();
			_update.BaseDirectory = "/mybase";
		}
コード例 #3
0
		public ConfigurationParameters CreateCompilationParameters (XmlElement projectOptions)
		{
			CSharpCompilerParameters pars = new CSharpCompilerParameters ();
			if (projectOptions != null) {
				string platform = projectOptions.GetAttribute ("Platform");
				if (SupportedPlatforms.Contains (platform))
					pars.PlatformTarget = platform;
				string debugAtt = projectOptions.GetAttribute ("DefineDebug");
				if (string.Compare ("True", debugAtt, true) == 0)
					pars.AddDefineSymbol ("DEBUG");
			}
			return pars;
		}
コード例 #4
0
		public void Load (DotNetProjectConfiguration configuration)
		{
			this.configuration = configuration;
			compilerParameters = (CSharpCompilerParameters) configuration.CompilationParameters;
			
			symbolsEntry.Text                          = compilerParameters.DefineSymbols;
			generateDebugInformationCheckButton.Active = configuration.DebugMode;
			generateXmlOutputCheckButton.Active        = compilerParameters.GenerateXmlDocumentation;
			enableOptimizationCheckButton.Active       = compilerParameters.Optimize;
			generateOverflowChecksCheckButton.Active   = compilerParameters.GenerateOverflowChecks;
			warningsAsErrorsCheckButton.Active         = compilerParameters.TreatWarningsAsErrors;
			warningLevelSpinButton.Value               = compilerParameters.WarningLevel;
			additionalArgsEntry.Text                   = compilerParameters.AdditionalArguments;
			ignoreWarningsEntry.Text                   = compilerParameters.NoWarnings;
			
			int i = CSharpLanguageBinding.SupportedPlatforms.IndexOf (compilerParameters.PlatformTarget);
			comboPlatforms.Active = i != -1 ? i : 0;
		}
コード例 #5
0
		public ConfigurationParameters CreateCompilationParameters (XmlElement projectOptions)
		{
			CSharpCompilerParameters pars = new CSharpCompilerParameters ();
			if (projectOptions != null) {
				string platform = projectOptions.GetAttribute ("Platform");
				if (SupportedPlatforms.Contains (platform))
					pars.PlatformTarget = platform;
				string debugAtt = projectOptions.GetAttribute ("DefineDebug");
				if (string.Compare ("True", debugAtt, StringComparison.OrdinalIgnoreCase) == 0) {
					pars.AddDefineSymbol ("DEBUG");
					pars.DebugType = "full";
				}
				string releaseAtt = projectOptions.GetAttribute ("Release");
				if (string.Compare ("True", releaseAtt, StringComparison.OrdinalIgnoreCase) == 0)
					pars.Optimize = true;
			}
			return pars;
		}
コード例 #6
0
		protected override DotNetCompilerParameters OnCreateCompilationParameters (DotNetProjectConfiguration config, ConfigurationKind kind)
		{
			var pars = new CSharpCompilerParameters ();
			if (SupportedPlatforms.Contains (config.Platform))
				pars.PlatformTarget = config.Platform;
			
			if (kind == ConfigurationKind.Debug)
				pars.AddDefineSymbol ("DEBUG");
			else if (kind == ConfigurationKind.Release)
				pars.Optimize = true;
			return pars;
		}
コード例 #7
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();
        }
コード例 #8
0
        public void Store(ItemConfigurationCollection <ItemConfiguration> configs)
        {
            int codePage;

            var      langVersion = LanguageVersion.Default;
            TreeIter iter;

            if (langVerCombo.GetActiveIter(out iter))
            {
                langVersion = (LanguageVersion)langVerCombo.Model.GetValue(iter, 1);
            }

            if (codepageEntry.Entry.Text.Length > 0)
            {
                // Get the codepage. If the user specified an encoding name, find it.
                int trialCodePage = -1;
                foreach (TextEncoding e in TextEncoding.SupportedEncodings)
                {
                    if (e.Id == codepageEntry.Entry.Text)
                    {
                        trialCodePage = e.CodePage;
                        break;
                    }
                }

                if (trialCodePage != -1)
                {
                    codePage = trialCodePage;
                }
                else
                {
                    if (!int.TryParse(codepageEntry.Entry.Text, out trialCodePage))
                    {
                        return;
                    }
                    codePage = trialCodePage;
                }
            }
            else
            {
                codePage = 0;
            }

            project.CompileTarget = compileTargetCombo.CompileTarget;

            var csproject = (CSharpProject)project;

            csproject.CodePage = codePage;

            if (iconEntry.Sensitive)
            {
                csproject.Win32Icon = iconEntry.Path;
            }

            if (mainClassEntry.Sensitive)
            {
                csproject.MainClass = mainClassEntry.Entry.Text;
            }
            foreach (DotNetProjectConfiguration configuration in configs)
            {
                CSharpCompilerParameters compilerParameters = (CSharpCompilerParameters)configuration.CompilationParameters;
                compilerParameters.UnsafeCode  = allowUnsafeCodeCheckButton.Active;
                compilerParameters.NoStdLib    = noStdLibCheckButton.Active;
                compilerParameters.LangVersion = langVersion;
            }
        }
コード例 #9
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;

            ListStore store = new ListStore(typeof(string));

            store.AppendValues(GettextCatalog.GetString("Executable"));
            store.AppendValues(GettextCatalog.GetString("Library"));
            store.AppendValues(GettextCatalog.GetString("Executable with GUI"));
            store.AppendValues(GettextCatalog.GetString("Module"));
            compileTargetCombo.Model = store;
            CellRendererText cr = new CellRendererText();

            compileTargetCombo.PackStart(cr, true);
            compileTargetCombo.AddAttribute(cr, "text", 0);
            compileTargetCombo.Active   = (int)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;

            ListStore langVerStore = new ListStore(typeof(string));

            langVerStore.AppendValues(GettextCatalog.GetString("Default"));
            langVerStore.AppendValues("ISO-1");
            langVerStore.AppendValues("ISO-2");
            langVerStore.AppendValues("Version 3");
            langVerStore.AppendValues("Version 4");
            langVerStore.AppendValues("Version 5");
            langVerStore.AppendValues("Version 6");
            langVerCombo.Model  = langVerStore;
            langVerCombo.Active = (int)compilerParameters.LangVersion;
        }
コード例 #10
0
		protected SolutionItemConfiguration CreateConfigurationBlock (MonoDevelop.Projects.DotNetProject project, Config ConfigBlock, string AssemblyName, string OuputType, IProgressMonitor monitor)
		{
			DotNetProjectConfiguration confObj = project.CreateConfiguration (ConfigBlock.Name) as DotNetProjectConfiguration;

			confObj.RunWithWarnings = false;
			confObj.DebugMode = ConfigBlock.DebugSymbols;
			project.CompileTarget = (CompileTarget) Enum.Parse (typeof(CompileTarget), OuputType, true);
			
			string dir = MapPath (project.BaseDirectory, ConfigBlock.OutputPath);
			if (dir == null) {
				dir = Path.Combine ("bin", ConfigBlock.Name);
				monitor.ReportWarning (string.Format (GettextCatalog.GetString ("Output directory '{0}' can't be mapped to a local directory. The directory '{1}' will be used instead"), ConfigBlock.OutputPath, dir));
			}
			confObj.OutputDirectory = dir;
			confObj.OutputAssembly = AssemblyName;
			
			CSharpCompilerParameters compilerParams = new CSharpCompilerParameters ();
			compilerParams.WarningLevel = ConfigBlock.WarningLevel;
			compilerParams.NoWarnings = "";
			compilerParams.Optimize = ConfigBlock.Optimize;
			compilerParams.DefineSymbols = ConfigBlock.DefineConstants;
			compilerParams.UnsafeCode = ConfigBlock.AllowUnsafeBlocks; 
			compilerParams.GenerateOverflowChecks = ConfigBlock.CheckForOverflowUnderflow;
			
			return confObj;
		}
コード例 #11
0
        public void Store(ItemConfigurationCollection <ItemConfiguration> configs)
        {
            int           codePage;
            CompileTarget compileTarget = (CompileTarget)compileTargetCombo.Active;
            LangVersion   langVersion   = (LangVersion)langVerCombo.Active;


            if (codepageEntry.Entry.Text.Length > 0)
            {
                // Get the codepage. If the user specified an encoding name, find it.
                int trialCodePage = -1;
                foreach (TextEncoding e in TextEncoding.SupportedEncodings)
                {
                    if (e.Id == codepageEntry.Entry.Text)
                    {
                        trialCodePage = e.CodePage;
                        break;
                    }
                }

                if (trialCodePage != -1)
                {
                    codePage = trialCodePage;
                }
                else
                {
                    if (!int.TryParse(codepageEntry.Entry.Text, out trialCodePage))
                    {
                        return;
                    }
                    codePage = trialCodePage;
                }
            }
            else
            {
                codePage = 0;
            }

            project.CompileTarget = compileTarget;

            CSharpProjectParameters projectParameters = (CSharpProjectParameters)project.LanguageParameters;

            projectParameters.CodePage = codePage;

            if (iconEntry.Sensitive)
            {
                projectParameters.Win32Icon = iconEntry.Path;
            }

            if (mainClassEntry.Sensitive)
            {
                projectParameters.MainClass = mainClassEntry.Entry.Text;
            }

            foreach (DotNetProjectConfiguration configuration in configs)
            {
                CSharpCompilerParameters compilerParameters = (CSharpCompilerParameters)configuration.CompilationParameters;
                compilerParameters.UnsafeCode  = allowUnsafeCodeCheckButton.Active;
                compilerParameters.LangVersion = langVersion;
            }
        }
コード例 #12
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();
        }