/// <summary>
		/// Removes the first occurence of a specific <see cref="AssemblySlashDoc"/> from the collection.
		/// </summary>
		/// <param name="assySlashDoc">The <see cref="AssemblySlashDoc"/> to remove from the collection.</param>
		/// <exception cref="ArgumentNullException"><paramref name="assySlashDoc"/> is a <see langword="null"/>.</exception>
		/// <remarks>
		/// Elements that follow the removed element move up to occupy the vacated spot and the indexes of the elements that are moved are also updated.
		/// </remarks>
		public void Remove(AssemblySlashDoc assySlashDoc)
		{
			if (assySlashDoc == null)
				throw new ArgumentNullException("assySlashDoc");

			this.List.Remove(assySlashDoc);
		}
		/// <summary>
		/// Adds the specified <see cref="AssemblySlashDoc"/> object to the collection.
		/// </summary>
		/// <param name="assySlashDoc">The <see cref="AssemblySlashDoc"/> to add to the collection.</param>
		/// <exception cref="ArgumentNullException"><paramref name="assySlashDoc"/> is a <see langword="null"/>.</exception>
		/// <remarks>
		/// If the path of the <see cref="AssemblySlashDoc.Assembly"/> 
		/// in <paramref name="assySlashDoc"/> matches one already existing in the collection, the
		/// operation is silently ignored.
		/// </remarks>
		public void Add(AssemblySlashDoc assySlashDoc)
		{
			if (assySlashDoc == null)
				throw new ArgumentNullException("assySlashDoc");

			if ( !Contains( assySlashDoc.Assembly.Path ) )
				this.List.Add(assySlashDoc);
		}
Exemple #3
0
		/// <summary>
		/// <see cref="System.ICloneable"/>
		/// </summary>
		/// <returns>cloned object</returns>
		public object Clone()
		{
			AssemblySlashDoc ret = new AssemblySlashDoc();
			ret.assembly = new FilePath( this.assembly );
			ret.slashDoc = new FilePath( this.slashDoc );

			return ret;
		}
		internal AssemblySlashDocEventArgs( AssemblySlashDoc assemblySlashDoc )
		{
			AssemblySlashDoc = assemblySlashDoc;
		}
		/// <summary>
		/// Loads <see cref="AssemblySlashDoc"/> details from an <see cref="XmlReader"/>.
		/// </summary>
		/// <param name="reader">
		/// <exception cref="DocumenterException">The <i>location</i> attribute is missing or is an empty string</exception>
		/// An open <see cref="XmlReader"/> positioned before, or on, the <b>&lt;assemblies&gt;</b> element.</param>
		/// <remarks>
		/// The expected format is is follows
		/// <code escaped="true">
		/// <assemblies>
		///		<assembly location="relative or fixed path" documentation="relative or fixed path"/>
		///		...
		/// </assemblies>
		/// </code>
		/// <para>If the <i>location</i> attribute is missing or an empty string an exception will be thrown.</para>
		/// <para>If the <i>documentation</i> attribute is missing or an empty string it will be silently ignored.</para>
		/// </remarks>
		public void ReadXml(XmlReader reader)
		{
			while (!reader.EOF && !(reader.NodeType == XmlNodeType.EndElement && reader.Name == "assemblies"))
			{
				if (reader.NodeType == XmlNodeType.Element && reader.Name == "assembly")
				{
					if (reader.GetAttribute("location") == null) 
					{
						throw new DocumenterException("\"location\" attribute is" + " required for <assembly> element in project file.");
					}
					string location = reader.GetAttribute("location").Trim();
					if (location.Length == 0) 
					{
						throw new DocumenterException("\"location\" attribute of" + " <assembly> element cannot be empty in project file.");
					}
					string documentation = reader.GetAttribute("documentation");
					if ( documentation==null ) 
						documentation=String.Empty;
					AssemblySlashDoc assemblySlashDoc = new AssemblySlashDoc(location, documentation);
					Add(assemblySlashDoc);
				}
				reader.Read();
			}
		}
		/// <overloads>Determines whether the collection contains a specified element.</overloads>
		/// <summary>
		/// Determines whether the collection contains the specified <see cref="AssemblySlashDoc"/>.
		/// </summary>
		/// <param name="assySlashDoc">The <see cref="AssemblySlashDoc"/> to locate in the collection.</param>
		/// <returns><see langword="true"/> if the collection contains the specified <see cref="AssemblySlashDoc"/>, 
		/// otherwise <see langword="false"/>.</returns>
		public bool Contains(AssemblySlashDoc assySlashDoc)
		{
			return base.InnerList.Contains(assySlashDoc);
		}
Exemple #7
0
		private void AddRowToListView(AssemblySlashDoc assemblySlashDoc)
		{
			ListViewItem  listItem;
			string[]  subItems = new string[1];

			subItems[0] = Path.GetFileName(assemblySlashDoc.SlashDoc.Path);
			listItem = new ListViewItem(
				Path.GetFileName(assemblySlashDoc.Assembly.Path));
			assembliesListView.Items.Add(listItem);
		}
