diff options
Diffstat (limited to 'main/src/addins/AspNet/WebForms')
9 files changed, 59 insertions, 32 deletions
diff --git a/main/src/addins/AspNet/WebForms/MasterContentFileDescriptionTemplate.cs b/main/src/addins/AspNet/WebForms/MasterContentFileDescriptionTemplate.cs index bced906b6d..8ca2ded55d 100644 --- a/main/src/addins/AspNet/WebForms/MasterContentFileDescriptionTemplate.cs +++ b/main/src/addins/AspNet/WebForms/MasterContentFileDescriptionTemplate.cs @@ -38,7 +38,7 @@ namespace MonoDevelop.AspNet.WebForms { public class MasterContentFileDescriptionTemplate : SingleFileDescriptionTemplate { - public override void ModifyTags (SolutionItem policyParent, Project project, string language, string identifier, string fileName, ref Dictionary<string,string> tags) + public override void ModifyTags (SolutionFolderItem policyParent, Project project, string language, string identifier, string fileName, ref Dictionary<string,string> tags) { base.ModifyTags (policyParent, project, language, identifier, fileName, ref tags); if (fileName == null) @@ -47,13 +47,13 @@ namespace MonoDevelop.AspNet.WebForms tags ["AspNetMaster"] = ""; tags ["AspNetMasterContent"] = ""; - AspNetAppProject aspProj = project as AspNetAppProject; + var aspProj = project.GetService<AspNetFlavor> (); if (aspProj == null) throw new InvalidOperationException ("MasterContentFileDescriptionTemplate is only valid for ASP.NET projects"); ProjectFile masterPage = null; - var dialog = new MonoDevelop.Ide.Projects.ProjectFileSelectorDialog (aspProj, null, "*.master"); + var dialog = new MonoDevelop.Ide.Projects.ProjectFileSelectorDialog (project, null, "*.master"); try { dialog.Title = GettextCatalog.GetString ("Select a Master Page..."); int response = MonoDevelop.Ide.MessageService.RunCustomDialog (dialog); diff --git a/main/src/addins/AspNet/WebForms/WebFormsCodeBehind.cs b/main/src/addins/AspNet/WebForms/WebFormsCodeBehind.cs index bfdce9399f..ed1977dc84 100644 --- a/main/src/addins/AspNet/WebForms/WebFormsCodeBehind.cs +++ b/main/src/addins/AspNet/WebForms/WebFormsCodeBehind.cs @@ -47,7 +47,7 @@ namespace MonoDevelop.AspNet.WebForms { public static string GetCodeBehindClassName (ProjectFile file) { - AspNetAppProject proj = file.Project as AspNetAppProject; + var proj = file.Project.GetService<AspNetFlavor> (); if (proj == null) return null; return proj.GetCodebehindTypeName (file.Name); @@ -55,19 +55,19 @@ namespace MonoDevelop.AspNet.WebForms public static ProjectFile GetDesignerFile (ProjectFile file) { - var project = file.Project as AspNetAppProject; + var ext = file.Project.GetService<AspNetFlavor> (); - var type = AspNetAppProject.DetermineWebSubtype (file.FilePath); + var type = AspNetFlavor.DetermineWebSubtype (file.FilePath); if (type != WebSubtype.WebForm && type != WebSubtype.WebControl && type != WebSubtype.MasterPage) return null; - var dfName = project.LanguageBinding.GetFileName (file.FilePath + ".designer"); - return project.Files.GetFile (dfName); + var dfName = ext.Project.LanguageBinding.GetFileName (file.FilePath + ".designer"); + return ext.Project.Files.GetFile (dfName); } public static BuildResult UpdateDesignerFile ( CodeBehindWriter writer, - AspNetAppProject project, + DotNetProject project, ProjectFile file, ProjectFile designerFile ) { @@ -102,7 +102,7 @@ namespace MonoDevelop.AspNet.WebForms } public static BuildResult GenerateCodeBehind ( - AspNetAppProject project, + DotNetProject project, string filename, WebFormsParsedDocument document, out CodeCompileUnit ccu) @@ -149,7 +149,8 @@ namespace MonoDevelop.AspNet.WebForms masterTypeName = document.Info.MasterPageTypeName; } else if (!String.IsNullOrEmpty (document.Info.MasterPageTypeVPath)) { try { - ProjectFile resolvedMaster = project.ResolveVirtualPath (document.Info.MasterPageTypeVPath, document.FileName); + var ext = project.GetService<AspNetFlavor> (); + ProjectFile resolvedMaster = ext.ResolveVirtualPath (document.Info.MasterPageTypeVPath, document.FileName); WebFormsParsedDocument masterParsedDocument = null; if (resolvedMaster != null) masterParsedDocument = TypeSystemService.ParseFile (project, resolvedMaster.FilePath) as WebFormsParsedDocument; diff --git a/main/src/addins/AspNet/WebForms/WebFormsCodeBehindTypeNameCache.cs b/main/src/addins/AspNet/WebForms/WebFormsCodeBehindTypeNameCache.cs index 526911a74f..c5088a67b6 100644 --- a/main/src/addins/AspNet/WebForms/WebFormsCodeBehindTypeNameCache.cs +++ b/main/src/addins/AspNet/WebForms/WebFormsCodeBehindTypeNameCache.cs @@ -31,13 +31,14 @@ using MonoDevelop.Core; using MonoDevelop.Ide.TypeSystem; using MonoDevelop.Ide; using MonoDevelop.AspNet.WebForms;
-using MonoDevelop.AspNet.Projects; +using MonoDevelop.AspNet.Projects;
+using MonoDevelop.Projects; namespace MonoDevelop.AspNet.WebForms { - class WebFormsCodeBehindTypeNameCache : ProjectFileCache<AspNetAppProject,string> + class WebFormsCodeBehindTypeNameCache : ProjectFileCache<Project,string> { - public WebFormsCodeBehindTypeNameCache (AspNetAppProject proj) : base (proj) + public WebFormsCodeBehindTypeNameCache (Project proj) : base (proj) { } diff --git a/main/src/addins/AspNet/WebForms/WebFormsDirectiveCompletion.cs b/main/src/addins/AspNet/WebForms/WebFormsDirectiveCompletion.cs index 54839d53ae..a7ded63cf7 100644 --- a/main/src/addins/AspNet/WebForms/WebFormsDirectiveCompletion.cs +++ b/main/src/addins/AspNet/WebForms/WebFormsDirectiveCompletion.cs @@ -36,6 +36,7 @@ using System.Web.UI; using MonoDevelop.Core; using MonoDevelop.Ide.CodeCompletion; using MonoDevelop.AspNet.Projects; +using MonoDevelop.Projects; namespace MonoDevelop.AspNet.WebForms { @@ -94,7 +95,7 @@ namespace MonoDevelop.AspNet.WebForms } - public static CompletionDataList GetAttributeValues (AspNetAppProject project, FilePath fromFile, string directiveName, string attribute) + public static CompletionDataList GetAttributeValues (DotNetProject project, FilePath fromFile, string directiveName, string attribute) { switch (directiveName.ToLowerInvariant ()) { case "page": @@ -105,7 +106,7 @@ namespace MonoDevelop.AspNet.WebForms return null; } - public static CompletionDataList GetAttributes (AspNetAppProject project, string directiveName, + public static CompletionDataList GetAttributes (DotNetProject project, string directiveName, Dictionary<string, string> existingAtts) { var list = new CompletionDataList (); @@ -199,7 +200,7 @@ namespace MonoDevelop.AspNet.WebForms list.Add (s); } - static CompletionDataList GetPageAttributeValues (AspNetAppProject project, FilePath fromFile, string attribute) + static CompletionDataList GetPageAttributeValues (Project project, FilePath fromFile, string attribute) { var list = new CompletionDataList (); switch (attribute.ToLowerInvariant ()) { @@ -346,7 +347,7 @@ namespace MonoDevelop.AspNet.WebForms return list.Count > 0? list : null; } - static CompletionDataList GetRegisterAttributeValues (AspNetAppProject project, FilePath fromFile, string attribute) + static CompletionDataList GetRegisterAttributeValues (Project project, FilePath fromFile, string attribute) { switch (attribute.ToLowerInvariant ()) { case "src": diff --git a/main/src/addins/AspNet/WebForms/WebFormsEditorExtension.cs b/main/src/addins/AspNet/WebForms/WebFormsEditorExtension.cs index 96a0239b78..bc2cc3ef64 100644 --- a/main/src/addins/AspNet/WebForms/WebFormsEditorExtension.cs +++ b/main/src/addins/AspNet/WebForms/WebFormsEditorExtension.cs @@ -48,6 +48,7 @@ using S = MonoDevelop.Xml.Parser; using MonoDevelop.AspNet.WebForms.Dom; using MonoDevelop.Xml.Parser; using MonoDevelop.Xml.Dom; +using MonoDevelop.Projects; namespace MonoDevelop.AspNet.WebForms { @@ -56,7 +57,7 @@ namespace MonoDevelop.AspNet.WebForms static readonly Regex DocTypeRegex = new Regex (@"(?:PUBLIC|public)\s+""(?<fpi>[^""]*)""\s+""(?<uri>[^""]*)"""); WebFormsParsedDocument aspDoc; - AspNetAppProject project; + DotNetProject project; WebFormsTypeContext refman = new WebFormsTypeContext (); ILanguageCompletionBuilder documentBuilder; @@ -90,7 +91,7 @@ namespace MonoDevelop.AspNet.WebForms if (HasDoc) refman.Doc = aspDoc; - var newProj = Document.Project as AspNetAppProject; + var newProj = Document.Project as DotNetProject; if (newProj != null) { project = newProj; refman.Project = newProj; diff --git a/main/src/addins/AspNet/WebForms/WebFormsParser.cs b/main/src/addins/AspNet/WebForms/WebFormsParser.cs index 03f19b91be..f29967ff7d 100644 --- a/main/src/addins/AspNet/WebForms/WebFormsParser.cs +++ b/main/src/addins/AspNet/WebForms/WebFormsParser.cs @@ -67,7 +67,7 @@ namespace MonoDevelop.AspNet.WebForms XDocument xDoc = parser.Nodes.GetRoot (); info.Populate (xDoc, errors); - var type = AspNetAppProject.DetermineWebSubtype (fileName); + var type = AspNetFlavor.DetermineWebSubtype (fileName); if (type != info.Subtype) { if (info.Subtype == WebSubtype.None) { errors.Add (new Error (ErrorType.Error, "File directive is missing", 1, 1)); diff --git a/main/src/addins/AspNet/WebForms/WebFormsRegistrationCache.cs b/main/src/addins/AspNet/WebForms/WebFormsRegistrationCache.cs index ac1a6ccb6c..494eae7723 100644 --- a/main/src/addins/AspNet/WebForms/WebFormsRegistrationCache.cs +++ b/main/src/addins/AspNet/WebForms/WebFormsRegistrationCache.cs @@ -38,9 +38,9 @@ using MonoDevelop.AspNet.Projects; namespace MonoDevelop.AspNet.WebForms { - class WebFormsRegistrationCache : ProjectFileCache<AspNetAppProject,RegistrationInfo> + class WebFormsRegistrationCache : ProjectFileCache<DotNetProject,RegistrationInfo> { - public WebFormsRegistrationCache (AspNetAppProject project) : base (project) + public WebFormsRegistrationCache (DotNetProject project) : base (project) { } @@ -135,6 +135,16 @@ namespace MonoDevelop.AspNet.WebForms info.Namespaces.AddRange (defaultNamespaces.Select (ns => new NamespaceRegistration (true, ns))); info.Assemblies.AddRange (defaultAssemblies.Select (asm => new AssemblyRegistration (true, asm))); + + // from Mono's 4.5 machine web.config + info.Controls.AddRange (new [] { + MachineControlReg ("asp", "System.Web.UI.WebControls.WebParts", "System.Web"), + MachineControlReg ("asp", "System.Web.UI", "System.Web.Extensions"), + MachineControlReg ("asp", "System.Web.UI.WebControls", "System.Web.Extensions"), + MachineControlReg ("asp", "System.Web.UI.WebControls.Expressions", "System.Web.Extensions"), + MachineControlReg ("asp", "System.Web.DynamicData", "System.Web.DynamicData"), + MachineControlReg ("asp", "System.Web.UI.WebControls", "System.Web.Entity"), + }); return info; } @@ -171,6 +181,11 @@ namespace MonoDevelop.AspNet.WebForms "System.Web.UI.WebControls.WebParts", }; + static ControlRegistration MachineControlReg(string prefix, string ns, string asm) + { + return new ControlRegistration (null, true, prefix, ns, asm, null, null); + } + public static bool IsDefaultReference (string reference) { return defaultAssemblies.Any (r => diff --git a/main/src/addins/AspNet/WebForms/WebFormsToolboxNode.cs b/main/src/addins/AspNet/WebForms/WebFormsToolboxNode.cs index 6ccccbddc5..f0804abf65 100644 --- a/main/src/addins/AspNet/WebForms/WebFormsToolboxNode.cs +++ b/main/src/addins/AspNet/WebForms/WebFormsToolboxNode.cs @@ -157,7 +157,7 @@ namespace MonoDevelop.AspNet.WebForms public bool IsCompatibleWith (MonoDevelop.Ide.Gui.Document document)
{ - switch (AspNetAppProject.DetermineWebSubtype (document.FileName)) { + switch (AspNetFlavor.DetermineWebSubtype (document.FileName)) { case WebSubtype.WebForm: case WebSubtype.MasterPage: case WebSubtype.WebControl: @@ -167,7 +167,7 @@ namespace MonoDevelop.AspNet.WebForms } var clrVersion = ClrVersion.Net_2_0; - var aspProj = document.Project as AspNetAppProject; + var aspProj = document.Project as DotNetProject; if (aspProj != null && aspProj.TargetFramework.ClrVersion != ClrVersion.Default) clrVersion = aspProj.TargetFramework.ClrVersion; diff --git a/main/src/addins/AspNet/WebForms/WebFormsTypeContext.cs b/main/src/addins/AspNet/WebForms/WebFormsTypeContext.cs index 7778cf5844..5af1c706a6 100644 --- a/main/src/addins/AspNet/WebForms/WebFormsTypeContext.cs +++ b/main/src/addins/AspNet/WebForms/WebFormsTypeContext.cs @@ -51,8 +51,9 @@ namespace MonoDevelop.AspNet.WebForms public class WebFormsTypeContext { ICompilation compilation; - AspNetAppProject project; + DotNetProject project; WebFormsParsedDocument doc; + AspNetFlavor aspFlavor; public WebFormsParsedDocument Doc { get { @@ -66,7 +67,7 @@ namespace MonoDevelop.AspNet.WebForms } } - public AspNetAppProject Project { + public DotNetProject Project { get { return project; } @@ -75,6 +76,7 @@ namespace MonoDevelop.AspNet.WebForms return; project = value; compilation = null; + aspFlavor = project.GetFlavor<AspNetFlavor> (); } } @@ -336,7 +338,7 @@ namespace MonoDevelop.AspNet.WebForms IList<RegistrationInfo> GetRegistrationInfos () { if (project != null && doc != null) - return project.RegistrationCache.GetInfosForPath (Path.GetDirectoryName (doc.FileName)); + return aspFlavor.RegistrationCache.GetInfosForPath (Path.GetDirectoryName (doc.FileName)); return new[] { WebFormsRegistrationCache.MachineRegistrationInfo }; } @@ -570,7 +572,10 @@ namespace MonoDevelop.AspNet.WebForms IType AssemblyTypeLookup (string namespac, string tagName) { var fullName = namespac + "." + tagName; - return ReflectionHelper.ParseReflectionName (fullName).Resolve (Compilation); + var type = ReflectionHelper.ParseReflectionName (fullName).Resolve (Compilation); + if (type.Kind == TypeKind.Unknown) + return null; + return type; } public string GetControlPrefix (IType control) @@ -595,8 +600,8 @@ namespace MonoDevelop.AspNet.WebForms { string typeName = null; if (project != null && doc != null) { - string absolute = project.VirtualToLocalPath (virtualPath, doc.FileName); - typeName = project.GetCodebehindTypeName (absolute); + string absolute = aspFlavor.VirtualToLocalPath (virtualPath, doc.FileName); + typeName = aspFlavor.GetCodebehindTypeName (absolute); } return typeName ?? "System.Web.UI.UserControl"; } @@ -604,7 +609,10 @@ namespace MonoDevelop.AspNet.WebForms IType GetUserControlType (string virtualPath) { var name = GetUserControlTypeName (virtualPath); - return ReflectionHelper.ParseReflectionName (name).Resolve (Compilation); + var type = ReflectionHelper.ParseReflectionName (name).Resolve (Compilation); + if (type.Kind == TypeKind.Unknown) + return null; + return type; } } |