diff options
Diffstat (limited to 'main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project')
-rw-r--r-- | main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CSharpCompilerParameters.cs | 57 | ||||
-rw-r--r-- | main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CompilerOptionsPanelWidget.cs | 14 |
2 files changed, 63 insertions, 8 deletions
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CSharpCompilerParameters.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CSharpCompilerParameters.cs index fb6650042d..6a5f2cbbdf 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CSharpCompilerParameters.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CSharpCompilerParameters.cs @@ -34,6 +34,8 @@ using MonoDevelop.Core; using Mono.Collections.Generic; using System.Linq; using MonoDevelop.Projects.Formats.MSBuild; +using System.Collections.Immutable; +using Microsoft.CodeAnalysis; namespace MonoDevelop.CSharp.Project { @@ -112,6 +114,48 @@ namespace MonoDevelop.CSharp.Project } } + public override Microsoft.CodeAnalysis.CompilationOptions CreateCompilationOptions () + { + CSharpProjectParameters cparams; + if (ParentConfiguration != null && ParentConfiguration.ProjectParameters != null) { + cparams = (CSharpProjectParameters)ParentConfiguration.ProjectParameters; + } else { + cparams = new CSharpProjectParameters (); + } + + return new Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions ( + OutputKind.ConsoleApplication, + null, + cparams.MainClass, + "Script", + null, + OptimizationLevel.Debug, + GenerateOverflowChecks, + UnsafeCode, + null, + null, + null, + Microsoft.CodeAnalysis.Platform.AnyCpu, + ReportDiagnostic.Default, + WarningLevel, + null, + false, + assemblyIdentityComparer: DesktopAssemblyIdentityComparer.Default + ); + } + + public override Microsoft.CodeAnalysis.ParseOptions CreateParseOptions () + { + return new Microsoft.CodeAnalysis.CSharp.CSharpParseOptions ( + GetRoslynLanguageVersion (langVersion), + Microsoft.CodeAnalysis.DocumentationMode.Parse, + Microsoft.CodeAnalysis.SourceCodeKind.Regular, + ImmutableArray<string>.Empty.AddRange (GetDefineSymbols ()) + ); + + } + + public LangVersion LangVersion { get { var val = TryLangVersionFromString (langVersion); @@ -282,6 +326,19 @@ namespace MonoDevelop.CSharp.Project } } + Microsoft.CodeAnalysis.CSharp.LanguageVersion GetRoslynLanguageVersion (string value) + { + switch (value) { + case "ISO-1": return Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp1; + case "ISO-2": return Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp2; + case "3": return Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp3; + case "4": return Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp4; + case "5": return Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp5; + case "6": return Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp6; + default: return Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp6; + } + } + internal static string TryLangVersionToString (LangVersion value) { switch (value) { diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CompilerOptionsPanelWidget.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CompilerOptionsPanelWidget.cs index 2f1603b1ce..dcbddc3bf8 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CompilerOptionsPanelWidget.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CompilerOptionsPanelWidget.cs @@ -35,8 +35,8 @@ using MonoDevelop.Projects; using MonoDevelop.Projects.Text;
using MonoDevelop.Ide.Gui.Dialogs; using MonoDevelop.Ide; -using ICSharpCode.NRefactory.TypeSystem; using MonoDevelop.Ide.TypeSystem; +using Microsoft.CodeAnalysis; namespace MonoDevelop.CSharp.Project { @@ -209,16 +209,14 @@ namespace MonoDevelop.CSharp.Project void FillClasses ()
{
try { - var ctx = TypeSystemService.GetCompilation (project); + var ctx = TypeSystemService.GetCompilationAsync (project).Result; if (ctx == null) // Project not found in parser database return; - foreach (var c in ctx.GetAllTypeDefinitions ()) {
- if (c.Methods != null) {
- foreach (var m in c.Methods) {
- if (m.IsStatic && m.Name == "Main")
- classListStore.AppendValues (c.FullName);
- }
+ foreach (var c in ctx.Assembly.GlobalNamespace.GetTypeMembers ()) {
+ foreach (var m in c.GetMembers().OfType<IMethodSymbol> ()) {
+ if (m.IsStatic && m.Name == "Main")
+ classListStore.AppendValues (c.ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat));
}
}
classListFilled = true;
|