public static CSharpParseOptions GetCompilerArguments (MonoDevelop.Projects.Project project) { var compilerArguments = new CSharpParseOptions (); // compilerArguments.TabSize = 1; if (project == null || MonoDevelop.Ide.IdeApp.Workspace == null) { // compilerArguments.AllowUnsafeBlocks = true; return compilerArguments; } var configuration = project.GetConfiguration (MonoDevelop.Ide.IdeApp.Workspace.ActiveConfiguration) as DotNetProjectConfiguration; if (configuration == null) return compilerArguments; compilerArguments = compilerArguments.WithPreprocessorSymbols (configuration.GetDefineSymbols ()); var par = configuration.CompilationParameters as CSharpCompilerParameters; if (par == null) return compilerArguments; // compilerArguments.AllowUnsafeBlocks = par.UnsafeCode; compilerArguments = compilerArguments.WithLanguageVersion (ConvertLanguageVersion (par.LangVersion)); // compilerArguments.CheckForOverflow = par.GenerateOverflowChecks; // compilerArguments.WarningLevel = par.WarningLevel; // compilerArguments.TreatWarningsAsErrors = par.TreatWarningsAsErrors; // if (!string.IsNullOrEmpty (par.NoWarnings)) { // foreach (var warning in par.NoWarnings.Split (';', ',', ' ', '\t')) { // int w; // try { // w = int.Parse (warning); // } catch (Exception) { // continue; // } // compilerArguments.DisabledWarnings.Add (w); // } // } return compilerArguments; }
async Task<ProjectInfo> LoadProject (MonoDevelop.Projects.Project p, CancellationToken token) { if (!projectIdMap.ContainsKey (p)) { p.FileAddedToProject += OnFileAdded; p.FileRemovedFromProject += OnFileRemoved; p.FileRenamedInProject += OnFileRenamed; p.Modified += OnProjectModified; } var projectId = GetOrCreateProjectId (p); var projectData = GetOrCreateProjectData (projectId); var references = await CreateMetadataReferences (p, projectId, token).ConfigureAwait (false); if (token.IsCancellationRequested) return null; var config = IdeApp.Workspace != null ? p.GetConfiguration (IdeApp.Workspace.ActiveConfiguration) as MonoDevelop.Projects.DotNetProjectConfiguration : null; MonoDevelop.Projects.DotNetCompilerParameters cp = null; if (config != null) cp = config.CompilationParameters; FilePath fileName = IdeApp.Workspace != null ? p.GetOutputFileName (IdeApp.Workspace.ActiveConfiguration) : (FilePath)""; if (fileName.IsNullOrEmpty) fileName = new FilePath (p.Name + ".dll"); var sourceFiles = await p.GetSourceFilesAsync (config != null ? config.Selector : null).ConfigureAwait (false); var info = ProjectInfo.Create ( projectId, VersionStamp.Create (), p.Name, fileName.FileNameWithoutExtension, LanguageNames.CSharp, p.FileName, fileName, cp != null ? cp.CreateCompilationOptions () : null, cp != null ? cp.CreateParseOptions (config) : null, CreateDocuments (projectData, p, token, sourceFiles), CreateProjectReferences (p, token), references ); projectData.Info = info; return info; }
public static IEnumerable<string> GetDefinedSymbols (MonoDevelop.Projects.Project project) { var workspace = IdeApp.Workspace; if (workspace == null || project == null) yield break; var configuration = project.GetConfiguration (workspace.ActiveConfiguration) as DotNetProjectConfiguration; if (configuration != null) { foreach (string s in configuration.GetDefineSymbols ()) yield return s; // Workaround for mcs defined symbol if (configuration.TargetRuntime.RuntimeId == "Mono") yield return "__MonoCS__"; } }