/Main/Source/WebCodeProviders/CSharpCodeProviderWithDocs.cs
C# | 117 lines | 40 code | 9 blank | 68 comment | 0 complexity | 4b0f168403567de12ee633476d4643d7 MD5 | raw file
Possible License(s): CC-BY-SA-3.0
1//============================================================================= 2// System : EWSoftware Custom Code Providers 3// File : CSharpCodeProviderWithDocs.cs 4// Author : Eric Woodruff (Eric@EWoodruff.us) 5// Updated : 02/03/2009 6// Note : Copyright 2008-2009, Eric Woodruff, All rights reserved 7// Compiler: Microsoft Visual C# 8// 9// This file contains a custom C# code provider that is able to output an 10// individual XML comments file for each unit that is compiled to a folder 11// of your choice. This changes the default behavior which overwrites the 12// comments file on each invocation and dumps it into the temporary ASP.NET 13// compilation folder. 14// 15// This code is published under the Code Project Open License (CPOL). A copy 16// of the license can be found at: http://www.codeproject.com/info/cpol10.aspx. 17// This notice, the author's name, and all copyright notices must remain intact 18// in all applications, documentation, and source files. 19// 20// Version Date Who Comments 21// ============================================================================ 22// 1.0.0.0 04/06/2008 EFW Created the code 23// 1.1.0.0 02/03/2009 EFW Added support for providerOptions 24//============================================================================= 25 26using System; 27using System.CodeDom; 28using System.CodeDom.Compiler; 29using System.Collections.Generic; 30 31using Microsoft.CSharp; 32 33namespace EWSoftware.CodeDom 34{ 35 /// <summary> 36 /// This is a custom C# code provider that is able to output an individual 37 /// XML comments file for each unit that is compiled to a folder of your 38 /// choice. 39 /// </summary> 40 /// <remarks>This changes the default behavior which overwrites the 41 /// comments file on each invocation and dumps it into the temporary 42 /// ASP.NET compilation folder. 43 /// 44 /// <p/>A <c>/docpath:[path]</c> option should be added to the 45 /// <c>compilerOptions</c> attribute in the <b>Web.config</b> file to 46 /// specify the path to which the XML comments files will be written. 47 /// The filenames will match the assembly names generated by the 48 /// compiler.</remarks> 49 /// <example> 50 /// <code lang="xml" title="Example Compiler Configuration"> 51 /// <![CDATA[ 52 /// <configuration> 53 /// <system.codedom> 54 /// <compilers> 55 /// <!-- For C# --> 56 /// <compiler language="c#;cs;csharp" extension=".cs" 57 /// compilerOptions="/docpath:C:\Publish\Doc" 58 /// type="EWSoftware.CodeDom.CSharpCodeProviderWithDocs, 59 /// EWSoftware.CodeDom, Version=1.0.0.0, Culture=neutral, 60 /// PublicKeyToken=d633d7d5b41cbb65" /> 61 /// </compilers> 62 /// </system.codedom> 63 /// </configuration>]]> 64 /// </code> 65 /// </example> 66 public class CSharpCodeProviderWithDocs : CSharpCodeProvider 67 { 68 #region Constructors 69 //===================================================================== 70 71 /// <summary> 72 /// Default constructor 73 /// </summary> 74 /// <overloads>There are two overloads for the constructor</overloads> 75 public CSharpCodeProviderWithDocs() : base() 76 { 77 } 78 79 /// <summary> 80 /// This constructor is passed a provider options dictionary 81 /// </summary> 82 /// <param name="providerOptions">The provider options</param> 83 public CSharpCodeProviderWithDocs( 84 IDictionary<string, string> providerOptions) : base(providerOptions) 85 { 86 } 87 #endregion 88 89 #region CodeDomProvider overrides 90 //===================================================================== 91 92 /// <inheritdoc /> 93 public override CompilerResults CompileAssemblyFromDom( 94 CompilerParameters options, params CodeCompileUnit[] compilationUnits) 95 { 96 CodeProviderHelper.ReplaceDocPathOption(options, null); 97 return base.CompileAssemblyFromDom(options, compilationUnits); 98 } 99 100 /// <inheritdoc /> 101 public override CompilerResults CompileAssemblyFromFile( 102 CompilerParameters options, params string[] fileNames) 103 { 104 CodeProviderHelper.ReplaceDocPathOption(options, null); 105 return base.CompileAssemblyFromFile(options, fileNames); 106 } 107 108 /// <inheritdoc /> 109 public override CompilerResults CompileAssemblyFromSource( 110 CompilerParameters options, params string[] sources) 111 { 112 CodeProviderHelper.ReplaceDocPathOption(options, null); 113 return base.CompileAssemblyFromSource(options, sources); 114 } 115 #endregion 116 } 117}