~ubuntu-branches/ubuntu/natty/monodevelop/natty

« back to all changes in this revision

Viewing changes to src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet/AspNetAppProject.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2010-07-05 13:00:05 UTC
  • mfrom: (1.2.8 upstream) (1.3.9 experimental)
  • Revision ID: james.westby@ubuntu.com-20100705130005-d6hp4k5gcn1xkj8c
Tags: 2.4+dfsg-1ubuntu1
* debian/patches/remove_support_for_moonlight.patch,
  debian/patches/dont_add_moonlight_to_core_addins.patch,
  debian/control:
  + Enable support for Moonlight
* debian/rules:
  + Ensure Moonlight addin isn't shipped in main MonoDevelop package by
    mistake

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
using System.Xml;
35
35
using System.Collections.Generic;
36
36
using MonoDevelop.Core;
37
 
using MonoDevelop.Core.Gui;
38
37
using MonoDevelop.Core.Execution;
39
38
using MonoDevelop.Core.ProgressMonitoring;
40
39
using MonoDevelop.Projects;
67
66
                [ItemProperty ("Target", ValueType=typeof(WebDeployTarget), Scope="*")]
68
67
                protected WebDeployTargetCollection webDeployTargets = new WebDeployTargetCollection ();
69
68
                
70
 
                ProjectRegisteredControls controlRegistrationCache;
 
69
                RegistrationCache registrationCache;
71
70
                CodeBehindTypeNameCache codebehindTypeNameCache;
72
71
                
73
72
                #region properties
121
120
                        get { return webDeployTargets; }
122
121
                }
123
122
                