Exemple #8
0
		private void menuFileOpenSolution_Click (object sender, System.EventArgs e)
		{
			if (project.IsDirty)
			{
				DialogResult result = PromptToSave();
				switch (result)
				{
					case DialogResult.Yes:
						SaveOrSaveAs();
						break;
					case DialogResult.No:
						break;
					case DialogResult.Cancel:
						return;
				}
			}
			OpenFileDialog openFileDlg = new OpenFileDialog();
			openFileDlg.InitialDirectory = Directory.GetCurrentDirectory();
			openFileDlg.Filter = "Visual Studio Solution files (*.sln)|*.sln|All files (*.*)|*.*" ;

			if(openFileDlg.ShowDialog() == DialogResult.OK)
			{
				VS.Solution sol = new VS.Solution(openFileDlg.FileName);

				try
				{
					this.Cursor = Cursors.WaitCursor;

					string warningMessages=String.Empty;

					if (sol.ProjectCount==0)
					{
						warningMessages = "There are no projects in this solution that NDoc can import.\n\n";
						warningMessages += "Either the solution is blank, or the projects contained within\n";
						warningMessages += "the solution are not of a type NDoc can import.\n"; 
						WarningForm warningForm = new WarningForm("VS Solution Import Warnings", warningMessages);
						warningForm.ShowDialog(this);
						return;
					}

					SolutionForm sf = new SolutionForm();
					sf.Text = "Solution " + sol.Name;

					sf.ConfigList.Items.Clear();
					foreach (string configkey in sol.GetConfigurations())
					{
						sf.ConfigList.Items.Add(configkey);
					}

					sf.ShowDialog(this);
					if (sf.ConfigList.SelectedIndex < 0)
						return;

					string solconfig = (string)sf.ConfigList.SelectedItem;

					//clear current ndoc project settings
					Clear();

					foreach (VS.Project p in sol.GetProjects())
					{
						string projid = p.ID.ToString();
						string projconfig = sol.GetProjectConfigName(solconfig, projid);

						if (projconfig == null)
						{
							warningMessages += String.Format("VS Project {0} could not be imported.\n- There are no settings in the project file for configuration '{1}'\n\n",p.Name,solconfig);
							continue;
						}

						string apath = p.GetRelativeOutputPathForConfiguration(projconfig);
						string xpath = p.GetRelativePathToDocumentationFile(projconfig);
						string spath = sol.Directory;

						AssemblySlashDoc asd = new AssemblySlashDoc();
						asd.Assembly.Path=Path.Combine(spath, apath);

						if (!File.Exists(asd.Assembly.Path))
						{
							warningMessages += String.Format("VS Project '{0}' has been imported, but the specified assembly does not exist.\n- You will not be able to build documentation for this project until its assembly has been successfully compiled...\n\n",p.Name);
						}

						if (xpath!=null && xpath.Length>0)
						{
							asd.SlashDoc.Path=Path.Combine(spath, xpath);
							if (!File.Exists(asd.SlashDoc.Path))
							{
							warningMessages += String.Format("VS Project '{0}' has been imported, but the XML documentation file specified in the project cannot be found.\n- This can occur if the project is set to do 'incremental' compiles.\n- NDoc output will be very limited until the VS project is rebuilt with XML documntation...\n",p.Name);
						
							}
						}
						else
						{
							warningMessages += String.Format("VS Project '{0}' has been imported, but the project is not set to produce XML documentation.\n- NDoc output for this assembly will be very limited...\n\n",p.Name);
						}

						project.AssemblySlashDocs.Add(asd);
						AddRowToListView(asd);
					}

					EnableMenuItems(true);
					EnableAssemblyItems();

					projectFilename =  Path.Combine(sol.Directory, sol.Name + ".ndoc");

					if (warningMessages.Length>0)
					{
						WarningForm warningForm = new WarningForm("VS Solution Import Warnings", warningMessages);
						warningForm.ShowDialog(this);
					}
				}
				finally
				{
					this.Cursor = Cursors.Arrow;
				}
			}
		}
