Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/addins/AspNet')
-rw-r--r--main/src/addins/AspNet/Commands/AddControllerDialog.cs6
-rw-r--r--main/src/addins/AspNet/Commands/AddViewDialog.cs19
-rw-r--r--main/src/addins/AspNet/Commands/AddViewFromControllerCommandHandler.cs7
-rw-r--r--main/src/addins/AspNet/Commands/GoToControllerCommandHandler.cs8
-rw-r--r--main/src/addins/AspNet/Commands/MvcCommandsCommonHandler.cs8
-rw-r--r--main/src/addins/AspNet/Execution/AspNetExecutionHandler.cs2
-rw-r--r--main/src/addins/AspNet/Execution/BrowserLauncher.cs2
-rw-r--r--main/src/addins/AspNet/Execution/XspOptionsPanel.cs4
-rw-r--r--main/src/addins/AspNet/Execution/XspOptionsPanelWidget.cs4
-rw-r--r--main/src/addins/AspNet/Makefile.am2
-rw-r--r--main/src/addins/AspNet/MonoDevelop.AspNet.csproj10
-rw-r--r--main/src/addins/AspNet/ProjectPad/AspNetFolderNodeCommandHandler.cs20
-rw-r--r--main/src/addins/AspNet/ProjectPad/AspNetProjectNodeBuilderExtension.cs3
-rw-r--r--main/src/addins/AspNet/ProjectPad/AspNetProjectNodeCommandHandler.cs18
-rw-r--r--main/src/addins/AspNet/Projects/AspMvcProject.cs88
-rw-r--r--main/src/addins/AspNet/Projects/AspNetAppProjectBinding.cs84
-rw-r--r--main/src/addins/AspNet/Projects/AspNetFlavor.cs (renamed from main/src/addins/AspNet/Projects/AspNetAppProject.cs)289
-rw-r--r--main/src/addins/AspNet/Projects/AspNetMvcFileTemplateCondition.cs2
-rw-r--r--main/src/addins/AspNet/Properties/MonoDevelop.AspNet.addin.xml43
-rw-r--r--main/src/addins/AspNet/Razor/Generator/RazorTemplatePreprocessor.cs9
-rw-r--r--main/src/addins/AspNet/Razor/RazorCSharpParser.cs6
-rw-r--r--main/src/addins/AspNet/Tests/Razor/RazorCompletionTesting.cs2
-rw-r--r--main/src/addins/AspNet/Tests/WebForms/WebFormsTesting.cs2
-rw-r--r--main/src/addins/AspNet/WebForms/MasterContentFileDescriptionTemplate.cs6
-rw-r--r--main/src/addins/AspNet/WebForms/WebFormsCodeBehind.cs17
-rw-r--r--main/src/addins/AspNet/WebForms/WebFormsCodeBehindTypeNameCache.cs7
-rw-r--r--main/src/addins/AspNet/WebForms/WebFormsDirectiveCompletion.cs9
-rw-r--r--main/src/addins/AspNet/WebForms/WebFormsEditorExtension.cs5
-rw-r--r--main/src/addins/AspNet/WebForms/WebFormsParser.cs2
-rw-r--r--main/src/addins/AspNet/WebForms/WebFormsRegistrationCache.cs19
-rw-r--r--main/src/addins/AspNet/WebForms/WebFormsToolboxNode.cs4
-rw-r--r--main/src/addins/AspNet/WebForms/WebFormsTypeContext.cs22
32 files changed, 296 insertions, 433 deletions
diff --git a/main/src/addins/AspNet/Commands/AddControllerDialog.cs b/main/src/addins/AspNet/Commands/AddControllerDialog.cs
index 603e60dbf0..c3af4ed5db 100644
--- a/main/src/addins/AspNet/Commands/AddControllerDialog.cs
+++ b/main/src/addins/AspNet/Commands/AddControllerDialog.cs
@@ -29,6 +29,7 @@ using System.Collections.Generic;
using Gtk;
using MonoDevelop.Core;
using MonoDevelop.AspNet.Projects;
+using MonoDevelop.Projects;
namespace MonoDevelop.AspNet.Commands
{
@@ -57,13 +58,14 @@ namespace MonoDevelop.AspNet.Commands
}
}
- public AddControllerDialog (AspNetAppProject project)
+ public AddControllerDialog (DotNetProject project)
{
Build ();
+ var ext = project.GetService<AspNetFlavor> ();
provider = project.LanguageBinding.GetCodeDomProvider ();
- loadedTemplateList = project.GetCodeTemplates ("AddController");
+ loadedTemplateList = ext.GetCodeTemplates ("AddController");
bool foundEmptyTemplate = false;
int templateIndex = 0;
foreach (string file in loadedTemplateList) {
diff --git a/main/src/addins/AspNet/Commands/AddViewDialog.cs b/main/src/addins/AspNet/Commands/AddViewDialog.cs
index c9d4c56a21..ef54af54bb 100644
--- a/main/src/addins/AspNet/Commands/AddViewDialog.cs
+++ b/main/src/addins/AspNet/Commands/AddViewDialog.cs
@@ -37,12 +37,14 @@ using MonoDevelop.AspNet.Projects;
using MonoDevelop.AspNet.WebForms.Dom;
using MonoDevelop.AspNet.WebForms;
using Gtk;
+using MonoDevelop.Projects;
namespace MonoDevelop.AspNet.Commands
{
class AddViewDialog : Dialog
{
- readonly AspNetAppProject project;
+ readonly DotNetProject project;
+ readonly AspNetFlavor aspFlavor;
IDictionary<string, IList<string>> loadedTemplateList;
IDictionary<string, ListStore> templateStore;
ListStore dataClassStore;
@@ -61,9 +63,10 @@ namespace MonoDevelop.AspNet.Commands
CheckButton partialCheck, stronglyTypedCheck, masterCheck;
Alignment typePanel, masterPanel;
- public AddViewDialog (AspNetAppProject project)
+ public AddViewDialog (DotNetProject project)
{
this.project = project;
+ aspFlavor = project.GetService<AspNetFlavor> ();
Build ();
@@ -73,14 +76,14 @@ namespace MonoDevelop.AspNet.Commands
loadedTemplateList = new Dictionary<string, IList<string>> ();
foreach (var engine in viewEngines) {
viewEngineCombo.AppendText (engine);
- loadedTemplateList[engine] = project.GetCodeTemplates ("AddView", engine);
+ loadedTemplateList[engine] = aspFlavor.GetCodeTemplates ("AddView", engine);
}
viewEngineCombo.Active = 0;
InitializeTemplateStore (loadedTemplateList);
ContentPlaceHolders = new List<string> ();
- string siteMaster = project.VirtualToLocalPath ("~/Views/Shared/Site.master", null);
+ string siteMaster = aspFlavor.VirtualToLocalPath ("~/Views/Shared/Site.master", null);
if (project.Files.GetFile (siteMaster) != null)
masterEntry.Text = "~/Views/Shared/Site.master";
@@ -221,7 +224,7 @@ namespace MonoDevelop.AspNet.Commands
IEnumerable<string> GetProperViewEngines ()
{
yield return "Aspx";
- if (project.SupportsRazorViewEngine)
+ if (aspFlavor.SupportsRazorViewEngine)
yield return "Razor";
}
@@ -307,7 +310,7 @@ namespace MonoDevelop.AspNet.Commands
return false;
if (!IsPartialView && HasMaster && ActiveViewEngine != "Razor") {
- if (String.IsNullOrEmpty (MasterFile) || !File.Exists (project.VirtualToLocalPath (oldMaster, null)))
+ if (String.IsNullOrEmpty (MasterFile) || !File.Exists (aspFlavor.VirtualToLocalPath (oldMaster, null)))
return false;
//PrimaryPlaceHolder can be empty
//Layout Page can be empty in Razor Views - it's usually set in _ViewStart.cshtml file
@@ -341,7 +344,7 @@ namespace MonoDevelop.AspNet.Commands
};
try {
if (MessageService.RunCustomDialog (dialog) == (int) ResponseType.Ok)
- masterEntry.Text = project.LocalToVirtualPath (dialog.SelectedFile.FilePath);
+ masterEntry.Text = aspFlavor.LocalToVirtualPath (dialog.SelectedFile.FilePath);
} finally {
dialog.Destroy ();
}
@@ -359,7 +362,7 @@ namespace MonoDevelop.AspNet.Commands
primaryPlaceholderStore.Clear ();
ContentPlaceHolders.Clear ();
- string realPath = project.VirtualToLocalPath (oldMaster, null);
+ string realPath = aspFlavor.VirtualToLocalPath (oldMaster, null);
if (!File.Exists (realPath))
return;
diff --git a/main/src/addins/AspNet/Commands/AddViewFromControllerCommandHandler.cs b/main/src/addins/AspNet/Commands/AddViewFromControllerCommandHandler.cs
index 0bf46856ec..0d732c6f54 100644
--- a/main/src/addins/AspNet/Commands/AddViewFromControllerCommandHandler.cs
+++ b/main/src/addins/AspNet/Commands/AddViewFromControllerCommandHandler.cs
@@ -28,6 +28,7 @@ using System;
using MonoDevelop.Components.Commands;
using MonoDevelop.Ide;
using MonoDevelop.AspNet.Projects;
+using MonoDevelop.Projects;
namespace MonoDevelop.AspNet.Commands
{
@@ -41,7 +42,7 @@ namespace MonoDevelop.AspNet.Commands
protected override void Run ()
{
var doc = IdeApp.Workbench.ActiveDocument;
- var project = (AspNetAppProject)doc.Project;
+ var project = (DotNetProject)doc.Project;
var currentLocation = doc.Editor.Caret.Location;
string controllerName = doc.ParsedDocument.GetTopLevelTypeDefinition (currentLocation).Name;
@@ -54,7 +55,7 @@ namespace MonoDevelop.AspNet.Commands
AddView (project, path, actionName);
}
- public static void AddView (AspNetAppProject project, string path, string name)
+ public static void AddView (DotNetProject project, string path, string name)
{
var provider = project.LanguageBinding.GetCodeDomProvider ();
if (provider == null)
@@ -125,7 +126,7 @@ namespace MonoDevelop.AspNet.Commands
if (System.IO.File.Exists (outputFile)) {
project.AddFile (outputFile);
- IdeApp.ProjectOperations.Save (project);
+ IdeApp.ProjectOperations.SaveAsync (project);
}
}
}
diff --git a/main/src/addins/AspNet/Commands/GoToControllerCommandHandler.cs b/main/src/addins/AspNet/Commands/GoToControllerCommandHandler.cs
index ed2251cb31..3e62a685bb 100644
--- a/main/src/addins/AspNet/Commands/GoToControllerCommandHandler.cs
+++ b/main/src/addins/AspNet/Commands/GoToControllerCommandHandler.cs
@@ -40,8 +40,12 @@ namespace MonoDevelop.AspNet.Commands
protected override void Update (CommandInfo info)
{
var doc = IdeApp.Workbench.ActiveDocument;
- AspNetAppProject project;
- if (doc == null || (project = doc.Project as AspNetAppProject) == null || !project.IsAspMvcProject) {
+ if (doc == null || doc.Project == null) {
+ info.Enabled = info.Visible = false;
+ return;
+ }
+ var aspFlavor = doc.Project.GetService<AspNetFlavor> ();
+ if (aspFlavor == null || !aspFlavor.IsAspMvcProject) {
info.Enabled = info.Visible = false;
return;
}
diff --git a/main/src/addins/AspNet/Commands/MvcCommandsCommonHandler.cs b/main/src/addins/AspNet/Commands/MvcCommandsCommonHandler.cs
index 03fa16fb63..fcc9aa7acd 100644
--- a/main/src/addins/AspNet/Commands/MvcCommandsCommonHandler.cs
+++ b/main/src/addins/AspNet/Commands/MvcCommandsCommonHandler.cs
@@ -38,8 +38,12 @@ namespace MonoDevelop.AspNet.Commands
public static void Update (CommandInfo info)
{
var doc = IdeApp.Workbench.ActiveDocument;
- AspNetAppProject project;
- if (doc == null || (project = doc.Project as AspNetAppProject) == null || !project.IsAspMvcProject || doc.ParsedDocument == null) {
+ if (doc == null || doc.Project == null || doc.ParsedDocument == null) {
+ info.Enabled = info.Visible = false;
+ return;
+ }
+ var aspFlavor = doc.Project.GetService<AspNetFlavor> ();
+ if (aspFlavor == null || !aspFlavor.IsAspMvcProject) {
info.Enabled = info.Visible = false;
return;
}
diff --git a/main/src/addins/AspNet/Execution/AspNetExecutionHandler.cs b/main/src/addins/AspNet/Execution/AspNetExecutionHandler.cs
index 2e0dcca894..19566f4656 100644
--- a/main/src/addins/AspNet/Execution/AspNetExecutionHandler.cs
+++ b/main/src/addins/AspNet/Execution/AspNetExecutionHandler.cs
@@ -89,7 +89,7 @@ namespace MonoDevelop.AspNet.Execution
return cmd != null && !string.IsNullOrEmpty (GetXspName (cmd));
}
- public IProcessAsyncOperation Execute (ExecutionCommand command, IConsole console)
+ public ProcessAsyncOperation Execute (ExecutionCommand command, IConsole console)
{
var cmd = (AspNetExecutionCommand) command;
var xspPath = GetXspPath (cmd);
diff --git a/main/src/addins/AspNet/Execution/BrowserLauncher.cs b/main/src/addins/AspNet/Execution/BrowserLauncher.cs
index 6a03216721..628b4cdd00 100644
--- a/main/src/addins/AspNet/Execution/BrowserLauncher.cs
+++ b/main/src/addins/AspNet/Execution/BrowserLauncher.cs
@@ -35,7 +35,7 @@ namespace MonoDevelop.AspNet.Execution
{
static class BrowserLauncher
{
- public static IProcessAsyncOperation LaunchDefaultBrowser (string url)
+ public static ProcessAsyncOperation LaunchDefaultBrowser (string url)
{
try {
DesktopService.ShowUrl (url);
diff --git a/main/src/addins/AspNet/Execution/XspOptionsPanel.cs b/main/src/addins/AspNet/Execution/XspOptionsPanel.cs
index 6bd97b965d..1565afca86 100644
--- a/main/src/addins/AspNet/Execution/XspOptionsPanel.cs
+++ b/main/src/addins/AspNet/Execution/XspOptionsPanel.cs
@@ -41,12 +41,12 @@ namespace MonoDevelop.AspNet.Execution
public override Widget CreatePanelWidget ()
{
- return panel = new XspOptionsPanelWidget ((AspNetAppProject) ConfiguredProject);
+ return panel = new XspOptionsPanelWidget (ConfiguredProject.GetService<AspNetFlavor> ());
}
public override void ApplyChanges ()
{
- panel.Store ((AspNetAppProject) ConfiguredProject);
+ panel.Store (ConfiguredProject.GetService<AspNetFlavor> ());
}
}
}
diff --git a/main/src/addins/AspNet/Execution/XspOptionsPanelWidget.cs b/main/src/addins/AspNet/Execution/XspOptionsPanelWidget.cs
index 18126f4836..da3a559f14 100644
--- a/main/src/addins/AspNet/Execution/XspOptionsPanelWidget.cs
+++ b/main/src/addins/AspNet/Execution/XspOptionsPanelWidget.cs
@@ -46,7 +46,7 @@ namespace MonoDevelop.AspNet.Execution
readonly FileEntry certLocation = new FileEntry ();
readonly Entry passwordEntry = new Entry { InvisibleChar = '●' };
- public XspOptionsPanelWidget (AspNetAppProject project)
+ public XspOptionsPanelWidget (AspNetFlavor project)
{
Build ();
@@ -165,7 +165,7 @@ namespace MonoDevelop.AspNet.Execution
ShowAll ();
}
- public void Store (AspNetAppProject project)
+ public void Store (AspNetFlavor project)
{
XspParameters xPar = project.XspParameters;
diff --git a/main/src/addins/AspNet/Makefile.am b/main/src/addins/AspNet/Makefile.am
index b8a06787c8..2dc30cad76 100644
--- a/main/src/addins/AspNet/Makefile.am
+++ b/main/src/addins/AspNet/Makefile.am
@@ -1,4 +1,4 @@
include $(top_srcdir)/xbuild.include
EXTRA_DIST += \
$(wildcard lib/*) \
- $(wildcard Templates/Common/*.cshtml)
+ $(wildcard Templates/MvcCommon/*.cshtml)
diff --git a/main/src/addins/AspNet/MonoDevelop.AspNet.csproj b/main/src/addins/AspNet/MonoDevelop.AspNet.csproj
index 26e3e80662..f0b66a4ae4 100644
--- a/main/src/addins/AspNet/MonoDevelop.AspNet.csproj
+++ b/main/src/addins/AspNet/MonoDevelop.AspNet.csproj
@@ -9,6 +9,7 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDevelop.AspNet</AssemblyName>
<RootNamespace>MonoDevelop.AspNet</RootNamespace>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
@@ -125,6 +126,7 @@
<Reference Include="System.Web.WebPages.Razor">
<HintPath>..\..\..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Razor.dll</HintPath>
</Reference>
+ <Reference Condition="!Exists('$(SolutionDir)\..\.git')" Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<Reference Include="System.Web.Mvc">
<HintPath>..\..\..\packages\Microsoft.AspNet.Mvc.4.0.30506.0\lib\net40\System.Web.Mvc.dll</HintPath>
</Reference>
@@ -187,8 +189,6 @@
<Compile Include="Razor\EditorParserFixed\RazorResources.Designer.cs" />
<Compile Include="Projects\AspMvcProject.cs" />
<Compile Include="Projects\AspMvcProjectConfiguration.cs" />
- <Compile Include="Projects\AspNetAppProject.cs" />
- <Compile Include="Projects\AspNetAppProjectBinding.cs" />
<Compile Include="Projects\AspNetAppProjectConfiguration.cs" />
<Compile Include="Projects\AspNetMSBuildImportProvider.cs" />
<Compile Include="WebForms\MasterContentFileDescriptionTemplate.cs" />
@@ -290,6 +290,7 @@
<Compile Include="Razor\RazorCSharpParsedDocument.cs" />
<Compile Include="Razor\RazorPageInfo.cs" />
<Compile Include="WebForms\WebFormsTypeContext.cs" />
+ <Compile Include="Projects\AspNetFlavor.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Makefile.am" />
@@ -490,10 +491,9 @@
</ItemGroup>
<Target Name="BeforeBuild">
<PropertyGroup>
- <NuGet>..\..\..\external\nuget-binary\NuGet.exe</NuGet>
+ <NuGet>$(SolutionDir)\external\nuget-binary\NuGet.exe</NuGet>
<NuGet Condition="$(OS)=='Unix'">mono $(NuGet)</NuGet>
- <SlnDir>..\..\..</SlnDir>
</PropertyGroup>
- <Exec Command="$(NuGet) restore -SolutionDirectory $(SlnDir)" />
+ <Exec Condition="Exists('$(SolutionDir)\..\.git')" Command="$(NuGet) restore -SolutionDirectory $(SolutionDir)" />
</Target>
</Project>
diff --git a/main/src/addins/AspNet/ProjectPad/AspNetFolderNodeCommandHandler.cs b/main/src/addins/AspNet/ProjectPad/AspNetFolderNodeCommandHandler.cs
index 30e870fccc..b6f5169fc6 100644
--- a/main/src/addins/AspNet/ProjectPad/AspNetFolderNodeCommandHandler.cs
+++ b/main/src/addins/AspNet/ProjectPad/AspNetFolderNodeCommandHandler.cs
@@ -31,7 +31,8 @@ using MonoDevelop.Ide.Gui.Components;
using MonoDevelop.Ide.Gui.Pads.ProjectPad;
using MonoDevelop.Ide;
using MonoDevelop.AspNet.Projects;
-using MonoDevelop.AspNet.Commands;
+using MonoDevelop.AspNet.Commands;
+using MonoDevelop.Projects;
namespace MonoDevelop.AspNet.ProjectPad
{
@@ -40,8 +41,9 @@ namespace MonoDevelop.AspNet.ProjectPad
[CommandUpdateHandler (AspNetCommands.AddController)]
public void AddControllerUpdate (CommandInfo info)
{
- var project = CurrentNode.GetParentDataItem (typeof (AspNetAppProject), true) as AspNetAppProject;
- if (project == null || !project.IsAspMvcProject) {
+ var project = CurrentNode.GetParentDataItem (typeof (DotNetProject), true) as DotNetProject;
+ var aspFlavor = project != null ? project.GetService<AspNetFlavor> () : null;
+ if (aspFlavor == null || !aspFlavor.IsAspMvcProject) {
info.Enabled = info.Visible = false;
return;
}
@@ -54,7 +56,7 @@ namespace MonoDevelop.AspNet.ProjectPad
[CommandHandler (AspNetCommands.AddController)]
public void AddController ()
{
- var project = (AspNetAppProject) CurrentNode.GetParentDataItem (typeof (AspNetAppProject), true);
+ var project = (DotNetProject) CurrentNode.GetParentDataItem (typeof (DotNetProject), true);
object currentItem = CurrentNode.DataItem;
@@ -68,7 +70,7 @@ namespace MonoDevelop.AspNet.ProjectPad
nav.Expanded = true;
}
- public static void AddController (AspNetAppProject project, string path, string name)
+ public static void AddController (DotNetProject project, string path, string name)
{
var provider = project.LanguageBinding.GetCodeDomProvider ();
if (provider == null)
@@ -119,15 +121,15 @@ namespace MonoDevelop.AspNet.ProjectPad
if (System.IO.File.Exists (outputFile)) {
project.AddFile (outputFile);
- IdeApp.ProjectOperations.Save (project);
+ IdeApp.ProjectOperations.SaveAsync (project);
}
}
[CommandUpdateHandler (AspNetCommands.AddView)]
public void AddViewUpdate (CommandInfo info)
{
- var project = CurrentNode.GetParentDataItem (typeof (AspNetAppProject), true) as AspNetAppProject;
- if (project == null || !project.IsAspMvcProject) {
+ var project = CurrentNode.GetParentDataItem<DotNetProject> (true);
+ if (project == null || !project.HasFlavor<AspNetFlavor>() || !project.GetFlavor<AspNetFlavor>().IsAspMvcProject) {
info.Enabled = info.Visible = false;
return;
}
@@ -140,7 +142,7 @@ namespace MonoDevelop.AspNet.ProjectPad
[CommandHandler (AspNetCommands.AddView)]
public void AddView ()
{
- var project = (AspNetAppProject) CurrentNode.GetParentDataItem (typeof (AspNetAppProject), true);
+ var project = CurrentNode.GetParentDataItem<DotNetProject> (true);
object currentItem = CurrentNode.DataItem;
diff --git a/main/src/addins/AspNet/ProjectPad/AspNetProjectNodeBuilderExtension.cs b/main/src/addins/AspNet/ProjectPad/AspNetProjectNodeBuilderExtension.cs
index da125b8376..572f5e864b 100644
--- a/main/src/addins/AspNet/ProjectPad/AspNetProjectNodeBuilderExtension.cs
+++ b/main/src/addins/AspNet/ProjectPad/AspNetProjectNodeBuilderExtension.cs
@@ -29,6 +29,7 @@ using System;
using MonoDevelop.Ide.Gui.Components;
using MonoDevelop.AspNet.Projects;
+using MonoDevelop.Projects;
namespace MonoDevelop.AspNet.ProjectPad
{
@@ -36,7 +37,7 @@ namespace MonoDevelop.AspNet.ProjectPad
{
public override bool CanBuildNode (Type dataType)
{
- return typeof(AspNetAppProject).IsAssignableFrom (dataType);
+ return typeof(DotNetProject).IsAssignableFrom (dataType);
}
public override Type CommandHandlerType {
diff --git a/main/src/addins/AspNet/ProjectPad/AspNetProjectNodeCommandHandler.cs b/main/src/addins/AspNet/ProjectPad/AspNetProjectNodeCommandHandler.cs
index 3bf027f7c8..3373c62b1b 100644
--- a/main/src/addins/AspNet/ProjectPad/AspNetProjectNodeCommandHandler.cs
+++ b/main/src/addins/AspNet/ProjectPad/AspNetProjectNodeCommandHandler.cs
@@ -42,21 +42,25 @@ namespace MonoDevelop.AspNet.ProjectPad
[CommandHandler (AspNetCommands.AddAspNetDirectory)]
public void OnAddSpecialDirectory (object ob)
{
- AspNetAppProject proj = CurrentNode.DataItem as AspNetAppProject;
+ var proj = CurrentNode.DataItem as DotNetProject;
if (proj == null)
return;
proj.AddDirectory ((string) ob);
- IdeApp.ProjectOperations.Save (proj);
+ IdeApp.ProjectOperations.SaveAsync (proj);
}
[CommandUpdateHandler (AspNetCommands.AddAspNetDirectory)]
public void OnAddSpecialDirectoryUpdate (CommandArrayInfo info)
{
- AspNetAppProject proj = CurrentNode.DataItem as AspNetAppProject;
- if (proj == null)
- return;
-
- List<string> dirs = new List<string> (proj.GetSpecialDirectories ());
+ var proj = CurrentNode.DataItem as DotNetProject;
+ if (proj == null)
+ return;
+
+ var asp = proj.GetFlavor<AspNetFlavor> ();
+ if (asp == null)
+ return;
+
+ List<string> dirs = new List<string> (asp.GetSpecialDirectories ());
dirs.Sort ();
List<FilePath> fullPaths = new List<FilePath> (dirs.Count);
foreach (string s in dirs)
diff --git a/main/src/addins/AspNet/Projects/AspMvcProject.cs b/main/src/addins/AspNet/Projects/AspMvcProject.cs
index 8161c25ee2..9faf060a04 100644
--- a/main/src/addins/AspNet/Projects/AspMvcProject.cs
+++ b/main/src/addins/AspNet/Projects/AspMvcProject.cs
@@ -31,37 +31,21 @@ using MonoDevelop.Projects;
namespace MonoDevelop.AspNet.Projects
{
- abstract class AspMvcProject : AspNetAppProject
+ abstract class AspMvcProject : AspNetFlavor
{
- protected AspMvcProject ()
- {
- }
-
- protected AspMvcProject (string languageName)
- : base (languageName)
- {
- }
-
- protected AspMvcProject (string languageName, ProjectCreateInformation info, XmlElement projectOptions)
- : base (languageName, info, projectOptions)
- {
- }
-
- public override SolutionItemConfiguration CreateConfiguration (string name)
+ protected override SolutionItemConfiguration OnCreateConfiguration (string name)
{
var conf = new AspMvcProjectConfiguration (name);
- conf.CopyFrom (base.CreateConfiguration (name));
+ conf.CopyFrom (base.OnCreateConfiguration (name));
return conf;
}
- public override IEnumerable<string> GetProjectTypes ()
+ protected override void OnGetProjectTypes (HashSet<string> types)
{
- yield return "AspNetMvc";
- foreach (var t in base.GetProjectTypes ())
- yield return t;
+ types.Add ("AspNetMvc");
}
- public override bool SupportsFramework (MonoDevelop.Core.Assemblies.TargetFramework framework)
+ protected override bool OnGetSupportsFramework (MonoDevelop.Core.Assemblies.TargetFramework framework)
{
return framework.CanReferenceAssembliesTargetingFramework (MonoDevelop.Core.Assemblies.TargetFrameworkMoniker.NET_3_5);
}
@@ -75,20 +59,6 @@ namespace MonoDevelop.AspNet.Projects
class AspMvc1Project : AspMvcProject
{
- public AspMvc1Project ()
- {
- }
-
- public AspMvc1Project (string languageName)
- : base (languageName)
- {
- }
-
- public AspMvc1Project (string languageName, ProjectCreateInformation info, XmlElement projectOptions)
- : base (languageName, info, projectOptions)
- {
- }
-
protected override string GetDefaultAspNetMvcVersion ()
{
return "1.0.0.0";
@@ -97,20 +67,6 @@ namespace MonoDevelop.AspNet.Projects
class AspMvc2Project : AspMvcProject
{
- public AspMvc2Project ()
- {
- }
-
- public AspMvc2Project (string languageName)
- : base (languageName)
- {
- }
-
- public AspMvc2Project (string languageName, ProjectCreateInformation info, XmlElement projectOptions)
- : base (languageName, info, projectOptions)
- {
- }
-
protected override string GetDefaultAspNetMvcVersion ()
{
return "2.0.0.0";
@@ -119,21 +75,7 @@ namespace MonoDevelop.AspNet.Projects
class AspMvc3Project : AspMvcProject
{
- public AspMvc3Project ()
- {
- }
-
- public AspMvc3Project (string languageName)
- : base (languageName)
- {
- }
-
- public AspMvc3Project (string languageName, ProjectCreateInformation info, XmlElement projectOptions)
- : base (languageName, info, projectOptions)
- {
- }
-
- public override bool SupportsFramework (MonoDevelop.Core.Assemblies.TargetFramework framework)
+ protected override bool OnGetSupportsFramework (MonoDevelop.Core.Assemblies.TargetFramework framework)
{
return framework.CanReferenceAssembliesTargetingFramework (MonoDevelop.Core.Assemblies.TargetFrameworkMoniker.NET_4_0);
}
@@ -146,21 +88,7 @@ namespace MonoDevelop.AspNet.Projects
class AspMvc4Project : AspMvcProject
{
- public AspMvc4Project ()
- {
- }
-
- public AspMvc4Project (string languageName)
- : base (languageName)
- {
- }
-
- public AspMvc4Project (string languageName, ProjectCreateInformation info, XmlElement projectOptions)
- : base (languageName, info, projectOptions)
- {
- }
-
- public override bool SupportsFramework (MonoDevelop.Core.Assemblies.TargetFramework framework)
+ protected override bool OnGetSupportsFramework (MonoDevelop.Core.Assemblies.TargetFramework framework)
{
return framework.CanReferenceAssembliesTargetingFramework (MonoDevelop.Core.Assemblies.TargetFrameworkMoniker.NET_4_0);
}
diff --git a/main/src/addins/AspNet/Projects/AspNetAppProjectBinding.cs b/main/src/addins/AspNet/Projects/AspNetAppProjectBinding.cs
deleted file mode 100644
index 3a89feac81..0000000000
--- a/main/src/addins/AspNet/Projects/AspNetAppProjectBinding.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-//
-// AspNetAppProjectBinding.cs: Project binding for AspNetAppProject
-//
-// Authors:
-// Michael Hutchinson <m.j.hutchinson@gmail.com>
-//
-// Copyright (C) 2006 Michael Hutchinson
-//
-//
-// This source code is licenced under The MIT License:
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.IO;
-using MonoDevelop.Core;
-using MonoDevelop.Projects;
-using MonoDevelop.Core.Serialization;
-using System.Xml;
-
-namespace MonoDevelop.AspNet.Projects
-{
- //based heavily on DotNetProjectBinding
- public class AspNetAppProjectBinding : IProjectBinding
- {
-
- public string Name {
- get { return "AspNetApp"; }
- }
-
- public Project CreateProject (ProjectCreateInformation info, XmlElement projectOptions)
- {
- string lang = projectOptions.GetAttribute ("language");
- return CreateProject (lang, info, projectOptions);
- }
-
- public Project CreateProject (string language, ProjectCreateInformation info, XmlElement projectOptions)
- {
- return new AspNetAppProject (language, info, projectOptions);
- }
-
- public Project CreateSingleFileProject (string file)
- {
- //TODO: get page language
- string language = "C#";
-
- var info = new ProjectCreateInformation () {
- ProjectName = Path.GetFileNameWithoutExtension (file),
- SolutionPath = Path.GetDirectoryName (file),
- ProjectBasePath = Path.GetDirectoryName (file),
- };
- var project = CreateProject (language, info, null);
- project.Files.Add (new ProjectFile (file));
- return project;
- }
-
- public bool CanCreateSingleFileProject (string sourceFile)
- {
- WebSubtype type = AspNetAppProject.DetermineWebSubtype (sourceFile);
-
- return ((type == WebSubtype.WebForm)
- || (type == WebSubtype.WebHandler)
- || (type == WebSubtype.WebService));
- }
- }
-}
diff --git a/main/src/addins/AspNet/Projects/AspNetAppProject.cs b/main/src/addins/AspNet/Projects/AspNetFlavor.cs
index ef44893202..96902a8fdb 100644
--- a/main/src/addins/AspNet/Projects/AspNetAppProject.cs
+++ b/main/src/addins/AspNet/Projects/AspNetFlavor.cs
@@ -16,10 +16,10 @@
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
-//
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
-//
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -49,148 +49,130 @@ using MonoDevelop.Ide.TypeSystem;
using MonoDevelop.Projects;
using MonoDevelop.AspNet.Execution;
using MonoDevelop.AspNet.WebForms;
+using System.Threading.Tasks;
namespace MonoDevelop.AspNet.Projects
{
[DataInclude (typeof(AspNetAppProjectConfiguration))]
- public class AspNetAppProject : DotNetAssemblyProject
+ public class AspNetFlavor : DotNetProjectExtension
{
[ItemProperty("XspParameters", IsExternal=true)]
XspParameters xspParameters = new XspParameters ();
WebFormsRegistrationCache registrationCache;
WebFormsCodeBehindTypeNameCache codebehindTypeNameCache;
-
+
#region properties
- public override IEnumerable<string> GetProjectTypes ()
+ protected override void OnGetProjectTypes (HashSet<string> types)
{
- yield return "AspNetApp";
- foreach (var t in base.GetProjectTypes ())
- yield return t;
+ types.Add ("AspNetApp");
}
- public override bool IsLibraryBasedProjectType {
+ protected override bool IsLibraryBasedProjectType {
get { return true; }
}
-
+
public XspParameters XspParameters {
get { return xspParameters; }
}
-
+
internal WebFormsRegistrationCache RegistrationCache {
get {
if (registrationCache == null)
- registrationCache = new WebFormsRegistrationCache (this);
+ registrationCache = new WebFormsRegistrationCache (Project);
return registrationCache;
}
}
-
+
#endregion
-
+
#region constructors
-
- public AspNetAppProject ()
- {
- Init ();
- }
-
- public AspNetAppProject (string languageName)
- : base (languageName)
- {
- Init ();
- }
-
- public AspNetAppProject (string languageName, ProjectCreateInformation info, XmlElement projectOptions)
- : base (languageName, info, projectOptions)
+
+ protected override void OnInitializeNew (string languageName, ProjectCreateInformation info, XmlElement projectOptions)
{
- Init ();
-
+ base.OnInitializeNew (languageName, info, projectOptions);
+ codebehindTypeNameCache = new WebFormsCodeBehindTypeNameCache (Project);
+
var binPath = info == null? (FilePath)"bin" : info.BinPath;
- foreach (var cfg in Configurations.Cast<AspNetAppProjectConfiguration> ())
+ foreach (var cfg in Project.Configurations.Cast<DotNetProjectConfiguration> ())
cfg.OutputDirectory = binPath;
- }
-
- public override SolutionItemConfiguration CreateConfiguration (string name)
+ }
+
+ protected override SolutionItemConfiguration OnCreateConfiguration (string name)
{
var conf = new AspNetAppProjectConfiguration (name);
- conf.CopyFrom (base.CreateConfiguration (name));
- conf.OutputDirectory = BaseDirectory.IsNullOrEmpty? "bin" : (string)BaseDirectory.Combine ("bin");
+ conf.CopyFrom (base.OnCreateConfiguration (name));
+ conf.OutputDirectory = Project.BaseDirectory.IsNullOrEmpty? "bin" : (string)Project.BaseDirectory.Combine ("bin");
return conf;
}
-
- void Init ()
- {
- codebehindTypeNameCache = new WebFormsCodeBehindTypeNameCache (this);
- }
- public new AspNetAppProjectConfiguration GetConfiguration (ConfigurationSelector configuration)
+ public AspNetAppProjectConfiguration GetConfiguration (ConfigurationSelector configuration)
{
- return (AspNetAppProjectConfiguration) base.GetConfiguration (configuration);
+ return (AspNetAppProjectConfiguration) Project.GetConfiguration (configuration);
}
-
+
#endregion
-
+
public override void Dispose ()
{
codebehindTypeNameCache.Dispose ();
RegistrationCache.Dispose ();
base.Dispose ();
}
-
+
#region build/prebuild/execute
-
-
- protected override BuildResult DoBuild (IProgressMonitor monitor, ConfigurationSelector configuration)
+
+
+ protected override Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration)
{
//if no files are set to compile, then some compilers will error out
//though this is valid with ASP.NET apps, so we just avoid calling the compiler in this case
bool needsCompile = false;
- foreach (ProjectFile pf in Files) {
+ foreach (ProjectFile pf in Project.Files) {
if (pf.BuildAction == BuildAction.Compile) {
needsCompile = true;
break;
}
}
-
+
if (needsCompile)
- return base.DoBuild (monitor, configuration);
- return new BuildResult ();
+ return base.OnBuild (monitor, configuration);
+ return Task.FromResult (BuildResult.Success);
}
-
+
ExecutionCommand CreateExecutionCommand (ConfigurationSelector config, AspNetAppProjectConfiguration configuration)
{
return new AspNetExecutionCommand {
ClrVersion = configuration.ClrVersion,
DebugMode = configuration.DebugMode,
XspParameters = XspParameters,
- BaseDirectory = BaseDirectory,
- TargetRuntime = TargetRuntime,
- TargetFramework = TargetFramework,
- UserAssemblyPaths = GetUserAssemblyPaths (config),
+ BaseDirectory = Project.BaseDirectory,
+ TargetRuntime = Project.TargetRuntime,
+ TargetFramework = Project.TargetFramework,
+ UserAssemblyPaths = Project.GetUserAssemblyPaths (config),
EnvironmentVariables = configuration.EnvironmentVariables,
};
}
-
+
protected override bool OnGetCanExecute (ExecutionContext context, ConfigurationSelector configuration)
{
var cmd = CreateExecutionCommand (configuration, GetConfiguration (configuration));
return context.ExecutionHandler.CanExecute (cmd);
}
-
- protected override void DoExecute (IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
+
+ protected async override Task OnExecute (ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
{
//check XSP is available
-
+
var cfg = GetConfiguration (configuration);
var cmd = CreateExecutionCommand (configuration, cfg);
var browserExcTarget = (BrowserExecutionTarget) context.ExecutionTarget;
IConsole console = null;
- var operationMonitor = new AggregatedOperationMonitor (monitor);
bool isXsp = true; //FIXME: fix this when it might not be true - should delegate to the ExecutionHandler
-
+
try {
//HACK: check XSP exists first, because error UX is cleaner w/o displaying a blank console pad.
if (isXsp) {
@@ -211,8 +193,8 @@ namespace MonoDevelop.AspNet.Projects
// The running Port value is now captured in the XspBrowserLauncherConsole object
string url = String.Format ("http://{0}", XspParameters.Address);
-
-
+
+
if (isXsp) {
console = new XspBrowserLauncherConsole (console, delegate (string port) {
if (browserExcTarget != null)
@@ -221,53 +203,52 @@ namespace MonoDevelop.AspNet.Projects
BrowserLauncher.LaunchDefaultBrowser (String.Format("{0}:{1}", url, port));
});
}
-
+
monitor.Log.WriteLine ("Running web server...");
-
+
var op = context.ExecutionHandler.Execute (cmd, console);
- operationMonitor.AddOperation (op); //handles cancellation
-
+
if (!isXsp) {
if (browserExcTarget != null)
browserExcTarget.DesktopApp.Launch (url);
else
BrowserLauncher.LaunchDefaultBrowser (url);
}
-
- op.WaitForCompleted ();
-
+
+ using (monitor.CancellationToken.Register (op.Cancel))
+ await op.Task;
+
monitor.Log.WriteLine ("The web server exited with code: {0}", op.ExitCode);
-
+
} catch (Exception ex) {
if (!(ex is UserException)) {
LoggingService.LogError ("Could not launch ASP.NET web server.", ex);
}
monitor.ReportError ("Could not launch web server.", ex);
} finally {
- operationMonitor.Dispose ();
if (console != null)
console.Dispose ();
}
}
-
+
#endregion
-
+
#region File utility methods
-
+
public WebSubtype DetermineWebSubtype (ProjectFile file)
{
- if (LanguageBinding != null && LanguageBinding.IsSourceCodeFile (file.FilePath))
+ if (Project.LanguageBinding != null && Project.LanguageBinding.IsSourceCodeFile (file.FilePath))
return WebSubtype.Code;
return DetermineWebSubtype (file.Name);
}
-
+
public static WebSubtype DetermineWebSubtype (string fileName)
{
string extension = Path.GetExtension (fileName);
if (extension == null)
return WebSubtype.None;
extension = extension.ToUpperInvariant ().TrimStart ('.');
-
+
//NOTE: No way to identify WebSubtype.Code from here
//use the instance method for that
switch (extension) {
@@ -325,21 +306,21 @@ namespace MonoDevelop.AspNet.Projects
return WebSubtype.None;
}
}
-
+
#endregion
-
+
#region special files
-
+
#endregion
-
+
public ProjectFile ResolveVirtualPath (string virtualPath, string relativeToFile)
{
string name = VirtualToLocalPath (virtualPath, relativeToFile);
if (name == null)
return null;
- return Files.GetFile (name);
+ return Project.Files.GetFile (name);
}
-
+
public string VirtualToLocalPath (string virtualPath, string relativeToFile)
{
if (string.IsNullOrEmpty (virtualPath) || virtualPath [0] == '/' || virtualPath.IndexOf (':') > -1)
@@ -351,60 +332,60 @@ namespace MonoDevelop.AspNet.Projects
virtualPath = virtualPath.Substring (2);
else
virtualPath = virtualPath.Substring (1);
- relativeToDir = BaseDirectory;
+ relativeToDir = Project.BaseDirectory;
} else {
relativeToDir = String.IsNullOrEmpty (relativeToFile)
- ? BaseDirectory
+ ? Project.BaseDirectory
: (FilePath) Path.GetDirectoryName (relativeToFile);
}
-
+
virtualPath = virtualPath.Replace ('/', Path.DirectorySeparatorChar);
return relativeToDir.Combine (virtualPath).FullPath;
}
-
+
public string LocalToVirtualPath (string filename)
{
- string rel = FileService.AbsoluteToRelativePath (BaseDirectory, filename);
+ string rel = FileService.AbsoluteToRelativePath (Project.BaseDirectory, filename);
return "~/" + rel.Replace (Path.DirectorySeparatorChar, '/');
}
-
+
public string LocalToVirtualPath (ProjectFile file)
{
return LocalToVirtualPath (file.FilePath);
}
-
+
#region Reference handling
-
+
protected override void OnReferenceAddedToProject (ProjectReferenceEventArgs e)
{
//short-circuit if the project is being deserialised
- if (Loading) {
+ if (Project.Loading) {
base.OnReferenceAddedToProject (e);
return;
}
-
+
UpdateWebConfigRefs ();
-
+
base.OnReferenceAddedToProject (e);
}
-
+
protected override void OnReferenceRemovedFromProject (ProjectReferenceEventArgs e)
{
//short-circuit if the project is being deserialised
- if (Loading) {
+ if (Project.Loading) {
base.OnReferenceAddedToProject (e);
return;
}
-
+
UpdateWebConfigRefs ();
-
+
base.OnReferenceRemovedFromProject (e);
}
-
+
void UpdateWebConfigRefs ()
{
var refs = new List<string> ();
- foreach (var reference in References) {
+ foreach (var reference in Project.References) {
//local copied assemblies are copied to the bin directory so ASP.NET references them automatically
if (reference.LocalCopy && (reference.ReferenceType == ReferenceType.Project || reference.ReferenceType == ReferenceType.Assembly))
continue;
@@ -419,39 +400,39 @@ namespace MonoDevelop.AspNet.Projects
continue;
refs.Add (reference.Reference);
}
-
+
var webConfig = GetWebConfig ();
if (webConfig == null || !File.Exists (webConfig.FilePath))
return;
-
+
var textFile = TextFileProvider.Instance.GetEditableTextFile (webConfig.FilePath);
//use textfile API because it's write safe (writes out to another file then moves)
if (textFile == null)
textFile = MonoDevelop.Projects.Text.TextFile.ReadFile (webConfig.FilePath);
-
+
//can't use System.Web.Configuration.WebConfigurationManager, as it can only access virtual paths within an app
//so need full manual handling
try {
var doc = new XmlDocument ();
-
+
//FIXME: PreserveWhitespace doesn't handle whitespace in attribute lists
//doc.PreserveWhitespace = true;
doc.LoadXml (textFile.Text);
-
+
//hunt our way to the assemblies element, creating elements if necessary
XmlElement configElement = doc.DocumentElement;
if (configElement == null || string.Compare (configElement.Name, "configuration", StringComparison.OrdinalIgnoreCase) != 0) {
configElement = (XmlElement) doc.AppendChild (doc.CreateNode (XmlNodeType.Document, "configuration", null));
}
- XmlElement webElement = GetNamedXmlElement (doc, configElement, "system.web");
+ XmlElement webElement = GetNamedXmlElement (doc, configElement, "system.web");
XmlElement compilationNode = GetNamedXmlElement (doc, webElement, "compilation");
XmlElement assembliesNode = GetNamedXmlElement (doc, compilationNode, "assemblies");
-
+
List<XmlNode> existingAdds = new List<XmlNode> ();
foreach (XmlNode node in assembliesNode)
if (string.Compare (node.Name, "add", StringComparison.OrdinalIgnoreCase) == 0)
existingAdds.Add (node);
-
+
//add refs to the doc if they're not in it
foreach (string reference in refs) {
int index = 0;
@@ -477,27 +458,27 @@ namespace MonoDevelop.AspNet.Projects
assembliesNode.AppendChild (newAdd);
}
}
-
+
//any nodes that weren't removed from the existingAdds list are old/redundant, so remove from doc
foreach (XmlNode node in existingAdds)
assembliesNode.RemoveChild (node);
-
+
StringWriter sw = new StringWriter ();
XmlTextWriter tw = new XmlTextWriter (sw);
tw.Formatting = Formatting.Indented;
doc.WriteTo (tw);
tw.Flush ();
textFile.Text = sw.ToString ();
-
+
MonoDevelop.Projects.Text.TextFile tf = textFile as MonoDevelop.Projects.Text.TextFile;
if (tf != null)
tf.Save ();
} catch (Exception e) {
- LoggingService.LogWarning ("Could not modify application web.config in project " + Name, e);
+ LoggingService.LogWarning ("Could not modify application web.config in project " + Project.Name, e);
}
}
-
-
+
+
XmlElement GetNamedXmlElement (XmlDocument doc, XmlElement parent, string name)
{
XmlElement result = null;
@@ -513,78 +494,78 @@ namespace MonoDevelop.AspNet.Projects
}
return result;
}
-
+
ProjectFile GetWebConfig ()
{
- var webConf = BaseDirectory.Combine ("web.config");
- foreach (var file in Files)
+ var webConf = Project.BaseDirectory.Combine ("web.config");
+ foreach (var file in Project.Files)
if (string.Compare (file.FilePath.ToString (), webConf, StringComparison.OrdinalIgnoreCase) == 0)
return file;
return null;
}
-
+
bool IsWebConfig (FilePath file)
{
- var webConf = BaseDirectory.Combine ("web.config");
+ var webConf = Project.BaseDirectory.Combine ("web.config");
return (string.Compare (file, webConf, StringComparison.OrdinalIgnoreCase) == 0);
}
-
+
#endregion
-
+
#region File event handlers
-
+
protected override void OnFileAddedToProject (ProjectFileEventArgs e)
{
//short-circuit if the project is being deserialised
- if (Loading) {
+ if (Project.Loading) {
base.OnFileAddedToProject (e);
return;
}
bool webConfigChange = false;
List<string> filesToAdd = new List<string> ();
-
+
foreach (ProjectFileEventInfo fargs in e) {
IEnumerable<string> files = MonoDevelop.DesignerSupport.CodeBehind.GuessDependencies
- (this, fargs.ProjectFile, groupedExtensions);
+ (Project, fargs.ProjectFile, groupedExtensions);
if (files != null)
filesToAdd.AddRange (files);
if (IsWebConfig (fargs.ProjectFile.FilePath))
webConfigChange = true;
}
-
+
if (webConfigChange)
UpdateWebConfigRefs ();
-
+
//let the base fire the event before we add files
//don't want to fire events out of order of files being added
base.OnFileAddedToProject (e);
-
+
//make sure that the parent and child files are in the project
foreach (string file in filesToAdd) {
//NOTE: this only adds files if they are not already in the project
- AddFile (file);
+ Project.AddFile (file);
}
}
-
- public override string GetDefaultBuildAction (string fileName)
+
+ protected override string OnGetDefaultBuildAction (string fileName)
{
-
+
WebSubtype type = DetermineWebSubtype (fileName);
switch (type) {
case WebSubtype.Code:
return BuildAction.Compile;
case WebSubtype.None:
- return base.GetDefaultBuildAction (fileName);
+ return base.OnGetDefaultBuildAction (fileName);
default:
return BuildAction.Content;
}
}
-
+
static string[] groupedExtensions = { ".aspx", ".master", ".ashx", ".ascx", ".asmx", ".asax" };
-
+
#endregion
-
+
public virtual IEnumerable<string> GetSpecialDirectories ()
{
yield return "App_Browsers";
@@ -598,12 +579,12 @@ namespace MonoDevelop.AspNet.Projects
yield return "Models";
yield return "Controllers";
}
-
+
// For "web site" projects
// "App_WebReferences", "App_Resources","App_Themes", "App_Code",
}
-
- protected override IList<string> GetCommonBuildActions ()
+
+ protected override IList<string> OnGetCommonBuildActions ()
{
return new [] {
BuildAction.None,
@@ -612,7 +593,7 @@ namespace MonoDevelop.AspNet.Projects
BuildAction.EmbeddedResource,
};
}
-
+
public string GetCodebehindTypeName (string fileName)
{
lock (codebehindTypeNameCache)
@@ -624,8 +605,8 @@ namespace MonoDevelop.AspNet.Projects
var files = new List<string> ();
var names = new HashSet<string> ();
- string asmDir = Path.GetDirectoryName (typeof (AspNetAppProject).Assembly.Location);
- string lang = LanguageName;
+ string asmDir = Path.GetDirectoryName (GetType().Assembly.Location);
+ string lang = Project.LanguageName;
if (lang == "C#") {
lang = "CSharp";
}
@@ -635,8 +616,8 @@ namespace MonoDevelop.AspNet.Projects
}
var dirs = new [] {
- Path.Combine (BaseDirectory, "CodeTemplates", type),
- Path.Combine (BaseDirectory, "CodeTemplates", lang, type),
+ Path.Combine (Project.BaseDirectory, "CodeTemplates", type),
+ Path.Combine (Project.BaseDirectory, "CodeTemplates", lang, type),
Path.Combine (asmDir, "CodeTemplates", type),
Path.Combine (asmDir, "CodeTemplates", lang, type),
};
@@ -650,12 +631,12 @@ namespace MonoDevelop.AspNet.Projects
return files;
}
- protected override void PopulateSupportFileList (FileCopySet list, ConfigurationSelector configuration)
+ protected override void OnPopulateSupportFileList (FileCopySet list, ConfigurationSelector configuration)
{
- base.PopulateSupportFileList (list, configuration);
+ base.OnPopulateSupportFileList (list, configuration);
//HACK: workaround for MD not local-copying package references
- foreach (MonoDevelop.Projects.ProjectReference projectReference in References) {
+ foreach (MonoDevelop.Projects.ProjectReference projectReference in Project.References) {
if (projectReference.Package != null && projectReference.Package.Name == "system.web.mvc") {
if (projectReference.ReferenceType == ReferenceType.Package)
foreach (SystemAssembly assem in projectReference.Package.Assemblies)
@@ -667,7 +648,7 @@ namespace MonoDevelop.AspNet.Projects
public string GetAspNetMvcVersion ()
{
- foreach (var pref in References) {
+ foreach (var pref in Project.References) {
if (pref.Reference.IndexOf ("System.Web.Mvc", StringComparison.OrdinalIgnoreCase) < 0)
continue;
switch (pref.ReferenceType) {
@@ -692,7 +673,7 @@ namespace MonoDevelop.AspNet.Projects
public bool SupportsRazorViewEngine {
get {
- return References.Any (r => r.Reference.StartsWith ("System.Web.WebPages.Razor", StringComparison.Ordinal));
+ return Project.References.Any (r => r.Reference.StartsWith ("System.Web.WebPages.Razor", StringComparison.Ordinal));
}
}
@@ -703,7 +684,7 @@ namespace MonoDevelop.AspNet.Projects
public virtual bool IsAspMvcProject {
get {
- return References.Any (r => r.Reference.StartsWith ("System.Web.Mvc", StringComparison.Ordinal));
+ return Project.References.Any (r => r.Reference.StartsWith ("System.Web.Mvc", StringComparison.Ordinal));
}
}
diff --git a/main/src/addins/AspNet/Projects/AspNetMvcFileTemplateCondition.cs b/main/src/addins/AspNet/Projects/AspNetMvcFileTemplateCondition.cs
index 0a4f581ad1..58a71c5371 100644
--- a/main/src/addins/AspNet/Projects/AspNetMvcFileTemplateCondition.cs
+++ b/main/src/addins/AspNet/Projects/AspNetMvcFileTemplateCondition.cs
@@ -50,7 +50,7 @@ namespace MonoDevelop.AspNet.Projects
if (proj == null)
return true;
- var aspProj = proj as AspNetAppProject;
+ var aspProj = proj.GetFlavor<AspNetFlavor> ();
if (aspProj == null)
return false;
diff --git a/main/src/addins/AspNet/Properties/MonoDevelop.AspNet.addin.xml b/main/src/addins/AspNet/Properties/MonoDevelop.AspNet.addin.xml
index 17406e444f..a6f13d0f3d 100644
--- a/main/src/addins/AspNet/Properties/MonoDevelop.AspNet.addin.xml
+++ b/main/src/addins/AspNet/Properties/MonoDevelop.AspNet.addin.xml
@@ -178,32 +178,23 @@
extensions = "*.htm,*.html"/>
</Extension>
- <Extension path = "/MonoDevelop/ProjectModel/ProjectBindings">
- <ProjectBinding id = "AspNetApp" class = "MonoDevelop.AspNet.Projects.AspNetAppProjectBinding" />
- </Extension>
-
- <Extension path = "/MonoDevelop/ProjectModel/MSBuildItemTypes">
- <DotNetProjectSubtype
+ <Extension path = "/MonoDevelop/ProjectModel/ProjectModelExtensions">
+ <ProjectExtension
guid="{603C0E0B-DB56-11DC-BE95-000D561079B0}"
- type="MonoDevelop.AspNet.Projects.AspMvc1Project"
- useXBuild="true" />
- <DotNetProjectSubtype
+ type="MonoDevelop.AspNet.Projects.AspMvc1ProjectExtension" />
+ <ProjectExtension
guid="{F85E285D-A4E0-4152-9332-AB1D724D3325}"
- type="MonoDevelop.AspNet.Projects.AspMvc2Project"
- useXBuild="true" />
- <DotNetProjectSubtype
+ type="MonoDevelop.AspNet.Projects.AspMvc2ProjectExtension" />
+ <ProjectExtension
guid="{E53F8FEA-EAE0-44A6-8774-FFD645390401}"
- type="MonoDevelop.AspNet.Projects.AspMvc3Project"
- useXBuild="true" />
- <DotNetProjectSubtype
+ type="MonoDevelop.AspNet.Projects.AspMvc3ProjectExtension" />
+ <ProjectExtension
guid="{E3E379DF-F4C6-4180-9B81-6769533ABE47}"
- type="MonoDevelop.AspNet.Projects.AspMvc4Project"
- useXBuild="true" />
- <DotNetProjectSubtype
- id="MonoDevelop.AspNet.Projects.AspNetAppProject"
+ type="MonoDevelop.AspNet.Projects.AspMvc4ProjectExtension" />
+ <ProjectExtension
+ id="MonoDevelop.AspNet.Projects.AspNetAppProjectExtension"
guid="{349C5851-65DF-11DA-9384-00065B846F21}"
- type="MonoDevelop.AspNet.Projects.AspNetAppProject"
- useXBuild="true" />
+ type="MonoDevelop.AspNet.Projects.AspNetAppProjectExtension" />
</Extension>
<Extension path = "/MonoDevelop/TypeSystem/Parser">
@@ -217,7 +208,7 @@
</Extension>
<Extension path = "/MonoDevelop/ProjectModel/Gui/ItemOptionPanels/Run">
- <Condition id="ItemType" value="MonoDevelop.AspNet.Projects.AspNetAppProject">
+ <Condition id="FlavorType" value="MonoDevelop.AspNet.Projects.AspNetFlavor">
<Section id = "XspOptions"
_label = "XSP Web Server"
class = "MonoDevelop.AspNet.Execution.XspOptionsPanel"/>
@@ -262,11 +253,9 @@
</Extension>
<Extension path = "/MonoDevelop/Ide/ContextMenu/ProjectPad/Add">
- <Condition id="ItemType" value="MonoDevelop.AspNet.Projects.AspNetAppProject">
- <ItemSet id = "AspNetDirectories" _label = "ASP.NET Directory" insertafter = "MonoDevelop.Ide.Commands.ProjectCommands.NewFolder" autohide = "true">
- <CommandItem id = "MonoDevelop.AspNet.Commands.AspNetCommands.AddAspNetDirectory" />
- </ItemSet>
- </Condition>
+ <ItemSet id = "AspNetDirectories" _label = "ASP.NET Directory" insertafter = "MonoDevelop.Ide.Commands.ProjectCommands.NewFolder" autohide = "true">
+ <CommandItem id = "MonoDevelop.AspNet.Commands.AspNetCommands.AddAspNetDirectory" />
+ </ItemSet>
</Extension>
<Extension path = "/MonoDevelop/Ide/ContextMenu/ProjectPad/Add">
diff --git a/main/src/addins/AspNet/Razor/Generator/RazorTemplatePreprocessor.cs b/main/src/addins/AspNet/Razor/Generator/RazorTemplatePreprocessor.cs
index 32a8a31ff2..41d105e862 100644
--- a/main/src/addins/AspNet/Razor/Generator/RazorTemplatePreprocessor.cs
+++ b/main/src/addins/AspNet/Razor/Generator/RazorTemplatePreprocessor.cs
@@ -30,6 +30,7 @@ using System.CodeDom.Compiler;
using MonoDevelop.Projects;
using MonoDevelop.Core;
using MonoDevelop.TextTemplating;
+using System.Threading.Tasks;
namespace MonoDevelop.AspNet.Razor.Generator
{
@@ -46,18 +47,18 @@ namespace MonoDevelop.AspNet.Razor.Generator
return ns;
}
- public IAsyncOperation Generate (IProgressMonitor monitor, ProjectFile file, SingleFileCustomToolResult result)
+ public Task Generate (ProgressMonitor monitor, ProjectFile file, SingleFileCustomToolResult result)
{
- return new ThreadAsyncOperation (delegate {
+ return Task.Factory.StartNew (delegate {
try {
GenerateInternal (monitor, file, result);
} catch (Exception ex) {
result.UnhandledException = ex;
}
- }, result);
+ });
}
- void GenerateInternal (IProgressMonitor monitor, ProjectFile file, SingleFileCustomToolResult result)
+ void GenerateInternal (ProgressMonitor monitor, ProjectFile file, SingleFileCustomToolResult result)
{
var dnp = file.Project as DotNetProject;
if (dnp == null || dnp.LanguageName != "C#") {
diff --git a/main/src/addins/AspNet/Razor/RazorCSharpParser.cs b/main/src/addins/AspNet/Razor/RazorCSharpParser.cs
index ac77e93f69..390e00e819 100644
--- a/main/src/addins/AspNet/Razor/RazorCSharpParser.cs
+++ b/main/src/addins/AspNet/Razor/RazorCSharpParser.cs
@@ -64,7 +64,7 @@ namespace MonoDevelop.AspNet.Razor
ChangeInfo lastChange;
string lastParsedFile;
TextDocument currentDocument;
- AspNetAppProject aspProject;
+ AspNetFlavor aspProject;
DotNetProject project;
IList<TextDocument> openDocuments;
@@ -90,7 +90,7 @@ namespace MonoDevelop.AspNet.Razor
if (currentDocument == null && !TryAddDocument (fileName))
return new RazorCSharpParsedDocument (fileName, new RazorCSharpPageInfo ());
- this.aspProject = project as AspNetAppProject;
+ this.aspProject = project.GetService<AspNetFlavor> ();
EnsureParserInitializedFor (fileName);
@@ -211,7 +211,7 @@ namespace MonoDevelop.AspNet.Razor
// Try to create host using web.config file
var webConfigMap = new WebConfigurationFileMap ();
if (aspProject != null) {
- var vdm = new VirtualDirectoryMapping (aspProject.BaseDirectory.Combine ("Views"), true, "web.config");
+ var vdm = new VirtualDirectoryMapping (project.BaseDirectory.Combine ("Views"), true, "web.config");
webConfigMap.VirtualDirectories.Add ("/", vdm);
}
Configuration configuration;
diff --git a/main/src/addins/AspNet/Tests/Razor/RazorCompletionTesting.cs b/main/src/addins/AspNet/Tests/Razor/RazorCompletionTesting.cs
index 7da98546eb..d35f5f9ca5 100644
--- a/main/src/addins/AspNet/Tests/Razor/RazorCompletionTesting.cs
+++ b/main/src/addins/AspNet/Tests/Razor/RazorCompletionTesting.cs
@@ -92,7 +92,7 @@ namespace MonoDevelop.AspNet.Tests.Razor
cursorPosition = endPos - 1;
}
- var project = new AspNetAppProject ("C#");
+ var project = Services.ProjectService.CreateDotNetProject ("C#");
project.FileName = UnitTests.TestBase.GetTempFile (".csproj");
string file = UnitTests.TestBase.GetTempFile (extension);
diff --git a/main/src/addins/AspNet/Tests/WebForms/WebFormsTesting.cs b/main/src/addins/AspNet/Tests/WebForms/WebFormsTesting.cs
index 4f8e2444d9..74f486803c 100644
--- a/main/src/addins/AspNet/Tests/WebForms/WebFormsTesting.cs
+++ b/main/src/addins/AspNet/Tests/WebForms/WebFormsTesting.cs
@@ -69,7 +69,7 @@ namespace MonoDevelop.AspNet.Tests.WebForms
cursorPosition = endPos - 1;
}
- var project = new AspNetAppProject ("C#");
+ var project = Services.ProjectService.CreateDotNetProject ("C#");
project.References.Add (new ProjectReference (ReferenceType.Package, "System"));
project.References.Add (new ProjectReference (ReferenceType.Package, "System.Web"));
project.FileName = UnitTests.TestBase.GetTempFile (".csproj");
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;
}
}