124
 
                internal ProjectRegisteredControls ControlRegistrationCache {
 
123
                internal RegistrationCache RegistrationCache {
125
124
                        get {
126
 
                                if (controlRegistrationCache == null)
127
 
                                        controlRegistrationCache = new ProjectRegisteredControls (this);
128
 
                                
129
 
                                return controlRegistrationCache;
 
125
                                if (registrationCache == null)
 
126
                                        registrationCache = new RegistrationCache (this);
 
127
                                return registrationCache;
130
128
                        }
131
129
                }
132
130
                
133
 
                public override ClrVersion[] SupportedClrVersions {
134
 
                        get {
135
 
                                ClrVersion[] versions = base.SupportedClrVersions;
136
 
                                if (versions == null)
137
 
                                        return null;
138
 
                                
139
 
                                bool ver1 = false, ver2 = false;
140
 
                                foreach (ClrVersion version in versions) {
141
 
                                        if (version == ClrVersion.Net_1_1)
142
 
                                                ver1 = true;
143
 
                                        if (version == ClrVersion.Net_2_0)
144
 
                                                ver2 = true;
145
 
                                }
146
 
                                if (ver1) {
147
 
                                        if (ver2)
148
 
                                                return new ClrVersion[] { ClrVersion.Net_1_1, ClrVersion.Net_2_0 };
149
 
                                        else return new ClrVersion[] { ClrVersion.Net_1_1 };
150
 
                                } else if (ver2) {
151
 
                                        return new ClrVersion[] { ClrVersion.Net_2_0 };
152
 
                                }
153
 
                                return null;
154
 
                        }
 
131
                public override bool SupportsFramework (TargetFramework framework)
 
132
                {
 
133
                        //only support 1.1, 2.0, 3.5, 4.0 etc, not monotouch, moonlight and so on
 
134
                        return framework.IsCompatibleWithFramework ("1.1") && base.SupportsFramework (framework);
155
135
                }
156
136
                
157
137
                #endregion
172
152
                public AspNetAppProject (string languageName, ProjectCreateInformation info, XmlElement projectOptions)
173
153
                        : base (languageName, info, projectOptions)
174
154
                {
175
 
                        foreach (AspNetAppProjectConfiguration conf in Configurations)
176
 
                                conf.OutputDirectory = "bin";
177
155
                        Init ();
 
156
                        
 
157
                        var binPath = info == null? (FilePath)"bin" : info.BinPath;
 
158
                        foreach (AspNetAppProjectConfiguration cfg in Configurations)
 
159
                                cfg.OutputDirectory = binPath;
178
160
                }       
179
161
                
180
162
                public override SolutionItemConfiguration CreateConfiguration (string name)
181
163
                {
182
 
                        AspNetAppProjectConfiguration conf = new AspNetAppProjectConfiguration ();
183
 
                        conf.Name = name;
184
 
                        conf.OutputDirectory = String.IsNullOrEmpty (BaseDirectory)? "bin" : Path.Combine (BaseDirectory, "bin");
185
 
                        if (LanguageBinding != null)
186
 
                                conf.CompilationParameters = LanguageBinding.CreateCompilationParameters (null);                        
 
164
                        var conf = new AspNetAppProjectConfiguration (name);
 
165
                        conf.CopyFrom (base.CreateConfiguration (name));
 
166
                        conf.OutputDirectory = BaseDirectory.IsNullOrEmpty? "bin" : (string)BaseDirectory.Combine ("bin");                      
187
167
                        return conf;
188
168
                }
189
169
                
194
174
                
195
175
                #endregion
196
176
                
 
177
                public override void Dispose ()
 
178
                {
 
179
                        codebehindTypeNameCache.Dispose ();
 
180
                        RegistrationCache.Dispose ();
 
181
                        base.Dispose ();
 
182
                }
 
183
                
197
184
                #region build/prebuild/execute
198
185
                
199
186
                
352
339
                
353
340
                public ProjectDom ResolveAssemblyDom (string assemblyName)
354
341
                {
355
 
                        System.Reflection.AssemblyName parsed = SystemAssemblyService.ParseAssemblyName (assemblyName);
 
342
                        var parsed = SystemAssemblyService.ParseAssemblyName (assemblyName);
356
343
                        if (string.IsNullOrEmpty (parsed.Name))
357
344
                                return null;
358
345
                        
381
368
                
382
369
                string GetAssemblyPath (string assemblyName)
383
370
                {
384
 
                        System.Reflection.AssemblyName parsed = SystemAssemblyService.ParseAssemblyName (assemblyName);
 
371
                        var parsed = SystemAssemblyService.ParseAssemblyName (assemblyName);
385
372
                        if (string.IsNullOrEmpty (parsed.Name))
386
373
                                return null;
387
374
                        
470
457
                
471
458
                void UpdateWebConfigRefs ()
472
459
                {
473
 
                        List<string> refs = new List<string> ();
474
 
                        foreach (ProjectReference reference in References) {
 
460
                        var refs = new List<string> ();
 
461
                        foreach (var reference in References) {
475
462
                                //local copied assemblies are copied to the bin directory so ASP.NET references them automatically
476
463
                                if (reference.LocalCopy && (reference.ReferenceType == ReferenceType.Project || reference.ReferenceType == ReferenceType.Assembly))
477
464
                                        continue;
487
474
                                refs.Add (reference.Reference);
488
475
                        }
489
476
                                                
490
 
                        string webConfigPath = WebConfigPath;
491
 
                        if (!File.Exists (webConfigPath))
 
477
                        var webConfig = GetWebConfig ();
 
478
                        if (webConfig == null || !File.Exists (webConfig.FilePath))
492
479
                                return;
493
480
                        
494
 
                        MonoDevelop.Projects.Text.IEditableTextFile textFile = 
495
 
                                MonoDevelop.DesignerSupport.OpenDocumentFileProvider.Instance.GetEditableTextFile (webConfigPath);
 
481
                        var textFile = DesignerSupport.OpenDocumentFileProvider.Instance.GetEditableTextFile (webConfig.FilePath);
496
482
                        //use textfile API because it's write safe (writes out to another file then moves)
497
483
                        if (textFile == null)
498
 
                                textFile = MonoDevelop.Projects.Text.TextFile.ReadFile (webConfigPath);
 
484
                                textFile = MonoDevelop.Projects.Text.TextFile.ReadFile (webConfig.FilePath);
499
485
                                
500
486
                        //can't use System.Web.Configuration.WebConfigurationManager, as it can only access virtual paths within an app
501
487
                        //so need full manual handling
583
569
                        return result;
584
570
                }
585
571
                
586
 
                string WebConfigPath {
587
 
                        get { return Path.Combine (this.BaseDirectory, "web.config"); }
 
572
                ProjectFile GetWebConfig ()
 
573
                {
 
574
                        var webConf = this.BaseDirectory.Combine ("web.config");
 
575
                        foreach (var file in this.Files)
 
576
                                if (string.Compare (file.FilePath.ToString (), webConf, StringComparison.OrdinalIgnoreCase) == 0)
 
577
                                        return file;
 
578
                        return null;
 
579
                }
 
580
                
 
581
                bool IsWebConfig (FilePath file)
 
582
                {
 
583
                        var webConf = this.BaseDirectory.Combine ("web.config");
 
584
                        return (string.Compare (file, webConf, StringComparison.OrdinalIgnoreCase) == 0);
588
585
                }
589
586
                
590
587
                bool IsSystemReference (string reference)
631
628
                        IEnumerable<string> filesToAdd = MonoDevelop.DesignerSupport.CodeBehind.GuessDependencies
632
629
                                (this, e.ProjectFile, groupedExtensions);
633
630
                        
634
 
                        if (Path.GetFullPath (e.ProjectFile.FilePath) == Path.GetFullPath (WebConfigPath))
 
631
                        if (IsWebConfig (e.ProjectFile.FilePath))
635
632
                                UpdateWebConfigRefs ();
636
633
                        
637
634
                        //let the base fire the event before we add files
697
694
                        }
698
695
                        return null;
699
696
                }
700
 
 
 
697
                
701
698
                public string GetCodebehindTypeName (string fileName)
702
699
                {
703
700
                        lock (codebehindTypeNameCache)
704
701
                                return codebehindTypeNameCache.GetCodeBehindTypeName (fileName);
705
702
                }
706
703
                
707
 
                class CodeBehindTypeNameCache : FileInfoCache<string> 
 
704
                class CodeBehindTypeNameCache : ProjectFileCache<AspNetAppProject,string>
708
705
                {
709
 
                        AspNetAppProject proj;
710
 
                        
711
 
                        public CodeBehindTypeNameCache (AspNetAppProject proj)
 
706
                        public CodeBehindTypeNameCache (AspNetAppProject proj) : base (proj)
712
707
                        {
713
 
                                this.proj = proj;
714
708
                        }
715
709
                        
716
 
                        protected override string GenerateInfo (string fileName)
 
710
                        protected override string GenerateInfo (string filename)
717
711
                        {
718
 
                                var cu = ProjectDomService.Parse (proj, fileName, null) as AspNetParsedDocument;
719
 
                                if (cu != null && !string.IsNullOrEmpty (cu.PageInfo.InheritedClass))
720
 
                                        return cu.PageInfo.InheritedClass;
 
712
                                try {
 
713
                                        var doc = ProjectDomService.Parse (Project, filename, null) as AspNetParsedDocument;
 
714
                                        if (doc != null && !string.IsNullOrEmpty (doc.Info.InheritedClass))
 
715
                                                return doc.Info.InheritedClass;
 
716
                                } catch (Exception ex) {
 
717
                                        LoggingService.LogError ("Error reading codebehind name for file '" + filename + "'", ex);
 
718
                                }
721
719
                                return null;
722
720
                        }
723
721