Exemple #9
0
		private string LoadFromSolution( VS.ISolution sol, string solconfig )
		{
			using ( new WaitCursor( this ) )
			{
				string warningMessages = "";
                foreach (VS.IProject p in sol.GetProjects())
				{
					string projconfig = sol.GetProjectConfigName( solconfig, p.ID.ToString() );

					if ( projconfig == null )
					{
						warningMessages += String.Format("VS Project {0} could not be imported.\n- There are no settings in the project file for configuration '{1}'\n\n",p.Name,solconfig);
						continue;
					}

					string apath = p.GetRelativeOutputPathForConfiguration(projconfig);
					string xpath = p.GetRelativePathToDocumentationFile(projconfig);
					string spath = sol.Directory;

					AssemblySlashDoc assemblySlashDoc = new AssemblySlashDoc();
					assemblySlashDoc.Assembly.Path = Path.Combine( spath, apath );

					if ( !File.Exists( assemblySlashDoc.Assembly.Path ) )
						warningMessages += String.Format("VS Project '{0}' has been imported, but the specified assembly does not exist.\n- You will not be able to build documentation for this project until its assembly has been successfully compiled...\n\n",p.Name);

					if ( xpath != null && xpath.Length > 0  )
					{
						assemblySlashDoc.SlashDoc.Path = Path.Combine( spath, xpath );

						if ( !File.Exists( assemblySlashDoc.SlashDoc.Path ) )
							warningMessages += String.Format("VS Project '{0}' has been imported, but the XML documentation file specified in the project cannot be found.\n- This can occur if the project is set to do 'incremental' compiles.\n- NDoc output will be very limited until the VS project is rebuilt with XML documntation...\n",p.Name);						
					}
					else
					{
						warningMessages += String.Format("VS Project '{0}' has been imported, but the project is not set to produce XML documentation.\n- NDoc output for this assembly will be very limited...\n\n",p.Name);
					}

					project.AssemblySlashDocs.Add( assemblySlashDoc );
				}

				return warningMessages;
			}
		}
Exemple #10
0
		private static void RecurseDir(string dirName, int maxDepth)
		{
			if (0 == maxDepth) return;
			string docFile;
			string[] extensions = {"*.dll", "*.exe"};
			foreach (string extension in extensions)
			{
				foreach (string file in System.IO.Directory.GetFiles(dirName, extension))
				{
					docFile = Path.ChangeExtension(file, ".xml");
					if (System.IO.File.Exists(docFile))
					{
						project.AssemblySlashDocs.Add(new AssemblySlashDoc(file, docFile));
					}
					else
					{
						Console.WriteLine("[Warning] No XML doc file found for '" + file + "'");
						AssemblySlashDoc assemblySlashDoc=new AssemblySlashDoc();
						assemblySlashDoc.Assembly.Path=file;
						project.AssemblySlashDocs.Add(assemblySlashDoc);
					}
				}
			}
			foreach (string subDir in System.IO.Directory.GetDirectories(dirName))
			{
				RecurseDir(subDir, maxDepth - 1);
			}
		}
Exemple #11
0
		private ArrayList GetAssemblySlashDocs()
		{
			AssemblySlashDoc	assemblySlashDoc;
			ArrayList			arrayList = new ArrayList();
			string				shortAssemblyFilename;
			string				shortSlashDocFilename;
			string				assemblyFilename;
			string				slashDocFilename;
			string				projectPath;
			string				relativeOutputPath;
			string				outputPath;

			// Walk over the solution gathering up C# projects that have XML documentation turned on.
			foreach (EnvDTE.Project project in (EnvDTE.Projects)applicationObject.GetObject("CSharpProjects"))
			{
				shortSlashDocFilename = project.ConfigurationManager.ActiveConfiguration.Properties.Item("DocumentationFile").Value.ToString();

				if (shortSlashDocFilename != null && shortSlashDocFilename != "")
				{
					projectPath = project.Properties.Item("FullPath").Value.ToString();
					shortAssemblyFilename = project.Properties.Item("OutputFileName").Value.ToString();
					relativeOutputPath = project.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value.ToString();
					outputPath = Path.Combine(projectPath, relativeOutputPath);
						
					assemblyFilename = Path.Combine(outputPath, shortAssemblyFilename);
					slashDocFilename = Path.Combine(outputPath, shortSlashDocFilename);
					assemblySlashDoc = new AssemblySlashDoc(assemblyFilename, slashDocFilename);

					arrayList.Add(assemblySlashDoc);
				}
			}

			return arrayList;
		}
Exemple #12
0
		private static string GetFixedPathType( AssemblySlashDoc assemblySlashDoc )
		{
			if ( assemblySlashDoc.Assembly.FixedPath == assemblySlashDoc.SlashDoc.FixedPath )
				return assemblySlashDoc.Assembly.FixedPath.ToString();
			else
				return string.Format( "{0}/{1}", assemblySlashDoc.Assembly.FixedPath, assemblySlashDoc.SlashDoc.FixedPath );
		}
Exemple #13
0
		private void AddListViewItem( AssemblySlashDoc assemblySlashDoc )
		{
			Debug.Assert( assemblySlashDoc != null );

			ListViewItem item = new ListViewItem( Path.GetFileName( assemblySlashDoc.Assembly.Path ) );
			item.SubItems.Add( Path.GetDirectoryName( assemblySlashDoc.Assembly.Path ) );
			item.SubItems.Add( GetFixedPathType( assemblySlashDoc ) );
			item.Tag = assemblySlashDoc;

			if ( File.Exists( assemblySlashDoc.Assembly.Path ) == false )
				item.ForeColor = Color.Red;

			assembliesListView.Items.Add( item );
			item.EnsureVisible();
		}