diff options
author | Lluis Sanchez Gual <lluis@xamarin.com> | 2015-04-20 19:07:51 +0300 |
---|---|---|
committer | Lluis Sanchez Gual <lluis@xamarin.com> | 2015-04-20 19:07:51 +0300 |
commit | 95408b1a41b31b645f3a8c3323ab7d3ca4bff26b (patch) | |
tree | f8f137cddcb9a40499d303be95722fd2c6081bce /main/src/addins/AspNet/WebForms/WebFormsCodeBehind.cs | |
parent | b70e4e04b4e41b8ec28d7e4b220b401ecf467e7a (diff) | |
parent | de043d330a8bf5855d4d983c804cd36727cb2406 (diff) |
Merge remote-tracking branch 'origin/roslyn' into new-project-model
Diffstat (limited to 'main/src/addins/AspNet/WebForms/WebFormsCodeBehind.cs')
-rw-r--r-- | main/src/addins/AspNet/WebForms/WebFormsCodeBehind.cs | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/main/src/addins/AspNet/WebForms/WebFormsCodeBehind.cs b/main/src/addins/AspNet/WebForms/WebFormsCodeBehind.cs index 9a2df0e831..1eb82b8a97 100644 --- a/main/src/addins/AspNet/WebForms/WebFormsCodeBehind.cs +++ b/main/src/addins/AspNet/WebForms/WebFormsCodeBehind.cs @@ -34,12 +34,12 @@ using System.CodeDom; using System.Collections.Generic; using System.Linq; -using ICSharpCode.NRefactory.TypeSystem; using MonoDevelop.Core; using MonoDevelop.DesignerSupport; using MonoDevelop.Ide.TypeSystem; using MonoDevelop.Projects; using MonoDevelop.AspNet.Projects; +using Microsoft.CodeAnalysis; namespace MonoDevelop.AspNet.WebForms { @@ -74,7 +74,7 @@ namespace MonoDevelop.AspNet.WebForms var result = new BuildResult (); //parse the ASP.NET file - var parsedDocument = TypeSystemService.ParseFile (project, file.FilePath) as WebFormsParsedDocument; + var parsedDocument = TypeSystemService.ParseFile (project, file.FilePath).Result as WebFormsParsedDocument; if (parsedDocument == null) { result.AddError (string.Format ("Failed to parse file '{0}'", file.Name)); return result; @@ -91,7 +91,7 @@ namespace MonoDevelop.AspNet.WebForms return result; } - static void AddErrorsToResult (BuildResult result, string filename, IList<Error> errors) + static void AddErrorsToResult (BuildResult result, string filename, IEnumerable<Error> errors) { foreach (var err in errors) { if (err.ErrorType == ErrorType.Warning) @@ -110,7 +110,7 @@ namespace MonoDevelop.AspNet.WebForms ccu = null; var result = new BuildResult (); string className = document.Info.InheritedClass; - AddErrorsToResult (result, filename, document.Errors); + AddErrorsToResult (result, filename, document.GetErrorsAsync().Result); if (result.ErrorCount > 0) return result; @@ -153,7 +153,7 @@ namespace MonoDevelop.AspNet.WebForms ProjectFile resolvedMaster = ext.ResolveVirtualPath (document.Info.MasterPageTypeVPath, document.FileName); WebFormsParsedDocument masterParsedDocument = null; if (resolvedMaster != null) - masterParsedDocument = TypeSystemService.ParseFile (project, resolvedMaster.FilePath) as WebFormsParsedDocument; + masterParsedDocument = TypeSystemService.ParseFile (project, resolvedMaster.FilePath).Result as WebFormsParsedDocument; if (masterParsedDocument != null && !String.IsNullOrEmpty (masterParsedDocument.Info.InheritedClass)) masterTypeName = masterParsedDocument.Info.InheritedClass; } catch (Exception ex) { @@ -186,13 +186,13 @@ namespace MonoDevelop.AspNet.WebForms return result; var dom = refman.Compilation; - var cls = ReflectionHelper.ParseReflectionName (className).Resolve (dom); + var cls = dom.GetTypeByMetadataName (className); var members = GetDesignerMembers (memberList.Members.Values, cls, filename); //add fields for each control in the page foreach (var member in members) { - var type = new CodeTypeReference (member.Type.FullName); + var type = new CodeTypeReference (member.Type.ToDisplayString (SymbolDisplayFormat.CSharpErrorMessageFormat)); typeDecl.Members.Add (new CodeMemberField (type, member.Name) { Attributes = MemberAttributes.Family }); } return result; @@ -205,22 +205,23 @@ namespace MonoDevelop.AspNet.WebForms /// <returns>The filtered list of non-conflicting members.</returns> // TODO: check compatibilty with existing members public static IEnumerable<CodeBehindMember> GetDesignerMembers ( - IEnumerable<CodeBehindMember> members, IType cls, string designerFile) + IEnumerable<CodeBehindMember> members, INamedTypeSymbol cls, string designerFile) { var existingMembers = new HashSet<string> (); while (cls != null) { - if (cls.GetDefinition () == null) - break; +// if (cls.GetDefinition () == null) +// break; foreach (var member in cls.GetMembers ()) { - if (member.Accessibility == Accessibility.Private || member.Accessibility == Accessibility.Internal) + if (member.DeclaredAccessibility == Accessibility.Private || member.DeclaredAccessibility == Accessibility.Internal) continue; - if (member.Region.FileName == designerFile) + if (member.Locations.Any (loc => loc.IsInSource && loc.SourceTree.FilePath == designerFile)) continue; existingMembers.Add (member.Name); } - if (cls.DirectBaseTypes.All (t => t.Kind == TypeKind.Interface)) + // TODO: check + if (cls.Interfaces.Any ()) break; - cls = cls.DirectBaseTypes.First(t => t.Kind != TypeKind.Interface); + cls = cls.BaseType; } return members.Where (m => !existingMembers.Contains (m.Name)); } |