/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
- //=============================================================================
- // System : EWSoftware Custom Code Providers
- // File : CSharpCodeProviderWithDocs.cs
- // Author : Eric Woodruff (Eric@EWoodruff.us)
- // Updated : 02/03/2009
- // Note : Copyright 2008-2009, Eric Woodruff, All rights reserved
- // Compiler: Microsoft Visual C#
- //
- // This file contains a custom C# code provider that is able to output an
- // individual XML comments file for each unit that is compiled to a folder
- // of your choice. This changes the default behavior which overwrites the
- // comments file on each invocation and dumps it into the temporary ASP.NET
- // compilation folder.
- //
- // This code is published under the Code Project Open License (CPOL). A copy
- // of the license can be found at: http://www.codeproject.com/info/cpol10.aspx.
- // This notice, the author's name, and all copyright notices must remain intact
- // in all applications, documentation, and source files.
- //
- // Version Date Who Comments
- // ============================================================================
- // 1.0.0.0 04/06/2008 EFW Created the code
- // 1.1.0.0 02/03/2009 EFW Added support for providerOptions
- //=============================================================================
-
- using System;
- using System.CodeDom;
- using System.CodeDom.Compiler;
- using System.Collections.Generic;
-
- using Microsoft.CSharp;
-
- namespace EWSoftware.CodeDom
- {
- /// <summary>
- /// This is a custom C# code provider that is able to output an individual
- /// XML comments file for each unit that is compiled to a folder of your
- /// choice.
- /// </summary>
- /// <remarks>This changes the default behavior which overwrites the
- /// comments file on each invocation and dumps it into the temporary
- /// ASP.NET compilation folder.
- ///
- /// <p/>A <c>/docpath:[path]</c> option should be added to the
- /// <c>compilerOptions</c> attribute in the <b>Web.config</b> file to
- /// specify the path to which the XML comments files will be written.
- /// The filenames will match the assembly names generated by the
- /// compiler.</remarks>
- /// <example>
- /// <code lang="xml" title="Example Compiler Configuration">
- /// <![CDATA[
- /// <configuration>
- /// <system.codedom>
- /// <compilers>
- /// <!-- For C# -->
- /// <compiler language="c#;cs;csharp" extension=".cs"
- /// compilerOptions="/docpath:C:\Publish\Doc"
- /// type="EWSoftware.CodeDom.CSharpCodeProviderWithDocs,
- /// EWSoftware.CodeDom, Version=1.0.0.0, Culture=neutral,
- /// PublicKeyToken=d633d7d5b41cbb65" />
- /// </compilers>
- /// </system.codedom>
- /// </configuration>]]>
- /// </code>
- /// </example>
- public class CSharpCodeProviderWithDocs : CSharpCodeProvider
- {
- #region Constructors
- //=====================================================================
-
- /// <summary>
- /// Default constructor
- /// </summary>
- /// <overloads>There are two overloads for the constructor</overloads>
- public CSharpCodeProviderWithDocs() : base()
- {
- }
-
- /// <summary>
- /// This constructor is passed a provider options dictionary
- /// </summary>
- /// <param name="providerOptions">The provider options</param>
- public CSharpCodeProviderWithDocs(
- IDictionary<string, string> providerOptions) : base(providerOptions)
- {
- }
- #endregion
-
- #region CodeDomProvider overrides
- //=====================================================================
-
- /// <inheritdoc />
- public override CompilerResults CompileAssemblyFromDom(
- CompilerParameters options, params CodeCompileUnit[] compilationUnits)
- {
- CodeProviderHelper.ReplaceDocPathOption(options, null);
- return base.CompileAssemblyFromDom(options, compilationUnits);
- }
-
- /// <inheritdoc />
- public override CompilerResults CompileAssemblyFromFile(
- CompilerParameters options, params string[] fileNames)
- {
- CodeProviderHelper.ReplaceDocPathOption(options, null);
- return base.CompileAssemblyFromFile(options, fileNames);
- }
-
- /// <inheritdoc />
- public override CompilerResults CompileAssemblyFromSource(
- CompilerParameters options, params string[] sources)
- {
- CodeProviderHelper.ReplaceDocPathOption(options, null);
- return base.CompileAssemblyFromSource(options, sources);
- }
- #endregion
- }
- }